wkyuer 1 month ago
parent
commit
31266e1e9f
2 changed files with 25 additions and 29 deletions
  1. 23 27
      internal/logic/middleware/middleware.go
  2. 2 2
      internal/logic/timedTask/init.go

+ 23 - 27
internal/logic/middleware/middleware.go

@@ -2,8 +2,6 @@ package middleware
 
 
 import (
 import (
 	elastic "app.yhyue.com/moapp/jybase/es"
 	elastic "app.yhyue.com/moapp/jybase/es"
-	"strings"
-
 	//. "app.yhyue.com/moapp/jybase/api"
 	//. "app.yhyue.com/moapp/jybase/api"
 	"context"
 	"context"
 	"fmt"
 	"fmt"
@@ -94,35 +92,33 @@ func (s *sMiddleware) LoginFilter(r *ghttp.Request) {
 		uMsg *model.User
 		uMsg *model.User
 		err  error
 		err  error
 	)
 	)
-	if !strings.HasPrefix(r.RequestURI, "/debug") {
-		if token := r.Header.Get("Token"); token != "" {
-			uMsg, err = jyutil.GetUserMsgFromToken(r.Context(), token)
-			if err != nil {
-				r.SetError(fmt.Errorf("无效token"))
-				return
-			}
-		} else {
-			uMsg = &model.User{
-				PositionId: r.Session.MustGet("positionId", 0).Int64(),
-				EntUserId:  r.Session.MustGet("entUserId", 0).Int64(),
-				EntId:      r.Session.MustGet("entId", 0).Int64(),
-				EntDeptId:  r.Session.MustGet("entDeptId", 0).Int64(),
-				EntRole:    r.Session.MustGet("entRole", 0).Int64(),
-				AccountId:  r.Session.MustGet("accountId", 0).Int64(),
-				//MgoUserId:   r.Session.MustGet("mgoUserId", 0).String(),
-				EntUserName: r.Session.MustGet("entUserName", "").String(),
-			}
-		}
-		if uMsg == nil || uMsg.EntId == 0 || uMsg.EntUserId == 0 {
-			r.SetError(fmt.Errorf("身份异常"))
+	if token := r.Header.Get("Token"); token != "" {
+		uMsg, err = jyutil.GetUserMsgFromToken(r.Context(), token)
+		if err != nil {
+			r.SetError(fmt.Errorf("无效token"))
 			return
 			return
 		}
 		}
-		if uMsg.EntId != g.Cfg("global").MustGet(r.Context(), "powerEntId", 25917).Int64() {
-			r.SetError(fmt.Errorf("非法请求"))
-			return
+	} else {
+		uMsg = &model.User{
+			PositionId: r.Session.MustGet("positionId", 0).Int64(),
+			EntUserId:  r.Session.MustGet("entUserId", 0).Int64(),
+			EntId:      r.Session.MustGet("entId", 0).Int64(),
+			EntDeptId:  r.Session.MustGet("entDeptId", 0).Int64(),
+			EntRole:    r.Session.MustGet("entRole", 0).Int64(),
+			AccountId:  r.Session.MustGet("accountId", 0).Int64(),
+			//MgoUserId:   r.Session.MustGet("mgoUserId", 0).String(),
+			EntUserName: r.Session.MustGet("entUserName", "").String(),
 		}
 		}
-		r.SetCtxVar(consts.ContextKey, uMsg)
 	}
 	}
+	if uMsg == nil || uMsg.EntId == 0 || uMsg.EntUserId == 0 {
+		r.SetError(fmt.Errorf("身份异常"))
+		return
+	}
+	if uMsg.EntId != g.Cfg("global").MustGet(r.Context(), "powerEntId", 25917).Int64() {
+		r.SetError(fmt.Errorf("非法请求"))
+		return
+	}
+	r.SetCtxVar(consts.ContextKey, uMsg)
 	r.Middleware.Next()
 	r.Middleware.Next()
 }
 }
 
 

+ 2 - 2
internal/logic/timedTask/init.go

@@ -8,9 +8,9 @@ import (
 
 
 func AutoReturnTask() {
 func AutoReturnTask() {
 	cr := cron.New()
 	cr := cron.New()
-	//go AutomaticPayment()  //首次执行
+	go AutomaticPayment()  //首次执行
 	go OnlineReturnMoney() //首次执行
 	go OnlineReturnMoney() //首次执行
-	//cr.AddFunc(g.Cfg().MustGet(context.Background(), "autoReturnTaskTime", "0 */3 * * * ?").String(), AutomaticPayment)
+	cr.AddFunc(g.Cfg().MustGet(context.Background(), "autoReturnTaskTime", "0 */3 * * * ?").String(), AutomaticPayment)
 	cr.AddFunc(g.Cfg().MustGet(context.Background(), "onlineReturnMoney", "0 */2 * * * ?").String(), OnlineReturnMoney)
 	cr.AddFunc(g.Cfg().MustGet(context.Background(), "onlineReturnMoney", "0 */2 * * * ?").String(), OnlineReturnMoney)
 	cr.AddFunc(g.Cfg().MustGet(context.Background(), "protocolNotice.cron", "# 0 2 * * *").String(), OrderProtocolNotice)
 	cr.AddFunc(g.Cfg().MustGet(context.Background(), "protocolNotice.cron", "# 0 2 * * *").String(), OrderProtocolNotice)
 	cr.Start()
 	cr.Start()