Explorar el Código

Merge remote-tracking branch 'origin/yb/1.1'

Roc hace 3 años
padre
commit
93263a238f
Se han modificado 6 ficheros con 42 adiciones y 9 borrados
  1. 1 1
      controller/response/base.go
  2. 3 2
      logic/report/research_report.go
  3. 3 1
      main.go
  4. 4 4
      middleware/token.go
  5. 4 1
      services/user/user.go
  6. 27 0
      utils/common.go

+ 1 - 1
controller/response/base.go

@@ -35,7 +35,7 @@ func result(code int, resultData ResultData, c *gin.Context) {
 	logSlice = append(logSlice, fmt.Sprint("Url:", c.Request.RequestURI))
 	logSlice = append(logSlice, fmt.Sprint("Token:", token))
 	logSlice = append(logSlice, fmt.Sprint("resultData:", string(jsonByte)))
-	global.LOG.Info(strings.Join(logSlice, "\n"))
+	global.LOG.Info(strings.Join(logSlice, ""))
 
 	//测试环境,数据不进行加密
 	/*if global.CONFIG.Serve.RunMode == "debug" {

+ 3 - 2
logic/report/research_report.go

@@ -3,7 +3,7 @@ package report
 import (
 	"hongze/hongze_yb/models/tables/company_report_permission"
 	"hongze/hongze_yb/models/tables/research_report"
-	"strings"
+	"hongze/hongze_yb/utils"
 )
 
 func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchReportInfo, hasPermission bool, err error) {
@@ -14,7 +14,8 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
 	}
 	reportType := reportInfo.Type
 	//这些个报告需要做权限校验
-	if strings.Contains("month,two_week,other", reportInfo.Type) {
+
+	if utils.InArray(reportInfo.Type, []string{"month", "two_week", "other"}) {
 		list, tmpErr := company_report_permission.GetReportVarietyList(userId, reportType)
 		if tmpErr != nil {
 			err = tmpErr

+ 3 - 1
main.go

@@ -1,6 +1,8 @@
 package main
 
-import "hongze/hongze_yb/core"
+import (
+	"hongze/hongze_yb/core"
+)
 
 // @title 弘则研报API接口文档
 // @version 1.0

+ 4 - 4
middleware/token.go

@@ -35,7 +35,7 @@ func Token() gin.HandlerFunc {
 		}
 
 		if sessionInfo == nil {
-			response.TokenError(nil, "网络异常,请稍后重试!", c)
+			response.TokenError(nil, "网络异常,请稍后重试1038!", c)
 			c.Abort()
 			return
 		}
@@ -55,18 +55,18 @@ func Token() gin.HandlerFunc {
 		if err != nil {
 			//用户openid查询出来发现没有绑定用户
 			if err == services.ERR_USER_NOT_BIND {
-				response.TokenError(nil, "信息已变更,请重新登陆!", c)
+				response.TokenError(nil, "信息已变更,请重新登陆1058!", c)
 				c.Abort()
 				return
 			}
 			//没有找到记录
 			if err == utils.ErrNoRow {
-				response.TokenError(nil, "信息已变更,请重新登陆!", c)
+				response.TokenError(nil, "信息已变更,请重新登陆2064!", c)
 				c.Abort()
 				return
 			}
 
-			response.TokenError(nil, "网络异常,请稍后重试!", c)
+			response.TokenError(nil, "网络异常,请稍后重试3069!", c)
 			c.Abort()
 			return
 		}

+ 4 - 1
services/user/user.go

@@ -299,7 +299,10 @@ QUERY_WX_USER:
 	} else {
 		token = tokenItem.AccessToken
 		//如果联系人编号不为空,且联系人编号与session里面的联系人编号不一致的时候,需要做session变更
-		if userId > 0 && tokenItem.UserID != int64(userId) {
+		//if userId > 0 && tokenItem.UserID != int64(userId) {
+		//	_ = tokenItem.UpdateSession(int64(userId), time.Now().AddDate(0, 1, 0))
+		//}
+		if userId > 0 {
 			_ = tokenItem.UpdateSession(int64(userId), time.Now().AddDate(0, 1, 0))
 		}
 	}

+ 27 - 0
utils/common.go

@@ -933,3 +933,30 @@ func getMonthDay(year, month int) (days int) {
 	}
 	return
 }
+
+// InArray 是否在切片(数组/map)中含有该值,目前只支持:string、int 、 int64,其他都是返回false
+func InArray(needle interface{}, hyStack interface{}) bool {
+	switch key := needle.(type) {
+	case string:
+		for _, item := range hyStack.([]string) {
+			if key == item {
+				return true
+			}
+		}
+	case int:
+		for _, item := range hyStack.([]int) {
+			if key == item {
+				return true
+			}
+		}
+	case int64:
+		for _, item := range hyStack.([]int64) {
+			if key == item {
+				return true
+			}
+		}
+	default:
+		return false
+	}
+	return false
+}