plat_user_config.go 31 KB

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