xingzai 1 год назад
Родитель
Сommit
dd402ebd12
4 измененных файлов с 50 добавлено и 3 удалено
  1. 2 2
      controllers/banner.go
  2. 10 0
      controllers/user.go
  3. 14 1
      controllers/yanxuan_special.go
  4. 24 0
      services/user_permission.go

+ 2 - 2
controllers/banner.go

@@ -136,8 +136,8 @@ func (this *BannerController) ListYx() {
 			&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/2.png", Path: "pages-purchaser/survey/surveySubmit"},
 		}
 		listB = []*models.BannerUrlYxResp{
-			&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/4_short.png", Path: "pages-purchaser/specialColumn/specialColumn"},
-			//&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/3.png", Path: "pages-purchaser/researchList/researchList"},
+			//&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/4_short.png", Path: "pages-purchaser/specialColumn/specialColumn"},
+			&models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/3.png", Path: "pages-purchaser/researchList/researchList"},
 		}
 	}
 

+ 10 - 0
controllers/user.go

@@ -1010,6 +1010,16 @@ func (this *UserController) ApplyTryOut() {
 		}
 		title = ProductInteriorDetail.Title
 		source = "productinterior"
+	} else if tryType == "YanxuanSpecial" {
+		// 研选专栏
+		YanxuanSpecialBySpeciaDetail, e := models.GetYanxuanSpecialBySpecialId(detailId)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "产品内测信息有误, 不存在的detailId: " + strconv.Itoa(detailId)
+			return
+		}
+		title = YanxuanSpecialBySpeciaDetail.Title
+		source = "yanxuanspecial"
 	}
 
 	//缓存校验

+ 14 - 1
controllers/yanxuan_special.go

@@ -211,7 +211,20 @@ func (this *YanxuanSpecialController) Detail() {
 	resp.ExamineStatus = item.Status
 	if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
 		resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
-		resp.HasPermission = 2
+		//resp.HasPermission = 2
+	}
+
+	//如果是用户本人写的专栏,那么就不做校验
+	if item.UserId == sysUser.UserId {
+		resp.HasPermission = 1
+	} else {
+		hasPermission, err := services.GetUserRaiPermissionYanXuanInfo(sysUser)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败, Err:" + err.Error()
+			return
+		}
+		resp.HasPermission = hasPermission
 	}
 
 	//如果在web端有样式或者上传了文件,小程序就禁止编辑修改内容

+ 24 - 0
services/user_permission.go

@@ -85,3 +85,27 @@ func GetUserRaiPermissionInfo(userId, companyId int) (authInfo models.UserPermis
 	permissionArr = strings.Split(permissions, ",")
 	return
 }
+
+// 查询研选的权限状态
+func GetUserRaiPermissionYanXuanInfo(user *models.WxUserItem) (hasPermission int, err error) {
+	var condition string
+	var pars []interface{}
+	condition = " AND company_id = ?  AND status  IN ('正式','试用')  AND chart_permission_id = ?   ORDER BY company_report_permission_id DESC LIMIT 1  "
+	pars = append(pars, user.CompanyId, utils.CHART_PERMISSION_ID_YANXUAN)
+	companyReportPermissionDetail, e := models.GetCompanyReportPermissionDetailByCondition(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyReportPermissionDetailByCondition, Err: " + e.Error())
+		return
+	}
+	//如果用户没有研选权限,那么就获取他对应的状态码
+	if companyReportPermissionDetail == nil {
+		hasPermission, _, _, _, e = GetUserHasPermissionArticle(user)
+		if e != nil {
+			err = errors.New("GetUserHasPermissionArticle, Err: " + e.Error())
+			return
+		}
+	} else {
+		hasPermission = 1
+	}
+	return
+}