article_abstract_history.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. TagsName string `gorm:"column:tags_name" description:"标签名,多个用英文逗号隔开"`
  16. QuestionContent string `gorm:"column:question_content" description:"questionContent"`
  17. Content string `gorm:"column:content" description:"摘要内容"`
  18. Version int `gorm:"column:version" description:"版本号"`
  19. VectorKey string `gorm:"column:vector_key" description:"向量key标识"`
  20. ModifyTime time.Time `gorm:"column:modify_time" description:"modifyTime"`
  21. CreateTime time.Time `gorm:"column:create_time" description:"createTime"`
  22. }
  23. // TableName get sql table name.获取数据库表名
  24. func (m *ArticleAbstractHistory) TableName() string {
  25. return "article_abstract_history"
  26. }
  27. // ArticleAbstractHistoryColumns get sql column name.获取数据库列名
  28. var ArticleAbstractHistoryColumns = struct {
  29. ArticleAbstractHistoryID string
  30. Source string
  31. ArticleAbstractID string
  32. ArticleID string
  33. QuestionId string
  34. Tags string
  35. TagsName string
  36. QuestionContent string
  37. Content string
  38. Version string
  39. VectorKey string
  40. ModifyTime string
  41. CreateTime string
  42. }{
  43. ArticleAbstractHistoryID: "article_abstract_history_id",
  44. Source: "source",
  45. ArticleAbstractID: "article_abstract_id",
  46. ArticleID: "article_id",
  47. QuestionId: "question_id",
  48. Tags: "tags",
  49. TagsName: "tags_name",
  50. QuestionContent: "question_content",
  51. Content: "content",
  52. Version: "version",
  53. VectorKey: "vector_key",
  54. ModifyTime: "modify_time",
  55. CreateTime: "create_time",
  56. }
  57. func (m *ArticleAbstractHistory) Create() (err error) {
  58. err = global.DbMap[utils.DbNameAI].Create(&m).Error
  59. return
  60. }
  61. // AddArticleAbstractHistoryByWechatArticleAbstract
  62. // @Description: 根据eta报告摘要添加历史记录
  63. // @author: Roc
  64. // @datetime 2025-04-17 14:05:10
  65. // @param item *WechatArticleAbstract
  66. func AddArticleAbstractHistoryByWechatArticleAbstract(item *WechatArticleAbstract) {
  67. history := &ArticleAbstractHistory{
  68. ArticleAbstractHistoryID: 0,
  69. Source: 0,
  70. ArticleAbstractID: item.WechatArticleAbstractId,
  71. ArticleID: item.WechatArticleId,
  72. QuestionId: item.QuestionId,
  73. Tags: item.Tags,
  74. TagsName: item.TagsName,
  75. QuestionContent: item.QuestionContent,
  76. Content: item.Content,
  77. Version: item.Version,
  78. VectorKey: item.VectorKey,
  79. ModifyTime: time.Now(),
  80. CreateTime: time.Now(),
  81. }
  82. _ = history.Create()
  83. }
  84. // AddArticleAbstractHistoryByWechatArticleAbstract
  85. // @Description: 根据eta报告摘要添加历史记录
  86. // @author: Roc
  87. // @datetime 2025-04-17 14:05:10
  88. // @param item *WechatArticleAbstract
  89. func AddArticleAbstractHistoryByRagEtaReportAbstract(item *RagEtaReportAbstract) {
  90. history := &ArticleAbstractHistory{
  91. ArticleAbstractHistoryID: 0,
  92. Source: 0,
  93. ArticleAbstractID: item.RagEtaReportAbstractId,
  94. ArticleID: item.RagEtaReportId,
  95. QuestionId: item.QuestionId,
  96. Tags: item.Tags,
  97. TagsName: item.TagsName,
  98. QuestionContent: item.QuestionContent,
  99. Content: item.Content,
  100. Version: item.Version,
  101. VectorKey: item.VectorKey,
  102. ModifyTime: time.Now(),
  103. CreateTime: time.Now(),
  104. }
  105. _ = history.Create()
  106. }