admin_notice.gen.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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 query
  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. "gadmin/internal/gorm/model"
  14. )
  15. func newAdminNotice(db *gorm.DB, opts ...gen.DOOption) adminNotice {
  16. _adminNotice := adminNotice{}
  17. _adminNotice.adminNoticeDo.UseDB(db, opts...)
  18. _adminNotice.adminNoticeDo.UseModel(&model.AdminNotice{})
  19. tableName := _adminNotice.adminNoticeDo.TableName()
  20. _adminNotice.ALL = field.NewAsterisk(tableName)
  21. _adminNotice.ID = field.NewInt64(tableName, "id")
  22. _adminNotice.Environment = field.NewString(tableName, "environment")
  23. _adminNotice.NoticeType = field.NewInt32(tableName, "notice_type")
  24. _adminNotice.Content = field.NewString(tableName, "content")
  25. _adminNotice.ServerIds = field.NewString(tableName, "server_ids")
  26. _adminNotice.SendInterval = field.NewInt64(tableName, "send_interval")
  27. _adminNotice.StartAt = field.NewInt64(tableName, "start_at")
  28. _adminNotice.EndAt = field.NewInt64(tableName, "end_at")
  29. _adminNotice.LastSendAt = field.NewInt64(tableName, "last_send_at")
  30. _adminNotice.MsgID = field.NewString(tableName, "msg_id")
  31. _adminNotice.Status = field.NewInt32(tableName, "status")
  32. _adminNotice.UpdatedAt = field.NewInt64(tableName, "updated_at")
  33. _adminNotice.CreatedAt = field.NewInt64(tableName, "created_at")
  34. _adminNotice.fillFieldMap()
  35. return _adminNotice
  36. }
  37. type adminNotice struct {
  38. adminNoticeDo
  39. ALL field.Asterisk
  40. ID field.Int64
  41. Environment field.String // 所在环境
  42. NoticeType field.Int32 // 公告类型(1普通;2停服)
  43. Content field.String // 公告内容
  44. ServerIds field.String // 服务器
  45. SendInterval field.Int64 // 发送间隔(分钟)
  46. StartAt field.Int64 // 开始时间
  47. EndAt field.Int64 // 结束时间
  48. LastSendAt field.Int64 // 最后发送时间
  49. MsgID field.String // 广播消息ID
  50. Status field.Int32 // 公告状态(1运行中;2已结束;3已终止;4未开始)
  51. UpdatedAt field.Int64 // 更新时间
  52. CreatedAt field.Int64 // 创建时间
  53. fieldMap map[string]field.Expr
  54. }
  55. func (a adminNotice) Table(newTableName string) *adminNotice {
  56. a.adminNoticeDo.UseTable(newTableName)
  57. return a.updateTableName(newTableName)
  58. }
  59. func (a adminNotice) As(alias string) *adminNotice {
  60. a.adminNoticeDo.DO = *(a.adminNoticeDo.As(alias).(*gen.DO))
  61. return a.updateTableName(alias)
  62. }
  63. func (a *adminNotice) updateTableName(table string) *adminNotice {
  64. a.ALL = field.NewAsterisk(table)
  65. a.ID = field.NewInt64(table, "id")
  66. a.Environment = field.NewString(table, "environment")
  67. a.NoticeType = field.NewInt32(table, "notice_type")
  68. a.Content = field.NewString(table, "content")
  69. a.ServerIds = field.NewString(table, "server_ids")
  70. a.SendInterval = field.NewInt64(table, "send_interval")
  71. a.StartAt = field.NewInt64(table, "start_at")
  72. a.EndAt = field.NewInt64(table, "end_at")
  73. a.LastSendAt = field.NewInt64(table, "last_send_at")
  74. a.MsgID = field.NewString(table, "msg_id")
  75. a.Status = field.NewInt32(table, "status")
  76. a.UpdatedAt = field.NewInt64(table, "updated_at")
  77. a.CreatedAt = field.NewInt64(table, "created_at")
  78. a.fillFieldMap()
  79. return a
  80. }
  81. func (a *adminNotice) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  82. _f, ok := a.fieldMap[fieldName]
  83. if !ok || _f == nil {
  84. return nil, false
  85. }
  86. _oe, ok := _f.(field.OrderExpr)
  87. return _oe, ok
  88. }
  89. func (a *adminNotice) fillFieldMap() {
  90. a.fieldMap = make(map[string]field.Expr, 13)
  91. a.fieldMap["id"] = a.ID
  92. a.fieldMap["environment"] = a.Environment
  93. a.fieldMap["notice_type"] = a.NoticeType
  94. a.fieldMap["content"] = a.Content
  95. a.fieldMap["server_ids"] = a.ServerIds
  96. a.fieldMap["send_interval"] = a.SendInterval
  97. a.fieldMap["start_at"] = a.StartAt
  98. a.fieldMap["end_at"] = a.EndAt
  99. a.fieldMap["last_send_at"] = a.LastSendAt
  100. a.fieldMap["msg_id"] = a.MsgID
  101. a.fieldMap["status"] = a.Status
  102. a.fieldMap["updated_at"] = a.UpdatedAt
  103. a.fieldMap["created_at"] = a.CreatedAt
  104. }
  105. func (a adminNotice) clone(db *gorm.DB) adminNotice {
  106. a.adminNoticeDo.ReplaceConnPool(db.Statement.ConnPool)
  107. return a
  108. }
  109. func (a adminNotice) replaceDB(db *gorm.DB) adminNotice {
  110. a.adminNoticeDo.ReplaceDB(db)
  111. return a
  112. }
  113. type adminNoticeDo struct{ gen.DO }
  114. func (a adminNoticeDo) Debug() *adminNoticeDo {
  115. return a.withDO(a.DO.Debug())
  116. }
  117. func (a adminNoticeDo) WithContext(ctx context.Context) *adminNoticeDo {
  118. return a.withDO(a.DO.WithContext(ctx))
  119. }
  120. func (a adminNoticeDo) ReadDB() *adminNoticeDo {
  121. return a.Clauses(dbresolver.Read)
  122. }
  123. func (a adminNoticeDo) WriteDB() *adminNoticeDo {
  124. return a.Clauses(dbresolver.Write)
  125. }
  126. func (a adminNoticeDo) Session(config *gorm.Session) *adminNoticeDo {
  127. return a.withDO(a.DO.Session(config))
  128. }
  129. func (a adminNoticeDo) Clauses(conds ...clause.Expression) *adminNoticeDo {
  130. return a.withDO(a.DO.Clauses(conds...))
  131. }
  132. func (a adminNoticeDo) Returning(value interface{}, columns ...string) *adminNoticeDo {
  133. return a.withDO(a.DO.Returning(value, columns...))
  134. }
  135. func (a adminNoticeDo) Not(conds ...gen.Condition) *adminNoticeDo {
  136. return a.withDO(a.DO.Not(conds...))
  137. }
  138. func (a adminNoticeDo) Or(conds ...gen.Condition) *adminNoticeDo {
  139. return a.withDO(a.DO.Or(conds...))
  140. }
  141. func (a adminNoticeDo) Select(conds ...field.Expr) *adminNoticeDo {
  142. return a.withDO(a.DO.Select(conds...))
  143. }
  144. func (a adminNoticeDo) Where(conds ...gen.Condition) *adminNoticeDo {
  145. return a.withDO(a.DO.Where(conds...))
  146. }
  147. func (a adminNoticeDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *adminNoticeDo {
  148. return a.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  149. }
  150. func (a adminNoticeDo) Order(conds ...field.Expr) *adminNoticeDo {
  151. return a.withDO(a.DO.Order(conds...))
  152. }
  153. func (a adminNoticeDo) Distinct(cols ...field.Expr) *adminNoticeDo {
  154. return a.withDO(a.DO.Distinct(cols...))
  155. }
  156. func (a adminNoticeDo) Omit(cols ...field.Expr) *adminNoticeDo {
  157. return a.withDO(a.DO.Omit(cols...))
  158. }
  159. func (a adminNoticeDo) Join(table schema.Tabler, on ...field.Expr) *adminNoticeDo {
  160. return a.withDO(a.DO.Join(table, on...))
  161. }
  162. func (a adminNoticeDo) LeftJoin(table schema.Tabler, on ...field.Expr) *adminNoticeDo {
  163. return a.withDO(a.DO.LeftJoin(table, on...))
  164. }
  165. func (a adminNoticeDo) RightJoin(table schema.Tabler, on ...field.Expr) *adminNoticeDo {
  166. return a.withDO(a.DO.RightJoin(table, on...))
  167. }
  168. func (a adminNoticeDo) Group(cols ...field.Expr) *adminNoticeDo {
  169. return a.withDO(a.DO.Group(cols...))
  170. }
  171. func (a adminNoticeDo) Having(conds ...gen.Condition) *adminNoticeDo {
  172. return a.withDO(a.DO.Having(conds...))
  173. }
  174. func (a adminNoticeDo) Limit(limit int) *adminNoticeDo {
  175. return a.withDO(a.DO.Limit(limit))
  176. }
  177. func (a adminNoticeDo) Offset(offset int) *adminNoticeDo {
  178. return a.withDO(a.DO.Offset(offset))
  179. }
  180. func (a adminNoticeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *adminNoticeDo {
  181. return a.withDO(a.DO.Scopes(funcs...))
  182. }
  183. func (a adminNoticeDo) Unscoped() *adminNoticeDo {
  184. return a.withDO(a.DO.Unscoped())
  185. }
  186. func (a adminNoticeDo) Create(values ...*model.AdminNotice) error {
  187. if len(values) == 0 {
  188. return nil
  189. }
  190. return a.DO.Create(values)
  191. }
  192. func (a adminNoticeDo) CreateInBatches(values []*model.AdminNotice, batchSize int) error {
  193. return a.DO.CreateInBatches(values, batchSize)
  194. }
  195. // Save : !!! underlying implementation is different with GORM
  196. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  197. func (a adminNoticeDo) Save(values ...*model.AdminNotice) error {
  198. if len(values) == 0 {
  199. return nil
  200. }
  201. return a.DO.Save(values)
  202. }
  203. func (a adminNoticeDo) First() (*model.AdminNotice, error) {
  204. if result, err := a.DO.First(); err != nil {
  205. return nil, err
  206. } else {
  207. return result.(*model.AdminNotice), nil
  208. }
  209. }
  210. func (a adminNoticeDo) Take() (*model.AdminNotice, error) {
  211. if result, err := a.DO.Take(); err != nil {
  212. return nil, err
  213. } else {
  214. return result.(*model.AdminNotice), nil
  215. }
  216. }
  217. func (a adminNoticeDo) Last() (*model.AdminNotice, error) {
  218. if result, err := a.DO.Last(); err != nil {
  219. return nil, err
  220. } else {
  221. return result.(*model.AdminNotice), nil
  222. }
  223. }
  224. func (a adminNoticeDo) Find() ([]*model.AdminNotice, error) {
  225. result, err := a.DO.Find()
  226. return result.([]*model.AdminNotice), err
  227. }
  228. func (a adminNoticeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminNotice, err error) {
  229. buf := make([]*model.AdminNotice, 0, batchSize)
  230. err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  231. defer func() { results = append(results, buf...) }()
  232. return fc(tx, batch)
  233. })
  234. return results, err
  235. }
  236. func (a adminNoticeDo) FindInBatches(result *[]*model.AdminNotice, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  237. return a.DO.FindInBatches(result, batchSize, fc)
  238. }
  239. func (a adminNoticeDo) Attrs(attrs ...field.AssignExpr) *adminNoticeDo {
  240. return a.withDO(a.DO.Attrs(attrs...))
  241. }
  242. func (a adminNoticeDo) Assign(attrs ...field.AssignExpr) *adminNoticeDo {
  243. return a.withDO(a.DO.Assign(attrs...))
  244. }
  245. func (a adminNoticeDo) Joins(fields ...field.RelationField) *adminNoticeDo {
  246. for _, _f := range fields {
  247. a = *a.withDO(a.DO.Joins(_f))
  248. }
  249. return &a
  250. }
  251. func (a adminNoticeDo) Preload(fields ...field.RelationField) *adminNoticeDo {
  252. for _, _f := range fields {
  253. a = *a.withDO(a.DO.Preload(_f))
  254. }
  255. return &a
  256. }
  257. func (a adminNoticeDo) FirstOrInit() (*model.AdminNotice, error) {
  258. if result, err := a.DO.FirstOrInit(); err != nil {
  259. return nil, err
  260. } else {
  261. return result.(*model.AdminNotice), nil
  262. }
  263. }
  264. func (a adminNoticeDo) FirstOrCreate() (*model.AdminNotice, error) {
  265. if result, err := a.DO.FirstOrCreate(); err != nil {
  266. return nil, err
  267. } else {
  268. return result.(*model.AdminNotice), nil
  269. }
  270. }
  271. func (a adminNoticeDo) FindByPage(offset int, limit int) (result []*model.AdminNotice, count int64, err error) {
  272. result, err = a.Offset(offset).Limit(limit).Find()
  273. if err != nil {
  274. return
  275. }
  276. if size := len(result); 0 < limit && 0 < size && size < limit {
  277. count = int64(size + offset)
  278. return
  279. }
  280. count, err = a.Offset(-1).Limit(-1).Count()
  281. return
  282. }
  283. func (a adminNoticeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  284. count, err = a.Count()
  285. if err != nil {
  286. return
  287. }
  288. err = a.Offset(offset).Limit(limit).Scan(result)
  289. return
  290. }
  291. func (a adminNoticeDo) Scan(result interface{}) (err error) {
  292. return a.DO.Scan(result)
  293. }
  294. func (a adminNoticeDo) Delete(models ...*model.AdminNotice) (result gen.ResultInfo, err error) {
  295. return a.DO.Delete(models)
  296. }
  297. func (a *adminNoticeDo) withDO(do gen.Dao) *adminNoticeDo {
  298. a.DO = *do.(*gen.DO)
  299. return a
  300. }