package models import ( "github.com/beego/beego/v2/client/orm" "time" //"time" ) type CygxArticleCategoryMapping struct { Id int `orm:"column(id);pk" description:"id"` ChartPermissionId int `description:"行业ID"` CategoryId int `description:"分类ID"` ChartPermissionName string `description:"行业名称"` MatchTypeName string `description:"分类名称"` ReportType int `description:"报告类型,2产业报告,1行业报告"` SubCategoryName string `description:"主题"` Sort int `description:"排序"` IsCustom int `description:"是否属于自定义的匹配类型 ,1是,0否"` IsSummary int `description:"是否是纪要库,1是,0否"` IsReport int `description:"是否是报告,1是,0否"` PermissionType int `description:"1主观,2客观"` CygxId int `description:"分类聚合ID"` CeLueId int `description:"策略平台领域ID"` } // 添加 func AddCygxArticleCategoryMapping(item *CygxArticleCategoryMapping) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } // 添加 func AddCygxReportMappingCygx(item *CygxReportMappingCygx) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } // 获取数量 func GetCygxReportMappingCygxCount(condition string) (count int, err error) { sqlCount := ` SELECT COUNT(1) AS count FROM cygx_report_mapping_cygx as art WHERE 1= 1 ` if condition != "" { sqlCount += condition } o := orm.NewOrm() err = o.Raw(sqlCount).QueryRow(&count) return } // 获取所有的报告分类 查研观向 func GetCygxReportMappingCygx() (items []*CygxReportMappingCygx, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_report_mapping_cygx ` _, err = o.Raw(sql).QueryRows(&items) return } // 获取所有的报告分类 策略 func GetCygxReportMappingcelue(condition string) (items []*CygxReportMapping, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_report_mapping_celue WHERE 1= 1 ` if condition != "" { sql += condition } _, err = o.Raw(sql).QueryRows(&items) return } // 通过分类ID获取详情 func GetCygxReportMappingCygxByCategoryId(categoryId int) (item *CygxReportMappingCygx, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_report_mapping_cygx WHERE id=? ` err = o.Raw(sql, categoryId).QueryRow(&item) return } type CygxReportMappingCelue struct { Id int `orm:"column(id);pk" description:"id"` ChartPermissionId int `description:"行业ID"` CategoryId int `description:"分类ID"` ChartPermissionName string `description:"行业名称"` SubCategoryName string `description:"主题"` ReportType int `description:"报告类型,2产业报告,1行业报告"` Sort int `description:"排序"` IsCustom int `description:"是否属于自定义的匹配类型 ,1是,0否"` IsSummary int `description:"是否是纪要库,1是,0否"` IsReport int `description:"是否是报告,1是,0否"` PermissionType int `description:"1主观,2客观"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"更新时间"` } // 通过 categoryId 获取详情 func GetCygxReportMappingCelueMaxDetailByCategoryId(categoryId int) (item *CygxReportMappingCelue, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_report_mapping_celue WHERE category_id = ? LIMIT 1 ` err = o.Raw(sql, categoryId).QueryRow(&item) return }