chat_msg_log.gen.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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 newChatMsgLog(db *gorm.DB, opts ...gen.DOOption) chatMsgLog {
  16. _chatMsgLog := chatMsgLog{}
  17. _chatMsgLog.chatMsgLogDo.UseDB(db, opts...)
  18. _chatMsgLog.chatMsgLogDo.UseModel(&model.ChatMsgLog{})
  19. tableName := _chatMsgLog.chatMsgLogDo.TableName()
  20. _chatMsgLog.ALL = field.NewAsterisk(tableName)
  21. _chatMsgLog.ID = field.NewInt64(tableName, "id")
  22. _chatMsgLog.PlayerID = field.NewInt64(tableName, "player_id")
  23. _chatMsgLog.NickName = field.NewString(tableName, "nick_name")
  24. _chatMsgLog.HeadID = field.NewInt32(tableName, "head_id")
  25. _chatMsgLog.FrameID = field.NewInt32(tableName, "frame_id")
  26. _chatMsgLog.HeadImg = field.NewString(tableName, "head_img")
  27. _chatMsgLog.CreateTime = field.NewInt64(tableName, "create_time")
  28. _chatMsgLog.ChatChannel = field.NewInt32(tableName, "chat_channel")
  29. _chatMsgLog.ChatID = field.NewString(tableName, "chat_id")
  30. _chatMsgLog.Content = field.NewString(tableName, "content")
  31. _chatMsgLog.SeverID = field.NewInt32(tableName, "sever_id")
  32. _chatMsgLog.ShowType = field.NewInt32(tableName, "show_type")
  33. _chatMsgLog.IntParam = field.NewString(tableName, "int_param")
  34. _chatMsgLog.StrParam = field.NewString(tableName, "str_param")
  35. _chatMsgLog.fillFieldMap()
  36. return _chatMsgLog
  37. }
  38. type chatMsgLog struct {
  39. chatMsgLogDo chatMsgLogDo
  40. ALL field.Asterisk
  41. ID field.Int64
  42. PlayerID field.Int64 // 玩家id
  43. NickName field.String // 玩家昵称
  44. HeadID field.Int32 // 头像 -1 代表使用 AvatarURL 微信授权头像
  45. FrameID field.Int32 // 头像框id
  46. HeadImg field.String // 头像
  47. CreateTime field.Int64 // 产生时间(毫秒)
  48. ChatChannel field.Int32 // 频道类型
  49. ChatID field.String // 聊天Id
  50. Content field.String // 聊天内容 [emoji:表情Id]
  51. SeverID field.Int32 // 服务器Id
  52. ShowType field.Int32
  53. IntParam field.String
  54. StrParam field.String
  55. fieldMap map[string]field.Expr
  56. }
  57. func (c chatMsgLog) Table(newTableName string) *chatMsgLog {
  58. c.chatMsgLogDo.UseTable(newTableName)
  59. return c.updateTableName(newTableName)
  60. }
  61. func (c chatMsgLog) As(alias string) *chatMsgLog {
  62. c.chatMsgLogDo.DO = *(c.chatMsgLogDo.As(alias).(*gen.DO))
  63. return c.updateTableName(alias)
  64. }
  65. func (c *chatMsgLog) updateTableName(table string) *chatMsgLog {
  66. c.ALL = field.NewAsterisk(table)
  67. c.ID = field.NewInt64(table, "id")
  68. c.PlayerID = field.NewInt64(table, "player_id")
  69. c.NickName = field.NewString(table, "nick_name")
  70. c.HeadID = field.NewInt32(table, "head_id")
  71. c.FrameID = field.NewInt32(table, "frame_id")
  72. c.HeadImg = field.NewString(table, "head_img")
  73. c.CreateTime = field.NewInt64(table, "create_time")
  74. c.ChatChannel = field.NewInt32(table, "chat_channel")
  75. c.ChatID = field.NewString(table, "chat_id")
  76. c.Content = field.NewString(table, "content")
  77. c.SeverID = field.NewInt32(table, "sever_id")
  78. c.ShowType = field.NewInt32(table, "show_type")
  79. c.IntParam = field.NewString(table, "int_param")
  80. c.StrParam = field.NewString(table, "str_param")
  81. c.fillFieldMap()
  82. return c
  83. }
  84. func (c *chatMsgLog) WithContext(ctx context.Context) *chatMsgLogDo {
  85. return c.chatMsgLogDo.WithContext(ctx)
  86. }
  87. func (c chatMsgLog) TableName() string { return c.chatMsgLogDo.TableName() }
  88. func (c chatMsgLog) Alias() string { return c.chatMsgLogDo.Alias() }
  89. func (c chatMsgLog) Columns(cols ...field.Expr) gen.Columns { return c.chatMsgLogDo.Columns(cols...) }
  90. func (c *chatMsgLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  91. _f, ok := c.fieldMap[fieldName]
  92. if !ok || _f == nil {
  93. return nil, false
  94. }
  95. _oe, ok := _f.(field.OrderExpr)
  96. return _oe, ok
  97. }
  98. func (c *chatMsgLog) fillFieldMap() {
  99. c.fieldMap = make(map[string]field.Expr, 14)
  100. c.fieldMap["id"] = c.ID
  101. c.fieldMap["player_id"] = c.PlayerID
  102. c.fieldMap["nick_name"] = c.NickName
  103. c.fieldMap["head_id"] = c.HeadID
  104. c.fieldMap["frame_id"] = c.FrameID
  105. c.fieldMap["head_img"] = c.HeadImg
  106. c.fieldMap["create_time"] = c.CreateTime
  107. c.fieldMap["chat_channel"] = c.ChatChannel
  108. c.fieldMap["chat_id"] = c.ChatID
  109. c.fieldMap["content"] = c.Content
  110. c.fieldMap["sever_id"] = c.SeverID
  111. c.fieldMap["show_type"] = c.ShowType
  112. c.fieldMap["int_param"] = c.IntParam
  113. c.fieldMap["str_param"] = c.StrParam
  114. }
  115. func (c chatMsgLog) clone(db *gorm.DB) chatMsgLog {
  116. c.chatMsgLogDo.ReplaceConnPool(db.Statement.ConnPool)
  117. return c
  118. }
  119. func (c chatMsgLog) replaceDB(db *gorm.DB) chatMsgLog {
  120. c.chatMsgLogDo.ReplaceDB(db)
  121. return c
  122. }
  123. type chatMsgLogDo struct{ gen.DO }
  124. func (c chatMsgLogDo) Debug() *chatMsgLogDo {
  125. return c.withDO(c.DO.Debug())
  126. }
  127. func (c chatMsgLogDo) WithContext(ctx context.Context) *chatMsgLogDo {
  128. return c.withDO(c.DO.WithContext(ctx))
  129. }
  130. func (c chatMsgLogDo) ReadDB() *chatMsgLogDo {
  131. return c.Clauses(dbresolver.Read)
  132. }
  133. func (c chatMsgLogDo) WriteDB() *chatMsgLogDo {
  134. return c.Clauses(dbresolver.Write)
  135. }
  136. func (c chatMsgLogDo) Session(config *gorm.Session) *chatMsgLogDo {
  137. return c.withDO(c.DO.Session(config))
  138. }
  139. func (c chatMsgLogDo) Clauses(conds ...clause.Expression) *chatMsgLogDo {
  140. return c.withDO(c.DO.Clauses(conds...))
  141. }
  142. func (c chatMsgLogDo) Returning(value interface{}, columns ...string) *chatMsgLogDo {
  143. return c.withDO(c.DO.Returning(value, columns...))
  144. }
  145. func (c chatMsgLogDo) Not(conds ...gen.Condition) *chatMsgLogDo {
  146. return c.withDO(c.DO.Not(conds...))
  147. }
  148. func (c chatMsgLogDo) Or(conds ...gen.Condition) *chatMsgLogDo {
  149. return c.withDO(c.DO.Or(conds...))
  150. }
  151. func (c chatMsgLogDo) Select(conds ...field.Expr) *chatMsgLogDo {
  152. return c.withDO(c.DO.Select(conds...))
  153. }
  154. func (c chatMsgLogDo) Where(conds ...gen.Condition) *chatMsgLogDo {
  155. return c.withDO(c.DO.Where(conds...))
  156. }
  157. func (c chatMsgLogDo) Order(conds ...field.Expr) *chatMsgLogDo {
  158. return c.withDO(c.DO.Order(conds...))
  159. }
  160. func (c chatMsgLogDo) Distinct(cols ...field.Expr) *chatMsgLogDo {
  161. return c.withDO(c.DO.Distinct(cols...))
  162. }
  163. func (c chatMsgLogDo) Omit(cols ...field.Expr) *chatMsgLogDo {
  164. return c.withDO(c.DO.Omit(cols...))
  165. }
  166. func (c chatMsgLogDo) Join(table schema.Tabler, on ...field.Expr) *chatMsgLogDo {
  167. return c.withDO(c.DO.Join(table, on...))
  168. }
  169. func (c chatMsgLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *chatMsgLogDo {
  170. return c.withDO(c.DO.LeftJoin(table, on...))
  171. }
  172. func (c chatMsgLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *chatMsgLogDo {
  173. return c.withDO(c.DO.RightJoin(table, on...))
  174. }
  175. func (c chatMsgLogDo) Group(cols ...field.Expr) *chatMsgLogDo {
  176. return c.withDO(c.DO.Group(cols...))
  177. }
  178. func (c chatMsgLogDo) Having(conds ...gen.Condition) *chatMsgLogDo {
  179. return c.withDO(c.DO.Having(conds...))
  180. }
  181. func (c chatMsgLogDo) Limit(limit int) *chatMsgLogDo {
  182. return c.withDO(c.DO.Limit(limit))
  183. }
  184. func (c chatMsgLogDo) Offset(offset int) *chatMsgLogDo {
  185. return c.withDO(c.DO.Offset(offset))
  186. }
  187. func (c chatMsgLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *chatMsgLogDo {
  188. return c.withDO(c.DO.Scopes(funcs...))
  189. }
  190. func (c chatMsgLogDo) Unscoped() *chatMsgLogDo {
  191. return c.withDO(c.DO.Unscoped())
  192. }
  193. func (c chatMsgLogDo) Create(values ...*model.ChatMsgLog) error {
  194. if len(values) == 0 {
  195. return nil
  196. }
  197. return c.DO.Create(values)
  198. }
  199. func (c chatMsgLogDo) CreateInBatches(values []*model.ChatMsgLog, batchSize int) error {
  200. return c.DO.CreateInBatches(values, batchSize)
  201. }
  202. // Save : !!! underlying implementation is different with GORM
  203. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  204. func (c chatMsgLogDo) Save(values ...*model.ChatMsgLog) error {
  205. if len(values) == 0 {
  206. return nil
  207. }
  208. return c.DO.Save(values)
  209. }
  210. func (c chatMsgLogDo) First() (*model.ChatMsgLog, error) {
  211. if result, err := c.DO.First(); err != nil {
  212. return nil, err
  213. } else {
  214. return result.(*model.ChatMsgLog), nil
  215. }
  216. }
  217. func (c chatMsgLogDo) Take() (*model.ChatMsgLog, error) {
  218. if result, err := c.DO.Take(); err != nil {
  219. return nil, err
  220. } else {
  221. return result.(*model.ChatMsgLog), nil
  222. }
  223. }
  224. func (c chatMsgLogDo) Last() (*model.ChatMsgLog, error) {
  225. if result, err := c.DO.Last(); err != nil {
  226. return nil, err
  227. } else {
  228. return result.(*model.ChatMsgLog), nil
  229. }
  230. }
  231. func (c chatMsgLogDo) Find() ([]*model.ChatMsgLog, error) {
  232. result, err := c.DO.Find()
  233. return result.([]*model.ChatMsgLog), err
  234. }
  235. func (c chatMsgLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatMsgLog, err error) {
  236. buf := make([]*model.ChatMsgLog, 0, batchSize)
  237. err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  238. defer func() { results = append(results, buf...) }()
  239. return fc(tx, batch)
  240. })
  241. return results, err
  242. }
  243. func (c chatMsgLogDo) FindInBatches(result *[]*model.ChatMsgLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  244. return c.DO.FindInBatches(result, batchSize, fc)
  245. }
  246. func (c chatMsgLogDo) Attrs(attrs ...field.AssignExpr) *chatMsgLogDo {
  247. return c.withDO(c.DO.Attrs(attrs...))
  248. }
  249. func (c chatMsgLogDo) Assign(attrs ...field.AssignExpr) *chatMsgLogDo {
  250. return c.withDO(c.DO.Assign(attrs...))
  251. }
  252. func (c chatMsgLogDo) Joins(fields ...field.RelationField) *chatMsgLogDo {
  253. for _, _f := range fields {
  254. c = *c.withDO(c.DO.Joins(_f))
  255. }
  256. return &c
  257. }
  258. func (c chatMsgLogDo) Preload(fields ...field.RelationField) *chatMsgLogDo {
  259. for _, _f := range fields {
  260. c = *c.withDO(c.DO.Preload(_f))
  261. }
  262. return &c
  263. }
  264. func (c chatMsgLogDo) FirstOrInit() (*model.ChatMsgLog, error) {
  265. if result, err := c.DO.FirstOrInit(); err != nil {
  266. return nil, err
  267. } else {
  268. return result.(*model.ChatMsgLog), nil
  269. }
  270. }
  271. func (c chatMsgLogDo) FirstOrCreate() (*model.ChatMsgLog, error) {
  272. if result, err := c.DO.FirstOrCreate(); err != nil {
  273. return nil, err
  274. } else {
  275. return result.(*model.ChatMsgLog), nil
  276. }
  277. }
  278. func (c chatMsgLogDo) FindByPage(offset int, limit int) (result []*model.ChatMsgLog, count int64, err error) {
  279. result, err = c.Offset(offset).Limit(limit).Find()
  280. if err != nil {
  281. return
  282. }
  283. if size := len(result); 0 < limit && 0 < size && size < limit {
  284. count = int64(size + offset)
  285. return
  286. }
  287. count, err = c.Offset(-1).Limit(-1).Count()
  288. return
  289. }
  290. func (c chatMsgLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  291. count, err = c.Count()
  292. if err != nil {
  293. return
  294. }
  295. err = c.Offset(offset).Limit(limit).Scan(result)
  296. return
  297. }
  298. func (c chatMsgLogDo) Scan(result interface{}) (err error) {
  299. return c.DO.Scan(result)
  300. }
  301. func (c chatMsgLogDo) Delete(models ...*model.ChatMsgLog) (result gen.ResultInfo, err error) {
  302. return c.DO.Delete(models)
  303. }
  304. func (c *chatMsgLogDo) withDO(do gen.Dao) *chatMsgLogDo {
  305. c.DO = *do.(*gen.DO)
  306. return c
  307. }