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