Selaa lähdekoodia

fix:修改权限

zqbao 9 kuukautta sitten
vanhempi
commit
a1a74b6c18
2 muutettua tiedostoa jossa 17 lisäystä ja 2 poistoa
  1. 10 2
      controllers/report.go
  2. 7 0
      utils/constants.go

+ 10 - 2
controllers/report.go

@@ -179,7 +179,15 @@ func (this *ReportController) Detail() {
 		return
 		return
 	}
 	}
 	// 有效期是否到期
 	// 有效期是否到期
-	IsVail := user.ValidEndTime.After(time.Now())
+	var IsVail bool
+	if user.Status == utils.UserStatusFormal {
+		if user.ValidEndTime.After(time.Now()) && user.ValidStartTime.Before(time.Now()) {
+			IsVail = true
+		} else {
+			IsVail = false
+			user.Status = utils.UserStatusNo
+		}
+	}
 
 
 	report, err := models.GetReportById(reportId)
 	report, err := models.GetReportById(reportId)
 	if err != nil {
 	if err != nil {
@@ -224,7 +232,7 @@ func (this *ReportController) Detail() {
 	resp := new(response.ReportDetailResp)
 	resp := new(response.ReportDetailResp)
 	if !IsPublic {
 	if !IsPublic {
 		// 如果被禁用或是潜在用户,直接返回无阅读报告权限
 		// 如果被禁用或是潜在用户,直接返回无阅读报告权限
-		if user.Status == 0 || user.Status == 1 {
+		if user.Status == utils.UserStatusNo || user.Status == utils.UserStatusPotential {
 			resp.Report = report
 			resp.Report = report
 			resp.Status = utils.ReportPermissionStatusNo
 			resp.Status = utils.ReportPermissionStatusNo
 			report.Content = ""
 			report.Content = ""

+ 7 - 0
utils/constants.go

@@ -30,3 +30,10 @@ const (
 const (
 const (
 	APPNAME = "东吴小程序桥接服务"
 	APPNAME = "东吴小程序桥接服务"
 )
 )
+
+// 用户状态定义
+const (
+	UserStatusNo        = 0 //禁用
+	UserStatusPotential = 1 //潜在用户
+	UserStatusFormal    = 2 //正式用户
+)