sa_compare_doc.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. type SaCompareDocSection struct {
  38. DocId int `description:"文档ID"`
  39. Title string `description:"文档标题"`
  40. Theme string `description:"文档主题"`
  41. ClassifyName string `description:"分类名称"`
  42. SectionId int `description:"段落ID"`
  43. Content string `description:"段落内容"`
  44. Sort int `description:"段落排序"`
  45. }