intent_records.gen.go 13 KB

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