temp
This commit is contained in:
@@ -2,29 +2,28 @@ package IVYZ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/IVYZ"
|
||||
"tianyuan-api/apps/api/internal/svc"
|
||||
"tianyuan-api/apps/api/internal/types"
|
||||
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
)
|
||||
|
||||
func IVYZ5733Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.Request
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
response.Fail(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := IVYZ.NewIVYZ5733Logic(r.Context(), svcCtx)
|
||||
resp, err := l.IVYZ5733(&req)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
response.Fail(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
response.Success(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"tianyuan-api/apps/sentinel/client/secret"
|
||||
"tianyuan-api/apps/sentinel/client/userproduct"
|
||||
"tianyuan-api/apps/sentinel/client/whitelist"
|
||||
"tianyuan-api/apps/sentinel/sentinel"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ApiAuthInterceptorMiddleware struct {
|
||||
|
||||
@@ -43,6 +43,4 @@ func (l *GetProductByIdLogic) GetProductById(req *types.GetProductByIdReq) (resp
|
||||
ProductPrice: productResp.ProductPrice,
|
||||
},
|
||||
}, nil
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user