Jelajahi Sumber

首页永续客户分享权限校验

xingzai 3 tahun lalu
induk
melakukan
0c222cb28f
4 mengubah file dengan 32 tambahan dan 19 penghapusan
  1. 3 13
      controllers/article.go
  2. 23 1
      controllers/home.go
  3. 3 3
      models/article.go
  4. 3 2
      models/home.go

+ 3 - 13
controllers/article.go

@@ -52,7 +52,7 @@ func (this *ArticleController) Detail() {
 	detail := new(models.ArticleDetail)
 	hasPermission := 0
 	hasFree := 0
-
+	var haveResearch bool
 	//判断是否已经申请过
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {
@@ -207,17 +207,6 @@ func (this *ArticleController) Detail() {
 			return
 		}
 		if detail.ArticleId >= utils.SummaryArticleId {
-			//var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
-			//match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
-			//if match != nil {
-			//	for _, v := range match {
-			//		sellerAndMobile := &models.SellerRep{
-			//			SellerMobile: v,
-			//			SellerName:   strings.Replace(detail.SellerAndMobile, v, "", -1),
-			//		}
-			//		sellerList = append(sellerList, sellerAndMobile)
-			//	}
-			//}
 			strnum := strings.Index(detail.SellerAndMobile, "-")
 			detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
 			if strnum > 0 {
@@ -259,10 +248,11 @@ Loop:
 		if detail.IsReport == 1 {
 			detail.IsBelongReport = true
 		}
-		detail.HaveResearch = true
+		haveResearch = true
 	}
 	resp := new(models.ArticleDetailResp)
 	resp.HasPermission = hasPermission
+	resp.HaveResearch = haveResearch
 	resp.HasFree = hasFree
 	resp.Detail = detail
 	br.Ret = 200

+ 23 - 1
controllers/home.go

@@ -9,7 +9,7 @@ import (
 )
 
 type HomeController struct {
-	BaseCommonController
+	BaseAuthController
 }
 
 // @Title 首页列表接口
@@ -25,6 +25,13 @@ func (this *HomeController) ListHome() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	chartPermissionId, _ := this.GetInt("ChartPermissionId")
@@ -57,6 +64,21 @@ func (this *HomeController) ListHome() {
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
+		userType, _, err := services.GetUserType(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+			return
+		}
+		if userType == 1 && categoryinfo.PermissionName == "研选" {
+			resp.Paging = page
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+		resp.HaveResearch = true
 		page = paging.GetPaging(currentIndex, pageSize, total)
 		if categoryId != "" {
 			condition += ` AND category_id IN(` + categoryId + `)`

+ 3 - 3
models/article.go

@@ -84,7 +84,6 @@ type HomeArticle struct {
 }
 
 type ArticleDetail struct {
-	HaveResearch         bool   `description:"是否有研选权限"`
 	ArticleId            int    `description:"报告id"`
 	Title                string `description:"标题"`
 	TitleEn              string `description:"英文标题 "`
@@ -190,8 +189,9 @@ 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:未付费(没有任何品类权限)"`
+	HasPermission int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	HasFree       int  `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
+	HaveResearch  bool `description:"是否有研选权限"`
 }
 
 func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {

+ 3 - 2
models/home.go

@@ -31,6 +31,7 @@ func GetHomeList(condition string, pars []interface{}, startSize, pageSize int)
 }
 
 type HomeListResp struct {
-	Paging *paging.PagingItem
-	List   []*HomeArticle
+	HaveResearch bool `description:"是否有研选权限"`
+	Paging       *paging.PagingItem
+	List         []*HomeArticle
 }