sa_compare_doc.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package semantic_analysis
  2. import (
  3. "eta_gn/eta_api/global"
  4. "fmt"
  5. "strings"
  6. )
  7. type SaCompareDoc struct {
  8. SaCompareDocId int `gorm:"primaryKey;column:sa_compare_doc_id;type:int(10) unsigned;not null"` // 比对文档Id
  9. CompareId int `gorm:"index:idx_compare_id;column:compare_id;type:int(10) unsigned;not null;default:0"` // 比对Id
  10. DocId int `gorm:"column:doc_id;type:int(10) unsigned;not null;default:0"` // 文档Id
  11. }
  12. var SaCompareDocColumns = struct {
  13. SaCompareDocId string
  14. CompareId string
  15. DocId string
  16. }{
  17. SaCompareDocId: "sa_compare_doc_id",
  18. CompareId: "compare_id",
  19. DocId: "doc_id",
  20. }
  21. func (m *SaCompareDoc) TableName() string {
  22. return "sa_compare_doc"
  23. }
  24. func (m *SaCompareDoc) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*SaCompareDoc, err error) {
  25. fields := strings.Join(fieldArr, ",")
  26. if len(fieldArr) == 0 {
  27. fields = `*`
  28. }
  29. order := ``
  30. if orderRule != "" {
  31. order = ` ORDER BY ` + orderRule
  32. }
  33. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  34. err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error
  35. return
  36. }
  37. // SaCompareDocSection 比对文档段落信息
  38. type SaCompareDocSection struct {
  39. DocId int `description:"文档ID"`
  40. Title string `description:"文档标题"`
  41. Theme string `description:"文档主题"`
  42. ClassifyName string `description:"分类名称"`
  43. SectionId int `description:"段落ID"`
  44. Content string `description:"段落内容"`
  45. Sort int `description:"段落排序"`
  46. }