123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package semantic_analysis
- import (
- "eta_gn/eta_api/global"
- "fmt"
- "strings"
- )
- //type SaCompareDoc struct {
- // SaCompareDocId int `orm:"column(sa_compare_doc_id);pk"`
- // CompareId int `description:"比对ID"`
- // DocId int `description:"文档ID"`
- //}
- type SaCompareDoc struct {
- SaCompareDocId int `gorm:"primaryKey;column:sa_compare_doc_id;type:int(10) unsigned;not null"` // 比对文档Id
- CompareId int `gorm:"index:idx_compare_id;column:compare_id;type:int(10) unsigned;not null;default:0"` // 比对Id
- DocId int `gorm:"column:doc_id;type:int(10) unsigned;not null;default:0"` // 文档Id
- }
- var SaCompareDocColumns = struct {
- SaCompareDocId string
- CompareId string
- DocId string
- }{
- SaCompareDocId: "sa_compare_doc_id",
- CompareId: "compare_id",
- DocId: "doc_id",
- }
- func (m *SaCompareDoc) TableName() string {
- return "sa_compare_doc"
- }
- //func (m *SaCompareDoc) Create() (err error) {
- // o := orm.NewOrm()
- // id, err := o.Insert(m)
- // if err != nil {
- // return
- // }
- // m.SaCompareDocId = int(id)
- // return
- //}
- //func (m *SaCompareDoc) Update(cols []string) (err error) {
- // o := orm.NewOrm()
- // _, err = o.Update(m, cols...)
- // return
- //}
- //func (m *SaCompareDoc) Del() (err error) {
- // o := orm.NewOrm()
- // sql := `DELETE FROM sa_compare_doc WHERE sa_compare_doc_id = ? LIMIT 1`
- // _, err = o.Raw(sql, m.SaCompareDocId).Exec()
- // return
- //}
- //func (m *SaCompareDoc) GetItemById(id int) (err error) {
- // o := orm.NewOrm()
- // sql := `SELECT * FROM sa_compare_doc WHERE sa_compare_doc_id = ? LIMIT 1`
- // err = o.Raw(sql, id).QueryRow(&m)
- // return
- //}
- //func (m *SaCompareDoc) GetItemByCondition(condition string, pars []interface{}) (err error) {
- // o := orm.NewOrm()
- // sql := `SELECT * FROM sa_compare_doc WHERE 1=1 `
- // sql += condition
- // sql += ` LIMIT 1`
- // err = o.Raw(sql, pars).QueryRow(&m)
- // return
- //}
- //func (m *SaCompareDoc) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
- // o := orm.NewOrm()
- // sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- // err = o.Raw(sql, pars).QueryRow(&count)
- // return
- //}
- func (m *SaCompareDoc) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*SaCompareDoc, err error) {
- //o := orm.NewOrm()
- fields := strings.Join(fieldArr, ",")
- if len(fieldArr) == 0 {
- fields = `*`
- }
- order := ``
- if orderRule != "" {
- order = ` ORDER BY ` + orderRule
- }
- sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
- //_, err = o.Raw(sql, pars).QueryRows(&items)
- err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error
- return
- }
- //func (m *SaCompareDoc) GetPageItemsByCondition(startSize, pageSize int, condition string, pars []interface{}, fieldArr []string, orderRule string) (total int, items []*SaCompareDoc, err error) {
- // o := orm.NewOrm()
- // fields := strings.Join(fieldArr, ",")
- // if len(fieldArr) == 0 {
- // fields = `*`
- // }
- // order := ``
- // if orderRule != "" {
- // order = ` ORDER BY ` + orderRule
- // }
- // sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
- // totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z`
- // if err = o.Raw(totalSql, pars).QueryRow(&total); err != nil {
- // return
- // }
- // sql += ` LIMIT ?,?`
- // _, err = o.Raw(sql, pars...).QueryRows(&items)
- // return
- //}
- // SaCompareDocSection 比对文档段落信息
- type SaCompareDocSection struct {
- DocId int `description:"文档ID"`
- Title string `description:"文档标题"`
- Theme string `description:"文档主题"`
- ClassifyName string `description:"分类名称"`
- SectionId int `description:"段落ID"`
- Content string `description:"段落内容"`
- Sort int `description:"段落排序"`
- }
- // GetSaCompareDocAndSections 获取比对关联的文档段落
- //func GetSaCompareDocAndSections(compareId int) (items []*SaCompareDocSection, err error) {
- // o := orm.NewOrm()
- // sql := `SELECT
- // a.doc_id,
- // b.title,
- // b.theme,
- // b.classify_name,
- // c.sa_doc_section_id AS section_id,
- // c.content,
- // c.sort
- // FROM
- // sa_compare_doc AS a
- // JOIN sa_doc AS b ON a.doc_id = b.sa_doc_id
- // JOIN sa_doc_section AS c ON a.doc_id = c.doc_id
- // WHERE
- // a.compare_id = ?
- // ORDER BY
- // a.doc_id,
- // c.sort ASC`
- // _, err = o.Raw(sql, compareId).QueryRows(&items)
- // return
- //}
|