boss_logs.gen.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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 newBossLog(db *gorm.DB, opts ...gen.DOOption) bossLog {
  16. _bossLog := bossLog{}
  17. _bossLog.bossLogDo.UseDB(db, opts...)
  18. _bossLog.bossLogDo.UseModel(&model.BossLog{})
  19. tableName := _bossLog.bossLogDo.TableName()
  20. _bossLog.ALL = field.NewAsterisk(tableName)
  21. _bossLog.ID = field.NewInt64(tableName, "id")
  22. _bossLog.UserID = field.NewInt64(tableName, "user_id")
  23. _bossLog.ServerID = field.NewInt32(tableName, "server_id")
  24. _bossLog.EventID = field.NewInt32(tableName, "event_id")
  25. _bossLog.Time = field.NewInt64(tableName, "time")
  26. _bossLog.Goods = field.NewString(tableName, "goods")
  27. _bossLog.Date = field.NewString(tableName, "date")
  28. _bossLog.EventAt = field.NewInt32(tableName, "event_at")
  29. _bossLog.EventAtNs = field.NewInt64(tableName, "event_at_ns")
  30. _bossLog.fillFieldMap()
  31. return _bossLog
  32. }
  33. type bossLog struct {
  34. bossLogDo
  35. ALL field.Asterisk
  36. ID field.Int64
  37. UserID field.Int64 // 用户ID
  38. ServerID field.Int32 // 服务器ID
  39. EventID field.Int32 // 事件ID
  40. Time field.Int64 // 战斗时长
  41. Goods field.String // {id,count}—{物品id,物品数量}
  42. Date field.String // 触发日期 2005-01-02
  43. EventAt field.Int32 // 触发时间戳
  44. EventAtNs field.Int64 // 发生时间ns
  45. fieldMap map[string]field.Expr
  46. }
  47. func (b bossLog) Table(newTableName string) *bossLog {
  48. b.bossLogDo.UseTable(newTableName)
  49. return b.updateTableName(newTableName)
  50. }
  51. func (b bossLog) As(alias string) *bossLog {
  52. b.bossLogDo.DO = *(b.bossLogDo.As(alias).(*gen.DO))
  53. return b.updateTableName(alias)
  54. }
  55. func (b *bossLog) updateTableName(table string) *bossLog {
  56. b.ALL = field.NewAsterisk(table)
  57. b.ID = field.NewInt64(table, "id")
  58. b.UserID = field.NewInt64(table, "user_id")
  59. b.ServerID = field.NewInt32(table, "server_id")
  60. b.EventID = field.NewInt32(table, "event_id")
  61. b.Time = field.NewInt64(table, "time")
  62. b.Goods = field.NewString(table, "goods")
  63. b.Date = field.NewString(table, "date")
  64. b.EventAt = field.NewInt32(table, "event_at")
  65. b.EventAtNs = field.NewInt64(table, "event_at_ns")
  66. b.fillFieldMap()
  67. return b
  68. }
  69. func (b *bossLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  70. _f, ok := b.fieldMap[fieldName]
  71. if !ok || _f == nil {
  72. return nil, false
  73. }
  74. _oe, ok := _f.(field.OrderExpr)
  75. return _oe, ok
  76. }
  77. func (b *bossLog) fillFieldMap() {
  78. b.fieldMap = make(map[string]field.Expr, 9)
  79. b.fieldMap["id"] = b.ID
  80. b.fieldMap["user_id"] = b.UserID
  81. b.fieldMap["server_id"] = b.ServerID
  82. b.fieldMap["event_id"] = b.EventID
  83. b.fieldMap["time"] = b.Time
  84. b.fieldMap["goods"] = b.Goods
  85. b.fieldMap["date"] = b.Date
  86. b.fieldMap["event_at"] = b.EventAt
  87. b.fieldMap["event_at_ns"] = b.EventAtNs
  88. }
  89. func (b bossLog) clone(db *gorm.DB) bossLog {
  90. b.bossLogDo.ReplaceConnPool(db.Statement.ConnPool)
  91. return b
  92. }
  93. func (b bossLog) replaceDB(db *gorm.DB) bossLog {
  94. b.bossLogDo.ReplaceDB(db)
  95. return b
  96. }
  97. type bossLogDo struct{ gen.DO }
  98. func (b bossLogDo) Debug() *bossLogDo {
  99. return b.withDO(b.DO.Debug())
  100. }
  101. func (b bossLogDo) WithContext(ctx context.Context) *bossLogDo {
  102. return b.withDO(b.DO.WithContext(ctx))
  103. }
  104. func (b bossLogDo) ReadDB() *bossLogDo {
  105. return b.Clauses(dbresolver.Read)
  106. }
  107. func (b bossLogDo) WriteDB() *bossLogDo {
  108. return b.Clauses(dbresolver.Write)
  109. }
  110. func (b bossLogDo) Session(config *gorm.Session) *bossLogDo {
  111. return b.withDO(b.DO.Session(config))
  112. }
  113. func (b bossLogDo) Clauses(conds ...clause.Expression) *bossLogDo {
  114. return b.withDO(b.DO.Clauses(conds...))
  115. }
  116. func (b bossLogDo) Returning(value interface{}, columns ...string) *bossLogDo {
  117. return b.withDO(b.DO.Returning(value, columns...))
  118. }
  119. func (b bossLogDo) Not(conds ...gen.Condition) *bossLogDo {
  120. return b.withDO(b.DO.Not(conds...))
  121. }
  122. func (b bossLogDo) Or(conds ...gen.Condition) *bossLogDo {
  123. return b.withDO(b.DO.Or(conds...))
  124. }
  125. func (b bossLogDo) Select(conds ...field.Expr) *bossLogDo {
  126. return b.withDO(b.DO.Select(conds...))
  127. }
  128. func (b bossLogDo) Where(conds ...gen.Condition) *bossLogDo {
  129. return b.withDO(b.DO.Where(conds...))
  130. }
  131. func (b bossLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *bossLogDo {
  132. return b.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  133. }
  134. func (b bossLogDo) Order(conds ...field.Expr) *bossLogDo {
  135. return b.withDO(b.DO.Order(conds...))
  136. }
  137. func (b bossLogDo) Distinct(cols ...field.Expr) *bossLogDo {
  138. return b.withDO(b.DO.Distinct(cols...))
  139. }
  140. func (b bossLogDo) Omit(cols ...field.Expr) *bossLogDo {
  141. return b.withDO(b.DO.Omit(cols...))
  142. }
  143. func (b bossLogDo) Join(table schema.Tabler, on ...field.Expr) *bossLogDo {
  144. return b.withDO(b.DO.Join(table, on...))
  145. }
  146. func (b bossLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *bossLogDo {
  147. return b.withDO(b.DO.LeftJoin(table, on...))
  148. }
  149. func (b bossLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *bossLogDo {
  150. return b.withDO(b.DO.RightJoin(table, on...))
  151. }
  152. func (b bossLogDo) Group(cols ...field.Expr) *bossLogDo {
  153. return b.withDO(b.DO.Group(cols...))
  154. }
  155. func (b bossLogDo) Having(conds ...gen.Condition) *bossLogDo {
  156. return b.withDO(b.DO.Having(conds...))
  157. }
  158. func (b bossLogDo) Limit(limit int) *bossLogDo {
  159. return b.withDO(b.DO.Limit(limit))
  160. }
  161. func (b bossLogDo) Offset(offset int) *bossLogDo {
  162. return b.withDO(b.DO.Offset(offset))
  163. }
  164. func (b bossLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *bossLogDo {
  165. return b.withDO(b.DO.Scopes(funcs...))
  166. }
  167. func (b bossLogDo) Unscoped() *bossLogDo {
  168. return b.withDO(b.DO.Unscoped())
  169. }
  170. func (b bossLogDo) Create(values ...*model.BossLog) error {
  171. if len(values) == 0 {
  172. return nil
  173. }
  174. return b.DO.Create(values)
  175. }
  176. func (b bossLogDo) CreateInBatches(values []*model.BossLog, batchSize int) error {
  177. return b.DO.CreateInBatches(values, batchSize)
  178. }
  179. // Save : !!! underlying implementation is different with GORM
  180. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  181. func (b bossLogDo) Save(values ...*model.BossLog) error {
  182. if len(values) == 0 {
  183. return nil
  184. }
  185. return b.DO.Save(values)
  186. }
  187. func (b bossLogDo) First() (*model.BossLog, error) {
  188. if result, err := b.DO.First(); err != nil {
  189. return nil, err
  190. } else {
  191. return result.(*model.BossLog), nil
  192. }
  193. }
  194. func (b bossLogDo) Take() (*model.BossLog, error) {
  195. if result, err := b.DO.Take(); err != nil {
  196. return nil, err
  197. } else {
  198. return result.(*model.BossLog), nil
  199. }
  200. }
  201. func (b bossLogDo) Last() (*model.BossLog, error) {
  202. if result, err := b.DO.Last(); err != nil {
  203. return nil, err
  204. } else {
  205. return result.(*model.BossLog), nil
  206. }
  207. }
  208. func (b bossLogDo) Find() ([]*model.BossLog, error) {
  209. result, err := b.DO.Find()
  210. return result.([]*model.BossLog), err
  211. }
  212. func (b bossLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BossLog, err error) {
  213. buf := make([]*model.BossLog, 0, batchSize)
  214. err = b.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  215. defer func() { results = append(results, buf...) }()
  216. return fc(tx, batch)
  217. })
  218. return results, err
  219. }
  220. func (b bossLogDo) FindInBatches(result *[]*model.BossLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  221. return b.DO.FindInBatches(result, batchSize, fc)
  222. }
  223. func (b bossLogDo) Attrs(attrs ...field.AssignExpr) *bossLogDo {
  224. return b.withDO(b.DO.Attrs(attrs...))
  225. }
  226. func (b bossLogDo) Assign(attrs ...field.AssignExpr) *bossLogDo {
  227. return b.withDO(b.DO.Assign(attrs...))
  228. }
  229. func (b bossLogDo) Joins(fields ...field.RelationField) *bossLogDo {
  230. for _, _f := range fields {
  231. b = *b.withDO(b.DO.Joins(_f))
  232. }
  233. return &b
  234. }
  235. func (b bossLogDo) Preload(fields ...field.RelationField) *bossLogDo {
  236. for _, _f := range fields {
  237. b = *b.withDO(b.DO.Preload(_f))
  238. }
  239. return &b
  240. }
  241. func (b bossLogDo) FirstOrInit() (*model.BossLog, error) {
  242. if result, err := b.DO.FirstOrInit(); err != nil {
  243. return nil, err
  244. } else {
  245. return result.(*model.BossLog), nil
  246. }
  247. }
  248. func (b bossLogDo) FirstOrCreate() (*model.BossLog, error) {
  249. if result, err := b.DO.FirstOrCreate(); err != nil {
  250. return nil, err
  251. } else {
  252. return result.(*model.BossLog), nil
  253. }
  254. }
  255. func (b bossLogDo) FindByPage(offset int, limit int) (result []*model.BossLog, count int64, err error) {
  256. result, err = b.Offset(offset).Limit(limit).Find()
  257. if err != nil {
  258. return
  259. }
  260. if size := len(result); 0 < limit && 0 < size && size < limit {
  261. count = int64(size + offset)
  262. return
  263. }
  264. count, err = b.Offset(-1).Limit(-1).Count()
  265. return
  266. }
  267. func (b bossLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  268. count, err = b.Count()
  269. if err != nil {
  270. return
  271. }
  272. err = b.Offset(offset).Limit(limit).Scan(result)
  273. return
  274. }
  275. func (b bossLogDo) Scan(result interface{}) (err error) {
  276. return b.DO.Scan(result)
  277. }
  278. func (b bossLogDo) Delete(models ...*model.BossLog) (result gen.ResultInfo, err error) {
  279. return b.DO.Delete(models)
  280. }
  281. func (b *bossLogDo) withDO(do gen.Dao) *bossLogDo {
  282. b.DO = *do.(*gen.DO)
  283. return b
  284. }