xunji_contact.gen.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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. "wechat-api/database/dao/wechat/model"
  14. )
  15. func newXunjiContact(db *gorm.DB, opts ...gen.DOOption) xunjiContact {
  16. _xunjiContact := xunjiContact{}
  17. _xunjiContact.xunjiContactDo.UseDB(db, opts...)
  18. _xunjiContact.xunjiContactDo.UseModel(&model.XunjiContact{})
  19. tableName := _xunjiContact.xunjiContactDo.TableName()
  20. _xunjiContact.ALL = field.NewAsterisk(tableName)
  21. _xunjiContact.ID = field.NewInt64(tableName, "id")
  22. _xunjiContact.CreatedAt = field.NewTime(tableName, "created_at")
  23. _xunjiContact.UpdatedAt = field.NewTime(tableName, "updated_at")
  24. _xunjiContact.Status = field.NewInt64(tableName, "status")
  25. _xunjiContact.DeletedAt = field.NewField(tableName, "deleted_at")
  26. _xunjiContact.RobotID = field.NewString(tableName, "robot_id")
  27. _xunjiContact.AccountID = field.NewString(tableName, "account_id")
  28. _xunjiContact.Nickname = field.NewString(tableName, "nickname")
  29. _xunjiContact.Avatar = field.NewString(tableName, "avatar")
  30. _xunjiContact.fillFieldMap()
  31. return _xunjiContact
  32. }
  33. type xunjiContact struct {
  34. xunjiContactDo
  35. ALL field.Asterisk
  36. ID field.Int64
  37. CreatedAt field.Time // Create Time | 创建日期
  38. UpdatedAt field.Time // Update Time | 修改日期
  39. Status field.Int64 // Status 1: normal 2: ban | 状态 1 正常 2 禁用
  40. DeletedAt field.Field // Delete Time | 删除日期
  41. RobotID field.String // 机器人ID
  42. AccountID field.String // 客户ID
  43. Nickname field.String // 昵称
  44. Avatar field.String // 头像
  45. fieldMap map[string]field.Expr
  46. }
  47. func (x xunjiContact) Table(newTableName string) *xunjiContact {
  48. x.xunjiContactDo.UseTable(newTableName)
  49. return x.updateTableName(newTableName)
  50. }
  51. func (x xunjiContact) As(alias string) *xunjiContact {
  52. x.xunjiContactDo.DO = *(x.xunjiContactDo.As(alias).(*gen.DO))
  53. return x.updateTableName(alias)
  54. }
  55. func (x *xunjiContact) updateTableName(table string) *xunjiContact {
  56. x.ALL = field.NewAsterisk(table)
  57. x.ID = field.NewInt64(table, "id")
  58. x.CreatedAt = field.NewTime(table, "created_at")
  59. x.UpdatedAt = field.NewTime(table, "updated_at")
  60. x.Status = field.NewInt64(table, "status")
  61. x.DeletedAt = field.NewField(table, "deleted_at")
  62. x.RobotID = field.NewString(table, "robot_id")
  63. x.AccountID = field.NewString(table, "account_id")
  64. x.Nickname = field.NewString(table, "nickname")
  65. x.Avatar = field.NewString(table, "avatar")
  66. x.fillFieldMap()
  67. return x
  68. }
  69. func (x *xunjiContact) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  70. _f, ok := x.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 (x *xunjiContact) fillFieldMap() {
  78. x.fieldMap = make(map[string]field.Expr, 9)
  79. x.fieldMap["id"] = x.ID
  80. x.fieldMap["created_at"] = x.CreatedAt
  81. x.fieldMap["updated_at"] = x.UpdatedAt
  82. x.fieldMap["status"] = x.Status
  83. x.fieldMap["deleted_at"] = x.DeletedAt
  84. x.fieldMap["robot_id"] = x.RobotID
  85. x.fieldMap["account_id"] = x.AccountID
  86. x.fieldMap["nickname"] = x.Nickname
  87. x.fieldMap["avatar"] = x.Avatar
  88. }
  89. func (x xunjiContact) clone(db *gorm.DB) xunjiContact {
  90. x.xunjiContactDo.ReplaceConnPool(db.Statement.ConnPool)
  91. return x
  92. }
  93. func (x xunjiContact) replaceDB(db *gorm.DB) xunjiContact {
  94. x.xunjiContactDo.ReplaceDB(db)
  95. return x
  96. }
  97. type xunjiContactDo struct{ gen.DO }
  98. type IXunjiContactDo interface {
  99. gen.SubQuery
  100. Debug() IXunjiContactDo
  101. WithContext(ctx context.Context) IXunjiContactDo
  102. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  103. ReplaceDB(db *gorm.DB)
  104. ReadDB() IXunjiContactDo
  105. WriteDB() IXunjiContactDo
  106. As(alias string) gen.Dao
  107. Session(config *gorm.Session) IXunjiContactDo
  108. Columns(cols ...field.Expr) gen.Columns
  109. Clauses(conds ...clause.Expression) IXunjiContactDo
  110. Not(conds ...gen.Condition) IXunjiContactDo
  111. Or(conds ...gen.Condition) IXunjiContactDo
  112. Select(conds ...field.Expr) IXunjiContactDo
  113. Where(conds ...gen.Condition) IXunjiContactDo
  114. Order(conds ...field.Expr) IXunjiContactDo
  115. Distinct(cols ...field.Expr) IXunjiContactDo
  116. Omit(cols ...field.Expr) IXunjiContactDo
  117. Join(table schema.Tabler, on ...field.Expr) IXunjiContactDo
  118. LeftJoin(table schema.Tabler, on ...field.Expr) IXunjiContactDo
  119. RightJoin(table schema.Tabler, on ...field.Expr) IXunjiContactDo
  120. Group(cols ...field.Expr) IXunjiContactDo
  121. Having(conds ...gen.Condition) IXunjiContactDo
  122. Limit(limit int) IXunjiContactDo
  123. Offset(offset int) IXunjiContactDo
  124. Count() (count int64, err error)
  125. Scopes(funcs ...func(gen.Dao) gen.Dao) IXunjiContactDo
  126. Unscoped() IXunjiContactDo
  127. Create(values ...*model.XunjiContact) error
  128. CreateInBatches(values []*model.XunjiContact, batchSize int) error
  129. Save(values ...*model.XunjiContact) error
  130. First() (*model.XunjiContact, error)
  131. Take() (*model.XunjiContact, error)
  132. Last() (*model.XunjiContact, error)
  133. Find() ([]*model.XunjiContact, error)
  134. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.XunjiContact, err error)
  135. FindInBatches(result *[]*model.XunjiContact, batchSize int, fc func(tx gen.Dao, batch int) error) error
  136. Pluck(column field.Expr, dest interface{}) error
  137. Delete(...*model.XunjiContact) (info gen.ResultInfo, err error)
  138. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  139. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  140. Updates(value interface{}) (info gen.ResultInfo, err error)
  141. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  142. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  143. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  144. UpdateFrom(q gen.SubQuery) gen.Dao
  145. Attrs(attrs ...field.AssignExpr) IXunjiContactDo
  146. Assign(attrs ...field.AssignExpr) IXunjiContactDo
  147. Joins(fields ...field.RelationField) IXunjiContactDo
  148. Preload(fields ...field.RelationField) IXunjiContactDo
  149. FirstOrInit() (*model.XunjiContact, error)
  150. FirstOrCreate() (*model.XunjiContact, error)
  151. FindByPage(offset int, limit int) (result []*model.XunjiContact, count int64, err error)
  152. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  153. Scan(result interface{}) (err error)
  154. Returning(value interface{}, columns ...string) IXunjiContactDo
  155. UnderlyingDB() *gorm.DB
  156. schema.Tabler
  157. }
  158. func (x xunjiContactDo) Debug() IXunjiContactDo {
  159. return x.withDO(x.DO.Debug())
  160. }
  161. func (x xunjiContactDo) WithContext(ctx context.Context) IXunjiContactDo {
  162. return x.withDO(x.DO.WithContext(ctx))
  163. }
  164. func (x xunjiContactDo) ReadDB() IXunjiContactDo {
  165. return x.Clauses(dbresolver.Read)
  166. }
  167. func (x xunjiContactDo) WriteDB() IXunjiContactDo {
  168. return x.Clauses(dbresolver.Write)
  169. }
  170. func (x xunjiContactDo) Session(config *gorm.Session) IXunjiContactDo {
  171. return x.withDO(x.DO.Session(config))
  172. }
  173. func (x xunjiContactDo) Clauses(conds ...clause.Expression) IXunjiContactDo {
  174. return x.withDO(x.DO.Clauses(conds...))
  175. }
  176. func (x xunjiContactDo) Returning(value interface{}, columns ...string) IXunjiContactDo {
  177. return x.withDO(x.DO.Returning(value, columns...))
  178. }
  179. func (x xunjiContactDo) Not(conds ...gen.Condition) IXunjiContactDo {
  180. return x.withDO(x.DO.Not(conds...))
  181. }
  182. func (x xunjiContactDo) Or(conds ...gen.Condition) IXunjiContactDo {
  183. return x.withDO(x.DO.Or(conds...))
  184. }
  185. func (x xunjiContactDo) Select(conds ...field.Expr) IXunjiContactDo {
  186. return x.withDO(x.DO.Select(conds...))
  187. }
  188. func (x xunjiContactDo) Where(conds ...gen.Condition) IXunjiContactDo {
  189. return x.withDO(x.DO.Where(conds...))
  190. }
  191. func (x xunjiContactDo) Order(conds ...field.Expr) IXunjiContactDo {
  192. return x.withDO(x.DO.Order(conds...))
  193. }
  194. func (x xunjiContactDo) Distinct(cols ...field.Expr) IXunjiContactDo {
  195. return x.withDO(x.DO.Distinct(cols...))
  196. }
  197. func (x xunjiContactDo) Omit(cols ...field.Expr) IXunjiContactDo {
  198. return x.withDO(x.DO.Omit(cols...))
  199. }
  200. func (x xunjiContactDo) Join(table schema.Tabler, on ...field.Expr) IXunjiContactDo {
  201. return x.withDO(x.DO.Join(table, on...))
  202. }
  203. func (x xunjiContactDo) LeftJoin(table schema.Tabler, on ...field.Expr) IXunjiContactDo {
  204. return x.withDO(x.DO.LeftJoin(table, on...))
  205. }
  206. func (x xunjiContactDo) RightJoin(table schema.Tabler, on ...field.Expr) IXunjiContactDo {
  207. return x.withDO(x.DO.RightJoin(table, on...))
  208. }
  209. func (x xunjiContactDo) Group(cols ...field.Expr) IXunjiContactDo {
  210. return x.withDO(x.DO.Group(cols...))
  211. }
  212. func (x xunjiContactDo) Having(conds ...gen.Condition) IXunjiContactDo {
  213. return x.withDO(x.DO.Having(conds...))
  214. }
  215. func (x xunjiContactDo) Limit(limit int) IXunjiContactDo {
  216. return x.withDO(x.DO.Limit(limit))
  217. }
  218. func (x xunjiContactDo) Offset(offset int) IXunjiContactDo {
  219. return x.withDO(x.DO.Offset(offset))
  220. }
  221. func (x xunjiContactDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IXunjiContactDo {
  222. return x.withDO(x.DO.Scopes(funcs...))
  223. }
  224. func (x xunjiContactDo) Unscoped() IXunjiContactDo {
  225. return x.withDO(x.DO.Unscoped())
  226. }
  227. func (x xunjiContactDo) Create(values ...*model.XunjiContact) error {
  228. if len(values) == 0 {
  229. return nil
  230. }
  231. return x.DO.Create(values)
  232. }
  233. func (x xunjiContactDo) CreateInBatches(values []*model.XunjiContact, batchSize int) error {
  234. return x.DO.CreateInBatches(values, batchSize)
  235. }
  236. // Save : !!! underlying implementation is different with GORM
  237. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  238. func (x xunjiContactDo) Save(values ...*model.XunjiContact) error {
  239. if len(values) == 0 {
  240. return nil
  241. }
  242. return x.DO.Save(values)
  243. }
  244. func (x xunjiContactDo) First() (*model.XunjiContact, error) {
  245. if result, err := x.DO.First(); err != nil {
  246. return nil, err
  247. } else {
  248. return result.(*model.XunjiContact), nil
  249. }
  250. }
  251. func (x xunjiContactDo) Take() (*model.XunjiContact, error) {
  252. if result, err := x.DO.Take(); err != nil {
  253. return nil, err
  254. } else {
  255. return result.(*model.XunjiContact), nil
  256. }
  257. }
  258. func (x xunjiContactDo) Last() (*model.XunjiContact, error) {
  259. if result, err := x.DO.Last(); err != nil {
  260. return nil, err
  261. } else {
  262. return result.(*model.XunjiContact), nil
  263. }
  264. }
  265. func (x xunjiContactDo) Find() ([]*model.XunjiContact, error) {
  266. result, err := x.DO.Find()
  267. return result.([]*model.XunjiContact), err
  268. }
  269. func (x xunjiContactDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.XunjiContact, err error) {
  270. buf := make([]*model.XunjiContact, 0, batchSize)
  271. err = x.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  272. defer func() { results = append(results, buf...) }()
  273. return fc(tx, batch)
  274. })
  275. return results, err
  276. }
  277. func (x xunjiContactDo) FindInBatches(result *[]*model.XunjiContact, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  278. return x.DO.FindInBatches(result, batchSize, fc)
  279. }
  280. func (x xunjiContactDo) Attrs(attrs ...field.AssignExpr) IXunjiContactDo {
  281. return x.withDO(x.DO.Attrs(attrs...))
  282. }
  283. func (x xunjiContactDo) Assign(attrs ...field.AssignExpr) IXunjiContactDo {
  284. return x.withDO(x.DO.Assign(attrs...))
  285. }
  286. func (x xunjiContactDo) Joins(fields ...field.RelationField) IXunjiContactDo {
  287. for _, _f := range fields {
  288. x = *x.withDO(x.DO.Joins(_f))
  289. }
  290. return &x
  291. }
  292. func (x xunjiContactDo) Preload(fields ...field.RelationField) IXunjiContactDo {
  293. for _, _f := range fields {
  294. x = *x.withDO(x.DO.Preload(_f))
  295. }
  296. return &x
  297. }
  298. func (x xunjiContactDo) FirstOrInit() (*model.XunjiContact, error) {
  299. if result, err := x.DO.FirstOrInit(); err != nil {
  300. return nil, err
  301. } else {
  302. return result.(*model.XunjiContact), nil
  303. }
  304. }
  305. func (x xunjiContactDo) FirstOrCreate() (*model.XunjiContact, error) {
  306. if result, err := x.DO.FirstOrCreate(); err != nil {
  307. return nil, err
  308. } else {
  309. return result.(*model.XunjiContact), nil
  310. }
  311. }
  312. func (x xunjiContactDo) FindByPage(offset int, limit int) (result []*model.XunjiContact, count int64, err error) {
  313. result, err = x.Offset(offset).Limit(limit).Find()
  314. if err != nil {
  315. return
  316. }
  317. if size := len(result); 0 < limit && 0 < size && size < limit {
  318. count = int64(size + offset)
  319. return
  320. }
  321. count, err = x.Offset(-1).Limit(-1).Count()
  322. return
  323. }
  324. func (x xunjiContactDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  325. count, err = x.Count()
  326. if err != nil {
  327. return
  328. }
  329. err = x.Offset(offset).Limit(limit).Scan(result)
  330. return
  331. }
  332. func (x xunjiContactDo) Scan(result interface{}) (err error) {
  333. return x.DO.Scan(result)
  334. }
  335. func (x xunjiContactDo) Delete(models ...*model.XunjiContact) (result gen.ResultInfo, err error) {
  336. return x.DO.Delete(models)
  337. }
  338. func (x *xunjiContactDo) withDO(do gen.Dao) *xunjiContactDo {
  339. x.DO = *do.(*gen.DO)
  340. return x
  341. }