|
@@ -318,6 +318,8 @@ type ArticleCollectionResp struct {
|
|
|
NickName string `description:"作者昵称"`
|
|
|
Pv int `description:"PV"`
|
|
|
CollectNum int `description:"收藏人数"`
|
|
|
+ MyCollectNum int `description:"本人是否收藏"`
|
|
|
+ IsCollect bool `description:"本人是否收藏"`
|
|
|
}
|
|
|
|
|
|
type ArticleCollectionLIstResp struct {
|
|
@@ -325,7 +327,7 @@ type ArticleCollectionLIstResp struct {
|
|
|
}
|
|
|
|
|
|
//列表
|
|
|
-func GetArticleCollectionList(permissionName string) (items []*ArticleCollectionResp, err error) {
|
|
|
+func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
|
a.article_id,
|
|
@@ -336,24 +338,19 @@ func GetArticleCollectionList(permissionName string) (items []*ArticleCollection
|
|
|
d.nick_name,
|
|
|
d.department_id,
|
|
|
( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
|
|
|
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
|
|
|
FROM
|
|
|
cygx_article AS a
|
|
|
INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
|
|
|
INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
|
|
|
INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
|
|
|
WHERE
|
|
|
- 1 = 1
|
|
|
- AND a.is_report = 1
|
|
|
- AND a.category_name LIKE '%` + permissionName + `%'
|
|
|
- AND publish_status = 1
|
|
|
- GROUP BY
|
|
|
- m.industrial_management_id
|
|
|
- ORDER BY
|
|
|
- collect_num DESC,
|
|
|
- publish_date DESC
|
|
|
- LIMIT 15`
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ 1 = 1 `
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql, userId).QueryRows(&items)
|
|
|
return
|
|
|
} //end
|
|
|
|
|
@@ -390,8 +387,7 @@ func GetThemeHeatList(permissionName string, userId int, condition string) (item
|
|
|
LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
|
|
|
LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
|
|
|
WHERE
|
|
|
- 1 = 1
|
|
|
- AND a.is_report = 1
|
|
|
+ 1 = 1
|
|
|
AND a.category_name LIKE '%` + permissionName + `%'
|
|
|
AND publish_status = 1
|
|
|
GROUP BY m.industrial_management_id ` + condition
|
|
@@ -400,7 +396,7 @@ func GetThemeHeatList(permissionName string, userId int, condition string) (item
|
|
|
}
|
|
|
|
|
|
//标的列表
|
|
|
-func GetThemeHeatSubjectList(permissionName string) (items []*IndustrialSubject, err error) {
|
|
|
+func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
|
m.subject_name,
|
|
@@ -411,10 +407,11 @@ func GetThemeHeatSubjectList(permissionName string) (items []*IndustrialSubject,
|
|
|
INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
|
|
|
INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
|
|
|
WHERE
|
|
|
- 1 = 1
|
|
|
- AND a.is_report = 1
|
|
|
- AND a.category_name LIKE '%` + permissionName + `%'
|
|
|
- AND publish_status = 1
|
|
|
+ 1 = 1`
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ sql += ` AND publish_status = 1
|
|
|
GROUP BY
|
|
|
m.industrial_subject_id
|
|
|
ORDER BY
|
|
@@ -455,8 +452,7 @@ func GetDepartmentList(permissionName string, userId int) (items []*DepartmentRe
|
|
|
cygx_article_department AS d
|
|
|
INNER JOIN cygx_article AS a ON d.department_id = a.department_id
|
|
|
WHERE
|
|
|
- 1 = 1
|
|
|
- AND a.is_report = 1
|
|
|
+ 1 = 1
|
|
|
AND a.category_name LIKE '%` + permissionName + `%'
|
|
|
AND publish_status = 1
|
|
|
GROUP BY
|
|
@@ -481,8 +477,7 @@ func GetIndustrialDepartmentList(permissionName string) (items []*IndustrialDepa
|
|
|
INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
|
|
|
INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
|
|
|
WHERE
|
|
|
- 1 = 1
|
|
|
- AND a.is_report = 1
|
|
|
+ 1 = 1
|
|
|
AND a.category_name LIKE '%` + permissionName + `%'
|
|
|
AND publish_status = 1
|
|
|
GROUP BY
|
|
@@ -495,6 +490,23 @@ func GetIndustrialDepartmentList(permissionName string) (items []*IndustrialDepa
|
|
|
|
|
|
//主题详情start
|
|
|
type GetThemeDetailListResp struct {
|
|
|
+ ArticleId int `description:"文章id"`
|
|
|
+ Title string `description:"标题"`
|
|
|
+ PublishDate string `description:"发布时间"`
|
|
|
+ SubjectName string `description:"标的名称"`
|
|
|
+ IndustrialSubjectId int `description:"标的id"`
|
|
|
+ DepartmentId int `description:"作者Id"`
|
|
|
+ NickName string `description:"作者昵称"`
|
|
|
+ Pv int `description:"PV"`
|
|
|
+ CollectNum int `description:"收藏人数"`
|
|
|
+ IndustrialManagementId int `description:"产业Id"`
|
|
|
+ IndustryName string `description:"产业名称"`
|
|
|
+ FllowNum int `description:"关注数量"`
|
|
|
+ MyCollectNum int `description:"本人是否收藏"`
|
|
|
+ IsCollect bool `description:"本人是否收藏"`
|
|
|
+}
|
|
|
+
|
|
|
+type GetThemeAericleListResp struct {
|
|
|
ArticleId int `description:"文章id"`
|
|
|
Title string `description:"标题"`
|
|
|
PublishDate string `description:"发布时间"`
|
|
@@ -503,19 +515,27 @@ type GetThemeDetailListResp struct {
|
|
|
NickName string `description:"作者昵称"`
|
|
|
Pv int `description:"PV"`
|
|
|
CollectNum int `description:"收藏人数"`
|
|
|
+ FllowNum int `description:"关注数量"`
|
|
|
+ MyCollectNum int `description:"本人是否收藏"`
|
|
|
+ IsCollect bool `description:"本人是否收藏"`
|
|
|
+}
|
|
|
+
|
|
|
+type GetThemeAericleListBuSubjectResp struct {
|
|
|
+ SubjectName string `description:"标的名称"`
|
|
|
+ List []*GetThemeAericleListResp
|
|
|
}
|
|
|
|
|
|
//主题详情start
|
|
|
type GetThemeDetailResp struct {
|
|
|
- IndustrialManagementId int `description:"产业Id"`
|
|
|
- IndustryName string `description:"产业名称"`
|
|
|
- IsFollw bool `description:"是否关注"`
|
|
|
- List []*GetThemeDetailListResp
|
|
|
+ IndustrialManagementId int `description:"产业Id"`
|
|
|
+ IndustryName string `description:"产业名称"`
|
|
|
+ IsFollw bool `description:"是否关注"`
|
|
|
ListSubject []*IndustrialSubject `description:"标的列表"`
|
|
|
+ List []*GetThemeAericleListBuSubjectResp
|
|
|
}
|
|
|
|
|
|
//列表
|
|
|
-func GetThemeDetail(permissionName string) (items []*GetThemeDetailListResp, err error) {
|
|
|
+func GetThemeDetail(userId, industrialManagementId int) (items []*GetThemeDetailListResp, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
|
a.article_id,
|
|
@@ -528,26 +548,120 @@ func GetThemeDetail(permissionName string) (items []*GetThemeDetailListResp, err
|
|
|
s.industrial_subject_id,
|
|
|
s.subject_name,
|
|
|
( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
|
|
|
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_industry_fllow AS ac WHERE user_id = ? AND ac.industrial_management_id = m.industrial_management_id ) AS fllow_num
|
|
|
FROM
|
|
|
cygx_article AS a
|
|
|
INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
|
|
|
INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
|
|
|
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
|
|
|
- LEFT JOIN cygx_industrial_article_group_subject as sg ON sg.article_id = a.article_id
|
|
|
- LEFT JOIN cygx_industrial_subject as s ON s.industrial_subject_id = sg.industrial_subject_id
|
|
|
+ INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
|
|
|
+ LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
|
|
|
+ LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
|
|
|
WHERE
|
|
|
- 1 = 1
|
|
|
- AND a.is_report = 1
|
|
|
+ 1 = 1
|
|
|
AND a.category_name LIKE '%研选%'
|
|
|
--- AND m.industrial_management_id = 337
|
|
|
+ AND m.industrial_management_id = ?
|
|
|
AND publish_status = 1
|
|
|
- GROUP BY
|
|
|
- a.article_id
|
|
|
ORDER BY
|
|
|
- publish_date DESC ,
|
|
|
- s.industrial_subject_id DESC
|
|
|
--- LIMIT 15`
|
|
|
+ publish_date DESC`
|
|
|
+ _, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
|
|
|
+ return
|
|
|
+} //end
|
|
|
+
|
|
|
+//用户收藏榜start
|
|
|
+type DepartmentDetailResp struct {
|
|
|
+ DepartmentId int `description:"作者Id"`
|
|
|
+ NickName string `description:"作者昵称"`
|
|
|
+ ImgUrl string `description:"图片链接"`
|
|
|
+ FllowNum int `description:"多少人关注"`
|
|
|
+ ArticleNum int `description:"文章数量"`
|
|
|
+ CollectNum int `description:"收藏人数"`
|
|
|
+ IsFllow bool `description:"是否关注"`
|
|
|
+ List []*ArticleCollectionResp
|
|
|
+}
|
|
|
+
|
|
|
+type DepartmentDetail struct {
|
|
|
+ DepartmentId int `description:"作者Id"`
|
|
|
+ NickName string `description:"作者昵称"`
|
|
|
+ ImgUrl string `description:"图片链接"`
|
|
|
+ FllowNum int `description:"多少人关注"`
|
|
|
+ ArticleNum int `description:"文章数量"`
|
|
|
+ CollectNum int `description:"收藏人数"`
|
|
|
+ IsFllow bool `description:"是否关注"`
|
|
|
+ MyFllowNum int `description:"本人是否关注"`
|
|
|
+}
|
|
|
+
|
|
|
+//列表
|
|
|
+func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ d.department_id,
|
|
|
+ d.nick_name,
|
|
|
+ d.img_url,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.user_id = ? AND af.department_id = d.department_id ) AS my_fllow_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id ) AS fllow_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ) AS article_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS c WHERE c.article_id IN (SELECT article_id FROM cygx_article AS a WHERE a.department_id = d.department_id )) AS collect_num
|
|
|
+ FROM
|
|
|
+ cygx_article_department AS d
|
|
|
+ WHERE
|
|
|
+ d.department_id = ?`
|
|
|
+ err = o.Raw(sql, userId, departmentId).QueryRow(&item)
|
|
|
+ return
|
|
|
+} //end
|
|
|
+
|
|
|
+//报告搜索start
|
|
|
+type ReoprtSearchResp struct {
|
|
|
+ ListYx []*ArticleCollectionResp `description:"研选报告"`
|
|
|
+ ListHz []*ArticleCollectionResp `description:"弘则报告"`
|
|
|
+}
|
|
|
+
|
|
|
+//列表
|
|
|
+func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ a.article_id,
|
|
|
+ a.title,
|
|
|
+ date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
|
|
|
+ m.industry_name,
|
|
|
+ m.industrial_management_id,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
|
|
|
+ FROM
|
|
|
+ cygx_article AS a
|
|
|
+ INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
|
|
|
+ INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
|
|
|
+ WHERE
|
|
|
+ 1 = 1 `
|
|
|
+ if condition != "" {
|
|
|
+ sql += condition
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql, userId).QueryRows(&items)
|
|
|
+ return
|
|
|
+} //end
|
|
|
+
|
|
|
+//搜索资源包 start
|
|
|
+type SearchResourceResp struct {
|
|
|
+ ListHz []*IndustrialManagementHotResp `description:"弘则"`
|
|
|
+ ListYx []*IndustrialManagementHotResp `description:"研选"`
|
|
|
+}
|
|
|
+
|
|
|
+//产业列表
|
|
|
+func GetSearchResourceList(condition string) (items []*IndustrialManagementHotResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ m.industry_name,
|
|
|
+ m.industrial_management_id,
|
|
|
+ date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
|
|
|
+ FROM
|
|
|
+ cygx_industrial_management AS m
|
|
|
+ INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
|
|
|
+ INNER JOIN cygx_article AS a ON a.article_id = mg.article_id
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND publish_status = 1 ` + condition
|
|
|
_, err = o.Raw(sql).QueryRows(&items)
|
|
|
return
|
|
|
}
|