sys_dict_data.go 15 KB

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