chat.gen.go 7.9 KB

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