|
@@ -12,8 +12,10 @@ import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"flag"
|
|
"flag"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ _ "github.com/gin-contrib/sessions"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
"github.com/go-xorm/xorm"
|
|
"github.com/go-xorm/xorm"
|
|
|
|
+
|
|
"github.com/robfig/cron"
|
|
"github.com/robfig/cron"
|
|
"github.com/tal-tech/go-zero/core/conf"
|
|
"github.com/tal-tech/go-zero/core/conf"
|
|
"github.com/tal-tech/go-zero/zrpc"
|
|
"github.com/tal-tech/go-zero/zrpc"
|
|
@@ -67,17 +69,53 @@ func init() {
|
|
func rateLimitInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
|
func rateLimitInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
|
fmt.Println("拦截器")
|
|
fmt.Println("拦截器")
|
|
log.Println("方法名:",info.FullMethod," 参数:",req)
|
|
log.Println("方法名:",info.FullMethod," 参数:",req)
|
|
- resp, err = handler(ctx, req)
|
|
|
|
- fmt.Println("返回值",resp,err)
|
|
|
|
- orm := entity.Engine.NewSession()
|
|
|
|
- /* reqData := req.(map[string]interface{})
|
|
|
|
- appId:=reqData["AppId"]*/
|
|
|
|
|
|
+
|
|
var dat map[string]interface{}
|
|
var dat map[string]interface{}
|
|
jsonStr := Strval(req)
|
|
jsonStr := Strval(req)
|
|
if err := json.Unmarshal([]byte(jsonStr), &dat); err == nil {
|
|
if err := json.Unmarshal([]byte(jsonStr), &dat); err == nil {
|
|
fmt.Println(dat)
|
|
fmt.Println(dat)
|
|
}
|
|
}
|
|
appId:=dat["appId"]
|
|
appId:=dat["appId"]
|
|
|
|
+
|
|
|
|
+ /*session := App.SessionManager.Session(req, w)
|
|
|
|
+ session := l.App.SessionManager.Session(req, w)
|
|
|
|
+ id := string(session.Id())*/
|
|
|
|
+ //验证是否为剑鱼用户、是否登录
|
|
|
|
+ /*fool, _ := util.Exists("other", id)
|
|
|
|
+ if fool {
|
|
|
|
+ res := util.Get("other", id)
|
|
|
|
+ data := res.(map[string]interface{})
|
|
|
|
+ if _, ok := data["userId"]; ok {
|
|
|
|
+ // 存在
|
|
|
|
+ log.Println("存在")
|
|
|
|
+ }else{
|
|
|
|
+ return &entity.Result{entity.Error_code_1001, entity.Error_msg_1001, nil} ,err
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ return &entity.Result{entity.Error_code_1001, entity.Error_msg_1001, nil} ,err
|
|
|
|
+
|
|
|
|
+ }*/
|
|
|
|
+ /*userId:=dat["userId"]
|
|
|
|
+ fool, _ := util.Exists("other", fmt.Sprint(userId))
|
|
|
|
+ if fool {
|
|
|
|
+ res := util.Get("other", fmt.Sprint(userId))
|
|
|
|
+ data := res.(map[string]interface{})
|
|
|
|
+ if _, ok := data["userId"]; ok {
|
|
|
|
+ // 存在
|
|
|
|
+ log.Println("存在")
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ return &entity.Result{entity.Error_code_1001, entity.Error_msg_1001, nil} ,err
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ return &entity.Result{entity.Error_code_1001, entity.Error_msg_1001, nil} ,err
|
|
|
|
+ }*/
|
|
|
|
+ resp, err = handler(ctx, req)
|
|
|
|
+ fmt.Println("返回值",resp,err)
|
|
|
|
+ orm := entity.Engine.NewSession()
|
|
|
|
+ /* reqData := req.(map[string]interface{})
|
|
|
|
+ appId:=reqData["AppId"]*/
|
|
|
|
+
|
|
eqspStr := Strval(resp)
|
|
eqspStr := Strval(resp)
|
|
if(len(eqspStr)>300){
|
|
if(len(eqspStr)>300){
|
|
eqspStr=eqspStr[0:300]
|
|
eqspStr=eqspStr[0:300]
|