sys_dict_data.go 16 KB

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