package pc import ( "fmt" "hongze/hongze_yb/global" "time" ) type Report struct { Id int `description:"报告Id"` AddType int `description:"新增方式:1:新增报告,2:继承报告"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` Title string `description:"标题"` Abstract string `description:"摘要"` Author string `description:"作者"` Frequency string `description:"频度"` CreateTime string `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` State int `description:"1:未发布,2:已发布"` PublishTime string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` ContentSub string `description:"内容前两个章节"` ClassifyName string `description:"分类名称"` HasPermission int `description:"报告权限:0:无权限,1:有权限"` TitleType string `description:"标题类型,FICC或者权益"` } func GetLatestReportList() (items []*Report, err error) { sql := `SELECT * FROM report WHERE state=2 ORDER BY publish_time DESC LIMIT 3 ` err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error return } func GetRecommendList(reportId, reportType, secondId int) (items []*Report, err error) { sql := `SELECT * FROM report WHERE state=2 AND id<> %v AND classify_id_second=%v ` sql = fmt.Sprintf(sql, reportId, secondId) if reportType == 1 { sql += ` AND classify_name_first='权益研报' ` } else { sql += ` AND classify_name_first<>'权益研报' ` } sql += ` ORDER BY publish_time DESC LIMIT 3` err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error return } type LatestReport struct { Id int `description:"报告Id" json:"_"` ClassifyNameFirst string `description:"一级分类名称" json:"classify_name_first"` ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"` ClassifyIdSecond int `description:"二级分类id" json:"classify_id_second"` Title string `description:"标题" json:"title"` State int `description:"1:未发布,2:已发布" json:"state"` PublishTime time.Time `description:"发布时间" json:"publish_time"` Stage int `description:"期数" json:"stage"` ReportId int } func GetLatestStage(classifyNames []string) (items []*LatestReport, err error) { sql := `SELECT * FROM(SELECT DISTINCT classify_name_first, id, title, state, publish_time, stage FROM report WHERE classify_name_first IN (?) AND state IN (2, 6) ORDER BY publish_time DESC) t GROUP BY t.classify_name_first` err = global.MYSQL["rddp"].Raw(sql, classifyNames).Scan(&items).Error return } type RecommendResp struct { ReportId int ReportChapterID int Title string Stage int ClassifyNameFirst string ClassifySecondFirst string } type DetailBannerResp struct { ReportId int Stage int VipTitle string Author string ReportAuthor string ImgUrl string ClassifyNameFirst string ClassifyIdFirst int ClassifyNameSecond string ClassifyIdSecond int Type string ShowType uint8 } type LatestReportBanner struct { ReportId int `description:"报告Id" json:"reportId"` ClassifyIdFirst int ClassifyIdSecond int ClassifyNameFirst string `description:"一级分类名称" json:"classify_name_first"` ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"` Title string `description:"标题" json:"title"` State int `description:"1:未发布,2:已发布" json:"state"` PublishTime time.Time `description:"发布时间" json:"publish_time"` Stage int `description:"期数" json:"stage"` VipTitle string Author string ReportAuthor string } // GetRecommendListV2 // @Description: 获取报告的推荐列表 // @author: Roc // @datetime 2024-06-24 14:25:01 // @param reportId int // @param reportType int // @param firstId int // @param secondId int // @param thirdId int // @return items []*Report // @return err error func GetRecommendListV2(reportId, reportType, firstId, secondId, thirdId int) (items []*Report, err error) { sql := `SELECT * FROM report WHERE state=2 AND id<> ? AND classify_id_first=? AND classify_id_second=? AND classify_id_third=? ` if reportType == 1 { sql += ` AND classify_name_first = ? ` } else { sql += ` AND classify_name_first<>? ` } sql += ` ORDER BY publish_time DESC LIMIT 3` err = global.MYSQL["rddp"].Raw(sql, reportId, firstId, secondId, thirdId, "权益研报").Scan(&items).Error return }