sys_dict_data.go 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // ==========================================================================
  2. // This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "database/sql"
  8. "github.com/gogf/gf/database/gdb"
  9. "github.com/gogf/gf/frame/g"
  10. "github.com/gogf/gf/frame/gmvc"
  11. "github.com/gogf/gf/util/gconv"
  12. "strings"
  13. "time"
  14. "dashoo.cn/micro/app/model"
  15. )
  16. // SysDictDataDao is the manager for logic model data accessing and custom defined data operations functions management.
  17. type SysDictDataDao struct {
  18. gmvc.M // M is the core and embedded struct that inherits all chaining operations from gdb.Model.
  19. C sysDictDataColumns // C is the short type for Columns, which contains all the column names of Table for convenient usage.
  20. DB gdb.DB // DB is the raw underlying database management object.
  21. Table string // Table is the underlying table name of the DAO.
  22. TableAs string // TableAs is the underlying table alias name of the DAO.
  23. }
  24. // SysDictDataColumns defines and stores column names for table sys_dict_data.
  25. type sysDictDataColumns struct {
  26. DictCode string // 字典编码
  27. DictSort string // 字典排序
  28. DictLabel string // 字典标签
  29. DictValue string // 字典键值
  30. DictType string // 字典类型
  31. CssClass string // 样式属性(其他样式扩展)
  32. ListClass string // 表格回显样式
  33. IsDefault string // 是否默认(10是20否)
  34. Status string // 状态(10正常20停用)
  35. Sort string // 显示顺序
  36. Remark string // 备注
  37. CreatedBy string // 创建者
  38. CreatedName string // 创建人
  39. CreatedTime string // 创建时间
  40. UpdatedBy string // 更新者
  41. UpdatedName string // 更新人
  42. UpdatedTime string // 更新时间
  43. DeletedTime string // 删除时间
  44. }
  45. var (
  46. // SysDictData is globally public accessible object for table sys_dict_data operations.
  47. SysDictData = SysDictDataDao{
  48. M: g.DB("default").Model("sys_dict_data").Safe(),
  49. DB: g.DB("default"),
  50. Table: "sys_dict_data",
  51. C: sysDictDataColumns{
  52. DictCode: "dict_code",
  53. DictSort: "dict_sort",
  54. DictLabel: "dict_label",
  55. DictValue: "dict_value",
  56. DictType: "dict_type",
  57. CssClass: "css_class",
  58. ListClass: "list_class",
  59. IsDefault: "is_default",
  60. Status: "status",
  61. Sort: "sort",
  62. Remark: "remark",
  63. CreatedBy: "created_by",
  64. CreatedName: "created_name",
  65. CreatedTime: "created_time",
  66. UpdatedBy: "updated_by",
  67. UpdatedName: "updated_name",
  68. UpdatedTime: "updated_time",
  69. DeletedTime: "deleted_time",
  70. },
  71. }
  72. )
  73. func NewSysDictDataDao(tenant string) SysDictDataDao {
  74. var dao SysDictDataDao
  75. dao = SysDictDataDao{
  76. M: g.DB(tenant).Model("sys_dict_data").Safe(),
  77. DB: g.DB(tenant),
  78. Table: "sys_dict_data",
  79. C: sysDictDataColumns{
  80. DictCode: "dict_code",
  81. DictSort: "dict_sort",
  82. DictLabel: "dict_label",
  83. DictValue: "dict_value",
  84. DictType: "dict_type",
  85. CssClass: "css_class",
  86. ListClass: "list_class",
  87. IsDefault: "is_default",
  88. Status: "status",
  89. Sort: "sort",
  90. Remark: "remark",
  91. CreatedBy: "created_by",
  92. CreatedName: "created_name",
  93. CreatedTime: "created_time",
  94. UpdatedBy: "updated_by",
  95. UpdatedName: "updated_name",
  96. UpdatedTime: "updated_time",
  97. DeletedTime: "deleted_time",
  98. },
  99. }
  100. return dao
  101. }
  102. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  103. // of current DB object and with given context in it.
  104. // Note that this returned DB object can be used only once, so do not assign it to
  105. // a global or package variable for long using.
  106. func (d *SysDictDataDao) Ctx(ctx context.Context) *SysDictDataDao {
  107. return &SysDictDataDao{M: d.M.Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  108. }
  109. // GetCtx returns the context for current Model.
  110. // It returns "context.Background() i"s there's no context previously set.
  111. func (d *SysDictDataDao) GetCtx() context.Context {
  112. return d.M.GetCtx()
  113. }
  114. // As sets an alias name for current table.
  115. func (d *SysDictDataDao) As(as string) *SysDictDataDao {
  116. return &SysDictDataDao{M: d.M.As(as), Table: d.Table, TableAs: as}
  117. }
  118. // TX sets the transaction for current operation.
  119. func (d *SysDictDataDao) TX(tx *gdb.TX) *SysDictDataDao {
  120. return &SysDictDataDao{M: d.M.TX(tx), Table: d.Table, TableAs: d.TableAs}
  121. }
  122. // Master marks the following operation on master node.
  123. func (d *SysDictDataDao) Master() *SysDictDataDao {
  124. return &SysDictDataDao{M: d.M.Master(), Table: d.Table, TableAs: d.TableAs}
  125. }
  126. // Slave marks the following operation on slave node.
  127. // Note that it makes sense only if there's any slave node configured.
  128. func (d *SysDictDataDao) Slave() *SysDictDataDao {
  129. return &SysDictDataDao{M: d.M.Slave(), Table: d.Table, TableAs: d.TableAs}
  130. }
  131. // Args sets custom arguments for model operation.
  132. func (d *SysDictDataDao) Args(args ...interface{}) *SysDictDataDao {
  133. return &SysDictDataDao{M: d.M.Args(args...), Table: d.Table, TableAs: d.TableAs}
  134. }
  135. // Handler calls each of "handlers" on current Model and returns a new Model.
  136. // ModelHandler is a function that handles given Model and returns a new Model that is custom modified.
  137. func (d *SysDictDataDao) Handler(handlers ...gdb.ModelHandler) *SysDictDataDao {
  138. return &SysDictDataDao{M: d.M.Handler(handlers...), Table: d.Table, TableAs: d.TableAs}
  139. }
  140. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  141. // The parameter <table> can be joined table and its joined condition,
  142. // and also with its alias name, like:
  143. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  144. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  145. func (d *SysDictDataDao) LeftJoin(table ...string) *SysDictDataDao {
  146. return &SysDictDataDao{M: d.M.LeftJoin(table...), Table: d.Table, TableAs: d.TableAs}
  147. }
  148. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  149. // The parameter <table> can be joined table and its joined condition,
  150. // and also with its alias name, like:
  151. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  152. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  153. func (d *SysDictDataDao) RightJoin(table ...string) *SysDictDataDao {
  154. return &SysDictDataDao{M: d.M.RightJoin(table...), Table: d.Table, TableAs: d.TableAs}
  155. }
  156. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  157. // The parameter <table> can be joined table and its joined condition,
  158. // and also with its alias name, like:
  159. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  160. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  161. func (d *SysDictDataDao) InnerJoin(table ...string) *SysDictDataDao {
  162. return &SysDictDataDao{M: d.M.InnerJoin(table...), Table: d.Table, TableAs: d.TableAs}
  163. }
  164. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  165. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  166. func (d *SysDictDataDao) Fields(fieldNamesOrMapStruct ...interface{}) *SysDictDataDao {
  167. return &SysDictDataDao{M: d.M.Fields(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  168. }
  169. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  170. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  171. func (d *SysDictDataDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *SysDictDataDao {
  172. return &SysDictDataDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...), Table: d.Table, TableAs: d.TableAs}
  173. }
  174. // FieldCount formats and appends commonly used field "COUNT(column)" to the select fields of model.
  175. func (d *SysDictDataDao) FieldCount(column string, as ...string) *SysDictDataDao {
  176. return &SysDictDataDao{M: d.M.FieldCount(column, as...), Table: d.Table, TableAs: d.TableAs}
  177. }
  178. // FieldSum formats and appends commonly used field "SUM(column)" to the select fields of model.
  179. func (d *SysDictDataDao) FieldSum(column string, as ...string) *SysDictDataDao {
  180. return &SysDictDataDao{M: d.M.FieldSum(column, as...), Table: d.Table, TableAs: d.TableAs}
  181. }
  182. // FieldMin formats and appends commonly used field "MIN(column)" to the select fields of model.
  183. func (d *SysDictDataDao) FieldMin(column string, as ...string) *SysDictDataDao {
  184. return &SysDictDataDao{M: d.M.FieldMin(column, as...), Table: d.Table, TableAs: d.TableAs}
  185. }
  186. // FieldMax formats and appends commonly used field "MAX(column)" to the select fields of model.
  187. func (d *SysDictDataDao) FieldMax(column string, as ...string) *SysDictDataDao {
  188. return &SysDictDataDao{M: d.M.FieldMax(column, as...), Table: d.Table, TableAs: d.TableAs}
  189. }
  190. // FieldAvg formats and appends commonly used field "AVG(column)" to the select fields of model.
  191. func (d *SysDictDataDao) FieldAvg(column string, as ...string) *SysDictDataDao {
  192. return &SysDictDataDao{M: d.M.FieldAvg(column, as...), Table: d.Table, TableAs: d.TableAs}
  193. }
  194. // Option adds extra operation option for the model.
  195. // Deprecated, use separate operations instead.
  196. func (d *SysDictDataDao) Option(option int) *SysDictDataDao {
  197. return &SysDictDataDao{M: d.M.Option(option), Table: d.Table, TableAs: d.TableAs}
  198. }
  199. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  200. // the data and where attributes for empty values.
  201. func (d *SysDictDataDao) OmitEmpty() *SysDictDataDao {
  202. return &SysDictDataDao{M: d.M.OmitEmpty(), Table: d.Table, TableAs: d.TableAs}
  203. }
  204. // OmitEmptyWhere sets optionOmitEmptyWhere option for the model, which automatically filers
  205. // the Where/Having parameters for "empty" values.
  206. func (d *SysDictDataDao) OmitEmptyWhere() *SysDictDataDao {
  207. return &SysDictDataDao{M: d.M.OmitEmptyWhere(), Table: d.Table, TableAs: d.TableAs}
  208. }
  209. // OmitEmptyData sets optionOmitEmptyData option for the model, which automatically filers
  210. // the Data parameters for "empty" values.
  211. func (d *SysDictDataDao) OmitEmptyData() *SysDictDataDao {
  212. return &SysDictDataDao{M: d.M.OmitEmptyData(), Table: d.Table, TableAs: d.TableAs}
  213. }
  214. // OmitNil sets optionOmitNil option for the model, which automatically filers
  215. // the data and where parameters for "nil" values.
  216. func (d *SysDictDataDao) OmitNil() *SysDictDataDao {
  217. return &SysDictDataDao{M: d.M.OmitNil(), Table: d.Table, TableAs: d.TableAs}
  218. }
  219. // OmitNilWhere sets optionOmitNilWhere option for the model, which automatically filers
  220. // the Where/Having parameters for "nil" values.
  221. func (d *SysDictDataDao) OmitNilWhere() *SysDictDataDao {
  222. return &SysDictDataDao{M: d.M.OmitNilWhere(), Table: d.Table, TableAs: d.TableAs}
  223. }
  224. // OmitNilData sets optionOmitNilData option for the model, which automatically filers
  225. // the Data parameters for "nil" values.
  226. func (d *SysDictDataDao) OmitNilData() *SysDictDataDao {
  227. return &SysDictDataDao{M: d.M.OmitNilData(), Table: d.Table, TableAs: d.TableAs}
  228. }
  229. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  230. // Note that this function supports only single table operations.
  231. // Deprecated, filter feature is automatically enabled from GoFrame v1.16.0, it is so no longer used.
  232. func (d *SysDictDataDao) Filter() *SysDictDataDao {
  233. return &SysDictDataDao{M: d.M.Filter(), Table: d.Table, TableAs: d.TableAs}
  234. }
  235. // Where sets the condition statement for the model. The parameter <where> can be type of
  236. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  237. // multiple conditions will be joined into where statement using "AND".
  238. // Eg:
  239. // Where("uid=10000")
  240. // Where("uid", 10000)
  241. // Where("money>? AND name like ?", 99999, "vip_%")
  242. // Where("uid", 1).Where("name", "john")
  243. // Where("status IN (?)", g.Slice{1,2,3})
  244. // Where("age IN(?,?)", 18, 50)
  245. // Where(User{ Id : 1, UserName : "john"})
  246. func (d *SysDictDataDao) Where(where interface{}, args ...interface{}) *SysDictDataDao {
  247. return &SysDictDataDao{M: d.M.Where(where, args...), Table: d.Table, TableAs: d.TableAs}
  248. }
  249. // WherePri does the same logic as M.Where except that if the parameter <where>
  250. // is a single condition like int/string/float/slice, it treats the condition as the primary
  251. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  252. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  253. // as string "123".
  254. func (d *SysDictDataDao) WherePri(where interface{}, args ...interface{}) *SysDictDataDao {
  255. return &SysDictDataDao{M: d.M.WherePri(where, args...), Table: d.Table, TableAs: d.TableAs}
  256. }
  257. // Having sets the having statement for the model.
  258. // The parameters of this function usage are as the same as function Where.
  259. // See Where.
  260. func (d *SysDictDataDao) Having(having interface{}, args ...interface{}) *SysDictDataDao {
  261. return &SysDictDataDao{M: d.M.Having(having, args...), Table: d.Table, TableAs: d.TableAs}
  262. }
  263. // Wheref builds condition string using fmt.Sprintf and arguments.
  264. // Note that if the number of "args" is more than the place holder in "format",
  265. // the extra "args" will be used as the where condition arguments of the Model.
  266. func (d *SysDictDataDao) Wheref(format string, args ...interface{}) *SysDictDataDao {
  267. return &SysDictDataDao{M: d.M.Wheref(format, args...), Table: d.Table, TableAs: d.TableAs}
  268. }
  269. // WhereLT builds "column < value" statement.
  270. func (d *SysDictDataDao) WhereLT(column string, value interface{}) *SysDictDataDao {
  271. return &SysDictDataDao{M: d.M.WhereLT(column, value), Table: d.Table, TableAs: d.TableAs}
  272. }
  273. // WhereLTE builds "column <= value" statement.
  274. func (d *SysDictDataDao) WhereLTE(column string, value interface{}) *SysDictDataDao {
  275. return &SysDictDataDao{M: d.M.WhereLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  276. }
  277. // WhereGT builds "column > value" statement.
  278. func (d *SysDictDataDao) WhereGT(column string, value interface{}) *SysDictDataDao {
  279. return &SysDictDataDao{M: d.M.WhereGT(column, value), Table: d.Table, TableAs: d.TableAs}
  280. }
  281. // WhereGTE builds "column >= value" statement.
  282. func (d *SysDictDataDao) WhereGTE(column string, value interface{}) *SysDictDataDao {
  283. return &SysDictDataDao{M: d.M.WhereGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  284. }
  285. // WhereBetween builds "column BETWEEN min AND max" statement.
  286. func (d *SysDictDataDao) WhereBetween(column string, min, max interface{}) *SysDictDataDao {
  287. return &SysDictDataDao{M: d.M.WhereBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  288. }
  289. // WhereLike builds "column LIKE like" statement.
  290. func (d *SysDictDataDao) WhereLike(column string, like interface{}) *SysDictDataDao {
  291. return &SysDictDataDao{M: d.M.WhereLike(column, like), Table: d.Table, TableAs: d.TableAs}
  292. }
  293. // WhereIn builds "column IN (in)" statement.
  294. func (d *SysDictDataDao) WhereIn(column string, in interface{}) *SysDictDataDao {
  295. return &SysDictDataDao{M: d.M.WhereIn(column, in), Table: d.Table, TableAs: d.TableAs}
  296. }
  297. // WhereNull builds "columns[0] IS NULL AND columns[1] IS NULL ..." statement.
  298. func (d *SysDictDataDao) WhereNull(columns ...string) *SysDictDataDao {
  299. return &SysDictDataDao{M: d.M.WhereNull(columns...), Table: d.Table, TableAs: d.TableAs}
  300. }
  301. // WhereNotBetween builds "column NOT BETWEEN min AND max" statement.
  302. func (d *SysDictDataDao) WhereNotBetween(column string, min, max interface{}) *SysDictDataDao {
  303. return &SysDictDataDao{M: d.M.WhereNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  304. }
  305. // WhereNotLike builds "column NOT LIKE like" statement.
  306. func (d *SysDictDataDao) WhereNotLike(column string, like interface{}) *SysDictDataDao {
  307. return &SysDictDataDao{M: d.M.WhereNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  308. }
  309. // WhereNot builds "column != value" statement.
  310. func (d *SysDictDataDao) WhereNot(column string, value interface{}) *SysDictDataDao {
  311. return &SysDictDataDao{M: d.M.WhereNot(column, value), Table: d.Table, TableAs: d.TableAs}
  312. }
  313. // WhereNotIn builds "column NOT IN (in)" statement.
  314. func (d *SysDictDataDao) WhereNotIn(column string, in interface{}) *SysDictDataDao {
  315. return &SysDictDataDao{M: d.M.WhereNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  316. }
  317. // WhereNotNull builds "columns[0] IS NOT NULL AND columns[1] IS NOT NULL ..." statement.
  318. func (d *SysDictDataDao) WhereNotNull(columns ...string) *SysDictDataDao {
  319. return &SysDictDataDao{M: d.M.WhereNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  320. }
  321. // WhereOr adds "OR" condition to the where statement.
  322. func (d *SysDictDataDao) WhereOr(where interface{}, args ...interface{}) *SysDictDataDao {
  323. return &SysDictDataDao{M: d.M.WhereOr(where, args...), Table: d.Table, TableAs: d.TableAs}
  324. }
  325. // WhereOrf builds "OR" condition string using fmt.Sprintf and arguments.
  326. func (d *SysDictDataDao) WhereOrf(format string, args ...interface{}) *SysDictDataDao {
  327. return &SysDictDataDao{M: d.M.WhereOrf(format, args...), Table: d.Table, TableAs: d.TableAs}
  328. }
  329. // WhereOrLT builds "column < value" statement in "OR" conditions..
  330. func (d *SysDictDataDao) WhereOrLT(column string, value interface{}) *SysDictDataDao {
  331. return &SysDictDataDao{M: d.M.WhereOrLT(column, value), Table: d.Table, TableAs: d.TableAs}
  332. }
  333. // WhereOrLTE builds "column <= value" statement in "OR" conditions..
  334. func (d *SysDictDataDao) WhereOrLTE(column string, value interface{}) *SysDictDataDao {
  335. return &SysDictDataDao{M: d.M.WhereOrLTE(column, value), Table: d.Table, TableAs: d.TableAs}
  336. }
  337. // WhereOrGT builds "column > value" statement in "OR" conditions..
  338. func (d *SysDictDataDao) WhereOrGT(column string, value interface{}) *SysDictDataDao {
  339. return &SysDictDataDao{M: d.M.WhereOrGT(column, value), Table: d.Table, TableAs: d.TableAs}
  340. }
  341. // WhereOrGTE builds "column >= value" statement in "OR" conditions..
  342. func (d *SysDictDataDao) WhereOrGTE(column string, value interface{}) *SysDictDataDao {
  343. return &SysDictDataDao{M: d.M.WhereOrGTE(column, value), Table: d.Table, TableAs: d.TableAs}
  344. }
  345. // WhereOrBetween builds "column BETWEEN min AND max" statement in "OR" conditions.
  346. func (d *SysDictDataDao) WhereOrBetween(column string, min, max interface{}) *SysDictDataDao {
  347. return &SysDictDataDao{M: d.M.WhereOrBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  348. }
  349. // WhereOrLike builds "column LIKE like" statement in "OR" conditions.
  350. func (d *SysDictDataDao) WhereOrLike(column string, like interface{}) *SysDictDataDao {
  351. return &SysDictDataDao{M: d.M.WhereOrLike(column, like), Table: d.Table, TableAs: d.TableAs}
  352. }
  353. // WhereOrIn builds "column IN (in)" statement in "OR" conditions.
  354. func (d *SysDictDataDao) WhereOrIn(column string, in interface{}) *SysDictDataDao {
  355. return &SysDictDataDao{M: d.M.WhereOrIn(column, in), Table: d.Table, TableAs: d.TableAs}
  356. }
  357. // WhereOrNull builds "columns[0] IS NULL OR columns[1] IS NULL ..." statement in "OR" conditions.
  358. func (d *SysDictDataDao) WhereOrNull(columns ...string) *SysDictDataDao {
  359. return &SysDictDataDao{M: d.M.WhereOrNull(columns...), Table: d.Table, TableAs: d.TableAs}
  360. }
  361. // WhereOrNotBetween builds "column NOT BETWEEN min AND max" statement in "OR" conditions.
  362. func (d *SysDictDataDao) WhereOrNotBetween(column string, min, max interface{}) *SysDictDataDao {
  363. return &SysDictDataDao{M: d.M.WhereOrNotBetween(column, min, max), Table: d.Table, TableAs: d.TableAs}
  364. }
  365. // WhereOrNotLike builds "column NOT LIKE like" statement in "OR" conditions.
  366. func (d *SysDictDataDao) WhereOrNotLike(column string, like interface{}) *SysDictDataDao {
  367. return &SysDictDataDao{M: d.M.WhereOrNotLike(column, like), Table: d.Table, TableAs: d.TableAs}
  368. }
  369. // WhereOrNotIn builds "column NOT IN (in)" statement.
  370. func (d *SysDictDataDao) WhereOrNotIn(column string, in interface{}) *SysDictDataDao {
  371. return &SysDictDataDao{M: d.M.WhereOrNotIn(column, in), Table: d.Table, TableAs: d.TableAs}
  372. }
  373. // WhereOrNotNull builds "columns[0] IS NOT NULL OR columns[1] IS NOT NULL ..." statement in "OR" conditions.
  374. func (d *SysDictDataDao) WhereOrNotNull(columns ...string) *SysDictDataDao {
  375. return &SysDictDataDao{M: d.M.WhereOrNotNull(columns...), Table: d.Table, TableAs: d.TableAs}
  376. }
  377. // Group sets the "GROUP BY" statement for the model.
  378. func (d *SysDictDataDao) Group(groupBy ...string) *SysDictDataDao {
  379. return &SysDictDataDao{M: d.M.Group(groupBy...), Table: d.Table, TableAs: d.TableAs}
  380. }
  381. // And adds "AND" condition to the where statement.
  382. // Deprecated, use Where instead.
  383. func (d *SysDictDataDao) And(where interface{}, args ...interface{}) *SysDictDataDao {
  384. return &SysDictDataDao{M: d.M.And(where, args...), Table: d.Table, TableAs: d.TableAs}
  385. }
  386. // Or adds "OR" condition to the where statement.
  387. // Deprecated, use WhereOr instead.
  388. func (d *SysDictDataDao) Or(where interface{}, args ...interface{}) *SysDictDataDao {
  389. return &SysDictDataDao{M: d.M.Or(where, args...), Table: d.Table, TableAs: d.TableAs}
  390. }
  391. // GroupBy sets the "GROUP BY" statement for the model.
  392. func (d *SysDictDataDao) GroupBy(groupBy string) *SysDictDataDao {
  393. return &SysDictDataDao{M: d.M.Group(groupBy), Table: d.Table, TableAs: d.TableAs}
  394. }
  395. // Order sets the "ORDER BY" statement for the model.
  396. func (d *SysDictDataDao) Order(orderBy ...string) *SysDictDataDao {
  397. return &SysDictDataDao{M: d.M.Order(orderBy...), Table: d.Table, TableAs: d.TableAs}
  398. }
  399. // OrderAsc sets the "ORDER BY xxx ASC" statement for the model.
  400. func (d *SysDictDataDao) OrderAsc(column string) *SysDictDataDao {
  401. return &SysDictDataDao{M: d.M.OrderAsc(column), Table: d.Table, TableAs: d.TableAs}
  402. }
  403. // OrderDesc sets the "ORDER BY xxx DESC" statement for the model.
  404. func (d *SysDictDataDao) OrderDesc(column string) *SysDictDataDao {
  405. return &SysDictDataDao{M: d.M.OrderDesc(column), Table: d.Table, TableAs: d.TableAs}
  406. }
  407. // OrderRandom sets the "ORDER BY RANDOM()" statement for the model.
  408. func (d *SysDictDataDao) OrderRandom() *SysDictDataDao {
  409. return &SysDictDataDao{M: d.M.OrderRandom(), Table: d.Table, TableAs: d.TableAs}
  410. }
  411. // OrderBy is alias of Model.Order.
  412. // See Model.Order.
  413. // Deprecated, use Order instead.
  414. func (d *SysDictDataDao) OrderBy(orderBy string) *SysDictDataDao {
  415. return &SysDictDataDao{M: d.M.Order(orderBy), Table: d.Table, TableAs: d.TableAs}
  416. }
  417. // Limit sets the "LIMIT" statement for the model.
  418. // The parameter <limit> can be either one or two number, if passed two number is passed,
  419. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  420. // statement.
  421. func (d *SysDictDataDao) Limit(limit ...int) *SysDictDataDao {
  422. return &SysDictDataDao{M: d.M.Limit(limit...), Table: d.Table, TableAs: d.TableAs}
  423. }
  424. // Offset sets the "OFFSET" statement for the model.
  425. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  426. func (d *SysDictDataDao) Offset(offset int) *SysDictDataDao {
  427. return &SysDictDataDao{M: d.M.Offset(offset), Table: d.Table, TableAs: d.TableAs}
  428. }
  429. // Distinct forces the query to only return distinct results.
  430. func (d *SysDictDataDao) Distinct() *SysDictDataDao {
  431. return &SysDictDataDao{M: d.M.Distinct(), Table: d.Table, TableAs: d.TableAs}
  432. }
  433. // Page sets the paging number for the model.
  434. // The parameter <page> is started from 1 for paging.
  435. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  436. func (d *SysDictDataDao) Page(page, limit int) *SysDictDataDao {
  437. return &SysDictDataDao{M: d.M.Page(page, limit), Table: d.Table, TableAs: d.TableAs}
  438. }
  439. // Batch sets the batch operation number for the model.
  440. func (d *SysDictDataDao) Batch(batch int) *SysDictDataDao {
  441. return &SysDictDataDao{M: d.M.Batch(batch), Table: d.Table, TableAs: d.TableAs}
  442. }
  443. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  444. // if there's another same sql request, it just reads and returns the result from cache, it
  445. // but not committed and executed into the database.
  446. //
  447. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  448. // If the parameter <duration> = 0, which means it never expires.
  449. // If the parameter <duration> > 0, which means it expires after <duration>.
  450. //
  451. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  452. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  453. //
  454. // Note that, the cache feature is disabled if the model is operating on a transaction.
  455. func (d *SysDictDataDao) Cache(duration time.Duration, name ...string) *SysDictDataDao {
  456. return &SysDictDataDao{M: d.M.Cache(duration, name...), Table: d.Table, TableAs: d.TableAs}
  457. }
  458. // Data sets the operation data for the model.
  459. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  460. // Eg:
  461. // Data("uid=10000")
  462. // Data("uid", 10000)
  463. // Data(g.Map{"uid": 10000, "name":"john"})
  464. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  465. func (d *SysDictDataDao) Data(data ...interface{}) *SysDictDataDao {
  466. return &SysDictDataDao{M: d.M.Data(data...), Table: d.Table, TableAs: d.TableAs}
  467. }
  468. // All does "SELECT FROM ..." statement for the model.
  469. // It retrieves the records from table and returns the result as []*model.SysDictData.
  470. // It returns nil if there's no record retrieved with the given conditions from table.
  471. //
  472. // The optional parameter <where> is the same as the parameter of M.Where function,
  473. // see M.Where.
  474. func (d *SysDictDataDao) All(where ...interface{}) ([]*model.SysDictData, error) {
  475. all, err := d.M.All(where...)
  476. if err != nil {
  477. return nil, err
  478. }
  479. var entities []*model.SysDictData
  480. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  481. return nil, err
  482. }
  483. return entities, nil
  484. }
  485. // One retrieves one record from table and returns the result as *model.SysDictData.
  486. // It returns nil if there's no record retrieved with the given conditions from table.
  487. //
  488. // The optional parameter <where> is the same as the parameter of M.Where function,
  489. // see M.Where.
  490. func (d *SysDictDataDao) One(where ...interface{}) (*model.SysDictData, error) {
  491. one, err := d.M.One(where...)
  492. if err != nil {
  493. return nil, err
  494. }
  495. var entity *model.SysDictData
  496. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  497. return nil, err
  498. }
  499. return entity, nil
  500. }
  501. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  502. // Also see M.WherePri and M.One.
  503. func (d *SysDictDataDao) FindOne(where ...interface{}) (*model.SysDictData, error) {
  504. one, err := d.M.FindOne(where...)
  505. if err != nil {
  506. return nil, err
  507. }
  508. var entity *model.SysDictData
  509. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  510. return nil, err
  511. }
  512. return entity, nil
  513. }
  514. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  515. // Also see M.WherePri and M.All.
  516. func (d *SysDictDataDao) FindAll(where ...interface{}) ([]*model.SysDictData, error) {
  517. all, err := d.M.FindAll(where...)
  518. if err != nil {
  519. return nil, err
  520. }
  521. var entities []*model.SysDictData
  522. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  523. return nil, err
  524. }
  525. return entities, nil
  526. }
  527. // Struct retrieves one record from table and converts it into given struct.
  528. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  529. // it can create the struct internally during converting.
  530. //
  531. // The optional parameter <where> is the same as the parameter of Model.Where function,
  532. // see Model.Where.
  533. //
  534. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  535. // from table and <pointer> is not nil.
  536. //
  537. // Eg:
  538. // user := new(User)
  539. // err := dao.User.Where("id", 1).Struct(user)
  540. //
  541. // user := (*User)(nil)
  542. // err := dao.User.Where("id", 1).Struct(&user)
  543. func (d *SysDictDataDao) Struct(pointer interface{}, where ...interface{}) error {
  544. return d.M.Struct(pointer, where...)
  545. }
  546. // Structs retrieves records from table and converts them into given struct slice.
  547. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  548. // slice internally during converting.
  549. //
  550. // The optional parameter <where> is the same as the parameter of Model.Where function,
  551. // see Model.Where.
  552. //
  553. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  554. // from table and <pointer> is not empty.
  555. //
  556. // Eg:
  557. // users := ([]User)(nil)
  558. // err := dao.User.Structs(&users)
  559. //
  560. // users := ([]*User)(nil)
  561. // err := dao.User.Structs(&users)
  562. func (d *SysDictDataDao) Structs(pointer interface{}, where ...interface{}) error {
  563. return d.M.Structs(pointer, where...)
  564. }
  565. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  566. // It calls function Struct if <pointer> is type of *struct/**struct.
  567. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  568. //
  569. // The optional parameter <where> is the same as the parameter of Model.Where function,
  570. // see Model.Where.
  571. //
  572. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  573. //
  574. // Eg:
  575. // user := new(User)
  576. // err := dao.User.Where("id", 1).Scan(user)
  577. //
  578. // user := (*User)(nil)
  579. // err := dao.User.Where("id", 1).Scan(&user)
  580. //
  581. // users := ([]User)(nil)
  582. // err := dao.User.Scan(&users)
  583. //
  584. // users := ([]*User)(nil)
  585. // err := dao.User.Scan(&users)
  586. func (d *SysDictDataDao) Scan(pointer interface{}, where ...interface{}) error {
  587. return d.M.Scan(pointer, where...)
  588. }
  589. // Chunk iterates the table with given size and callback function.
  590. func (d *SysDictDataDao) Chunk(limit int, callback func(entities []*model.SysDictData, err error) bool) {
  591. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  592. var entities []*model.SysDictData
  593. err = result.Structs(&entities)
  594. if err == sql.ErrNoRows {
  595. return false
  596. }
  597. return callback(entities, err)
  598. })
  599. }
  600. // LockUpdate sets the lock for update for current operation.
  601. func (d *SysDictDataDao) LockUpdate() *SysDictDataDao {
  602. return &SysDictDataDao{M: d.M.LockUpdate(), Table: d.Table, TableAs: d.TableAs}
  603. }
  604. // LockShared sets the lock in share mode for current operation.
  605. func (d *SysDictDataDao) LockShared() *SysDictDataDao {
  606. return &SysDictDataDao{M: d.M.LockShared(), Table: d.Table, TableAs: d.TableAs}
  607. }
  608. // Unscoped enables/disables the soft deleting feature.
  609. func (d *SysDictDataDao) Unscoped() *SysDictDataDao {
  610. return &SysDictDataDao{M: d.M.Unscoped(), Table: d.Table, TableAs: d.TableAs}
  611. }
  612. // DataScope enables the DataScope feature.
  613. func (d *SysDictDataDao) DataScope(ctx context.Context, userCol ...string) *SysDictDataDao {
  614. cs := ctx.Value("contextService")
  615. dataScope := gconv.Map(cs)["dataScope"].(g.Map)
  616. if dataScope != nil {
  617. userIds, ok := dataScope["userIds"]
  618. delete(dataScope, "userIds")
  619. var columns []string
  620. var values []interface{}
  621. if ok && userIds != "-1" {
  622. column := "created_by"
  623. if len(userCol) == 1 {
  624. column = userCol[0]
  625. }
  626. dataScope[column] = userIds
  627. if d.Table == "sys_user" {
  628. dataScope["id"] = userIds
  629. }
  630. }
  631. tableAs := d.TableAs
  632. if d.TableAs != "" {
  633. tableAs += "."
  634. }
  635. for k, v := range dataScope {
  636. if ok, _ := d.M.HasField(k); ok {
  637. columns = append(columns, tableAs+k+" IN (?) ")
  638. values = append(values, v)
  639. }
  640. }
  641. whereSql := strings.Join(columns, " OR ")
  642. return &SysDictDataDao{M: d.M.Where(whereSql, values).Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
  643. }
  644. return d
  645. }