package semantic_analysis import ( "eta_gn/eta_api/global" "fmt" "github.com/rdlucklib/rdluck_tools/paging" "strings" "time" ) type SaCompareClassify struct { SaCompareClassifyId int `gorm:"primaryKey;column:sa_compare_classify_id;type:int(10) unsigned;not null"` // 语义分析-文档分类Id ClassifyName string `gorm:"column:classify_name;type:varchar(128);not null;default:''"` // 分类名称 SysAdminId int `gorm:"column:sys_admin_id;type:int(10) unsigned;not null;default:0"` // 创建人Id SysAdminName string `gorm:"column:sys_admin_name;type:varchar(128);not null;default:''"` // 创建人姓名 CreateTime time.Time `gorm:"column:create_time;type:datetime"` // 创建时间 ModifyTime time.Time `gorm:"column:modify_time;type:datetime"` // 更新时间 } var SaCompareClassifyColumns = struct { SaCompareClassifyId string ClassifyName string SysAdminId string SysAdminName string CreateTime string ModifyTime string }{ SaCompareClassifyId: "sa_compare_classify_id", ClassifyName: "classify_name", SysAdminId: "sys_admin_id", SysAdminName: "sys_admin_name", CreateTime: "create_time", ModifyTime: "modify_time", } func (m *SaCompareClassify) TableName() string { return "sa_compare_classify" } func (m *SaCompareClassify) Create() (err error) { err = global.DEFAULT_DmSQL.Create(m).Error return } func (m *SaCompareClassify) Update(cols []string) (err error) { err = global.DEFAULT_DmSQL.Select(cols).Updates(m).Error return } func (m *SaCompareClassify) Del() (err error) { sql := `DELETE FROM sa_compare_classify WHERE sa_compare_classify_id = ? LIMIT 1` err = global.DEFAULT_DmSQL.Exec(sql, m.SaCompareClassifyId).Error return } func (m *SaCompareClassify) GetItemById(id int) (err error) { sql := `SELECT * FROM sa_compare_classify WHERE sa_compare_classify_id = ? LIMIT 1` err = global.DEFAULT_DmSQL.Raw(sql, id).First(&m).Error return } func (m *SaCompareClassify) GetItemByCondition(condition string, pars []interface{}) (err error) { sql := `SELECT * FROM sa_compare_classify WHERE 1=1 ` sql += condition sql += ` LIMIT 1` err = global.DEFAULT_DmSQL.Raw(sql, pars...).First(&m).Error return } func (m *SaCompareClassify) GetCountByCondition(condition string, pars []interface{}) (count int, err error) { sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition) err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&count).Error return } func (m *SaCompareClassify) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*SaCompareClassify, err error) { fields := strings.Join(fieldArr, ",") if len(fieldArr) == 0 { fields = `*` } order := `ORDER BY create_time DESC` if orderRule != "" { order = ` ORDER BY ` + orderRule } sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order) err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error return } func (m *SaCompareClassify) GetPageItemsByCondition(startSize, pageSize int, condition string, pars []interface{}, fieldArr []string, orderRule string) (total int, items []*SaCompareClassify, err error) { fields := strings.Join(fieldArr, ",") if len(fieldArr) == 0 { fields = `*` } order := `ORDER BY create_time DESC` 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` err = global.DEFAULT_DmSQL.Raw(totalSql, pars...).Scan(&total).Error if err != nil { return } sql += ` LIMIT ?,?` err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error return } type SaCompareClassifyAddReq struct { ClassifyName string `description:"分类名称"` } type SaCompareClassifyEditReq struct { SaCompareClassifyId int `description:"分类ID"` SaCompareClassifyAddReq } type SaCompareClassifyDelReq struct { SaCompareClassifyId int `description:"分类ID"` } type SaCompareClassifyPageListResp struct { List []*SaCompareClassifyItem Paging *paging.PagingItem `description:"分页数据"` } type SaCompareClassifyItem struct { SaCompareClassifyId int `description:"分类ID"` ClassifyName string `description:"分类名称"` SysAdminId int `description:"创建人ID"` SysAdminName string `description:"创建人姓名"` CreateTime string `description:"创建时间"` Children []*SaCompareItem `gorm:"-" description:"分类下的比对"` }