sop_node.gen.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 newSopNode(db *gorm.DB, opts ...gen.DOOption) sopNode {
  16. _sopNode := sopNode{}
  17. _sopNode.sopNodeDo.UseDB(db, opts...)
  18. _sopNode.sopNodeDo.UseModel(&model.SopNode{})
  19. tableName := _sopNode.sopNodeDo.TableName()
  20. _sopNode.ALL = field.NewAsterisk(tableName)
  21. _sopNode.ID = field.NewInt64(tableName, "id")
  22. _sopNode.CreatedAt = field.NewTime(tableName, "created_at")
  23. _sopNode.UpdatedAt = field.NewTime(tableName, "updated_at")
  24. _sopNode.Status = field.NewInt64(tableName, "status")
  25. _sopNode.DeletedAt = field.NewField(tableName, "deleted_at")
  26. _sopNode.StageID = field.NewInt64(tableName, "stage_id")
  27. _sopNode.ParentID = field.NewInt64(tableName, "parent_id")
  28. _sopNode.Name = field.NewString(tableName, "name")
  29. _sopNode.ConditionType = field.NewInt64(tableName, "condition_type")
  30. _sopNode.ConditionList = field.NewString(tableName, "condition_list")
  31. _sopNode.NoReplyCondition = field.NewInt64(tableName, "no_reply_condition")
  32. _sopNode.ActionMessage = field.NewString(tableName, "action_message")
  33. _sopNode.ActionLabelAdd = field.NewString(tableName, "action_label_add")
  34. _sopNode.ActionForward = field.NewString(tableName, "action_forward")
  35. _sopNode.NoReplyUnit = field.NewString(tableName, "no_reply_unit")
  36. _sopNode.ActionLabelDel = field.NewString(tableName, "action_label_del")
  37. _sopNode.fillFieldMap()
  38. return _sopNode
  39. }
  40. type sopNode struct {
  41. sopNodeDo
  42. ALL field.Asterisk
  43. ID field.Int64
  44. CreatedAt field.Time // Create Time | 创建日期
  45. UpdatedAt field.Time // Update Time | 修改日期
  46. Status field.Int64 // 状态 1 正常 2 禁用
  47. DeletedAt field.Field // Delete Time | 删除日期
  48. StageID field.Int64 // 阶段 ID
  49. ParentID field.Int64 // 父节点 ID
  50. Name field.String // 节点名称
  51. ConditionType field.Int64 // 触发条件类型 1 客户回复后触发 2 超时后触发
  52. ConditionList field.String // 触发语义列表 当为空时则代表用户回复任意内容后触发
  53. NoReplyCondition field.Int64 // 超时触发时间(分钟)
  54. ActionMessage field.String // 命中后发送的消息内容
  55. ActionLabelAdd field.String // 命中后需要打的标签
  56. ActionForward field.String // 命中后转发的消息
  57. NoReplyUnit field.String // 超时触发时间单位
  58. ActionLabelDel field.String // 命中后需要打的标签
  59. fieldMap map[string]field.Expr
  60. }
  61. func (s sopNode) Table(newTableName string) *sopNode {
  62. s.sopNodeDo.UseTable(newTableName)
  63. return s.updateTableName(newTableName)
  64. }
  65. func (s sopNode) As(alias string) *sopNode {
  66. s.sopNodeDo.DO = *(s.sopNodeDo.As(alias).(*gen.DO))
  67. return s.updateTableName(alias)
  68. }
  69. func (s *sopNode) updateTableName(table string) *sopNode {
  70. s.ALL = field.NewAsterisk(table)
  71. s.ID = field.NewInt64(table, "id")
  72. s.CreatedAt = field.NewTime(table, "created_at")
  73. s.UpdatedAt = field.NewTime(table, "updated_at")
  74. s.Status = field.NewInt64(table, "status")
  75. s.DeletedAt = field.NewField(table, "deleted_at")
  76. s.StageID = field.NewInt64(table, "stage_id")
  77. s.ParentID = field.NewInt64(table, "parent_id")
  78. s.Name = field.NewString(table, "name")
  79. s.ConditionType = field.NewInt64(table, "condition_type")
  80. s.ConditionList = field.NewString(table, "condition_list")
  81. s.NoReplyCondition = field.NewInt64(table, "no_reply_condition")
  82. s.ActionMessage = field.NewString(table, "action_message")
  83. s.ActionLabelAdd = field.NewString(table, "action_label_add")
  84. s.ActionForward = field.NewString(table, "action_forward")
  85. s.NoReplyUnit = field.NewString(table, "no_reply_unit")
  86. s.ActionLabelDel = field.NewString(table, "action_label_del")
  87. s.fillFieldMap()
  88. return s
  89. }
  90. func (s *sopNode) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  91. _f, ok := s.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 (s *sopNode) fillFieldMap() {
  99. s.fieldMap = make(map[string]field.Expr, 16)
  100. s.fieldMap["id"] = s.ID
  101. s.fieldMap["created_at"] = s.CreatedAt
  102. s.fieldMap["updated_at"] = s.UpdatedAt
  103. s.fieldMap["status"] = s.Status
  104. s.fieldMap["deleted_at"] = s.DeletedAt
  105. s.fieldMap["stage_id"] = s.StageID
  106. s.fieldMap["parent_id"] = s.ParentID
  107. s.fieldMap["name"] = s.Name
  108. s.fieldMap["condition_type"] = s.ConditionType
  109. s.fieldMap["condition_list"] = s.ConditionList
  110. s.fieldMap["no_reply_condition"] = s.NoReplyCondition
  111. s.fieldMap["action_message"] = s.ActionMessage
  112. s.fieldMap["action_label_add"] = s.ActionLabelAdd
  113. s.fieldMap["action_forward"] = s.ActionForward
  114. s.fieldMap["no_reply_unit"] = s.NoReplyUnit
  115. s.fieldMap["action_label_del"] = s.ActionLabelDel
  116. }
  117. func (s sopNode) clone(db *gorm.DB) sopNode {
  118. s.sopNodeDo.ReplaceConnPool(db.Statement.ConnPool)
  119. return s
  120. }
  121. func (s sopNode) replaceDB(db *gorm.DB) sopNode {
  122. s.sopNodeDo.ReplaceDB(db)
  123. return s
  124. }
  125. type sopNodeDo struct{ gen.DO }
  126. type ISopNodeDo interface {
  127. gen.SubQuery
  128. Debug() ISopNodeDo
  129. WithContext(ctx context.Context) ISopNodeDo
  130. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  131. ReplaceDB(db *gorm.DB)
  132. ReadDB() ISopNodeDo
  133. WriteDB() ISopNodeDo
  134. As(alias string) gen.Dao
  135. Session(config *gorm.Session) ISopNodeDo
  136. Columns(cols ...field.Expr) gen.Columns
  137. Clauses(conds ...clause.Expression) ISopNodeDo
  138. Not(conds ...gen.Condition) ISopNodeDo
  139. Or(conds ...gen.Condition) ISopNodeDo
  140. Select(conds ...field.Expr) ISopNodeDo
  141. Where(conds ...gen.Condition) ISopNodeDo
  142. Order(conds ...field.Expr) ISopNodeDo
  143. Distinct(cols ...field.Expr) ISopNodeDo
  144. Omit(cols ...field.Expr) ISopNodeDo
  145. Join(table schema.Tabler, on ...field.Expr) ISopNodeDo
  146. LeftJoin(table schema.Tabler, on ...field.Expr) ISopNodeDo
  147. RightJoin(table schema.Tabler, on ...field.Expr) ISopNodeDo
  148. Group(cols ...field.Expr) ISopNodeDo
  149. Having(conds ...gen.Condition) ISopNodeDo
  150. Limit(limit int) ISopNodeDo
  151. Offset(offset int) ISopNodeDo
  152. Count() (count int64, err error)
  153. Scopes(funcs ...func(gen.Dao) gen.Dao) ISopNodeDo
  154. Unscoped() ISopNodeDo
  155. Create(values ...*model.SopNode) error
  156. CreateInBatches(values []*model.SopNode, batchSize int) error
  157. Save(values ...*model.SopNode) error
  158. First() (*model.SopNode, error)
  159. Take() (*model.SopNode, error)
  160. Last() (*model.SopNode, error)
  161. Find() ([]*model.SopNode, error)
  162. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SopNode, err error)
  163. FindInBatches(result *[]*model.SopNode, batchSize int, fc func(tx gen.Dao, batch int) error) error
  164. Pluck(column field.Expr, dest interface{}) error
  165. Delete(...*model.SopNode) (info gen.ResultInfo, err error)
  166. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  167. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  168. Updates(value interface{}) (info gen.ResultInfo, err error)
  169. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  170. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  171. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  172. UpdateFrom(q gen.SubQuery) gen.Dao
  173. Attrs(attrs ...field.AssignExpr) ISopNodeDo
  174. Assign(attrs ...field.AssignExpr) ISopNodeDo
  175. Joins(fields ...field.RelationField) ISopNodeDo
  176. Preload(fields ...field.RelationField) ISopNodeDo
  177. FirstOrInit() (*model.SopNode, error)
  178. FirstOrCreate() (*model.SopNode, error)
  179. FindByPage(offset int, limit int) (result []*model.SopNode, count int64, err error)
  180. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  181. Scan(result interface{}) (err error)
  182. Returning(value interface{}, columns ...string) ISopNodeDo
  183. UnderlyingDB() *gorm.DB
  184. schema.Tabler
  185. }
  186. func (s sopNodeDo) Debug() ISopNodeDo {
  187. return s.withDO(s.DO.Debug())
  188. }
  189. func (s sopNodeDo) WithContext(ctx context.Context) ISopNodeDo {
  190. return s.withDO(s.DO.WithContext(ctx))
  191. }
  192. func (s sopNodeDo) ReadDB() ISopNodeDo {
  193. return s.Clauses(dbresolver.Read)
  194. }
  195. func (s sopNodeDo) WriteDB() ISopNodeDo {
  196. return s.Clauses(dbresolver.Write)
  197. }
  198. func (s sopNodeDo) Session(config *gorm.Session) ISopNodeDo {
  199. return s.withDO(s.DO.Session(config))
  200. }
  201. func (s sopNodeDo) Clauses(conds ...clause.Expression) ISopNodeDo {
  202. return s.withDO(s.DO.Clauses(conds...))
  203. }
  204. func (s sopNodeDo) Returning(value interface{}, columns ...string) ISopNodeDo {
  205. return s.withDO(s.DO.Returning(value, columns...))
  206. }
  207. func (s sopNodeDo) Not(conds ...gen.Condition) ISopNodeDo {
  208. return s.withDO(s.DO.Not(conds...))
  209. }
  210. func (s sopNodeDo) Or(conds ...gen.Condition) ISopNodeDo {
  211. return s.withDO(s.DO.Or(conds...))
  212. }
  213. func (s sopNodeDo) Select(conds ...field.Expr) ISopNodeDo {
  214. return s.withDO(s.DO.Select(conds...))
  215. }
  216. func (s sopNodeDo) Where(conds ...gen.Condition) ISopNodeDo {
  217. return s.withDO(s.DO.Where(conds...))
  218. }
  219. func (s sopNodeDo) Order(conds ...field.Expr) ISopNodeDo {
  220. return s.withDO(s.DO.Order(conds...))
  221. }
  222. func (s sopNodeDo) Distinct(cols ...field.Expr) ISopNodeDo {
  223. return s.withDO(s.DO.Distinct(cols...))
  224. }
  225. func (s sopNodeDo) Omit(cols ...field.Expr) ISopNodeDo {
  226. return s.withDO(s.DO.Omit(cols...))
  227. }
  228. func (s sopNodeDo) Join(table schema.Tabler, on ...field.Expr) ISopNodeDo {
  229. return s.withDO(s.DO.Join(table, on...))
  230. }
  231. func (s sopNodeDo) LeftJoin(table schema.Tabler, on ...field.Expr) ISopNodeDo {
  232. return s.withDO(s.DO.LeftJoin(table, on...))
  233. }
  234. func (s sopNodeDo) RightJoin(table schema.Tabler, on ...field.Expr) ISopNodeDo {
  235. return s.withDO(s.DO.RightJoin(table, on...))
  236. }
  237. func (s sopNodeDo) Group(cols ...field.Expr) ISopNodeDo {
  238. return s.withDO(s.DO.Group(cols...))
  239. }
  240. func (s sopNodeDo) Having(conds ...gen.Condition) ISopNodeDo {
  241. return s.withDO(s.DO.Having(conds...))
  242. }
  243. func (s sopNodeDo) Limit(limit int) ISopNodeDo {
  244. return s.withDO(s.DO.Limit(limit))
  245. }
  246. func (s sopNodeDo) Offset(offset int) ISopNodeDo {
  247. return s.withDO(s.DO.Offset(offset))
  248. }
  249. func (s sopNodeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ISopNodeDo {
  250. return s.withDO(s.DO.Scopes(funcs...))
  251. }
  252. func (s sopNodeDo) Unscoped() ISopNodeDo {
  253. return s.withDO(s.DO.Unscoped())
  254. }
  255. func (s sopNodeDo) Create(values ...*model.SopNode) error {
  256. if len(values) == 0 {
  257. return nil
  258. }
  259. return s.DO.Create(values)
  260. }
  261. func (s sopNodeDo) CreateInBatches(values []*model.SopNode, batchSize int) error {
  262. return s.DO.CreateInBatches(values, batchSize)
  263. }
  264. // Save : !!! underlying implementation is different with GORM
  265. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  266. func (s sopNodeDo) Save(values ...*model.SopNode) error {
  267. if len(values) == 0 {
  268. return nil
  269. }
  270. return s.DO.Save(values)
  271. }
  272. func (s sopNodeDo) First() (*model.SopNode, error) {
  273. if result, err := s.DO.First(); err != nil {
  274. return nil, err
  275. } else {
  276. return result.(*model.SopNode), nil
  277. }
  278. }
  279. func (s sopNodeDo) Take() (*model.SopNode, error) {
  280. if result, err := s.DO.Take(); err != nil {
  281. return nil, err
  282. } else {
  283. return result.(*model.SopNode), nil
  284. }
  285. }
  286. func (s sopNodeDo) Last() (*model.SopNode, error) {
  287. if result, err := s.DO.Last(); err != nil {
  288. return nil, err
  289. } else {
  290. return result.(*model.SopNode), nil
  291. }
  292. }
  293. func (s sopNodeDo) Find() ([]*model.SopNode, error) {
  294. result, err := s.DO.Find()
  295. return result.([]*model.SopNode), err
  296. }
  297. func (s sopNodeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SopNode, err error) {
  298. buf := make([]*model.SopNode, 0, batchSize)
  299. err = s.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  300. defer func() { results = append(results, buf...) }()
  301. return fc(tx, batch)
  302. })
  303. return results, err
  304. }
  305. func (s sopNodeDo) FindInBatches(result *[]*model.SopNode, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  306. return s.DO.FindInBatches(result, batchSize, fc)
  307. }
  308. func (s sopNodeDo) Attrs(attrs ...field.AssignExpr) ISopNodeDo {
  309. return s.withDO(s.DO.Attrs(attrs...))
  310. }
  311. func (s sopNodeDo) Assign(attrs ...field.AssignExpr) ISopNodeDo {
  312. return s.withDO(s.DO.Assign(attrs...))
  313. }
  314. func (s sopNodeDo) Joins(fields ...field.RelationField) ISopNodeDo {
  315. for _, _f := range fields {
  316. s = *s.withDO(s.DO.Joins(_f))
  317. }
  318. return &s
  319. }
  320. func (s sopNodeDo) Preload(fields ...field.RelationField) ISopNodeDo {
  321. for _, _f := range fields {
  322. s = *s.withDO(s.DO.Preload(_f))
  323. }
  324. return &s
  325. }
  326. func (s sopNodeDo) FirstOrInit() (*model.SopNode, error) {
  327. if result, err := s.DO.FirstOrInit(); err != nil {
  328. return nil, err
  329. } else {
  330. return result.(*model.SopNode), nil
  331. }
  332. }
  333. func (s sopNodeDo) FirstOrCreate() (*model.SopNode, error) {
  334. if result, err := s.DO.FirstOrCreate(); err != nil {
  335. return nil, err
  336. } else {
  337. return result.(*model.SopNode), nil
  338. }
  339. }
  340. func (s sopNodeDo) FindByPage(offset int, limit int) (result []*model.SopNode, count int64, err error) {
  341. result, err = s.Offset(offset).Limit(limit).Find()
  342. if err != nil {
  343. return
  344. }
  345. if size := len(result); 0 < limit && 0 < size && size < limit {
  346. count = int64(size + offset)
  347. return
  348. }
  349. count, err = s.Offset(-1).Limit(-1).Count()
  350. return
  351. }
  352. func (s sopNodeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  353. count, err = s.Count()
  354. if err != nil {
  355. return
  356. }
  357. err = s.Offset(offset).Limit(limit).Scan(result)
  358. return
  359. }
  360. func (s sopNodeDo) Scan(result interface{}) (err error) {
  361. return s.DO.Scan(result)
  362. }
  363. func (s sopNodeDo) Delete(models ...*model.SopNode) (result gen.ResultInfo, err error) {
  364. return s.DO.Delete(models)
  365. }
  366. func (s *sopNodeDo) withDO(do gen.Dao) *sopNodeDo {
  367. s.DO = *do.(*gen.DO)
  368. return s
  369. }