customer_service_chat_log.gen.go 11 KB

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