|
@@ -13,9 +13,9 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-type HtgjController struct {
|
|
|
- BaseAuthController
|
|
|
-}
|
|
|
+//type HtgjController struct {
|
|
|
+// BaseAuthController
|
|
|
+//}
|
|
|
|
|
|
type BaseHtgjController struct {
|
|
|
BaseCommonController
|
|
@@ -32,7 +32,7 @@ type BaseHtgjController struct {
|
|
|
// @Param Sign query string false "加密签名"
|
|
|
// @Success 200 {object} models.HomeListResp
|
|
|
// @router /home/listPublic [get]
|
|
|
-func (this *BaseCommonController) ListHomePublic() {
|
|
|
+func (this *BaseHtgjController) ListHomePublic() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -171,7 +171,7 @@ func (this *BaseCommonController) ListHomePublic() {
|
|
|
// @Description 获取搜索推荐词
|
|
|
// @Success 200 {object} models.ConfigResp
|
|
|
// @router /home/detail [get]
|
|
|
-func (this *BaseCommonController) BrowseHistoryList() {
|
|
|
+func (this *BaseHtgjController) BrowseHistoryList() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -224,7 +224,7 @@ func (this *BaseCommonController) BrowseHistoryList() {
|
|
|
// @Param request body models.ArticleInterviewApplyReqHtgj true "type json string"
|
|
|
// @Success 200 {object} models.FontsCollectResp
|
|
|
// @router /interview/apply [post]
|
|
|
-func (this *BaseCommonController) InterviewApply() {
|
|
|
+func (this *BaseHtgjController) InterviewApply() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -348,7 +348,7 @@ func (this *BaseCommonController) InterviewApply() {
|
|
|
// @Param request body models.ArticleInterviewApplyReqHtgj true "type json string"
|
|
|
// @Success 200 {object} models.FontsCollectResp
|
|
|
// @router /collect [post]
|
|
|
-func (this *BaseCommonController) ArticleCollect() {
|
|
|
+func (this *BaseHtgjController) ArticleCollect() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -456,7 +456,7 @@ func (this *BaseCommonController) ArticleCollect() {
|
|
|
// @Param request body models.ArticleAskReqHtgj true "type json string"
|
|
|
// @Success Ret=200 新增成功
|
|
|
// @router /askAdd [post]
|
|
|
-func (this *BaseCommonController) AskAdd() {
|
|
|
+func (this *BaseHtgjController) AskAdd() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
|
this.Data["json"] = br
|
|
@@ -590,3 +590,223 @@ func (this *BaseCommonController) AskAdd() {
|
|
|
br.Success = true
|
|
|
br.Msg = "提交成功"
|
|
|
}
|
|
|
+
|
|
|
+// @Title 获取所有品种(无需token)
|
|
|
+// @Description 获取所有品种(无需token)
|
|
|
+// @Success 200 {object} models.ChartPermissionResp
|
|
|
+// @router /permission/allPublic [get]
|
|
|
+func (this *BaseHtgjController) DetailPublic() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var condition string
|
|
|
+ list, err := models.GetChartPermissionAll(condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.ChartPermissionResp)
|
|
|
+ for k, v := range list {
|
|
|
+ resp.List = append(resp.List, v)
|
|
|
+ if services.GetShowSustainable() && v.PermissionName == "研选" {
|
|
|
+ resp.List[k].IsShowSustainable = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp.List = list
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 上传文章阅读时间(无需token)
|
|
|
+// @Description 上传文章阅读时间接口(无需token)
|
|
|
+// @Param request body models.AddStopTimeHtgjRep true "type json string"
|
|
|
+// @Success 200 {object} models.ArticleDetailResp
|
|
|
+// @router /article/addStopTimePublic [post]
|
|
|
+func (this *BaseHtgjController) AddStopTimePublic() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ var req models.AddStopTimeHtgjRep
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ articleId := req.ArticleId
|
|
|
+ stopTime := req.StopTime
|
|
|
+ outType := req.OutType
|
|
|
+ source := req.Source
|
|
|
+ companyCode := req.CompanyCode
|
|
|
+ companyName := req.CompanyName
|
|
|
+ wxuUserName := req.Email
|
|
|
+ sign := req.Sign
|
|
|
+ if companyCode == "" || companyName == "" || wxuUserName == "" || sign == "" {
|
|
|
+ br.Msg = "上传失败"
|
|
|
+ br.ErrMsg = "必填参数不能为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyNameHt := companyCode + "_" + companyName
|
|
|
+ errMsg := services.CheckSign(companyCode+companyName+wxuUserName, sign)
|
|
|
+ if errMsg != "" {
|
|
|
+ br.Msg = errMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyInfo, err := models.GetCompanyByThirdName(companyNameHt)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ user, err := models.GetUserByThirdName(companyInfo.CompanyId, wxuUserName)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ if articleId <= 0 {
|
|
|
+ br.Msg = "文章ID不存在"
|
|
|
+ br.ErrMsg = "参数错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if stopTime == 0 {
|
|
|
+ stopTime = 1
|
|
|
+ }
|
|
|
+ if outType != 2 {
|
|
|
+ outType = 1
|
|
|
+ }
|
|
|
+ if source != "PC" {
|
|
|
+ source = "MOBILE"
|
|
|
+ }
|
|
|
+ detail := new(models.ArticleDetail)
|
|
|
+ hasPermission := 0
|
|
|
+ hasFree := 0
|
|
|
+ //判断是否已经申请过
|
|
|
+ applyCount, err := models.GetApplyRecordCount(uid)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
|
|
|
+ if user.CompanyId > 1 {
|
|
|
+ companyPermission, err := models.GetCompanyPermission(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detail, err = models.GetArticleDetailById(articleId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyPermission == "" {
|
|
|
+ if applyCount > 0 {
|
|
|
+ hasPermission = 5
|
|
|
+ } else {
|
|
|
+ hasPermission = 2
|
|
|
+ }
|
|
|
+ hasFree = 2
|
|
|
+ goto Loop
|
|
|
+ } else {
|
|
|
+ hasFree = 1
|
|
|
+ var articlePermissionPermissionName string
|
|
|
+ if detail.CategoryId > 0 {
|
|
|
+ articlePermission, err := models.GetArticlePermission(detail.CategoryId)
|
|
|
+ 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:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ articlePermissionPermissionName = articlePermission.PermissionName
|
|
|
+ } else {
|
|
|
+ articlePermissionPermissionName = detail.CategoryName
|
|
|
+ }
|
|
|
+ var hasPersion bool
|
|
|
+ slice := strings.Split(articlePermissionPermissionName, ",")
|
|
|
+ for _, v := range slice {
|
|
|
+ if strings.Contains(companyPermission, v) {
|
|
|
+ hasPersion = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if hasPersion {
|
|
|
+ detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
|
|
|
+ if err == nil {
|
|
|
+ hasPermission = 1
|
|
|
+ historyRecord := new(models.AddStopTimeNewRep)
|
|
|
+ historyRecord.StopTime = detailNew.StopTime + stopTime
|
|
|
+ historyRecord.Id = detailNew.Id
|
|
|
+ historyRecord.OutType = outType
|
|
|
+ go models.UpdateArticleStopTime(historyRecord)
|
|
|
+ }
|
|
|
+
|
|
|
+ //不统计本公司的阅读记录、正常退出的不做时间差统计
|
|
|
+ if user.CompanyId != 16 && stopTime > 3 {
|
|
|
+ key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
|
|
|
+ record := new(models.CygxArticleHistoryRecordNewpv)
|
|
|
+ record.UserId = uid
|
|
|
+ record.ArticleId = articleId
|
|
|
+ record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
|
|
|
+ record.ModifyTime = time.Now()
|
|
|
+ record.Mobile = user.Mobile
|
|
|
+ record.Email = user.Email
|
|
|
+ record.CompanyId = user.CompanyId
|
|
|
+ record.CompanyName = companyInfo.CompanyName
|
|
|
+ record.StopTime = stopTime
|
|
|
+ record.OutType = outType
|
|
|
+ record.Source = source
|
|
|
+ if !utils.Rc.IsExist(key) || outType != 2 {
|
|
|
+ //新增浏览记录
|
|
|
+ go models.AddCygxArticleViewRecordNewpv(record)
|
|
|
+ recordRedis := new(services.ReportViewRecord)
|
|
|
+ recordRedis.UserId = user.UserId
|
|
|
+ recordRedis.ReportId = articleId
|
|
|
+ recordRedis.Mobile = user.Mobile
|
|
|
+ recordRedis.Email = user.Email
|
|
|
+ recordRedis.RealName = user.RealName
|
|
|
+ recordRedis.CompanyName = companyName
|
|
|
+ recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
|
|
|
+ go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
|
|
|
+ } else {
|
|
|
+ go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
|
|
|
+ }
|
|
|
+ utils.Rc.Put(key, 1, 10*time.Minute)
|
|
|
+ }
|
|
|
+
|
|
|
+ models.ModifyReportLastViewTime(uid)
|
|
|
+ } else { //无该行业权限
|
|
|
+ hasPermission = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { //潜在客户
|
|
|
+ if applyCount > 0 {
|
|
|
+ hasPermission = 5
|
|
|
+ } else {
|
|
|
+ hasPermission = 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+Loop:
|
|
|
+ resp := new(models.ArticleDetailAddStopTimeRep)
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.HasFree = hasFree
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|