xingzai 3 роки тому
батько
коміт
3de2738a91

+ 1 - 0
controllers/article.go

@@ -394,6 +394,7 @@ func (this *ArticleCommonController) Detail() {
 	}
 	if detail != nil {
 		detail.Body = html.UnescapeString(detail.Body)
+		detail.Abstract = html.UnescapeString(detail.Abstract)
 	}
 	resp.Detail = detail
 	br.Ret = 200

+ 21 - 5
controllers/chart_permission.go

@@ -7,6 +7,10 @@ type ChartPermissionController struct {
 	BaseCommonController
 }
 
+type ChartPermissionAuthController struct {
+	BaseAuthController
+}
+
 // @Title 获取所有品种
 // @Description 获取用户详情接口
 // @Success 200 {object} models.ChartPermissionResp
@@ -31,7 +35,6 @@ func (this *ChartPermissionController) Detail() {
 	br.Data = resp
 }
 
-
 // @Title 获取报告所有品种
 // @Description 获取报告所有品种接口
 // @Success 200 {object} models.ChartPermissionResp
@@ -60,22 +63,35 @@ func (this *ChartPermissionController) ReportDetail() {
 // @Description 获取策略下的所有分类接口
 // @Success 200 {object} models.ReportMappingResp
 // @router /strategyAll [get]
-func (this *ChartPermissionController) StrategyDetail() {
+func (this *ChartPermissionAuthController) StrategyDetail() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	list, err := models.GetReportMappingStrategyAll()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	list, err := models.GetReportMappingStrategyHomeAll(uid)
+
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	resp := new(models.ReportMappingResp)
+	for k, v := range list {
+		if v.Readnum == 0 {
+			list[k].IsRed = true
+		}
+	}
+	resp := new(models.ReportMappingHomeResp)
 	resp.List = list
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = resp
-}
+}

+ 1 - 3
controllers/tactics.go

@@ -99,9 +99,7 @@ func (this *TacticsController) List() {
 	}
 
 	for k, v := range list {
-		if v.Readnum > 0 {
-			list[k].IsRed = false
-		} else {
+		if v.Readnum == 0 {
 			list[k].IsRed = true
 		}
 	}

+ 30 - 0
models/report_mapping.go

@@ -8,6 +8,13 @@ type ReportMapping struct {
 	IsRed           bool   `description:"是否标红"`
 }
 
+type ReportMappingHome struct {
+	CategoryId      int    `description:"分类ID"`
+	SubCategoryName string `description:"权限名称"`
+	IsRed           bool   `description:"是否标红"`
+	Readnum         int    `description:"阅读数量"`
+}
+
 type TradeReportMapping struct {
 	CategoryId      int    `description:"分类ID"`
 	SubCategoryName string `description:"权限名称"`
@@ -20,6 +27,10 @@ type ReportMappingResp struct {
 	List []*ReportMapping
 }
 
+type ReportMappingHomeResp struct {
+	List []*ReportMappingHome
+}
+
 type TradeReportMappingResp struct {
 	List []*TradeReportMapping
 }
@@ -32,6 +43,25 @@ func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
 	return
 }
 
+//获取策略下面的所有分类
+func GetReportMappingStrategyHomeAll(uid int) (items []*ReportMappingHome, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	re.category_id,re.sub_category_name, ( SELECT COUNT( 1 ) FROM  cygx_article_history_record AS rec WHERE rec.user_id = ? AND rec.article_id = art.article_id ) AS readnum
+FROM
+	cygx_report_mapping AS re
+	INNER JOIN cygx_article AS art ON art.category_id = re.category_id 
+WHERE
+	re.report_type = 1 
+	AND re.chart_permission_id = 23 
+GROUP  BY
+	re.match_type_name
+ORDER BY
+	sort DESC , art.publish_date DESC`
+	_, err = o.Raw(sql, uid).QueryRows(&items)
+	return
+}
+
 //行业列表
 func GetTradeAll(uid, ChartPermissionId int) (items []*TradeReportMapping, err error) {
 	o := orm.NewOrm()

+ 1 - 0
routers/router.go

@@ -42,6 +42,7 @@ func init() {
 		beego.NSNamespace("/permission",
 			beego.NSInclude(
 				&controllers.ChartPermissionController{},
+				&controllers.ChartPermissionAuthController{},
 			),
 		),
 		beego.NSNamespace("/article",