plat_user_config.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. "time"
  12. model "dashoo.cn/micro/app/model/plat"
  13. )
  14. // PlatUserConfigDao is the manager for logic model data accessing
  15. // and custom defined data operations functions management.
  16. type PlatUserConfigDao struct {
  17. gmvc.M
  18. DB gdb.DB
  19. Table string
  20. Columns platUserConfigColumns
  21. }
  22. // PlatUserConfigColumns defines and stores column names for table plat_user_config.
  23. type platUserConfigColumns struct {
  24. Id string // 主键
  25. UserId string // 用户ID
  26. ModuleCode string // 模块代码
  27. ConfigInfo string // 配置信息
  28. Remark string // 备注
  29. CreatedBy string // 创建者
  30. CreatedName string // 创建人
  31. CreatedTime string // 创建时间
  32. UpdatedBy string // 更新者
  33. UpdatedName string // 更新人
  34. UpdatedTime string // 更新时间
  35. DeletedTime string // 删除时间
  36. }
  37. var (
  38. // PlatUserConfig is globally public accessible object for table plat_user_config operations.
  39. PlatUserConfig = PlatUserConfigDao{
  40. M: g.DB("default").Model("plat_user_config").Safe(),
  41. DB: g.DB("default"),
  42. Table: "plat_user_config",
  43. Columns: platUserConfigColumns{
  44. Id: "id",
  45. UserId: "user_id",
  46. ModuleCode: "module_code",
  47. ConfigInfo: "config_info",
  48. Remark: "remark",
  49. CreatedBy: "created_by",
  50. CreatedName: "created_name",
  51. CreatedTime: "created_time",
  52. UpdatedBy: "updated_by",
  53. UpdatedName: "updated_name",
  54. UpdatedTime: "updated_time",
  55. DeletedTime: "deleted_time",
  56. },
  57. }
  58. )
  59. func NewPlatUserConfigDao(tenant string) PlatUserConfigDao {
  60. var dao PlatUserConfigDao
  61. dao = PlatUserConfigDao{
  62. M: g.DB(tenant).Model("plat_user_config").Safe(),
  63. DB: g.DB(tenant),
  64. Table: "plat_user_config",
  65. Columns: platUserConfigColumns{
  66. Id: "id",
  67. UserId: "user_id",
  68. ModuleCode: "module_code",
  69. ConfigInfo: "config_info",
  70. Remark: "remark",
  71. CreatedBy: "created_by",
  72. CreatedName: "created_name",
  73. CreatedTime: "created_time",
  74. UpdatedBy: "updated_by",
  75. UpdatedName: "updated_name",
  76. UpdatedTime: "updated_time",
  77. DeletedTime: "deleted_time",
  78. },
  79. }
  80. return dao
  81. }
  82. // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
  83. // of current DB object and with given context in it.
  84. // Note that this returned DB object can be used only once, so do not assign it to
  85. // a global or package variable for long using.
  86. func (d *PlatUserConfigDao) Ctx(ctx context.Context) *PlatUserConfigDao {
  87. return &PlatUserConfigDao{M: d.M.Ctx(ctx)}
  88. }
  89. // As sets an alias name for current table.
  90. func (d *PlatUserConfigDao) As(as string) *PlatUserConfigDao {
  91. return &PlatUserConfigDao{M: d.M.As(as)}
  92. }
  93. // TX sets the transaction for current operation.
  94. func (d *PlatUserConfigDao) TX(tx *gdb.TX) *PlatUserConfigDao {
  95. return &PlatUserConfigDao{M: d.M.TX(tx)}
  96. }
  97. // Master marks the following operation on master node.
  98. func (d *PlatUserConfigDao) Master() *PlatUserConfigDao {
  99. return &PlatUserConfigDao{M: d.M.Master()}
  100. }
  101. // Slave marks the following operation on slave node.
  102. // Note that it makes sense only if there's any slave node configured.
  103. func (d *PlatUserConfigDao) Slave() *PlatUserConfigDao {
  104. return &PlatUserConfigDao{M: d.M.Slave()}
  105. }
  106. // Args sets custom arguments for model operation.
  107. func (d *PlatUserConfigDao) Args(args ...interface{}) *PlatUserConfigDao {
  108. return &PlatUserConfigDao{M: d.M.Args(args...)}
  109. }
  110. // LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
  111. // The parameter <table> can be joined table and its joined condition,
  112. // and also with its alias name, like:
  113. // Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
  114. // Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
  115. func (d *PlatUserConfigDao) LeftJoin(table ...string) *PlatUserConfigDao {
  116. return &PlatUserConfigDao{M: d.M.LeftJoin(table...)}
  117. }
  118. // RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
  119. // The parameter <table> can be joined table and its joined condition,
  120. // and also with its alias name, like:
  121. // Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
  122. // Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
  123. func (d *PlatUserConfigDao) RightJoin(table ...string) *PlatUserConfigDao {
  124. return &PlatUserConfigDao{M: d.M.RightJoin(table...)}
  125. }
  126. // InnerJoin does "INNER JOIN ... ON ..." statement on the model.
  127. // The parameter <table> can be joined table and its joined condition,
  128. // and also with its alias name, like:
  129. // Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
  130. // Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
  131. func (d *PlatUserConfigDao) InnerJoin(table ...string) *PlatUserConfigDao {
  132. return &PlatUserConfigDao{M: d.M.InnerJoin(table...)}
  133. }
  134. // Fields sets the operation fields of the model, multiple fields joined using char ','.
  135. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  136. func (d *PlatUserConfigDao) Fields(fieldNamesOrMapStruct ...interface{}) *PlatUserConfigDao {
  137. return &PlatUserConfigDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
  138. }
  139. // FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
  140. // The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
  141. func (d *PlatUserConfigDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *PlatUserConfigDao {
  142. return &PlatUserConfigDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
  143. }
  144. // Option sets the extra operation option for the model.
  145. func (d *PlatUserConfigDao) Option(option int) *PlatUserConfigDao {
  146. return &PlatUserConfigDao{M: d.M.Option(option)}
  147. }
  148. // OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
  149. // the data and where attributes for empty values.
  150. func (d *PlatUserConfigDao) OmitEmpty() *PlatUserConfigDao {
  151. return &PlatUserConfigDao{M: d.M.OmitEmpty()}
  152. }
  153. // Filter marks filtering the fields which does not exist in the fields of the operated table.
  154. func (d *PlatUserConfigDao) Filter() *PlatUserConfigDao {
  155. return &PlatUserConfigDao{M: d.M.Filter()}
  156. }
  157. // Where sets the condition statement for the model. The parameter <where> can be type of
  158. // string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
  159. // multiple conditions will be joined into where statement using "AND".
  160. // Eg:
  161. // Where("uid=10000")
  162. // Where("uid", 10000)
  163. // Where("money>? AND name like ?", 99999, "vip_%")
  164. // Where("uid", 1).Where("name", "john")
  165. // Where("status IN (?)", g.Slice{1,2,3})
  166. // Where("age IN(?,?)", 18, 50)
  167. // Where(User{ Id : 1, UserName : "john"})
  168. func (d *PlatUserConfigDao) Where(where interface{}, args ...interface{}) *PlatUserConfigDao {
  169. return &PlatUserConfigDao{M: d.M.Where(where, args...)}
  170. }
  171. // WherePri does the same logic as M.Where except that if the parameter <where>
  172. // is a single condition like int/string/float/slice, it treats the condition as the primary
  173. // key value. That is, if primary key is "id" and given <where> parameter as "123", the
  174. // WherePri function treats the condition as "id=123", but M.Where treats the condition
  175. // as string "123".
  176. func (d *PlatUserConfigDao) WherePri(where interface{}, args ...interface{}) *PlatUserConfigDao {
  177. return &PlatUserConfigDao{M: d.M.WherePri(where, args...)}
  178. }
  179. // And adds "AND" condition to the where statement.
  180. func (d *PlatUserConfigDao) And(where interface{}, args ...interface{}) *PlatUserConfigDao {
  181. return &PlatUserConfigDao{M: d.M.And(where, args...)}
  182. }
  183. // Or adds "OR" condition to the where statement.
  184. func (d *PlatUserConfigDao) Or(where interface{}, args ...interface{}) *PlatUserConfigDao {
  185. return &PlatUserConfigDao{M: d.M.Or(where, args...)}
  186. }
  187. // Group sets the "GROUP BY" statement for the model.
  188. func (d *PlatUserConfigDao) Group(groupBy string) *PlatUserConfigDao {
  189. return &PlatUserConfigDao{M: d.M.Group(groupBy)}
  190. }
  191. // Order sets the "ORDER BY" statement for the model.
  192. func (d *PlatUserConfigDao) Order(orderBy ...string) *PlatUserConfigDao {
  193. return &PlatUserConfigDao{M: d.M.Order(orderBy...)}
  194. }
  195. // Limit sets the "LIMIT" statement for the model.
  196. // The parameter <limit> can be either one or two number, if passed two number is passed,
  197. // it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
  198. // statement.
  199. func (d *PlatUserConfigDao) Limit(limit ...int) *PlatUserConfigDao {
  200. return &PlatUserConfigDao{M: d.M.Limit(limit...)}
  201. }
  202. // Offset sets the "OFFSET" statement for the model.
  203. // It only makes sense for some databases like SQLServer, PostgreSQL, etc.
  204. func (d *PlatUserConfigDao) Offset(offset int) *PlatUserConfigDao {
  205. return &PlatUserConfigDao{M: d.M.Offset(offset)}
  206. }
  207. // Page sets the paging number for the model.
  208. // The parameter <page> is started from 1 for paging.
  209. // Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
  210. func (d *PlatUserConfigDao) Page(page, limit int) *PlatUserConfigDao {
  211. return &PlatUserConfigDao{M: d.M.Page(page, limit)}
  212. }
  213. // Batch sets the batch operation number for the model.
  214. func (d *PlatUserConfigDao) Batch(batch int) *PlatUserConfigDao {
  215. return &PlatUserConfigDao{M: d.M.Batch(batch)}
  216. }
  217. // Cache sets the cache feature for the model. It caches the result of the sql, which means
  218. // if there's another same sql request, it just reads and returns the result from cache, it
  219. // but not committed and executed into the database.
  220. //
  221. // If the parameter <duration> < 0, which means it clear the cache with given <name>.
  222. // If the parameter <duration> = 0, which means it never expires.
  223. // If the parameter <duration> > 0, which means it expires after <duration>.
  224. //
  225. // The optional parameter <name> is used to bind a name to the cache, which means you can later
  226. // control the cache like changing the <duration> or clearing the cache with specified <name>.
  227. //
  228. // Note that, the cache feature is disabled if the model is operating on a transaction.
  229. func (d *PlatUserConfigDao) Cache(duration time.Duration, name ...string) *PlatUserConfigDao {
  230. return &PlatUserConfigDao{M: d.M.Cache(duration, name...)}
  231. }
  232. // Data sets the operation data for the model.
  233. // The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
  234. // Eg:
  235. // Data("uid=10000")
  236. // Data("uid", 10000)
  237. // Data(g.Map{"uid": 10000, "name":"john"})
  238. // Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
  239. func (d *PlatUserConfigDao) Data(data ...interface{}) *PlatUserConfigDao {
  240. return &PlatUserConfigDao{M: d.M.Data(data...)}
  241. }
  242. // All does "SELECT FROM ..." statement for the model.
  243. // It retrieves the records from table and returns the result as []*model.PlatUserConfig.
  244. // It returns nil if there's no record retrieved with the given conditions from table.
  245. //
  246. // The optional parameter <where> is the same as the parameter of M.Where function,
  247. // see M.Where.
  248. func (d *PlatUserConfigDao) All(where ...interface{}) ([]*model.PlatUserConfig, error) {
  249. all, err := d.M.All(where...)
  250. if err != nil {
  251. return nil, err
  252. }
  253. var entities []*model.PlatUserConfig
  254. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  255. return nil, err
  256. }
  257. return entities, nil
  258. }
  259. // One retrieves one record from table and returns the result as *model.PlatUserConfig.
  260. // It returns nil if there's no record retrieved with the given conditions from table.
  261. //
  262. // The optional parameter <where> is the same as the parameter of M.Where function,
  263. // see M.Where.
  264. func (d *PlatUserConfigDao) One(where ...interface{}) (*model.PlatUserConfig, error) {
  265. one, err := d.M.One(where...)
  266. if err != nil {
  267. return nil, err
  268. }
  269. var entity *model.PlatUserConfig
  270. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  271. return nil, err
  272. }
  273. return entity, nil
  274. }
  275. // FindOne retrieves and returns a single Record by M.WherePri and M.One.
  276. // Also see M.WherePri and M.One.
  277. func (d *PlatUserConfigDao) FindOne(where ...interface{}) (*model.PlatUserConfig, error) {
  278. one, err := d.M.FindOne(where...)
  279. if err != nil {
  280. return nil, err
  281. }
  282. var entity *model.PlatUserConfig
  283. if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
  284. return nil, err
  285. }
  286. return entity, nil
  287. }
  288. // FindAll retrieves and returns Result by by M.WherePri and M.All.
  289. // Also see M.WherePri and M.All.
  290. func (d *PlatUserConfigDao) FindAll(where ...interface{}) ([]*model.PlatUserConfig, error) {
  291. all, err := d.M.FindAll(where...)
  292. if err != nil {
  293. return nil, err
  294. }
  295. var entities []*model.PlatUserConfig
  296. if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
  297. return nil, err
  298. }
  299. return entities, nil
  300. }
  301. // Struct retrieves one record from table and converts it into given struct.
  302. // The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
  303. // it can create the struct internally during converting.
  304. //
  305. // The optional parameter <where> is the same as the parameter of Model.Where function,
  306. // see Model.Where.
  307. //
  308. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  309. // from table and <pointer> is not nil.
  310. //
  311. // Eg:
  312. // user := new(User)
  313. // err := dao.User.Where("id", 1).Struct(user)
  314. //
  315. // user := (*User)(nil)
  316. // err := dao.User.Where("id", 1).Struct(&user)
  317. func (d *PlatUserConfigDao) Struct(pointer interface{}, where ...interface{}) error {
  318. return d.M.Struct(pointer, where...)
  319. }
  320. // Structs retrieves records from table and converts them into given struct slice.
  321. // The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
  322. // slice internally during converting.
  323. //
  324. // The optional parameter <where> is the same as the parameter of Model.Where function,
  325. // see Model.Where.
  326. //
  327. // Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
  328. // from table and <pointer> is not empty.
  329. //
  330. // Eg:
  331. // users := ([]User)(nil)
  332. // err := dao.User.Structs(&users)
  333. //
  334. // users := ([]*User)(nil)
  335. // err := dao.User.Structs(&users)
  336. func (d *PlatUserConfigDao) Structs(pointer interface{}, where ...interface{}) error {
  337. return d.M.Structs(pointer, where...)
  338. }
  339. // Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
  340. // It calls function Struct if <pointer> is type of *struct/**struct.
  341. // It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
  342. //
  343. // The optional parameter <where> is the same as the parameter of Model.Where function,
  344. // see Model.Where.
  345. //
  346. // Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
  347. //
  348. // Eg:
  349. // user := new(User)
  350. // err := dao.User.Where("id", 1).Scan(user)
  351. //
  352. // user := (*User)(nil)
  353. // err := dao.User.Where("id", 1).Scan(&user)
  354. //
  355. // users := ([]User)(nil)
  356. // err := dao.User.Scan(&users)
  357. //
  358. // users := ([]*User)(nil)
  359. // err := dao.User.Scan(&users)
  360. func (d *PlatUserConfigDao) Scan(pointer interface{}, where ...interface{}) error {
  361. return d.M.Scan(pointer, where...)
  362. }
  363. // Chunk iterates the table with given size and callback function.
  364. func (d *PlatUserConfigDao) Chunk(limit int, callback func(entities []*model.PlatUserConfig, err error) bool) {
  365. d.M.Chunk(limit, func(result gdb.Result, err error) bool {
  366. var entities []*model.PlatUserConfig
  367. err = result.Structs(&entities)
  368. if err == sql.ErrNoRows {
  369. return false
  370. }
  371. return callback(entities, err)
  372. })
  373. }
  374. // LockUpdate sets the lock for update for current operation.
  375. func (d *PlatUserConfigDao) LockUpdate() *PlatUserConfigDao {
  376. return &PlatUserConfigDao{M: d.M.LockUpdate()}
  377. }
  378. // LockShared sets the lock in share mode for current operation.
  379. func (d *PlatUserConfigDao) LockShared() *PlatUserConfigDao {
  380. return &PlatUserConfigDao{M: d.M.LockShared()}
  381. }
  382. // Unscoped enables/disables the soft deleting feature.
  383. func (d *PlatUserConfigDao) Unscoped() *PlatUserConfigDao {
  384. return &PlatUserConfigDao{M: d.M.Unscoped()}
  385. }