label_relationship.gen.go 13 KB

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