Browse Source

Merge branch 'cygx_12.9' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 1 year ago
parent
commit
803b81e55c
4 changed files with 23 additions and 2 deletions
  1. 1 0
      controllers/user.go
  2. 5 1
      controllers/yanxuan_special.go
  3. 1 1
      services/user.go
  4. 16 0
      utils/common.go

+ 1 - 0
controllers/user.go

@@ -1038,6 +1038,7 @@ func (this *UserController) ApplyTryOut() {
 		}
 		title = YanxuanSpecialBySpeciaDetail.Title
 		source = "yanxuanspecial"
+		isResearch = true
 	}
 
 	//缓存校验

+ 5 - 1
controllers/yanxuan_special.go

@@ -215,7 +215,7 @@ func (this *YanxuanSpecialController) Detail() {
 	}
 
 	//如果是用户本人写的专栏,那么就不做校验
-	if item.UserId == sysUser.UserId {
+	if item.UserId == sysUser.UserId || sysUser.UserId == 0 {
 		resp.HasPermission = 1
 	} else {
 		hasPermission, err := services.GetUserRaiPermissionYanXuanInfo(sysUser)
@@ -240,6 +240,10 @@ func (this *YanxuanSpecialController) Detail() {
 		resp.ContentHasStyle = true
 	}
 
+	if resp.HasPermission != 1 || sysUser.UserId == 0 {
+		resp.Content = utils.InterceptHtmlLength(resp.Content, 240)
+	}
+
 	br.Data = resp
 	br.Ret = 200
 	br.Success = true

+ 1 - 1
services/user.go

@@ -1104,7 +1104,7 @@ func SendPermissionApplyTemplateMsgAdmin(req models.ApplyTryReq, usermobile, app
 	var configCode string
 	//如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
 	if isResearch {
-		configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
+		configCode = utils.TPL_MSG_WANG_YANG
 	} else {
 		configCode = utils.TPL_MSG
 	}

+ 16 - 0
utils/common.go

@@ -954,3 +954,19 @@ func GetHtmlContentText(content string) (contentSub string, err error) {
 	contentSub = body
 	return
 }
+
+// 富文本字符串截取指定长度
+func InterceptHtmlLength(body string, length int) (newbody string) {
+	content := html.UnescapeString(body)
+	doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
+	if err != nil {
+		fmt.Println("create doc err:", err.Error())
+		return
+	}
+	bodyText := doc.Text()
+	if len(bodyText) < length {
+		length = len(bodyText)
+	}
+	newbody = bodyText[0:length]
+	return
+}