sys_auth_rule.go 15 KB

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