temp
This commit is contained in:
parent
d520deacb3
commit
915d3f3716
89
aes.go
89
aes.go
@ -8,6 +8,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
@ -19,6 +20,19 @@ func PKCS7Padding(ciphertext []byte, blockSize int) []byte {
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
|
||||
// 去除PKCS7填充
|
||||
func PKCS7UnPadding(origData []byte) ([]byte, error) {
|
||||
length := len(origData)
|
||||
if length == 0 {
|
||||
return nil, errors.New("input data error")
|
||||
}
|
||||
unpadding := int(origData[length-1])
|
||||
if unpadding > length {
|
||||
return nil, errors.New("unpadding size is invalid")
|
||||
}
|
||||
return origData[:(length - unpadding)], nil
|
||||
}
|
||||
|
||||
// AES CBC模式加密,Base64传入传出
|
||||
func AesEncrypt(plainText, key []byte) (string, error) {
|
||||
block, err := aes.NewCipher(key)
|
||||
@ -41,9 +55,39 @@ func AesEncrypt(plainText, key []byte) (string, error) {
|
||||
return base64.StdEncoding.EncodeToString(cipherText), nil
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
// AES CBC模式解密,Base64传入传出
|
||||
func AesDecrypt(cipherTextBase64 string, key []byte) ([]byte, error) {
|
||||
cipherText, err := base64.StdEncoding.DecodeString(cipherTextBase64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blockSize := block.BlockSize()
|
||||
if len(cipherText) < blockSize {
|
||||
return nil, errors.New("ciphertext too short")
|
||||
}
|
||||
|
||||
iv := cipherText[:blockSize]
|
||||
cipherText = cipherText[blockSize:]
|
||||
|
||||
if len(cipherText)%blockSize != 0 {
|
||||
return nil, errors.New("ciphertext is not a multiple of the block size")
|
||||
}
|
||||
|
||||
mode := cipher.NewCBCDecrypter(block, iv)
|
||||
mode.CryptBlocks(cipherText, cipherText)
|
||||
|
||||
plainText, err := PKCS7UnPadding(cipherText)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return plainText, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -52,25 +96,34 @@ func main() {
|
||||
|
||||
var data interface{}
|
||||
|
||||
data = map[string]interface{}{
|
||||
"id_card": "45212220000827423X",
|
||||
"name": "张荣宏",
|
||||
}
|
||||
|
||||
// 将结构体转为 JSON 字符串
|
||||
jsonData, err := json.Marshal(data)
|
||||
decrypt, err := AesDecrypt("AEQHGRyEolE4o8GoZaWuEFGpGRLEvEMCNM54KzZ/HdnvfOtyFDfn1PVpD6Cb37rQpJm3CqZYLDJWmEcU0f7IeD0MG8Zh1PIvSEwJVEyI2OkZjooZNjuchARpqeG40sS8hFjQt/xVP3qBVsF6+tdnI8GNc8EdLpZ8ja4c/xVprhjr9yRmRHZOVvECFiJkqwrve8jq2vuC5CowNjc4THK8zRmJI+qWDazUL4vntdWFmqG4YmHDZm/UFecevDNMhWRfdeWE2aI9lTXZ/X/gtHEcVyzbx8cltdn+4KuR3t6VPf3edWDSDM0PTxSNbWwPgaTC1sMbBJiFJLW+cUgxJhfQqE1FF5yY+t6V7l8vfW6cUV4xRCFZ/clFvidnYev2CocvMKzf6gkbO/El2a4VA5ustRwL1G3hxMf9fd+5yGT5dEGci+cbysGHTKzNeHf75az1RgW2WEYUBUc7czNiZgkaIA==", key)
|
||||
if err != nil {
|
||||
fmt.Println("JSON 序列化错误:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 对 JSON 数据进行加密
|
||||
encryptedData, err := AesEncrypt(jsonData, key)
|
||||
err = json.Unmarshal(decrypt, &data)
|
||||
if err != nil {
|
||||
fmt.Println("加密错误:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 输出加密后的结果
|
||||
fmt.Println("加密后的数据:", encryptedData)
|
||||
fmt.Println(data)
|
||||
//data = map[string]interface{}{
|
||||
// "id_card": "45212220000827423X",
|
||||
// "name": "张荣宏",
|
||||
//}
|
||||
//
|
||||
//// 将结构体转为 JSON 字符串
|
||||
//jsonData, err := json.Marshal(data)
|
||||
//if err != nil {
|
||||
// fmt.Println("JSON 序列化错误:", err)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 对 JSON 数据进行加密
|
||||
//encryptedData, err := AesEncrypt(jsonData, key)
|
||||
//if err != nil {
|
||||
// fmt.Println("加密错误:", err)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// 输出加密后的结果
|
||||
//fmt.Println("加密后的数据:", encryptedData)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXG162AHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXG162ALogic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXG162A(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXG54F5Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXG54F5Logic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXG54F5(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXG5876Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXG5876Logic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXG5876(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXG75FEHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXG75FELogic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXG75FE(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXG9687Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXG9687Logic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXG9687(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXG970FHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXG970FLogic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXG970F(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXGC9D1Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXGC9D1Logic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXGC9D1(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXGCA3DHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXGCA3DLogic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXGCA3D(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package FLXG
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/FLXG"
|
||||
@ -22,9 +23,9 @@ func FLXGDEC7Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := FLXG.NewFLXGDEC7Logic(r.Context(), svcCtx)
|
||||
resp, err := l.FLXGDEC7(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package IVYZ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/IVYZ"
|
||||
@ -22,9 +23,9 @@ func IVYZ0B03Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := IVYZ.NewIVYZ0B03Logic(r.Context(), svcCtx)
|
||||
resp, err := l.IVYZ0B03(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package IVYZ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/IVYZ"
|
||||
@ -22,9 +23,9 @@ func IVYZ2125Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := IVYZ.NewIVYZ2125Logic(r.Context(), svcCtx)
|
||||
resp, err := l.IVYZ2125(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package IVYZ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/IVYZ"
|
||||
@ -22,9 +23,9 @@ func IVYZ385EHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := IVYZ.NewIVYZ385ELogic(r.Context(), svcCtx)
|
||||
resp, err := l.IVYZ385E(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package IVYZ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/IVYZ"
|
||||
@ -22,9 +23,9 @@ func IVYZ9363Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := IVYZ.NewIVYZ9363Logic(r.Context(), svcCtx)
|
||||
resp, err := l.IVYZ9363(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package IVYZ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/IVYZ"
|
||||
@ -22,9 +23,9 @@ func IVYZADEEHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := IVYZ.NewIVYZADEELogic(r.Context(), svcCtx)
|
||||
resp, err := l.IVYZADEE(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package JRZQ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/JRZQ"
|
||||
@ -22,9 +23,9 @@ func JRZQ0A03Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := JRZQ.NewJRZQ0A03Logic(r.Context(), svcCtx)
|
||||
resp, err := l.JRZQ0A03(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package JRZQ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/JRZQ"
|
||||
@ -22,9 +23,9 @@ func JRZQ4AA8Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := JRZQ.NewJRZQ4AA8Logic(r.Context(), svcCtx)
|
||||
resp, err := l.JRZQ4AA8(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package JRZQ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/JRZQ"
|
||||
@ -22,9 +23,9 @@ func JRZQ8203Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := JRZQ.NewJRZQ8203Logic(r.Context(), svcCtx)
|
||||
resp, err := l.JRZQ8203(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package JRZQ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/JRZQ"
|
||||
@ -22,9 +23,9 @@ func JRZQCEE8Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := JRZQ.NewJRZQCEE8Logic(r.Context(), svcCtx)
|
||||
resp, err := l.JRZQCEE8(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package JRZQ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/JRZQ"
|
||||
@ -22,9 +23,9 @@ func JRZQDCBEHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := JRZQ.NewJRZQDCBELogic(r.Context(), svcCtx)
|
||||
resp, err := l.JRZQDCBE(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package JRZQ
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/JRZQ"
|
||||
@ -22,9 +23,9 @@ func JRZQFEF8Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := JRZQ.NewJRZQFEF8Logic(r.Context(), svcCtx)
|
||||
resp, err := l.JRZQFEF8(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package QYGL
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/QYGL"
|
||||
@ -22,9 +23,9 @@ func QYGL2ACDHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := QYGL.NewQYGL2ACDLogic(r.Context(), svcCtx)
|
||||
resp, err := l.QYGL2ACD(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package QYGL
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/QYGL"
|
||||
@ -22,9 +23,9 @@ func QYGL45BDHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := QYGL.NewQYGL45BDLogic(r.Context(), svcCtx)
|
||||
resp, err := l.QYGL45BD(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package QYGL
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/QYGL"
|
||||
@ -22,9 +23,9 @@ func QYGL51BCHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := QYGL.NewQYGL51BCLogic(r.Context(), svcCtx)
|
||||
resp, err := l.QYGL51BC(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package QYGL
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/QYGL"
|
||||
@ -22,9 +23,9 @@ func QYGL6F2DHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := QYGL.NewQYGL6F2DLogic(r.Context(), svcCtx)
|
||||
resp, err := l.QYGL6F2D(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package QYGL
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/QYGL"
|
||||
@ -22,9 +23,9 @@ func QYGL8261Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := QYGL.NewQYGL8261Logic(r.Context(), svcCtx)
|
||||
resp, err := l.QYGL8261(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package QYGL
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/QYGL"
|
||||
@ -22,9 +23,9 @@ func QYGLB4C0Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := QYGL.NewQYGLB4C0Logic(r.Context(), svcCtx)
|
||||
resp, err := l.QYGLB4C0(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package YYSY
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/YYSY"
|
||||
@ -22,9 +23,9 @@ func YYSY09CDHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := YYSY.NewYYSY09CDLogic(r.Context(), svcCtx)
|
||||
resp, err := l.YYSY09CD(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package YYSY
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/YYSY"
|
||||
@ -22,9 +23,9 @@ func YYSY4B37Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := YYSY.NewYYSY4B37Logic(r.Context(), svcCtx)
|
||||
resp, err := l.YYSY4B37(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package YYSY
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/YYSY"
|
||||
@ -22,9 +23,9 @@ func YYSY6F2EHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := YYSY.NewYYSY6F2ELogic(r.Context(), svcCtx)
|
||||
resp, err := l.YYSY6F2E(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package YYSY
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/YYSY"
|
||||
@ -22,9 +23,9 @@ func YYSYBE08Handler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := YYSY.NewYYSYBE08Logic(r.Context(), svcCtx)
|
||||
resp, err := l.YYSYBE08(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package YYSY
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/YYSY"
|
||||
@ -22,9 +23,9 @@ func YYSYD50FHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := YYSY.NewYYSYD50FLogic(r.Context(), svcCtx)
|
||||
resp, err := l.YYSYD50F(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package YYSY
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"tianyuan-api/pkg/response"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/api/internal/logic/YYSY"
|
||||
@ -22,9 +23,9 @@ func YYSYF7DBHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
l := YYSY.NewYYSYF7DBLogic(r.Context(), svcCtx)
|
||||
resp, err := l.YYSYF7DB(&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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,9 +79,7 @@ func (l *FLXG162ALogic) FLXG162A(req *types.Request) (resp *types.Response, err
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||
l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
} else {
|
||||
if respData.Data.Code != "00" && respData.Data.Code != "100002" {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
|
@ -80,10 +80,8 @@ func (l *FLXG3D56Logic) FLXG3D56(req *types.Request) (resp *types.Response, err
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||
l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
} else {
|
||||
return nil, errs.ErrSystem
|
||||
if respData.Data.Code != "00" && respData.Data.Code != "100002" {
|
||||
return nil, errs.ErrDataSource
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
if aesEncrypt != nil {
|
||||
|
@ -79,9 +79,7 @@ func (l *FLXG54F5Logic) FLXG54F5(req *types.Request) (resp *types.Response, err
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
|
||||
if respData.Code == "0000" {
|
||||
l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||
} else {
|
||||
if respData.Code != "0000" {
|
||||
return nil, errs.ErrSystem
|
||||
}
|
||||
encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||
|
@ -45,6 +45,8 @@ func sendResponse(ctx context.Context, w http.ResponseWriter, code int, message
|
||||
// 响应成功
|
||||
func Success(ctx context.Context, w http.ResponseWriter, data interface{}) {
|
||||
ctx = context.WithValue(ctx, "status", "success")
|
||||
ctx = context.WithValue(ctx, "Charges", true)
|
||||
|
||||
sendResponse(ctx, w, 0, "success", data)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user