|
@@ -20,6 +20,12 @@ type DepartmentResp struct {
|
|
|
NickName string `description:"昵称"`
|
|
|
ImgUrl string `description:"头像链接"`
|
|
|
IsFollow bool `description:"是否关注"`
|
|
|
+ FllowNum int `description:"关注数量"`
|
|
|
+ List []*IndustrialDepartmentListResp
|
|
|
+}
|
|
|
+
|
|
|
+type DepartmentListResp struct {
|
|
|
+ List []*DepartmentResp
|
|
|
}
|
|
|
|
|
|
type CygxArticleDepartmentId struct {
|
|
@@ -33,7 +39,7 @@ func GetArticleDepartmentDateilById(departmentId int) (item *DepartmentResp, err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//数量
|
|
|
+// 数量
|
|
|
func GetArticleDepartmentCount(condition string) (count int, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := ` SELECT COUNT(*) count
|
|
@@ -54,3 +60,28 @@ func GetArticleDepartmentCount(condition string) (count int, err error) {
|
|
|
type IndustrialSubjectList struct {
|
|
|
SubjectName string `description:"标的名称"`
|
|
|
}
|
|
|
+
|
|
|
+// 作者列表
|
|
|
+func GetDepartmentList(userId int) (items []*DepartmentResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT
|
|
|
+ d.nick_name,
|
|
|
+ d.department_id,
|
|
|
+ d.img_url,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND user_id =? AND f.type= 1 ) AS fllow_num,
|
|
|
+ ( SELECT count( 1 ) FROM cygx_article_department_follow AS f INNER JOIN wx_user AS u ON u.user_id = f.user_id WHERE f.department_id = d.department_id AND f.type= 1 ) +( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user AS u ON u.user_id = ac.user_id WHERE ac.article_id IN (SELECT article_id FROM cygx_article WHERE department_id = d.department_id ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS sum_num
|
|
|
+ FROM
|
|
|
+ cygx_article_department AS d
|
|
|
+ INNER JOIN cygx_article AS a ON d.department_id = a.department_id
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND a.article_type_id > 0
|
|
|
+ AND publish_status = 1
|
|
|
+ GROUP BY
|
|
|
+ d.department_id
|
|
|
+ ORDER BY
|
|
|
+ sum_num DESC
|
|
|
+ LIMIT 15`
|
|
|
+ _, err = o.Raw(sql, userId).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|