modules.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package model
  5. import (
  6. "context"
  7. "gorm.io/gorm"
  8. "gorm.io/gorm/clause"
  9. "gorm.io/gorm/schema"
  10. "gorm.io/gen"
  11. "gorm.io/gen/field"
  12. "gorm.io/plugin/dbresolver"
  13. "icloudapp.cn/tools/service/entity"
  14. )
  15. func newModule(db *gorm.DB, opts ...gen.DOOption) MModule {
  16. _MModule := MModule{}
  17. _MModule.MModuleDo.UseDB(db, opts...)
  18. _MModule.MModuleDo.UseModel(&entity.Module{})
  19. tableName := _MModule.MModuleDo.TableName()
  20. _MModule.ALL = field.NewAsterisk(tableName)
  21. _MModule.ModelID = field.NewInt64(tableName, "model_id")
  22. _MModule.ModelName = field.NewString(tableName, "model_name")
  23. _MModule.ModelGroup = field.NewString(tableName, "model_group")
  24. _MModule.Menu = field.NewString(tableName, "menu")
  25. _MModule.ModelURL = field.NewString(tableName, "model_url")
  26. _MModule.ModelIndex = field.NewInt64(tableName, "model_index")
  27. _MModule.Visible = field.NewInt64(tableName, "visible")
  28. _MModule.ModelStatus = field.NewInt64(tableName, "model_status")
  29. _MModule.OperatorUID = field.NewInt64(tableName, "operator_uid")
  30. _MModule.CreateAt = field.NewTime(tableName, "create_at")
  31. _MModule.UpdateAt = field.NewTime(tableName, "update_at")
  32. _MModule.fillFieldMap()
  33. return _MModule
  34. }
  35. type MModule struct {
  36. MModuleDo MModuleDo
  37. ALL field.Asterisk
  38. ModelID field.Int64
  39. ModelName field.String // 模块名
  40. ModelGroup field.String // 模块分组
  41. Menu field.String // 菜单项
  42. ModelURL field.String // 模块连接
  43. ModelIndex field.Int64 // 模块序号
  44. Visible field.Int64 // 是否显示
  45. ModelStatus field.Int64 // 模块状态
  46. OperatorUID field.Int64 // 操作人
  47. CreateAt field.Time // 添加时间
  48. UpdateAt field.Time // 更新时间
  49. fieldMap map[string]field.Expr
  50. }
  51. func (m MModule) Table(newTableName string) *MModule {
  52. m.MModuleDo.UseTable(newTableName)
  53. return m.updateTableName(newTableName)
  54. }
  55. func (m MModule) As(alias string) *MModule {
  56. m.MModuleDo.DO = *(m.MModuleDo.As(alias).(*gen.DO))
  57. return m.updateTableName(alias)
  58. }
  59. func (m *MModule) updateTableName(table string) *MModule {
  60. m.ALL = field.NewAsterisk(table)
  61. m.ModelID = field.NewInt64(table, "model_id")
  62. m.ModelName = field.NewString(table, "model_name")
  63. m.ModelGroup = field.NewString(table, "model_group")
  64. m.Menu = field.NewString(table, "menu")
  65. m.ModelURL = field.NewString(table, "model_url")
  66. m.ModelIndex = field.NewInt64(table, "model_index")
  67. m.Visible = field.NewInt64(table, "visible")
  68. m.ModelStatus = field.NewInt64(table, "model_status")
  69. m.OperatorUID = field.NewInt64(table, "operator_uid")
  70. m.CreateAt = field.NewTime(table, "create_at")
  71. m.UpdateAt = field.NewTime(table, "update_at")
  72. m.fillFieldMap()
  73. return m
  74. }
  75. func (m *MModule) WithContext(ctx context.Context) IModuleDo { return m.MModuleDo.WithContext(ctx) }
  76. func (m MModule) TableName() string { return m.MModuleDo.TableName() }
  77. func (m MModule) Alias() string { return m.MModuleDo.Alias() }
  78. func (m *MModule) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  79. _f, ok := m.fieldMap[fieldName]
  80. if !ok || _f == nil {
  81. return nil, false
  82. }
  83. _oe, ok := _f.(field.OrderExpr)
  84. return _oe, ok
  85. }
  86. func (m *MModule) fillFieldMap() {
  87. m.fieldMap = make(map[string]field.Expr, 11)
  88. m.fieldMap["model_id"] = m.ModelID
  89. m.fieldMap["model_name"] = m.ModelName
  90. m.fieldMap["model_group"] = m.ModelGroup
  91. m.fieldMap["menu"] = m.Menu
  92. m.fieldMap["model_url"] = m.ModelURL
  93. m.fieldMap["model_index"] = m.ModelIndex
  94. m.fieldMap["visible"] = m.Visible
  95. m.fieldMap["model_status"] = m.ModelStatus
  96. m.fieldMap["operator_uid"] = m.OperatorUID
  97. m.fieldMap["create_at"] = m.CreateAt
  98. m.fieldMap["update_at"] = m.UpdateAt
  99. }
  100. func (m MModule) clone(db *gorm.DB) MModule {
  101. m.MModuleDo.ReplaceConnPool(db.Statement.ConnPool)
  102. return m
  103. }
  104. func (m MModule) replaceDB(db *gorm.DB) MModule {
  105. m.MModuleDo.ReplaceDB(db)
  106. return m
  107. }
  108. type MModuleDo struct{ gen.DO }
  109. type IModuleDo interface {
  110. gen.SubQuery
  111. Debug() IModuleDo
  112. WithContext(ctx context.Context) IModuleDo
  113. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  114. ReplaceDB(db *gorm.DB)
  115. ReadDB() IModuleDo
  116. WriteDB() IModuleDo
  117. As(alias string) gen.Dao
  118. Session(config *gorm.Session) IModuleDo
  119. Columns(cols ...field.Expr) gen.Columns
  120. Clauses(conds ...clause.Expression) IModuleDo
  121. Not(conds ...gen.Condition) IModuleDo
  122. Or(conds ...gen.Condition) IModuleDo
  123. Select(conds ...field.Expr) IModuleDo
  124. Where(conds ...gen.Condition) IModuleDo
  125. Order(conds ...field.Expr) IModuleDo
  126. Distinct(cols ...field.Expr) IModuleDo
  127. Omit(cols ...field.Expr) IModuleDo
  128. Join(table schema.Tabler, on ...field.Expr) IModuleDo
  129. LeftJoin(table schema.Tabler, on ...field.Expr) IModuleDo
  130. RightJoin(table schema.Tabler, on ...field.Expr) IModuleDo
  131. Group(cols ...field.Expr) IModuleDo
  132. Having(conds ...gen.Condition) IModuleDo
  133. Limit(limit int) IModuleDo
  134. Offset(offset int) IModuleDo
  135. Count() (count int64, err error)
  136. Scopes(funcs ...func(gen.Dao) gen.Dao) IModuleDo
  137. Unscoped() IModuleDo
  138. Create(values ...*entity.Module) error
  139. CreateInBatches(values []*entity.Module, batchSize int) error
  140. Save(values ...*entity.Module) error
  141. First() (*entity.Module, error)
  142. Take() (*entity.Module, error)
  143. Last() (*entity.Module, error)
  144. Find() ([]*entity.Module, error)
  145. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Module, err error)
  146. FindInBatches(result *[]*entity.Module, batchSize int, fc func(tx gen.Dao, batch int) error) error
  147. Pluck(column field.Expr, dest interface{}) error
  148. Delete(...*entity.Module) (info gen.ResultInfo, err error)
  149. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  150. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  151. Updates(value interface{}) (info gen.ResultInfo, err error)
  152. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  153. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  154. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  155. UpdateFrom(q gen.SubQuery) gen.Dao
  156. Attrs(attrs ...field.AssignExpr) IModuleDo
  157. Assign(attrs ...field.AssignExpr) IModuleDo
  158. Joins(fields ...field.RelationField) IModuleDo
  159. Preload(fields ...field.RelationField) IModuleDo
  160. FirstOrInit() (*entity.Module, error)
  161. FirstOrCreate() (*entity.Module, error)
  162. FindByPage(offset int, limit int) (result []*entity.Module, count int64, err error)
  163. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  164. Scan(result interface{}) (err error)
  165. Returning(value interface{}, columns ...string) IModuleDo
  166. UnderlyingDB() *gorm.DB
  167. schema.Tabler
  168. }
  169. func (m MModuleDo) Debug() IModuleDo {
  170. return m.withDO(m.DO.Debug())
  171. }
  172. func (m MModuleDo) WithContext(ctx context.Context) IModuleDo {
  173. return m.withDO(m.DO.WithContext(ctx))
  174. }
  175. func (m MModuleDo) ReadDB() IModuleDo {
  176. return m.Clauses(dbresolver.Read)
  177. }
  178. func (m MModuleDo) WriteDB() IModuleDo {
  179. return m.Clauses(dbresolver.Write)
  180. }
  181. func (m MModuleDo) Session(config *gorm.Session) IModuleDo {
  182. return m.withDO(m.DO.Session(config))
  183. }
  184. func (m MModuleDo) Clauses(conds ...clause.Expression) IModuleDo {
  185. return m.withDO(m.DO.Clauses(conds...))
  186. }
  187. func (m MModuleDo) Returning(value interface{}, columns ...string) IModuleDo {
  188. return m.withDO(m.DO.Returning(value, columns...))
  189. }
  190. func (m MModuleDo) Not(conds ...gen.Condition) IModuleDo {
  191. return m.withDO(m.DO.Not(conds...))
  192. }
  193. func (m MModuleDo) Or(conds ...gen.Condition) IModuleDo {
  194. return m.withDO(m.DO.Or(conds...))
  195. }
  196. func (m MModuleDo) Select(conds ...field.Expr) IModuleDo {
  197. return m.withDO(m.DO.Select(conds...))
  198. }
  199. func (m MModuleDo) Where(conds ...gen.Condition) IModuleDo {
  200. return m.withDO(m.DO.Where(conds...))
  201. }
  202. func (m MModuleDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IModuleDo {
  203. return m.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  204. }
  205. func (m MModuleDo) Order(conds ...field.Expr) IModuleDo {
  206. return m.withDO(m.DO.Order(conds...))
  207. }
  208. func (m MModuleDo) Distinct(cols ...field.Expr) IModuleDo {
  209. return m.withDO(m.DO.Distinct(cols...))
  210. }
  211. func (m MModuleDo) Omit(cols ...field.Expr) IModuleDo {
  212. return m.withDO(m.DO.Omit(cols...))
  213. }
  214. func (m MModuleDo) Join(table schema.Tabler, on ...field.Expr) IModuleDo {
  215. return m.withDO(m.DO.Join(table, on...))
  216. }
  217. func (m MModuleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IModuleDo {
  218. return m.withDO(m.DO.LeftJoin(table, on...))
  219. }
  220. func (m MModuleDo) RightJoin(table schema.Tabler, on ...field.Expr) IModuleDo {
  221. return m.withDO(m.DO.RightJoin(table, on...))
  222. }
  223. func (m MModuleDo) Group(cols ...field.Expr) IModuleDo {
  224. return m.withDO(m.DO.Group(cols...))
  225. }
  226. func (m MModuleDo) Having(conds ...gen.Condition) IModuleDo {
  227. return m.withDO(m.DO.Having(conds...))
  228. }
  229. func (m MModuleDo) Limit(limit int) IModuleDo {
  230. return m.withDO(m.DO.Limit(limit))
  231. }
  232. func (m MModuleDo) Offset(offset int) IModuleDo {
  233. return m.withDO(m.DO.Offset(offset))
  234. }
  235. func (m MModuleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IModuleDo {
  236. return m.withDO(m.DO.Scopes(funcs...))
  237. }
  238. func (m MModuleDo) Unscoped() IModuleDo {
  239. return m.withDO(m.DO.Unscoped())
  240. }
  241. func (m MModuleDo) Create(values ...*entity.Module) error {
  242. if len(values) == 0 {
  243. return nil
  244. }
  245. return m.DO.Create(values)
  246. }
  247. func (m MModuleDo) CreateInBatches(values []*entity.Module, batchSize int) error {
  248. return m.DO.CreateInBatches(values, batchSize)
  249. }
  250. // Save : !!! underlying implementation is different with GORM
  251. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  252. func (m MModuleDo) Save(values ...*entity.Module) error {
  253. if len(values) == 0 {
  254. return nil
  255. }
  256. return m.DO.Save(values)
  257. }
  258. func (m MModuleDo) First() (*entity.Module, error) {
  259. if result, err := m.DO.First(); err != nil {
  260. return nil, err
  261. } else {
  262. return result.(*entity.Module), nil
  263. }
  264. }
  265. func (m MModuleDo) Take() (*entity.Module, error) {
  266. if result, err := m.DO.Take(); err != nil {
  267. return nil, err
  268. } else {
  269. return result.(*entity.Module), nil
  270. }
  271. }
  272. func (m MModuleDo) Last() (*entity.Module, error) {
  273. if result, err := m.DO.Last(); err != nil {
  274. return nil, err
  275. } else {
  276. return result.(*entity.Module), nil
  277. }
  278. }
  279. func (m MModuleDo) Find() ([]*entity.Module, error) {
  280. result, err := m.DO.Find()
  281. return result.([]*entity.Module), err
  282. }
  283. func (m MModuleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Module, err error) {
  284. buf := make([]*entity.Module, 0, batchSize)
  285. err = m.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  286. defer func() { results = append(results, buf...) }()
  287. return fc(tx, batch)
  288. })
  289. return results, err
  290. }
  291. func (m MModuleDo) FindInBatches(result *[]*entity.Module, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  292. return m.DO.FindInBatches(result, batchSize, fc)
  293. }
  294. func (m MModuleDo) Attrs(attrs ...field.AssignExpr) IModuleDo {
  295. return m.withDO(m.DO.Attrs(attrs...))
  296. }
  297. func (m MModuleDo) Assign(attrs ...field.AssignExpr) IModuleDo {
  298. return m.withDO(m.DO.Assign(attrs...))
  299. }
  300. func (m MModuleDo) Joins(fields ...field.RelationField) IModuleDo {
  301. for _, _f := range fields {
  302. m = *m.withDO(m.DO.Joins(_f))
  303. }
  304. return &m
  305. }
  306. func (m MModuleDo) Preload(fields ...field.RelationField) IModuleDo {
  307. for _, _f := range fields {
  308. m = *m.withDO(m.DO.Preload(_f))
  309. }
  310. return &m
  311. }
  312. func (m MModuleDo) FirstOrInit() (*entity.Module, error) {
  313. if result, err := m.DO.FirstOrInit(); err != nil {
  314. return nil, err
  315. } else {
  316. return result.(*entity.Module), nil
  317. }
  318. }
  319. func (m MModuleDo) FirstOrCreate() (*entity.Module, error) {
  320. if result, err := m.DO.FirstOrCreate(); err != nil {
  321. return nil, err
  322. } else {
  323. return result.(*entity.Module), nil
  324. }
  325. }
  326. func (m MModuleDo) FindByPage(offset int, limit int) (result []*entity.Module, count int64, err error) {
  327. result, err = m.Offset(offset).Limit(limit).Find()
  328. if err != nil {
  329. return
  330. }
  331. if size := len(result); 0 < limit && 0 < size && size < limit {
  332. count = int64(size + offset)
  333. return
  334. }
  335. count, err = m.Offset(-1).Limit(-1).Count()
  336. return
  337. }
  338. func (m MModuleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  339. count, err = m.Count()
  340. if err != nil {
  341. return
  342. }
  343. err = m.Offset(offset).Limit(limit).Scan(result)
  344. return
  345. }
  346. func (m MModuleDo) Scan(result interface{}) (err error) {
  347. return m.DO.Scan(result)
  348. }
  349. func (m MModuleDo) Delete(models ...*entity.Module) (result gen.ResultInfo, err error) {
  350. return m.DO.Delete(models)
  351. }
  352. func (m *MModuleDo) withDO(do gen.Dao) *MModuleDo {
  353. m.DO = *do.(*gen.DO)
  354. return m
  355. }