123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- )
- type ReportMapping struct {
- CategoryId int `description:"分类ID"`
- SubCategoryName string `description:"主题"`
- MatchTypeName string `description:"分类名称"`
- ChartPermissionName string `description:"行业名称"`
- ChartPermissionId int `description:"行业ID"`
- IsRed bool `description:"是否标红"`
- PermissionType int `description:"1主观,2客观"`
- }
- type ReportMappingHome struct {
- CategoryId int `description:"分类ID"`
- SubCategoryName string `description:"主题名称"`
- MatchTypeName string `description:"匹配类型"`
- IsRed bool `description:"是否标红"`
- }
- type TradeReportMapping struct {
- CategoryId int `description:"分类ID"`
- MatchTypeName string `description:"匹配类型"`
- IsRed bool `description:"是否标红"`
- IsFollow bool `description:"是否关注"`
- UpdateTime string `description:"更新时间"`
- Readnum int `description:"阅读数量"`
- ListArticle []*HomeArticle `description:"文章列表"`
- }
- type ReportMappingResp struct {
- List []*ReportMapping
- }
- type ReportMappingHomeResp struct {
- List []*ReportMappingHome
- }
- type TradeReportMappingResp struct {
- List []*TradeReportMapping
- }
- //获取所有分类
- func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_report_mapping WHERE 1=1 ORDER BY sort ASC `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- //获取策略下面的所有分类
- func GetReportMappingStrategyHomeAll() (items []*TradeReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- MAX( art.publish_date ) AS update_time,
- re.category_id,re.sub_category_name,re.match_type_name
- FROM
- cygx_report_mapping AS re
- INNER JOIN cygx_article AS art ON art.category_id = re.category_id
- WHERE
- re.report_type = 1
- AND re.chart_permission_id = 23
- GROUP BY
- re.match_type_name
- ORDER BY
- sort DESC , art.publish_date DESC`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- //行业列表
- func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- MAX( art.publish_date ) AS update_time,
- re.category_id,
- re.sub_category_name,
- re.match_type_name
- FROM
- cygx_report_mapping AS re
- INNER JOIN cygx_article AS art ON re.category_id = art.category_id
- WHERE
- re.chart_permission_id =?
- AND re.report_type = 1
- AND art.is_class = 1
- AND re.category_id NOT IN (67)
- GROUP BY
- art.category_id
- ORDER BY
- update_time DESC`
- _, err = o.Raw(sql, ChartPermissionId).QueryRows(&items)
- return
- }
- type IndustrialToArticleCategoryRep struct {
- CategoryId int `description:"分类ID"`
- MatchTypeName string `description:"匹配类型"`
- IsRed bool `description:"是否标红"`
- }
- type IndustrialToArticleCategoryListRep struct {
- LayoutTime string `description:"布局时间"`
- IndustryName string `description:"产业名称"`
- IndustrialManagementId int `description:"产业D"`
- List []*IndustrialToArticleCategoryRep
- ListSubject []*IndustrialSubject
- IndustryVideo *MicroVideoSimpleInfo
- AuthInfo *UserPermissionAuthInfo
- }
- //通过分类ID获取详情
- func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? LIMIT 1 `
- err = o.Raw(sql, categoryId).QueryRow(&item)
- return
- }
- //通过分类ID获取详情
- func GetdetailByCategoryIdPush(categoryId int) (item *ReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? `
- err = o.Raw(sql, categoryId).QueryRow(&item)
- return
- }
- //通过分类ID获取详情主观客观
- func GetdetailByCategoryIdSando(categoryId int) (item *ReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_report_mapping WHERE permission_type>0 AND category_id=? LIMIT 1`
- err = o.Raw(sql, categoryId).QueryRow(&item)
- return
- }
- //通过分类ID获取详情
- func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? LIMIT 1`
- err = o.Raw(sql, categoryId).QueryRow(&item)
- return
- }
- //通过分类ID获取详情
- func GetdetailByCategoryIdSet(categoryId int) (ids string, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- GROUP_CONCAT( DISTINCT category_id SEPARATOR ',' ) AS ids
- FROM
- cygx_report_mapping
- WHERE
- category_id_set = ? `
- err = o.Raw(sql, categoryId).QueryRow(&ids)
- return
- }
- //判断该分类下最新的文章用户是否阅读
- func CheckThisCategoryNewArticleIsRead(uid, categoryId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(1) count
- FROM cygx_article_history_record
- WHERE user_id = ?
- AND article_id = ( SELECT article_id FROM cygx_article WHERE category_id = ? AND is_class = 1 AND is_report = 1 AND is_filter = 0 ORDER BY publish_date DESC LIMIT 1)`
- err = o.Raw(sql, uid, categoryId).QueryRow(&count)
- return
- }
- //获取策略下面的所有分类
- func GetMatchTypeNamenNotNull() (items []*ReportMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT category_id,match_type_name FROM cygx_report_mapping WHERE match_type_name <> ''`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type ReportMappingStatistical struct {
- CategoryId int `description:"分类ID"`
- SubCategoryName string `description:"主题名称"`
- MatchTypeName string `description:"匹配类型"`
- IsSummary string `description:"是否属于纪要,1 是,0否"`
- IsClass string `description:"是否归类,1 是,0否"`
- Pv int `description:"Pv"`
- Uv int `description:"Uv"`
- }
|