This commit is contained in:
2024-10-04 23:07:49 +08:00
parent f649d32c19
commit 8c09120db6
7 changed files with 78 additions and 62 deletions

View File

@@ -4,11 +4,10 @@ import (
"context"
"encoding/hex"
"errors"
"tianyuan-api/apps/api/internal/validator"
"tianyuan-api/pkg/crypto"
"tianyuan-api/apps/api/internal/svc"
"tianyuan-api/apps/api/internal/types"
"tianyuan-api/apps/api/internal/validator"
"tianyuan-api/pkg/crypto"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -27,6 +26,12 @@ func NewIVYZ5733Logic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ5733
}
}
type CustomResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data,omitempty"` // `omitempty` 使得当 Data 为空时字段不返回
}
func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp *types.Response, err error) {
//userId, ok := l.ctx.Value("userId").(int64)
//if !ok {
@@ -36,7 +41,6 @@ func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp *types.Response, err
if !ok {
return &types.Response{}, errors.New("系统错误,请联系管理员")
}
// 1、解密
key, err := hex.DecodeString(secretKey)
decryptData, err := crypto.AesDecrypt(req.Data, key)
@@ -46,7 +50,6 @@ func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp *types.Response, err
// 2、校验
var data validator.IVYZ5733Request
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
return nil, validatorErr
}