|
@@ -1,8 +1,8 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
+ "eta/eta_mini_bridge/utils"
|
|
|
"fmt"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
@@ -15,6 +15,8 @@ type ReportList struct {
|
|
|
ClassifyNameFirst string `description:"一级分类名称"`
|
|
|
ClassifyIdSecond int `description:"二级分类id"`
|
|
|
ClassifyNameSecond string `description:"二级分类名称"`
|
|
|
+ ClassifyIdThird int `description:"三级分类id"`
|
|
|
+ ClassifyNameThird string `description:"三级分类名称"`
|
|
|
PermissionNames []string `description:"二级分类名称"`
|
|
|
Title string `description:"标题"`
|
|
|
Abstract string `description:"摘要"`
|
|
@@ -45,19 +47,22 @@ func GetReportDailyListCount() (count int, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func GetReportDailyList(startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
+// o := orm.NewOrmUsingDB("rddp")
|
|
|
+// sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
|
|
|
+// a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
|
|
|
+// b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size,
|
|
|
+// CASE WHEN DATE(a.publish_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
|
|
|
+// FROM report AS a
|
|
|
+// INNER JOIN classify AS b ON a.classify_id_second=b.id
|
|
|
+// WHERE (a.state=2 OR a.state=6) AND DATE(a.publish_time)=DATE(NOW())
|
|
|
+// ORDER BY a.publish_time DESC LIMIT ?,? `
|
|
|
+// _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
|
|
|
+// return
|
|
|
+// }
|
|
|
func GetReportDailyList(startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
|
|
|
- a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
|
|
|
- b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size,
|
|
|
- CASE WHEN DATE(a.publish_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
|
|
|
- FROM report AS a
|
|
|
- INNER JOIN classify AS b ON a.classify_id_second=b.id
|
|
|
- WHERE (a.state=2 OR a.state=6) AND DATE(a.publish_time)=DATE(NOW()) AND a.classify_id_second IN (
|
|
|
- SELECT DISTINCT classify_id
|
|
|
- FROM chart_permission_search_key_word_mapping
|
|
|
- )
|
|
|
- ORDER BY a.publish_time DESC LIMIT ?,? `
|
|
|
+ sql := ` SELECT * FROM report WHERE (state=2 OR state=6) AND DATE(publish_time)=DATE(NOW()) ORDER BY publish_time DESC LIMIT ?,? `
|
|
|
_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
@@ -76,38 +81,54 @@ func GetReportRecentListCount() (count int, err error) {
|
|
|
|
|
|
func GetReportRecentList(startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
|
|
|
- a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
|
|
|
- b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size,
|
|
|
- CASE WHEN DATE(a.publish_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
|
|
|
- FROM report AS a
|
|
|
- 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 (
|
|
|
- SELECT DISTINCT classify_id
|
|
|
- FROM chart_permission_search_key_word_mapping
|
|
|
- )
|
|
|
- ORDER BY a.publish_time DESC LIMIT ?,? `
|
|
|
+ sql := ` SELECT * FROM report WHERE (state=2 OR state=6) ORDER BY publish_time DESC LIMIT ?,? `
|
|
|
_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetReportCountByClassifyIds(classifyIds []string, 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) AND (1=2 `
|
|
|
+
|
|
|
+ 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)))
|
|
|
+ }
|
|
|
+ sql += ` ) `
|
|
|
+ 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 {
|
|
|
+ return
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT COUNT(*) AS count FROM report AS a
|
|
|
WHERE (a.state=2 OR a.state=6) AND a.classify_id_second IN (%s) `
|
|
|
- var reportIdsStr string
|
|
|
- if len(classifyIds) > 0 {
|
|
|
- reportIdsStr = strings.Join(classifyIds, ",")
|
|
|
- sql = fmt.Sprintf(sql, reportIdsStr)
|
|
|
- }
|
|
|
+ sql = fmt.Sprintf(sql, utils.GetOrmReplaceHolder(len(classifyIds)))
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- err = o.Raw(sql).QueryRow(&count)
|
|
|
+ err = o.Raw(sql, classifyIds).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetReportListByClassifyIds(classifyIds []string, condition string, startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
+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
|
|
|
+ }
|
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
|
|
|
a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
|
|
@@ -115,49 +136,76 @@ func GetReportListByClassifyIds(classifyIds []string, condition string, startSiz
|
|
|
CASE WHEN DATE(a.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
|
|
|
FROM report AS a
|
|
|
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) `
|
|
|
-
|
|
|
- var reportIdsStr string
|
|
|
- if len(classifyIds) > 0 {
|
|
|
- reportIdsStr = strings.Join(classifyIds, ",")
|
|
|
- sql = fmt.Sprintf(sql, reportIdsStr)
|
|
|
+ WHERE (a.state=2 OR a.state=6) AND (1=2 `
|
|
|
+ // 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)))
|
|
|
}
|
|
|
+ sql += `) `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += ` ORDER BY a.publish_time DESC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
|
|
|
+ _, err = o.Raw(sql, classifyFirstIds, classifySecondIds, classifyThirdIds, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
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:"内容"`
|
|
|
- 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:"是否是公共报告 "`
|
|
|
+ Id int `description:"报告Id"`
|
|
|
+ AddType int `description:"新增方式:1:新增报告,2:继承报告"`
|
|
|
+ ClassifyIdFirst int `description:"一级分类id"`
|
|
|
+ ClassifyNameFirst string `description:"一级分类名称"`
|
|
|
+ ClassifyIdSecond int `description:"二级分类id"`
|
|
|
+ ClassifyNameSecond string `description:"二级分类名称"`
|
|
|
+ ClassifyIdThird int `description:"三级分类id"`
|
|
|
+ ClassifyNameThird 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 {
|
|
|
+ Title string `description:"章节标题"`
|
|
|
+ Content string `description:"章节内容"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetReportChapterList(reportId int) (items []*ReportChapter, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ sql := `SELECT * FROM report_chapter WHERE report_id=?`
|
|
|
+ _, err = o.Raw(sql, reportId).QueryRows(&items)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func GetReportById(reportId int) (item *ReportDetail, err error) {
|
|
@@ -181,4 +229,20 @@ type ReportCollectListItem struct {
|
|
|
Abstract string `description:"摘要"`
|
|
|
Stage string `description:"期数"`
|
|
|
Author string `description:"作者"`
|
|
|
+ PdfUrl string `description:"pdf文件url"`
|
|
|
+ ReportType int `description:"报告类型:1:eta报告,2:小程序pdf报告"`
|
|
|
+}
|
|
|
+
|
|
|
+type SmartReportResource struct {
|
|
|
+ ResourceId int `description:"资源库id"`
|
|
|
+ ImgUrl string `description:"图片url"`
|
|
|
+ Type int `description:"资源类型:1-版头 2-版尾"`
|
|
|
+ Style string `description:"版图样式"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetSmartReportResourceById(resourceId int) (item *SmartReportResource, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ sql := `SELECT * FROM smart_report_resource WHERE resource_id=?`
|
|
|
+ err = o.Raw(sql, resourceId).QueryRow(&item)
|
|
|
+ return
|
|
|
}
|