xingzai 7 mēneši atpakaļ
vecāks
revīzija
697d438147
1 mainītis faili ar 14 papildinājumiem un 9 dzēšanām
  1. 14 9
      controllers/yanxuan_special.go

+ 14 - 9
controllers/yanxuan_special.go

@@ -163,8 +163,8 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -179,7 +179,7 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		return
 	}
 
-	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, user.UserId)
 	if tmpErr != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
@@ -236,7 +236,7 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
 	}
-	if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
+	if item.UserId != user.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, user.Mobile) {
 		resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
 		resp.CygxYanxuanSpecialItem.Status = item.Status
 		//resp.HasPermission = 2
@@ -258,13 +258,13 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 	//判断是否属于审核人员
 	mobileSlice := strings.Split(cnf.ConfigValue, ",")
 	for _, v := range mobileSlice {
-		if v == sysUser.Mobile {
+		if v == user.Mobile {
 			resp.IsApprovalAdmin = true
 		}
 	}
 
-	if sysUser.UserId > 0 {
-		followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(sysUser.UserId, item.UserId)
+	if user.UserId > 0 {
+		followCount, err := models.GetCygxYanxuanSpecialFollowCountByUser(user.UserId, item.UserId)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败, Err:" + err.Error()
@@ -276,17 +276,22 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 	}
 
 	//校验研选专栏权限,以及无权限的时候的对应状态码
-	havePower, err := services.GetYanxuanSpecialDetailUserPower(sysUser)
+	havePower, err := services.GetYanxuanSpecialDetailUserPower(user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
+	//看自己的文章时不设权限限制,不需要判断是否有研选订阅权限,都可以看。
+	if user.UserId == item.UserId {
+		havePower = true
+	}
+
 	var hasPermission int
 	if havePower {
 		hasPermission = 1
 	} else {
-		hasPermission, err = services.GetUserDetailPermissionCode(sysUser.UserId, sysUser.CompanyId)
+		hasPermission, err = services.GetUserDetailPermissionCode(user.UserId, user.CompanyId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户权限状态失败,Err:" + err.Error()