Przeglądaj źródła

feat:防止重复提交

wangshan 2 lat temu
rodzic
commit
949bc1dfdb

+ 6 - 1
jyBXCore/rpc/internal/logic/participateactionlogic.go

@@ -5,6 +5,7 @@ import (
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/service"
 	"jyBXCore/rpc/service"
 	"jyBXCore/rpc/type/bxcore"
 	"jyBXCore/rpc/type/bxcore"
+	"jyBXCore/rpc/util"
 
 
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/logx"
 )
 )
@@ -28,7 +29,11 @@ func (l *ParticipateActionLogic) ParticipateAction(in *bxcore.ParticipateActionR
 	var res = &bxcore.ParticipateActionRes{
 	var res = &bxcore.ParticipateActionRes{
 		Data: true,
 		Data: true,
 	}
 	}
-	if err := service.ParticipateDo(in); err != nil {
+	if msg := util.IsAllowedAccess(in.ActionType); msg != "" {
+		res.ErrCode = -1
+		res.ErrMsg = msg
+		res.Data = false
+	} else if err := service.ParticipateDo(in); err != nil {
 		res.ErrCode = -1
 		res.ErrCode = -1
 		res.ErrMsg = err.Error()
 		res.ErrMsg = err.Error()
 		res.Data = false
 		res.Data = false

+ 9 - 1
jyBXCore/rpc/internal/logic/participatesetupinfologic.go

@@ -3,6 +3,7 @@ package logic
 import (
 import (
 	"context"
 	"context"
 	"jyBXCore/rpc/service"
 	"jyBXCore/rpc/service"
+	"jyBXCore/rpc/util"
 
 
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/internal/svc"
 	"jyBXCore/rpc/type/bxcore"
 	"jyBXCore/rpc/type/bxcore"
@@ -24,7 +25,14 @@ func NewParticipateSetUpInfoLogic(ctx context.Context, svcCtx *svc.ServiceContex
 	}
 	}
 }
 }
 
 
-//  参标设置信息
+// 参标设置信息
 func (l *ParticipateSetUpInfoLogic) ParticipateSetUpInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.ParticipateSetUpInfoRes, error) {
 func (l *ParticipateSetUpInfoLogic) ParticipateSetUpInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.ParticipateSetUpInfoRes, error) {
+	if msg := util.IsAllowedAccess("setup"); msg != "" {
+		return &bxcore.ParticipateSetUpInfoRes{
+			ErrCode: -1,
+			ErrMsg:  msg,
+			Data:    nil,
+		}, nil
+	}
 	return service.GetParticipateSetInfo(in)
 	return service.GetParticipateSetInfo(in)
 }
 }

+ 4 - 0
jyBXCore/rpc/internal/logic/updatebidstatuslogic.go

@@ -33,6 +33,10 @@ func (l *UpdateBidStatusLogic) UpdateBidStatus(in *bxcore.UpdateBidStatusReq) (*
 	result := &bxcore.UpdateBidStatusRes{
 	result := &bxcore.UpdateBidStatusRes{
 		ErrCode: -1,
 		ErrCode: -1,
 	}
 	}
+	if msg := util.IsAllowedAccess("updatebidstatus"); msg != "" {
+		result.ErrMsg = msg
+		return result, nil
+	}
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	// 不是超级订阅 也不是大会员
 	// 不是超级订阅 也不是大会员
 	if !b {
 	if !b {

+ 2 - 2
jyBXCore/rpc/service/participate.go

@@ -156,7 +156,7 @@ func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.Particip
 		RemindRule: nil,
 		RemindRule: nil,
 	}}
 	}}
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
 	b, entRoleId := util.IsAllowedParticipate(in.AppId, in.UserId, in.NewUserId, in.AccountId, in.EntAccountId, in.EntId, in.EntUserId, in.PositionId, in.PositionType)
-	if !b || entRoleId == 0 || entRoleId == 2 { //只有企业管理员有权限
+	if !b {
 		res.ErrMsg = "没有权限"
 		res.ErrMsg = "没有权限"
 		res.Data = nil
 		res.Data = nil
 		res.ErrCode = 0
 		res.ErrCode = 0
@@ -164,7 +164,7 @@ func GetParticipateSetInfo(in *bxcore.ParticipateSetUpInfoReq) (*bxcore.Particip
 		switch in.SetAction {
 		switch in.SetAction {
 		case "U": //update 更新设置信息
 		case "U": //update 更新设置信息
 			res.Data = nil
 			res.Data = nil
-			if entRoleId == 0 {
+			if entRoleId == 0 || entRoleId == 2 { //只有企业管理员有权限
 				res.ErrCode = -1
 				res.ErrCode = -1
 				res.ErrMsg = "当前企业身份无权限"
 				res.ErrMsg = "当前企业身份无权限"
 			}
 			}

+ 12 - 0
jyBXCore/rpc/util/participate.go

@@ -1,6 +1,8 @@
 package util
 package util
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jybase/redis"
+	"fmt"
 	IC "jyBXCore/rpc/init"
 	IC "jyBXCore/rpc/init"
 	"sync"
 	"sync"
 )
 )
@@ -49,3 +51,13 @@ func IsAllowedParticipate(appId, userId string, newUserId, accountId, entAccount
 	}
 	}
 	return
 	return
 }
 }
+
+// 5秒内防止重复提交
+func IsAllowedAccess(key string) string {
+	redisKey := fmt.Sprintf("participate_isAllowed_%s", key)
+	if b, err := redis.Exists("other", redisKey); err != nil && b {
+		return "访问频次过快,请稍后再试"
+	}
+	redis.Put("other", redisKey, key, 5)
+	return ""
+}