回调
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 30s
CI / admin (push) Successful in 22s
CI / bff (push) Successful in 39s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 19s
CI / express (push) Successful in 17s
CI / product (push) Successful in 16s
CI / record (push) Successful in 17s
CI / sale (push) Successful in 16s
CI / task (push) Successful in 16s
CI / user (push) Successful in 17s
CI / wecom (push) Successful in 18s

This commit is contained in:
2026-09-05 13:41:13 +08:00
parent be18a48148
commit 462d142a4c
9 changed files with 254 additions and 83 deletions
+7 -6
View File
@@ -14,6 +14,7 @@ import (
"time"
jsoniter "github.com/json-iterator/go"
"github.com/zeromicro/go-zero/core/logx"
"github.com/gin-gonic/gin"
"github.com/xuri/excelize/v2"
@@ -245,7 +246,7 @@ func RoundMoney(amount float64) float64 {
func Decrypt(str string) (string, Error) {
str, err := Crypto{}.AESDecryptECB(str)
if err != nil {
Logger.Error("decrypt str error", str, err)
logx.Error("decrypt str error", str, err)
return str, err
}
@@ -259,7 +260,7 @@ func DecryptMobile(mobile string) string {
mobile, err := Decrypt(mobile)
if err != nil {
Logger.Error("decrypt mobile error", mobile, err)
logx.Error("decrypt mobile error", mobile, err)
return mobile
}
@@ -488,12 +489,12 @@ func Unique(s []string) []string {
func MapToStruct(data map[string]interface{}, target interface{}) error {
jsonData, err := jsoniter.Marshal(data) // 将 map 转换为 JSON 字节切片
if err != nil {
Logger.Error("Error marshalling map to JSON:", err)
logx.Error("Error marshalling map to JSON:", err)
return err
}
err = jsoniter.Unmarshal(jsonData, &target) // 将 JSON 字节切片解析到结构体中
if err != nil {
Logger.Error("Error unmarshalling JSON:", err)
logx.Error("Error unmarshalling JSON:", err)
return err
}
@@ -503,14 +504,14 @@ func MapToStruct(data map[string]interface{}, target interface{}) error {
func JsonStringToStruct(jsonStr string, v interface{}) bool {
// 1. 校验入参:确保v是指针类型(否则json.Unmarshal无法工作)
if v == nil {
Logger.Error("传入的结构体指针不能为nil")
logx.Error("传入的结构体指针不能为nil")
return false
}
// 2. 将JSON字符串转为字节数组,执行解析
err := jsoniter.Unmarshal([]byte(jsonStr), v)
if err != nil {
Logger.Error("JSON解析失败: ", err, jsonStr)
logx.Error("JSON解析失败: ", err, jsonStr)
return false
}