Browse Source

报告主观客观处理

xingzai 3 years ago
parent
commit
d582307b6e
3 changed files with 54 additions and 17 deletions
  1. 17 17
      controllers/activity.go
  2. 28 0
      controllers/article.go
  3. 9 0
      models/report_mapping.go

+ 17 - 17
controllers/activity.go

@@ -591,7 +591,7 @@ func (this *ActivityCoAntroller) Detail() {
 			}
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"
@@ -670,7 +670,7 @@ func (this *ActivityCoAntroller) Detail() {
 			if err.Error() == utils.ErrNoRow() {
 				resp.HasPermission = 4
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Success = true
 				br.Msg = "获取成功"
@@ -688,17 +688,17 @@ func (this *ActivityCoAntroller) Detail() {
 			resp.HaqveJurisdiction = true
 		} else {
 			if permissionStr == "专家" {
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				resp.MsgType = "Type"
 			} else {
-				if strings.Contains("医药,消费,科技,智造", activityInfo.ChartPermissionName) {
-					if activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6 {
-						activityInfo.ChartPermissionName += "(主观)"
-					} else {
-						activityInfo.ChartPermissionName += "(客观)"
-					}
-				}
-				resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动"
+				//if strings.Contains("医药,消费,科技,智造", activityInfo.ChartPermissionName) {
+				//	if activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6 {
+				//		activityInfo.ChartPermissionName += "(主观)"
+				//	} else {
+				//		activityInfo.ChartPermissionName += "(客观)"
+				//	}
+				//}
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				resp.MsgType = "Industry"
 			}
 			resp.SellerMobile = companyItem.Mobile
@@ -816,7 +816,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 			}
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"
@@ -858,7 +858,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 			if err.Error() == utils.ErrNoRow() {
 				resp.HasPermission = 4
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Success = true
 				br.Msg = "获取成功"
@@ -1092,7 +1092,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 			hasPermission = 3
 		}
 		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	}
 	if signupType == 1 && user.IsMsgOutboundMobile == 0 {
 		resp.GoOutboundMobile = true
@@ -1417,7 +1417,7 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 			}
 			resp.HasPermission = hasPermission
 			resp.OperationMode = "Apply"
-			resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"
@@ -1462,7 +1462,7 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 			if err.Error() == utils.ErrNoRow() {
 				resp.HasPermission = 4
 				resp.OperationMode = "Apply"
-				resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 				br.Ret = 200
 				br.Success = true
 				br.Msg = "获取成功"
@@ -1529,7 +1529,7 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 			hasPermission = 3
 		}
 		resp.OperationMode = "Apply"
-		resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	}
 	resp.HasPermission = hasPermission
 	resp.SignupStatus = signupStatus

+ 28 - 0
controllers/article.go

@@ -138,6 +138,34 @@ func (this *ArticleController) Detail() {
 			if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
 				hasPersion = false
 			}
+
+			if detail.IsReport == 1 {
+				fmt.Println("报告权限")
+				detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
+				if err != nil && err.Error() != utils.ErrNoRow() {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
+					return
+				}
+				fmt.Println(detailCategory)
+				permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+					return
+				}
+				if detailCategory != nil {
+					if detailCategory.PermissionType == 1 {
+						if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
+							hasPersion = false
+						}
+					} else if detailCategory.PermissionType == 2 {
+						if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
+							hasPersion = false
+						}
+					}
+				}
+			}
 			if hasPersion {
 				hasPermission = 1
 				historyRecord := new(models.CygxArticleHistoryRecord)

+ 9 - 0
models/report_mapping.go

@@ -10,6 +10,7 @@ type ReportMapping struct {
 	MatchTypeName       string `description:"分类名称"`
 	ChartPermissionName string `description:"行业名称"`
 	IsRed               bool   `description:"是否标红"`
+	PermissionType      int    `description:"1主观,2客观"`
 }
 
 type ReportMappingHome struct {
@@ -112,6 +113,14 @@ func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
 	return
 }
 
+//通过分类ID获取详情主观客观
+func GetdetailByCategoryIdSando(categoryId int) (item *ReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping WHERE permission_type>0 AND category_id=?  LIMIT 1`
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}
+
 //通过分类ID获取详情
 func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
 	o := orm.NewOrm()