Browse Source

报告列表小红点标记处理

xingzai 3 years ago
parent
commit
c58da98704
4 changed files with 23 additions and 7 deletions
  1. 5 0
      controllers/article.go
  2. 11 2
      controllers/report.go
  3. 4 3
      models/article.go
  4. 3 2
      models/report_selection.go

+ 5 - 0
controllers/article.go

@@ -275,6 +275,11 @@ Loop:
 	resp.HaveResearch = haveResearch
 	resp.HasFree = hasFree
 	resp.Detail = detail
+	if user.Mobile != "" {
+		resp.Mobile = user.Mobile
+	} else {
+		resp.Mobile = user.Email
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 11 - 2
controllers/report.go

@@ -1167,7 +1167,7 @@ func (this *ReportController) ReportListByType() {
 		br.Ret = 408
 		return
 	}
-	//uid := user.UserId
+	uid := user.UserId
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	reportType := this.GetString("ReportType")
@@ -1185,12 +1185,17 @@ func (this *ReportController) ReportListByType() {
 	resp := new(models.CygxReportSelectionListPublicRep)
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	var tbdb string
+	var readSql string
+	var reportTypeStr string
 	if reportType == "1" {
 		tbdb = "cygx_report_selection"
+		reportTypeStr = "bgjx"
 	} else if reportType == "2" {
 		tbdb = "cygx_research_summary"
+		reportTypeStr = "bzyjhz"
 	} else if reportType == "3" {
 		tbdb = "cygx_minutes_summary"
+		reportTypeStr = "szjyhz"
 	} else {
 		br.Msg = "请选择报告类型"
 		return
@@ -1203,8 +1208,9 @@ func (this *ReportController) ReportListByType() {
 		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
 		return
 	}
+	readSql = ` (SELECT COUNT(1) AS  count  FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND  report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
 	page = paging.GetPaging(currentIndex, pageSize, total)
-	list, err := models.GetReportSelectionListPublic(condition, tbdb, pars, startSize, pageSize)
+	list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -1216,6 +1222,9 @@ func (this *ReportController) ReportListByType() {
 			list[k].Abstract = v.UpdateDescription
 		}
 		list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
+		if v.ReadNum == 0 {
+			list[k].IsRed = true
+		}
 	}
 
 	resp.List = list

+ 4 - 3
models/article.go

@@ -192,9 +192,10 @@ func GetArticlePermission(companyId int) (item *ChartPermission, err error) {
 
 type ArticleDetailResp struct {
 	Detail        *ArticleDetail
-	HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
-	HasFree       int  `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
-	HaveResearch  bool `description:"是否有研选权限"`
+	HasPermission int    `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	HasFree       int    `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
+	HaveResearch  bool   `description:"是否有研选权限"`
+	Mobile        string `description:"用户手机号"`
 }
 
 func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {

+ 3 - 2
models/report_selection.go

@@ -15,6 +15,7 @@ type CygxReportSelectionRep struct {
 	Abstract          string `description:"摘要/更新说明"`
 	UpdateDescription string `description:"更新说明"`
 	IsRed             bool   `description:"是否标记红点"`
+	ReadNum           int    `description:"阅读次数"`
 }
 
 type CygxReportSelectionListPublicRep struct {
@@ -85,9 +86,9 @@ func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelect
 }
 
 //列表
-func GetReportSelectionListPublic(condition, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM  ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1  `
+	sql := `SELECT * ,` + readSql + ` FROM  ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1  `
 	if condition != "" {
 		sql += condition
 	}