Browse Source

详情模块修改以及权限校验

xingzai 3 years ago
parent
commit
d63eb7ae13
7 changed files with 120 additions and 16 deletions
  1. 57 3
      controllers/report.go
  2. 2 0
      models/article.go
  3. 9 5
      models/minutesSummary.go
  4. 1 0
      models/report.go
  5. 6 3
      models/report_selection.go
  6. 10 5
      models/researchSummary.go
  7. 35 0
      services/user.go

+ 57 - 3
controllers/report.go

@@ -435,6 +435,9 @@ func (this *ReportController) List() {
 		if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
 			list[k].IsRed = true
 		}
+		if v.VideoUrl != "" {
+			list[k].IsHaveVideo = true
+		}
 	}
 	resp.List = list
 	resp.Paging = page
@@ -1248,6 +1251,20 @@ func (this *ReportController) Detail() {
 		return
 	}
 	resp := new(models.ReportSelectionLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
 	detail, err := models.GetCygxReportSelectionInfoById(articleId)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -1269,6 +1286,7 @@ func (this *ReportController) Detail() {
 		item := new(models.ReportSelectionChartPermission)
 		if existMap[v.ChartPermissionId] == 0 {
 			item.PermissionName = v.PermissionName + "领域深度调研和报告"
+			item.IcoLink = v.IcoLink
 			listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
 			if err != nil && err.Error() != utils.ErrNoRow() {
 				br.Msg = "获取信息失败"
@@ -1335,6 +1353,20 @@ func (this *ReportController) ResearchDetail() {
 		return
 	}
 	resp := new(models.ResearchSummaryLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
 	detail, err := models.GetCygxResearchSummaryInfoById(articleId)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -1362,9 +1394,13 @@ func (this *ReportController) ResearchDetail() {
 				br.ErrMsg = "获取信息失败,Err:" + err.Error()
 				return
 			}
-			fmt.Println(listThird)
 			if len(listThird) > 0 {
 				listSecond[k2].List = listThird
+				for k3, v3 := range listThird {
+					if v3.VideoUrl != "" {
+						listThird[k3].IsHaveVideo = true
+					}
+				}
 			}
 		}
 		if len(listSecond) > 0 {
@@ -1373,12 +1409,16 @@ func (this *ReportController) ResearchDetail() {
 		//`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
 		if v.Type == "SDBG" {
 			listFirst[k].ListName = "深度报告"
+			listFirst[k].IcoLink = ""
 		} else if v.Type == "BZCHJH" {
 			listFirst[k].ListName = "本周晨会精华"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
 		} else if v.Type == "CYDYJY" {
 			listFirst[k].ListName = "产业调研纪要"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
 		} else {
 			listFirst[k].ListName = "事件点评"
+			listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
 		}
 
 	}
@@ -1425,6 +1465,20 @@ func (this *ReportController) MinutesDetail() {
 		return
 	}
 	resp := new(models.MinutesSummaryLetailResp)
+	//判断用户权限
+	hasPermission, err := services.GetUserhasPermission(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
+	}
+	resp.HasPermission = hasPermission
+	if hasPermission != 1 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
 	detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -1467,8 +1521,8 @@ func (this *ReportController) MinutesDetail() {
 	br.Data = resp
 }
 
-// @Title 获取报告详情
-// @Description 获取报告详情接口
+// @Title 获取路演精华详情
+// @Description 获取路演精华详情接口
 // @Param   ArticleId   query   int  true       "报告ID"
 // @Success 200 {object} models.RoadshowDetailResp
 // @router /roadshowEssence/detail [get]

+ 2 - 0
models/article.go

@@ -336,6 +336,8 @@ type ReportArticle struct {
 	ExpertBackground string `description:"专家背景"`
 	IsRed            bool   `description:"是否标记红点"`
 	Readnum          int    `description:"阅读数量"`
+	VideoUrl         string `description:"链接"`
+	IsHaveVideo      bool   `description:"是否含有音频文件"`
 }
 
 func GetReportPermission(categoryName string) (item []*ChartPermission, err error) {

+ 9 - 5
models/minutesSummary.go

@@ -16,8 +16,9 @@ type DetailCygxMinutesSummaryRep struct {
 }
 
 type MinutesSummaryLetailResp struct {
-	Detail *DetailCygxMinutesSummaryRep
-	List   []*MinutesSummaryChartPermission
+	Detail        *DetailCygxMinutesSummaryRep
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List          []*MinutesSummaryChartPermission
 }
 
 type MinutesSummaryChartPermission struct {
@@ -28,8 +29,10 @@ type MinutesSummaryChartPermission struct {
 }
 
 type CygxMinutesSummaryLogDetail struct {
-	Body       string `description:"内容"`
-	ReportLink string `description:"报告链接"`
+	Body        string `description:"内容"`
+	ReportLink  string `orm:"column(link_article_id)"description:"报告链接"`
+	VideoUrl    string `description:"链接"`
+	IsHaveVideo bool   `description:"是否含有音频文件"`
 }
 type IndustriaMinutesSummary struct {
 	IndustrialManagementId int    `description:"产业Id"`
@@ -65,9 +68,10 @@ func GetMinutesSummarylogListAll(articleId int) (items []*MinutesSummaryChartPer
 //列表
 func GetMinutesSummarylogSonListAll(articleId, chartPermissionId int) (items []*CygxMinutesSummaryLogDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT  l.* 
+	sql := `SELECT   l.link_article_id,l.body ,a.video_url 
 			FROM
 			cygx_minutes_summary_log AS l
+			LEFT JOIN cygx_article as a ON a.article_id = l.link_article_id
 			WHERE l.article_id = ? AND l.chart_permission_id =?`
 	_, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
 	return

+ 1 - 0
models/report.go

@@ -237,6 +237,7 @@ type ReportDetailRoadshow struct {
 	Abstract         string `description:"摘要"`
 	Body             string `description:"内容"`
 	CategoryName     string `description:"行业名称"`
+	ReportLink       string `description:"报告链接"`
 }
 
 type RoadshowDetailResp struct {

+ 6 - 3
models/report_selection.go

@@ -39,12 +39,14 @@ type DetailCygxReportSelectionRep struct {
 }
 
 type ReportSelectionLetailResp struct {
-	Detail *DetailCygxReportSelectionRep
-	List   []*ReportSelectionChartPermission
+	Detail        *DetailCygxReportSelectionRep
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List          []*ReportSelectionChartPermission
 }
 
 type ReportSelectionChartPermission struct {
 	PermissionName string `description:"权限名称"`
+	IcoLink        string `orm:"column(image_url)"description:"图标链接"`
 	List           []*CygxReportSelectionLogDetail
 }
 
@@ -104,12 +106,13 @@ type CygxReportSelectionLog struct {
 	IndustrialSubjectId    string    `description:"标的ID"`
 	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
 	SubjectName            string    `description:"标的名称"`
+	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
 }
 
 //列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name ,s.subject_name , l.* 
+	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.* 
 			FROM
 			cygx_report_selection_log AS l
 			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 

+ 10 - 5
models/researchSummary.go

@@ -17,12 +17,14 @@ type DetailCygxResearchSummaryRep struct {
 }
 
 type ResearchSummaryLetailResp struct {
-	Detail *DetailCygxResearchSummaryRep
-	List   []*ResearchSummaryChartPermission
+	Detail        *DetailCygxResearchSummaryRep
+	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List          []*ResearchSummaryChartPermission
 }
 
 type ResearchSummaryChartPermission struct {
 	ListName string `description:"列表名称"`
+	IcoLink  string `orm:"column(image_url)"description:"图标链接"`
 	Type     string `description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
 	List     []*CygxResearchSummaryLogSecond
 }
@@ -35,8 +37,10 @@ type CygxResearchSummaryLogSecond struct {
 }
 
 type CygxResearchSummaryLogThird struct {
-	Body       string `description:"内容"`
-	ReportLink string `description:"报告链接"`
+	Body        string `description:"内容"`
+	ReportLink  string `orm:"column(link_article_id)"description:"报告链接"`
+	VideoUrl    string `description:"链接"`
+	IsHaveVideo bool   `description:"是否含有音频文件"`
 }
 type IndustriaResearchSummary struct {
 	IndustrialManagementId int    `description:"产业Id"`
@@ -97,8 +101,9 @@ func GetResearchSummarylogSonListSecond(articleId int, artType string) (items []
 //列表
 func GetResearchSummarylogSonListThird(articleId, chartPermissionId int, artType string) (items []*CygxResearchSummaryLogThird, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT  l.* 
+	sql := `SELECT  l.link_article_id,l.body ,a.video_url
 			FROM cygx_research_summary_log AS l
+			LEFT JOIN cygx_article as a ON a.article_id = l.link_article_id
 			WHERE l.article_id = ? AND l.type =? AND  l.chart_permission_id = ? 
 			ORDER  BY l.chart_permission_sort ASC `
 	_, err = o.Raw(sql, articleId, artType, chartPermissionId).QueryRows(&items)

+ 35 - 0
services/user.go

@@ -10,6 +10,7 @@ import (
 	"os"
 	"path/filepath"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -928,3 +929,37 @@ func SendEmailUserWhiteListChange(cont context.Context) (err error) {
 	fmt.Println("发送附件完成", len(listFrozen))
 	return
 }
+
+//获取用户权限
+func GetUserhasPermission(user *models.WxUserItem) (hasPermission int, err error) {
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(user.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if applyCount > 0 {
+		hasPermission = 3
+	} else {
+		hasPermission = 4
+	}
+	//HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, errPer := models.GetCompanyPermission(user.CompanyId)
+		if errPer != nil {
+			err = errPer
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 3
+			} else {
+				hasPermission = 4
+			}
+		} else {
+			if strings.Contains(companyPermission, "医药") || strings.Contains(companyPermission, "科技") || strings.Contains(companyPermission, "消费") || strings.Contains(companyPermission, "智造") {
+				hasPermission = 1
+			}
+		}
+	}
+	return
+}