article_abstract_history.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package rag
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "time"
  6. )
  7. // ArticleAbstractHistory 文章/报告摘要历史记录表
  8. type ArticleAbstractHistory struct {
  9. ArticleAbstractHistoryID int `gorm:"primaryKey;column:article_abstract_history_id" description:"-"`
  10. Source int8 `gorm:"column:source" description:"来源,0:公众号文章,1:eta报告"`
  11. ArticleAbstractID int `gorm:"column:article_abstract_id" description:"文章/报告摘要id"`
  12. ArticleID int `gorm:"column:article_id" description:"文章/报告Id"`
  13. QuestionId int `gorm:"column:question_id" description:"提示词Id"`
  14. Tags string `gorm:"column:tags" description:"标签"`
  15. QuestionContent string `gorm:"column:question_content" description:"questionContent"`
  16. Content string `gorm:"column:content" description:"摘要内容"`
  17. Version int `gorm:"column:version" description:"版本号"`
  18. VectorKey string `gorm:"column:vector_key" description:"向量key标识"`
  19. ModifyTime time.Time `gorm:"column:modify_time" description:"modifyTime"`
  20. CreateTime time.Time `gorm:"column:create_time" description:"createTime"`
  21. }
  22. // TableName get sql table name.获取数据库表名
  23. func (m *ArticleAbstractHistory) TableName() string {
  24. return "article_abstract_history"
  25. }
  26. // ArticleAbstractHistoryColumns get sql column name.获取数据库列名
  27. var ArticleAbstractHistoryColumns = struct {
  28. ArticleAbstractHistoryID string
  29. Source string
  30. ArticleAbstractID string
  31. ArticleID string
  32. QuestionId string
  33. Tags string
  34. QuestionContent string
  35. Content string
  36. Version string
  37. VectorKey string
  38. ModifyTime string
  39. CreateTime string
  40. }{
  41. ArticleAbstractHistoryID: "article_abstract_history_id",
  42. Source: "source",
  43. ArticleAbstractID: "article_abstract_id",
  44. ArticleID: "article_id",
  45. QuestionId: "question_id",
  46. Tags: "tags",
  47. QuestionContent: "question_content",
  48. Content: "content",
  49. Version: "version",
  50. VectorKey: "vector_key",
  51. ModifyTime: "modify_time",
  52. CreateTime: "create_time",
  53. }
  54. func (m *ArticleAbstractHistory) Create() (err error) {
  55. err = global.DbMap[utils.DbNameAI].Create(&m).Error
  56. return
  57. }
  58. // AddArticleAbstractHistoryByWechatArticleAbstract
  59. // @Description: 根据eta报告摘要添加历史记录
  60. // @author: Roc
  61. // @datetime 2025-04-17 14:05:10
  62. // @param item *WechatArticleAbstract
  63. func AddArticleAbstractHistoryByWechatArticleAbstract(item *RagEtaReportAbstract) {
  64. history := &ArticleAbstractHistory{
  65. ArticleAbstractHistoryID: 0,
  66. Source: 0,
  67. ArticleAbstractID: item.RagEtaReportAbstractId,
  68. ArticleID: item.RagEtaReportId,
  69. QuestionId: item.QuestionId,
  70. Tags: item.Tags,
  71. QuestionContent: item.QuestionContent,
  72. Content: item.Content,
  73. Version: item.Version,
  74. VectorKey: item.VectorKey,
  75. ModifyTime: time.Now(),
  76. CreateTime: time.Now(),
  77. }
  78. _ = history.Create()
  79. }