contact.gen.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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 newContact(db *gorm.DB, opts ...gen.DOOption) contact {
  16. _contact := contact{}
  17. _contact.contactDo.UseDB(db, opts...)
  18. _contact.contactDo.UseModel(&model.Contact{})
  19. tableName := _contact.contactDo.TableName()
  20. _contact.ALL = field.NewAsterisk(tableName)
  21. _contact.ID = field.NewInt64(tableName, "id")
  22. _contact.CreatedAt = field.NewTime(tableName, "created_at")
  23. _contact.UpdatedAt = field.NewTime(tableName, "updated_at")
  24. _contact.Status = field.NewInt64(tableName, "status")
  25. _contact.DeletedAt = field.NewField(tableName, "deleted_at")
  26. _contact.WxWxid = field.NewString(tableName, "wx_wxid")
  27. _contact.Type = field.NewInt64(tableName, "type")
  28. _contact.Wxid = field.NewString(tableName, "wxid")
  29. _contact.Account = field.NewString(tableName, "account")
  30. _contact.Nickname = field.NewString(tableName, "nickname")
  31. _contact.Markname = field.NewString(tableName, "markname")
  32. _contact.Headimg = field.NewString(tableName, "headimg")
  33. _contact.Sex = field.NewInt64(tableName, "sex")
  34. _contact.Starrole = field.NewString(tableName, "starrole")
  35. _contact.Dontseeit = field.NewInt64(tableName, "dontseeit")
  36. _contact.Dontseeme = field.NewInt64(tableName, "dontseeme")
  37. _contact.Lag = field.NewString(tableName, "lag")
  38. _contact.Gid = field.NewString(tableName, "gid")
  39. _contact.Gname = field.NewString(tableName, "gname")
  40. _contact.V3 = field.NewString(tableName, "v3")
  41. _contact.OrganizationID = field.NewInt64(tableName, "organization_id")
  42. _contact.Ctype = field.NewInt64(tableName, "ctype")
  43. _contact.Cc = field.NewString(tableName, "cc")
  44. _contact.Phone = field.NewString(tableName, "phone")
  45. _contact.Cname = field.NewString(tableName, "cname")
  46. _contact.Cage = field.NewInt64(tableName, "cage")
  47. _contact.Carea = field.NewString(tableName, "carea")
  48. _contact.Cbirthday = field.NewString(tableName, "cbirthday")
  49. _contact.Cbirtharea = field.NewString(tableName, "cbirtharea")
  50. _contact.CidcardNo = field.NewString(tableName, "cidcard_no")
  51. _contact.Ctitle = field.NewString(tableName, "ctitle")
  52. _contact.fillFieldMap()
  53. return _contact
  54. }
  55. type contact struct {
  56. contactDo
  57. ALL field.Asterisk
  58. ID field.Int64
  59. CreatedAt field.Time // Create Time | 创建日期
  60. UpdatedAt field.Time // Update Time | 修改日期
  61. Status field.Int64 // Status 1: normal 2: ban | 状态 1 正常 2 禁用
  62. DeletedAt field.Field // Delete Time | 删除日期
  63. WxWxid field.String // 属主微信id
  64. Type field.Int64 // 联系人类型:1好友,2群组,3公众号,4企业微信联系人
  65. Wxid field.String // 微信id 公众号微信ID
  66. Account field.String // 微信账号
  67. Nickname field.String // 微信昵称 群备注名称
  68. Markname field.String // 备注名
  69. Headimg field.String // 头像
  70. Sex field.Int64 // 性别 0未知 1男 2女
  71. Starrole field.String // 星标 65/67=星标 1/3=未星标
  72. Dontseeit field.Int64 // 不让他看我的朋友圈 0可以看 1不让看
  73. Dontseeme field.Int64 // 不看他的朋友圈 0可以看 1不看 1=开启了不看他 128/129=仅聊天
  74. Lag field.String // 所属标签id清单,多开会用逗号隔开
  75. Gid field.String // 群组id
  76. Gname field.String // 群组名称
  77. V3 field.String // v3数据
  78. OrganizationID field.Int64 // 机构 ID
  79. Ctype field.Int64 // 内容类型:1-微信 2-whatsapp 3-企微
  80. Cc field.String // 国家区号
  81. Phone field.String // 手机号
  82. Cname field.String // 姓名
  83. Cage field.Int64 // 年龄
  84. Carea field.String // 地区
  85. Cbirthday field.String // 出生日期
  86. Cbirtharea field.String // 出生地
  87. CidcardNo field.String // 身份证号
  88. Ctitle field.String // 称呼
  89. fieldMap map[string]field.Expr
  90. }
  91. func (c contact) Table(newTableName string) *contact {
  92. c.contactDo.UseTable(newTableName)
  93. return c.updateTableName(newTableName)
  94. }
  95. func (c contact) As(alias string) *contact {
  96. c.contactDo.DO = *(c.contactDo.As(alias).(*gen.DO))
  97. return c.updateTableName(alias)
  98. }
  99. func (c *contact) updateTableName(table string) *contact {
  100. c.ALL = field.NewAsterisk(table)
  101. c.ID = field.NewInt64(table, "id")
  102. c.CreatedAt = field.NewTime(table, "created_at")
  103. c.UpdatedAt = field.NewTime(table, "updated_at")
  104. c.Status = field.NewInt64(table, "status")
  105. c.DeletedAt = field.NewField(table, "deleted_at")
  106. c.WxWxid = field.NewString(table, "wx_wxid")
  107. c.Type = field.NewInt64(table, "type")
  108. c.Wxid = field.NewString(table, "wxid")
  109. c.Account = field.NewString(table, "account")
  110. c.Nickname = field.NewString(table, "nickname")
  111. c.Markname = field.NewString(table, "markname")
  112. c.Headimg = field.NewString(table, "headimg")
  113. c.Sex = field.NewInt64(table, "sex")
  114. c.Starrole = field.NewString(table, "starrole")
  115. c.Dontseeit = field.NewInt64(table, "dontseeit")
  116. c.Dontseeme = field.NewInt64(table, "dontseeme")
  117. c.Lag = field.NewString(table, "lag")
  118. c.Gid = field.NewString(table, "gid")
  119. c.Gname = field.NewString(table, "gname")
  120. c.V3 = field.NewString(table, "v3")
  121. c.OrganizationID = field.NewInt64(table, "organization_id")
  122. c.Ctype = field.NewInt64(table, "ctype")
  123. c.Cc = field.NewString(table, "cc")
  124. c.Phone = field.NewString(table, "phone")
  125. c.Cname = field.NewString(table, "cname")
  126. c.Cage = field.NewInt64(table, "cage")
  127. c.Carea = field.NewString(table, "carea")
  128. c.Cbirthday = field.NewString(table, "cbirthday")
  129. c.Cbirtharea = field.NewString(table, "cbirtharea")
  130. c.CidcardNo = field.NewString(table, "cidcard_no")
  131. c.Ctitle = field.NewString(table, "ctitle")
  132. c.fillFieldMap()
  133. return c
  134. }
  135. func (c *contact) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  136. _f, ok := c.fieldMap[fieldName]
  137. if !ok || _f == nil {
  138. return nil, false
  139. }
  140. _oe, ok := _f.(field.OrderExpr)
  141. return _oe, ok
  142. }
  143. func (c *contact) fillFieldMap() {
  144. c.fieldMap = make(map[string]field.Expr, 31)
  145. c.fieldMap["id"] = c.ID
  146. c.fieldMap["created_at"] = c.CreatedAt
  147. c.fieldMap["updated_at"] = c.UpdatedAt
  148. c.fieldMap["status"] = c.Status
  149. c.fieldMap["deleted_at"] = c.DeletedAt
  150. c.fieldMap["wx_wxid"] = c.WxWxid
  151. c.fieldMap["type"] = c.Type
  152. c.fieldMap["wxid"] = c.Wxid
  153. c.fieldMap["account"] = c.Account
  154. c.fieldMap["nickname"] = c.Nickname
  155. c.fieldMap["markname"] = c.Markname
  156. c.fieldMap["headimg"] = c.Headimg
  157. c.fieldMap["sex"] = c.Sex
  158. c.fieldMap["starrole"] = c.Starrole
  159. c.fieldMap["dontseeit"] = c.Dontseeit
  160. c.fieldMap["dontseeme"] = c.Dontseeme
  161. c.fieldMap["lag"] = c.Lag
  162. c.fieldMap["gid"] = c.Gid
  163. c.fieldMap["gname"] = c.Gname
  164. c.fieldMap["v3"] = c.V3
  165. c.fieldMap["organization_id"] = c.OrganizationID
  166. c.fieldMap["ctype"] = c.Ctype
  167. c.fieldMap["cc"] = c.Cc
  168. c.fieldMap["phone"] = c.Phone
  169. c.fieldMap["cname"] = c.Cname
  170. c.fieldMap["cage"] = c.Cage
  171. c.fieldMap["carea"] = c.Carea
  172. c.fieldMap["cbirthday"] = c.Cbirthday
  173. c.fieldMap["cbirtharea"] = c.Cbirtharea
  174. c.fieldMap["cidcard_no"] = c.CidcardNo
  175. c.fieldMap["ctitle"] = c.Ctitle
  176. }
  177. func (c contact) clone(db *gorm.DB) contact {
  178. c.contactDo.ReplaceConnPool(db.Statement.ConnPool)
  179. return c
  180. }
  181. func (c contact) replaceDB(db *gorm.DB) contact {
  182. c.contactDo.ReplaceDB(db)
  183. return c
  184. }
  185. type contactDo struct{ gen.DO }
  186. type IContactDo interface {
  187. gen.SubQuery
  188. Debug() IContactDo
  189. WithContext(ctx context.Context) IContactDo
  190. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  191. ReplaceDB(db *gorm.DB)
  192. ReadDB() IContactDo
  193. WriteDB() IContactDo
  194. As(alias string) gen.Dao
  195. Session(config *gorm.Session) IContactDo
  196. Columns(cols ...field.Expr) gen.Columns
  197. Clauses(conds ...clause.Expression) IContactDo
  198. Not(conds ...gen.Condition) IContactDo
  199. Or(conds ...gen.Condition) IContactDo
  200. Select(conds ...field.Expr) IContactDo
  201. Where(conds ...gen.Condition) IContactDo
  202. Order(conds ...field.Expr) IContactDo
  203. Distinct(cols ...field.Expr) IContactDo
  204. Omit(cols ...field.Expr) IContactDo
  205. Join(table schema.Tabler, on ...field.Expr) IContactDo
  206. LeftJoin(table schema.Tabler, on ...field.Expr) IContactDo
  207. RightJoin(table schema.Tabler, on ...field.Expr) IContactDo
  208. Group(cols ...field.Expr) IContactDo
  209. Having(conds ...gen.Condition) IContactDo
  210. Limit(limit int) IContactDo
  211. Offset(offset int) IContactDo
  212. Count() (count int64, err error)
  213. Scopes(funcs ...func(gen.Dao) gen.Dao) IContactDo
  214. Unscoped() IContactDo
  215. Create(values ...*model.Contact) error
  216. CreateInBatches(values []*model.Contact, batchSize int) error
  217. Save(values ...*model.Contact) error
  218. First() (*model.Contact, error)
  219. Take() (*model.Contact, error)
  220. Last() (*model.Contact, error)
  221. Find() ([]*model.Contact, error)
  222. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Contact, err error)
  223. FindInBatches(result *[]*model.Contact, batchSize int, fc func(tx gen.Dao, batch int) error) error
  224. Pluck(column field.Expr, dest interface{}) error
  225. Delete(...*model.Contact) (info gen.ResultInfo, err error)
  226. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  227. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  228. Updates(value interface{}) (info gen.ResultInfo, err error)
  229. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  230. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  231. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  232. UpdateFrom(q gen.SubQuery) gen.Dao
  233. Attrs(attrs ...field.AssignExpr) IContactDo
  234. Assign(attrs ...field.AssignExpr) IContactDo
  235. Joins(fields ...field.RelationField) IContactDo
  236. Preload(fields ...field.RelationField) IContactDo
  237. FirstOrInit() (*model.Contact, error)
  238. FirstOrCreate() (*model.Contact, error)
  239. FindByPage(offset int, limit int) (result []*model.Contact, count int64, err error)
  240. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  241. Scan(result interface{}) (err error)
  242. Returning(value interface{}, columns ...string) IContactDo
  243. UnderlyingDB() *gorm.DB
  244. schema.Tabler
  245. }
  246. func (c contactDo) Debug() IContactDo {
  247. return c.withDO(c.DO.Debug())
  248. }
  249. func (c contactDo) WithContext(ctx context.Context) IContactDo {
  250. return c.withDO(c.DO.WithContext(ctx))
  251. }
  252. func (c contactDo) ReadDB() IContactDo {
  253. return c.Clauses(dbresolver.Read)
  254. }
  255. func (c contactDo) WriteDB() IContactDo {
  256. return c.Clauses(dbresolver.Write)
  257. }
  258. func (c contactDo) Session(config *gorm.Session) IContactDo {
  259. return c.withDO(c.DO.Session(config))
  260. }
  261. func (c contactDo) Clauses(conds ...clause.Expression) IContactDo {
  262. return c.withDO(c.DO.Clauses(conds...))
  263. }
  264. func (c contactDo) Returning(value interface{}, columns ...string) IContactDo {
  265. return c.withDO(c.DO.Returning(value, columns...))
  266. }
  267. func (c contactDo) Not(conds ...gen.Condition) IContactDo {
  268. return c.withDO(c.DO.Not(conds...))
  269. }
  270. func (c contactDo) Or(conds ...gen.Condition) IContactDo {
  271. return c.withDO(c.DO.Or(conds...))
  272. }
  273. func (c contactDo) Select(conds ...field.Expr) IContactDo {
  274. return c.withDO(c.DO.Select(conds...))
  275. }
  276. func (c contactDo) Where(conds ...gen.Condition) IContactDo {
  277. return c.withDO(c.DO.Where(conds...))
  278. }
  279. func (c contactDo) Order(conds ...field.Expr) IContactDo {
  280. return c.withDO(c.DO.Order(conds...))
  281. }
  282. func (c contactDo) Distinct(cols ...field.Expr) IContactDo {
  283. return c.withDO(c.DO.Distinct(cols...))
  284. }
  285. func (c contactDo) Omit(cols ...field.Expr) IContactDo {
  286. return c.withDO(c.DO.Omit(cols...))
  287. }
  288. func (c contactDo) Join(table schema.Tabler, on ...field.Expr) IContactDo {
  289. return c.withDO(c.DO.Join(table, on...))
  290. }
  291. func (c contactDo) LeftJoin(table schema.Tabler, on ...field.Expr) IContactDo {
  292. return c.withDO(c.DO.LeftJoin(table, on...))
  293. }
  294. func (c contactDo) RightJoin(table schema.Tabler, on ...field.Expr) IContactDo {
  295. return c.withDO(c.DO.RightJoin(table, on...))
  296. }
  297. func (c contactDo) Group(cols ...field.Expr) IContactDo {
  298. return c.withDO(c.DO.Group(cols...))
  299. }
  300. func (c contactDo) Having(conds ...gen.Condition) IContactDo {
  301. return c.withDO(c.DO.Having(conds...))
  302. }
  303. func (c contactDo) Limit(limit int) IContactDo {
  304. return c.withDO(c.DO.Limit(limit))
  305. }
  306. func (c contactDo) Offset(offset int) IContactDo {
  307. return c.withDO(c.DO.Offset(offset))
  308. }
  309. func (c contactDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IContactDo {
  310. return c.withDO(c.DO.Scopes(funcs...))
  311. }
  312. func (c contactDo) Unscoped() IContactDo {
  313. return c.withDO(c.DO.Unscoped())
  314. }
  315. func (c contactDo) Create(values ...*model.Contact) error {
  316. if len(values) == 0 {
  317. return nil
  318. }
  319. return c.DO.Create(values)
  320. }
  321. func (c contactDo) CreateInBatches(values []*model.Contact, batchSize int) error {
  322. return c.DO.CreateInBatches(values, batchSize)
  323. }
  324. // Save : !!! underlying implementation is different with GORM
  325. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  326. func (c contactDo) Save(values ...*model.Contact) error {
  327. if len(values) == 0 {
  328. return nil
  329. }
  330. return c.DO.Save(values)
  331. }
  332. func (c contactDo) First() (*model.Contact, error) {
  333. if result, err := c.DO.First(); err != nil {
  334. return nil, err
  335. } else {
  336. return result.(*model.Contact), nil
  337. }
  338. }
  339. func (c contactDo) Take() (*model.Contact, error) {
  340. if result, err := c.DO.Take(); err != nil {
  341. return nil, err
  342. } else {
  343. return result.(*model.Contact), nil
  344. }
  345. }
  346. func (c contactDo) Last() (*model.Contact, error) {
  347. if result, err := c.DO.Last(); err != nil {
  348. return nil, err
  349. } else {
  350. return result.(*model.Contact), nil
  351. }
  352. }
  353. func (c contactDo) Find() ([]*model.Contact, error) {
  354. result, err := c.DO.Find()
  355. return result.([]*model.Contact), err
  356. }
  357. func (c contactDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Contact, err error) {
  358. buf := make([]*model.Contact, 0, batchSize)
  359. err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  360. defer func() { results = append(results, buf...) }()
  361. return fc(tx, batch)
  362. })
  363. return results, err
  364. }
  365. func (c contactDo) FindInBatches(result *[]*model.Contact, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  366. return c.DO.FindInBatches(result, batchSize, fc)
  367. }
  368. func (c contactDo) Attrs(attrs ...field.AssignExpr) IContactDo {
  369. return c.withDO(c.DO.Attrs(attrs...))
  370. }
  371. func (c contactDo) Assign(attrs ...field.AssignExpr) IContactDo {
  372. return c.withDO(c.DO.Assign(attrs...))
  373. }
  374. func (c contactDo) Joins(fields ...field.RelationField) IContactDo {
  375. for _, _f := range fields {
  376. c = *c.withDO(c.DO.Joins(_f))
  377. }
  378. return &c
  379. }
  380. func (c contactDo) Preload(fields ...field.RelationField) IContactDo {
  381. for _, _f := range fields {
  382. c = *c.withDO(c.DO.Preload(_f))
  383. }
  384. return &c
  385. }
  386. func (c contactDo) FirstOrInit() (*model.Contact, error) {
  387. if result, err := c.DO.FirstOrInit(); err != nil {
  388. return nil, err
  389. } else {
  390. return result.(*model.Contact), nil
  391. }
  392. }
  393. func (c contactDo) FirstOrCreate() (*model.Contact, error) {
  394. if result, err := c.DO.FirstOrCreate(); err != nil {
  395. return nil, err
  396. } else {
  397. return result.(*model.Contact), nil
  398. }
  399. }
  400. func (c contactDo) FindByPage(offset int, limit int) (result []*model.Contact, count int64, err error) {
  401. result, err = c.Offset(offset).Limit(limit).Find()
  402. if err != nil {
  403. return
  404. }
  405. if size := len(result); 0 < limit && 0 < size && size < limit {
  406. count = int64(size + offset)
  407. return
  408. }
  409. count, err = c.Offset(-1).Limit(-1).Count()
  410. return
  411. }
  412. func (c contactDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  413. count, err = c.Count()
  414. if err != nil {
  415. return
  416. }
  417. err = c.Offset(offset).Limit(limit).Scan(result)
  418. return
  419. }
  420. func (c contactDo) Scan(result interface{}) (err error) {
  421. return c.DO.Scan(result)
  422. }
  423. func (c contactDo) Delete(models ...*model.Contact) (result gen.ResultInfo, err error) {
  424. return c.DO.Delete(models)
  425. }
  426. func (c *contactDo) withDO(do gen.Dao) *contactDo {
  427. c.DO = *do.(*gen.DO)
  428. return c
  429. }