|
@@ -5,6 +5,7 @@ import (
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -15,7 +16,7 @@ type ArticleController struct {
|
|
|
// @Title 获取报告详情
|
|
|
// @Description 获取报告详情接口
|
|
|
// @Param ArticleId query int true "报告ID"
|
|
|
-// @Success 200 {object} models.ArticleDetail
|
|
|
+// @Success 200 {object} models.ArticleDetailResp
|
|
|
// @router /detail [get]
|
|
|
func (this *ArticleController) Detail() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -65,33 +66,49 @@ func (this *ArticleController) Detail() {
|
|
|
if interviewApplyCount > 0 {
|
|
|
detail.IsInterviewApply = true
|
|
|
}
|
|
|
- var status int
|
|
|
-
|
|
|
-
|
|
|
+ hasPermission := 2
|
|
|
+ articlePermission, err := models.GetArticlePermission(detail.SubCategoryName)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if articlePermission == nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "报告权限不存在,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
//GetCompanyPermission
|
|
|
- companyPermission,err:=models.GetCompanyPermission(user.CompanyId)
|
|
|
- if err!=nil {
|
|
|
+ companyPermission, err := models.GetCompanyPermission(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- //新增浏览记录
|
|
|
- {
|
|
|
+ if strings.Contains(companyPermission, articlePermission.PermissionName) {
|
|
|
+ hasPermission = 1
|
|
|
+ }
|
|
|
+ if hasPermission == 1 {
|
|
|
+ //新增浏览记录
|
|
|
record := new(models.CygxArticleViewRecord)
|
|
|
record.UserId = uid
|
|
|
record.ArticleId = articleId
|
|
|
record.CreateTime = time.Now()
|
|
|
- record.Mobile=user.Mobile
|
|
|
- record.Email=user.Email
|
|
|
- record.CompanyId=user.CompanyId
|
|
|
- record.CompanyName=user.CompanyName
|
|
|
+ record.Mobile = user.Mobile
|
|
|
+ record.Email = user.Email
|
|
|
+ record.CompanyId = user.CompanyId
|
|
|
+ record.CompanyName = user.CompanyName
|
|
|
go models.AddCygxArticleViewRecord(record)
|
|
|
+ } else {
|
|
|
+ detail.Body = ""
|
|
|
}
|
|
|
+ resp := new(models.ArticleDetailResp)
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.Detail = detail
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
|
- br.Data = detail
|
|
|
+ br.Data = resp
|
|
|
}
|
|
|
|
|
|
// @Title 收藏
|