From f0ea41056c26e8fcfd08e2ac9564cfedaeb59f7a Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 26 Jan 2026 14:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=A7=A3=E5=AF=86=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/shiyan/maptostruct/shiyan.go | 25 +++++++++++++++++++++++++ api/shiyan/maptostruct/type.go | 6 ++++++ api/version1/customerApp/companyduty.go | 2 +- apirouter/apishiyan/maptostruct.go | 1 + overall/publicmethod/formatOutput.go | 20 ++++++++++++++++++++ overall/publicmethod/newSm4.go | 3 --- 6 files changed, 53 insertions(+), 4 deletions(-) diff --git a/api/shiyan/maptostruct/shiyan.go b/api/shiyan/maptostruct/shiyan.go index 4d6ad89..51a2f1c 100644 --- a/api/shiyan/maptostruct/shiyan.go +++ b/api/shiyan/maptostruct/shiyan.go @@ -935,3 +935,28 @@ func generateSchedule(startDate time.Time, numDays int) []Shift { func (a *ApiMethod) JiaoZhengTableWord(c *gin.Context) { } + +/* +* +@ 作者: 秦东 +@ 时间: 2026-01-26 14:25:42 +@ 功能: SM4解密函数 +*/ +func (a *ApiMethod) Sm4JiemiVal(c *gin.Context) { + var requestData JimiToSm4 + err := c.ShouldBindJSON(&requestData) + if requestData.AuthKey == "" { + publicmethod.ResultNoJiami(100, err, c) + return + } + if requestData.Data == "" { + publicmethod.ResultNoJiami(100, err, c) + return + } + jimi, err := publicmethod.SM4DecryptNew(requestData.Data, requestData.AuthKey) + fmt.Printf("----------------->%v---------->%v\n\n", err, string(jimi)) + var sendMap map[string]interface{} + err = json.Unmarshal(jimi, &sendMap) + fmt.Printf("----------------->%v--------->%v\n\n", err, sendMap) + publicmethod.ResultNoJiami(0, sendMap, c) +} diff --git a/api/shiyan/maptostruct/type.go b/api/shiyan/maptostruct/type.go index 0aa5ab1..a064978 100644 --- a/api/shiyan/maptostruct/type.go +++ b/api/shiyan/maptostruct/type.go @@ -131,3 +131,9 @@ type PersonalityTestOut struct { Name string `json:"name"` Address string `json:"address"` } + +// 解密 +type JimiToSm4 struct { + AuthKey string `json:"authKey"` + Data string `json:"data"` +} diff --git a/api/version1/customerApp/companyduty.go b/api/version1/customerApp/companyduty.go index 48a01e1..b51a4f7 100644 --- a/api/version1/customerApp/companyduty.go +++ b/api/version1/customerApp/companyduty.go @@ -65,7 +65,7 @@ func (a *ApiMethod) CompanyDutyInit(c *gin.Context) { monthAllDay = append(monthAllDay, fmt.Sprintf("%v日", i)) } - myPower := publicmethod.GetMyMenuPower(userCont.Key, "38") + myPower := publicmethod.GetMyMenuPower(userCont.Key, "167") //角色权限范围判定 //1:本岗位;2:本部门;3:本分部;4:指定行政组织;5:所有 // switch SearchRoleLevev(userCont.Role) { diff --git a/apirouter/apishiyan/maptostruct.go b/apirouter/apishiyan/maptostruct.go index 7a19026..72d3d86 100644 --- a/apirouter/apishiyan/maptostruct.go +++ b/apirouter/apishiyan/maptostruct.go @@ -47,6 +47,7 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { apiRouter.POST("setUpWorkWatch", methodBinding.SetUpWorkWatch) //测试通过企业微信获取人员 apiRouter.POST("workTimeSortTP", methodBinding.WorkTimeSortTP) //工作段排序 + apiRouter.POST("sm4JiemiVal", methodBinding.Sm4JiemiVal) //SM4解密函数 } } diff --git a/overall/publicmethod/formatOutput.go b/overall/publicmethod/formatOutput.go index fac3c82..0a1dcdb 100644 --- a/overall/publicmethod/formatOutput.go +++ b/overall/publicmethod/formatOutput.go @@ -298,3 +298,23 @@ func ReceiveData(c *gin.Context) ([]byte, error) { } return json.Marshal(val) } + +// 格式化输出 +func ResultNoJiami(code int, data interface{}, c *gin.Context, msgAry ...string) { + var msg string + if _, isTrue := ErrorCodeMsg[code]; isTrue { + msg = ErrorCodeMsg[code] + } + if len(msgAry) > 0 { + for _, v := range msgAry { + if msg == "" { + msg = fmt.Sprintf("%v", v) + } else { + msg = fmt.Sprintf("%v。%v", msg, v) + } + + } + } + c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据 + +} diff --git a/overall/publicmethod/newSm4.go b/overall/publicmethod/newSm4.go index e4d0482..8bfd483 100644 --- a/overall/publicmethod/newSm4.go +++ b/overall/publicmethod/newSm4.go @@ -97,9 +97,6 @@ func SM4DecryptNew(data, sm4IvStr string, key ...string) ([]byte, error) { if len(key) > 0 { SM4Key = strings.Join(key, "-") } - if len(key) > 0 { - SM4Key = strings.Join(key, "-") - } SM4Key = ProcessString(SM4Key, 16, "s") //sm4随机安全码 SM4Iv := overall.CONSTANT_CONFIG.Appsetup.Sm4Token