xingzai 8 сар өмнө
parent
commit
7d2aef34d0

+ 14 - 10
controllers/yanxuan_special.go

@@ -150,8 +150,8 @@ func (this *YanxuanSpecialController) 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
@@ -167,7 +167,7 @@ func (this *YanxuanSpecialController) 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()
@@ -213,12 +213,12 @@ func (this *YanxuanSpecialController) Detail() {
 		return
 	}
 
-	if isSendWx == 1 && strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
+	if isSendWx == 1 && strings.Contains(cnf.ConfigValue, user.Mobile) {
 		resp.IsShowExamine = true
 		resp.ExamineStatus = item.Status
 	}
 	resp.ExamineStatus = item.Status
-	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.HasPermission = 2
 	}
@@ -249,12 +249,12 @@ func (this *YanxuanSpecialController) Detail() {
 		resp.ContentHasStyle = true
 	}
 
-	if resp.HasPermission != 1 || sysUser.UserId == 0 {
+	if resp.HasPermission != 1 || user.UserId == 0 {
 		resp.Content = services.AnnotationHtml(resp.Content)
 	}
 
-	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()
@@ -268,17 +268,21 @@ func (this *YanxuanSpecialController) 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()