plat_user_config.go 32 KB

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