|
@@ -91,7 +91,30 @@ func GetReportRecentList(startSize, pageSize int) (items []*ReportList, err erro
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func GetReportCountByClassifyIds(classifyIds []int, condition string) (count int, err error) {
|
|
|
|
|
|
+func GetReportCountByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds []int, condition string) (count int, err error) {
|
|
|
|
+ if len(classifyFirstIds) == 0 && len(classifySecondIds) == 0 && len(classifyThirdIds) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ sql := `SELECT COUNT(*) AS count FROM report AS a WHERE (a.state=2 OR a.state=6) `
|
|
|
|
+
|
|
|
|
+ if len(classifyFirstIds) > 0 {
|
|
|
|
+ sql += fmt.Sprintf(" OR a.classify_id_first IN (%s) ", utils.GetOrmReplaceHolder(len(classifyFirstIds)))
|
|
|
|
+ }
|
|
|
|
+ if len(classifySecondIds) > 0 {
|
|
|
|
+ sql += fmt.Sprintf(" OR a.classify_id_second IN (%s) ", utils.GetOrmReplaceHolder(len(classifySecondIds)))
|
|
|
|
+ }
|
|
|
|
+ if len(classifyThirdIds) > 0 {
|
|
|
|
+ sql += fmt.Sprintf(" OR a.classify_id_third IN (%s) ", utils.GetOrmReplaceHolder(len(classifyThirdIds)))
|
|
|
|
+ }
|
|
|
|
+ if condition != "" {
|
|
|
|
+ sql += condition
|
|
|
|
+ }
|
|
|
|
+ err = o.Raw(sql, classifyFirstIds, classifySecondIds, classifyThirdIds).QueryRow(&count)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func GetReportByClassifyIds(classifyIds []int, condition string) (count int, err error) {
|
|
if len(classifyIds) == 0 {
|
|
if len(classifyIds) == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -106,8 +129,8 @@ func GetReportCountByClassifyIds(classifyIds []int, condition string) (count int
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func GetReportListByClassifyIds(classifyIds []int, condition string, startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
|
- if len(classifyIds) == 0 {
|
|
|
|
|
|
+func GetReportListByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds []int, condition string, startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
|
+ if len(classifyFirstIds) == 0 && len(classifySecondIds) == 0 && len(classifyThirdIds) == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
@@ -117,53 +140,61 @@ func GetReportListByClassifyIds(classifyIds []int, condition string, startSize,
|
|
CASE WHEN DATE(a.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
|
|
CASE WHEN DATE(a.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
|
|
FROM report AS a
|
|
FROM report AS a
|
|
INNER JOIN classify AS b ON a.classify_id_second=b.id
|
|
INNER JOIN classify AS b ON a.classify_id_second=b.id
|
|
- WHERE (a.state=2 OR a.state=6) AND a.classify_id_second IN (%s) `
|
|
|
|
-
|
|
|
|
- sql = fmt.Sprintf(sql, utils.GetOrmReplaceHolder(len(classifyIds)))
|
|
|
|
|
|
+ WHERE (a.state=2 OR a.state=6) `
|
|
|
|
+ // AND (a.classify_id_first IN (%s) OR a.classify_id_second IN (%s) OR a.classify_id_third IN (%s)) `
|
|
|
|
+ if len(classifyFirstIds) > 0 {
|
|
|
|
+ sql += fmt.Sprintf(" OR a.classify_id_first IN (%s) ", utils.GetOrmReplaceHolder(len(classifyFirstIds)))
|
|
|
|
+ }
|
|
|
|
+ if len(classifySecondIds) > 0 {
|
|
|
|
+ sql += fmt.Sprintf(" OR a.classify_id_second IN (%s) ", utils.GetOrmReplaceHolder(len(classifySecondIds)))
|
|
|
|
+ }
|
|
|
|
+ if len(classifyThirdIds) > 0 {
|
|
|
|
+ sql += fmt.Sprintf(" OR a.classify_id_third IN (%s) ", utils.GetOrmReplaceHolder(len(classifyThirdIds)))
|
|
|
|
+ }
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
sql += ` ORDER BY a.publish_time DESC LIMIT ?,? `
|
|
sql += ` ORDER BY a.publish_time DESC LIMIT ?,? `
|
|
- _, err = o.Raw(sql, classifyIds, startSize, pageSize).QueryRows(&items)
|
|
|
|
|
|
+ _, err = o.Raw(sql, classifyFirstIds, classifySecondIds, classifyThirdIds, startSize, pageSize).QueryRows(&items)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
type ReportDetail struct {
|
|
type ReportDetail 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 string `description:"修改时间"`
|
|
|
|
- State int `description:"1:未发布,2:已发布"`
|
|
|
|
- PublishTime string `description:"发布时间"`
|
|
|
|
- Stage int `description:"期数"`
|
|
|
|
- MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
|
|
|
|
- Content string `description:"内容"`
|
|
|
|
- ChapterContent []*ReportChapter `description:"章节内容"`
|
|
|
|
- VideoUrl string `description:"音频文件URL"`
|
|
|
|
- VideoName string `description:"音频文件名称"`
|
|
|
|
- VideoPlaySeconds string `description:"音频播放时长"`
|
|
|
|
- VideoSize string `description:"音频文件大小,单位M"`
|
|
|
|
- ContentSub string `description:"内容前两个章节"`
|
|
|
|
- IsShowNewLabel int `description:"是否显示新标签"`
|
|
|
|
- IsCurrentDate int `description:"是否当前日期"`
|
|
|
|
- ClassifyName string `description:"分类名称"`
|
|
|
|
- TitleType string `description:"标题类型,FICC或者权益"`
|
|
|
|
- IsPublic bool `description:"是否是公共报告 "`
|
|
|
|
- HeadResourceId int `description:"版头资源库id"`
|
|
|
|
- EndResourceId int `description:"版尾资源库id"`
|
|
|
|
- HeadResourceUrl string `description:"版头资源库Url"`
|
|
|
|
- EndResourceUrl string `description:"版尾资源库Url"`
|
|
|
|
- CollaborateType int `description:"合作类型, 1:个人,2:多人协作"`
|
|
|
|
- ReportLayout int `description:"报告布局, 1:常规布局,2:智能布局"`
|
|
|
|
- HasChapter int `description:"是否有章节: 0-否 1-是"`
|
|
|
|
|
|
+ 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 string `description:"修改时间"`
|
|
|
|
+ State int `description:"1:未发布,2:已发布"`
|
|
|
|
+ PublishTime string `description:"发布时间"`
|
|
|
|
+ Stage int `description:"期数"`
|
|
|
|
+ MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
|
|
|
|
+ Content string `description:"内容"`
|
|
|
|
+ ChapterContent []*ReportChapter `description:"章节内容"`
|
|
|
|
+ VideoUrl string `description:"音频文件URL"`
|
|
|
|
+ VideoName string `description:"音频文件名称"`
|
|
|
|
+ VideoPlaySeconds string `description:"音频播放时长"`
|
|
|
|
+ VideoSize string `description:"音频文件大小,单位M"`
|
|
|
|
+ ContentSub string `description:"内容前两个章节"`
|
|
|
|
+ IsShowNewLabel int `description:"是否显示新标签"`
|
|
|
|
+ IsCurrentDate int `description:"是否当前日期"`
|
|
|
|
+ ClassifyName string `description:"分类名称"`
|
|
|
|
+ TitleType string `description:"标题类型,FICC或者权益"`
|
|
|
|
+ IsPublic bool `description:"是否是公共报告 "`
|
|
|
|
+ HeadResourceId int `description:"版头资源库id"`
|
|
|
|
+ EndResourceId int `description:"版尾资源库id"`
|
|
|
|
+ HeadResource *SmartReportResource `description:"版头资源库"`
|
|
|
|
+ EndResource *SmartReportResource `description:"版尾资源库"`
|
|
|
|
+ CollaborateType int `description:"合作类型, 1:个人,2:多人协作"`
|
|
|
|
+ ReportLayout int `description:"报告布局, 1:常规布局,2:智能布局"`
|
|
|
|
+ HasChapter int `description:"是否有章节: 0-否 1-是"`
|
|
}
|
|
}
|
|
|
|
|
|
type ReportChapter struct {
|
|
type ReportChapter struct {
|