Browse Source

研选用户收藏榜

xingzai 3 years ago
parent
commit
b58bc407c0

+ 0 - 44
controllers/chart_permission.go

@@ -198,47 +198,3 @@ func (this *ChartPermissionAuthController) StrategyDetail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
-
-//func init() {
-//
-//	list, err := models.GetCompanyReportPermissionAll()
-//	if err != nil {
-//		fmt.Println("获取品种信息失败,Err:" + err.Error())
-//		return
-//	}
-//	fmt.Println("len", len(list))
-//
-//	for _, v := range list {
-//		var newChartPermissionId int
-//		item := new(models.CompanyReportPermission)
-//		item.CompanyId = v.CompanyId
-//		item.ReportPermissionId = v.ReportPermissionId
-//		item.CreatedTime = time.Now()
-//		item.LastUpdatedTime = time.Now()
-//
-//		if v.ChartPermissionId == 19 {
-//			newChartPermissionId = 34
-//		} else if v.ChartPermissionId == 20 {
-//			newChartPermissionId = 35
-//		} else if v.ChartPermissionId == 21 {
-//			newChartPermissionId = 36
-//		} else if v.ChartPermissionId == 22 {
-//			newChartPermissionId = 37
-//		}
-//		item.ChartPermissionId = newChartPermissionId
-//		item.StartDate = v.StartDate
-//		item.EndDate = v.EndDate
-//		item.ProductId = v.ProductId
-//		item.ProductName = v.ProductName
-//		item.ModifyTime = v.ModifyTime
-//		item.CompanyContractId = v.CompanyContractId
-//		item.Status = v.Status
-//
-//		newId, err := models.AddChartPersion(item)
-//		if err != nil {
-//			fmt.Println("新增品种信息失败,Err:" + err.Error())
-//			//return
-//		}
-//		fmt.Println("新增", newId)
-//	}
-//}

+ 147 - 0
controllers/research.go

@@ -0,0 +1,147 @@
+package controllers
+
+import (
+	"hongze/hongze_cygx/models"
+)
+
+//研选
+type ResearchController struct {
+	BaseAuthController
+}
+
+// @Title 近期更新主题列表
+// @Description 近期更新主题列表接口
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Success 200 {object} models.IndustrialManagementNewList
+// @router /theme/newList [get]
+func (this *ResearchController) NewList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	if chartPermissionId < 1 {
+		br.Msg = "请输入分类ID"
+		return
+	}
+	categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetIndustrialManagementNewList(categoryinfo.PermissionName)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	detailHot3, err := models.GetIndustrialManagementHot3(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range list {
+		if v.ArticleReadNum >= detailHot3.ArticleReadNum {
+			list[k].IsHot = true
+		}
+	}
+	resp := new(models.IndustrialManagementNewList)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 用户收藏列表
+// @Description 用户收藏列表接口
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Success 200 {object} models.ArticleCollectionLIstResp
+// @router /collectionList [get]
+func (this *ResearchController) CollectionList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	if chartPermissionId < 1 {
+		br.Msg = "请输入分类ID"
+		return
+	}
+	categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetArticleCollectionList(categoryinfo.PermissionName)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ArticleCollectionLIstResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 主题热度列表
+// @Description 主题热度列表接口
+// @Param   ChartPermissionId   query   int  true       "分类ID"
+// @Success 200 {object} models.ArticleCollectionLIstResp
+// @router /hotList [get]
+func (this *ResearchController) HotList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	if chartPermissionId < 1 {
+		br.Msg = "请输入分类ID"
+		return
+	}
+	categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetArticleCollectionList(categoryinfo.PermissionName)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ArticleCollectionLIstResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 36 - 0
models/industrial_management.go

@@ -343,3 +343,39 @@ ORDER BY
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return
 }
+
+type IndustrialManagementNewResp struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	IsHot                  bool   `description:"是否是热门"`
+	ArticleReadNum         int    `description:"文章阅读数量"`
+}
+
+type IndustrialManagementNewList struct {
+	List []*IndustrialManagementNewResp
+}
+
+//近期更新主题列表
+func GetIndustrialManagementNewList(permissionName string) (items []*IndustrialManagementNewResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.industrial_management_id,
+			m.industry_name,
+			m.article_read_num,
+			MAX( a.publish_date ) AS publish_date 
+		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 
+			AND a.is_report = 1 
+			AND a.category_name LIKE '%` + permissionName + `%' 
+			AND publish_status = 1 
+		GROUP BY
+			m.industrial_management_id 
+		ORDER BY
+			publish_date DESC LIMIT 8`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 52 - 0
models/report.go

@@ -306,3 +306,55 @@ func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
 	err = o.Raw(sql).QueryRow(&articleIds)
 	return
 }
+
+//end
+
+//用户收藏榜start
+type ArticleCollectionResp struct {
+	ArticleId              int    `description:"文章id"`
+	Title                  string `description:"标题"`
+	PublishDate            string `description:"发布时间"`
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	DepartmentId           int    `description:"作者Id"`
+	NickName               string `description:"作者昵称"`
+	Pv                     int    `description:"PV"`
+	CollectNum             int    `description:"收藏人数"`
+}
+
+type ArticleCollectionLIstResp struct {
+	List []*ArticleCollectionResp
+}
+
+//列表
+func GetArticleCollectionList(permissionName string) (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,
+			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 
+		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)
+	return
+} //end

+ 27 - 0
routers/commentsRouter_controllers.go

@@ -475,6 +475,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
+        beego.ControllerComments{
+            Method: "CollectionList",
+            Router: "/collectionList",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
+        beego.ControllerComments{
+            Method: "HotList",
+            Router: "/hotList",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
+        beego.ControllerComments{
+            Method: "NewList",
+            Router: "/theme/newList",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResourceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResourceController"],
         beego.ControllerComments{
             Method: "Upload",

+ 5 - 0
routers/router.go

@@ -87,6 +87,11 @@ func init() {
 				&controllers.ActivityABaseController{},
 			),
 		),
+		web.NSNamespace("/research",
+			web.NSInclude(
+				&controllers.ResearchController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 1 - 1
services/task.go

@@ -62,7 +62,7 @@ func Task() {
 	//GetAddpArticle() //同步日度点评数据
 	//SendEmailAllUserWithRAI()     //发送当前所有权益用户到沈大爷的邮箱
 	//SendEmailAllUserWithCompany() //发送这些公司下的用户到沈大爷的邮箱
-	task.StartTask()
+	//task.StartTask()
 	//StatisticalReport()//导出报表
 	fmt.Println("end")
 }