You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.4 KiB
129 lines
3.4 KiB
package maptostruct
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"fmt"
|
|
"key_performance_indicators/middleware/wechatapp/wechatcallback"
|
|
"key_performance_indicators/models/modelshr"
|
|
"key_performance_indicators/overall"
|
|
"key_performance_indicators/overall/publicmethod"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// map 装 struct 实验
|
|
func (a *ApiMethod) MapToStructShiyan(c *gin.Context) {
|
|
mapShiyan := map[string]string{
|
|
"name": "秦东",
|
|
"age": "1",
|
|
"time": "456313",
|
|
"time1": "45631321654654",
|
|
"time2": "4.5631321654654",
|
|
"time3": "45.631321654654",
|
|
}
|
|
var shiyanVal shiyanType
|
|
err := publicmethod.MapToStruct(mapShiyan, &shiyanVal, "json")
|
|
if err != nil {
|
|
publicmethod.Result(1, err.Error(), c)
|
|
return
|
|
}
|
|
fmt.Printf("shiyanType---->%v\n", shiyanVal)
|
|
publicmethod.Result(0, shiyanVal, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-10-06 11:08:11
|
|
@ 功能: 模拟回调
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SimulationCallBack(c *gin.Context) {
|
|
var receivedValue callBackCont
|
|
c.ShouldBindJSON(&receivedValue)
|
|
|
|
var jieMiCont wechatcallback.DecryptMsgCont
|
|
jieMiCont.MsgSignature = receivedValue.MsgSignature
|
|
jieMiCont.Timestamp = receivedValue.Timestamp
|
|
jieMiCont.Nonce = receivedValue.Nonce
|
|
jieMiCont.ToUsername = receivedValue.ToUsername
|
|
jieMiCont.Agentid = receivedValue.Agentid
|
|
jieMiCont.Encrypt = receivedValue.Encrypt
|
|
decryptMsgCont, jsonErr := jieMiCont.DecryptMsgInfo()
|
|
fmt.Printf("Xml----->%v----->%v\n\n", string(decryptMsgCont), jsonErr)
|
|
|
|
var msgCont wechatcallback.MsgContentXml
|
|
errXml := xml.Unmarshal(decryptMsgCont, &msgCont)
|
|
if errXml != nil {
|
|
fmt.Printf("回调事件失败!%v\n", errXml)
|
|
return
|
|
}
|
|
fmt.Printf("XmlCont----->%v\n\nwxcptJson----->%v\n\n", string(decryptMsgCont), msgCont)
|
|
|
|
switch msgCont.MsgType {
|
|
/*消息格式类型
|
|
*/
|
|
case "text": //文本
|
|
case "image": //图片
|
|
case "voice": //语音
|
|
case "video": //视频
|
|
case "location": //位置
|
|
wechatcallback.GeographicalPosition(decryptMsgCont)
|
|
case "link": //链接
|
|
/*事件格式类型*/
|
|
case "event":
|
|
/*
|
|
事件附属格式
|
|
*/
|
|
wechatcallback.EventProcessing(decryptMsgCont, jieMiCont, c)
|
|
// return
|
|
default:
|
|
}
|
|
|
|
// outData := publicmethod.MapOut[string]()
|
|
// outData["Xml"] = string(decryptMsgCont)
|
|
// outData["jieMiCont"] = jieMiCont
|
|
// outData["jsonErr"] = jsonErr
|
|
// outData["msgCont"] = msgCont
|
|
// publicmethod.Result(0, outData, c)
|
|
}
|
|
|
|
// 设置HR系统对接账号和密码
|
|
func (a *ApiMethod) SetUpHrSystem(c *gin.Context) {
|
|
var receivedValue hrUsernameAndPassword
|
|
err := c.ShouldBindJSON(&receivedValue)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
var hrCont modelshr.EmpowerUser
|
|
err = hrCont.GetCont(map[string]interface{}{"`userkey`": receivedValue.Username}, "`id`")
|
|
if err == nil {
|
|
publicmethod.Result(1, err, c, "该授权已经存在!请不要重复!")
|
|
return
|
|
}
|
|
//密码加密
|
|
var passWordMd5 publicmethod.Md5Encryption
|
|
passWordMd5.Md5EncryptionInit(receivedValue.Password)
|
|
passWordMd5Str := passWordMd5.Md5EncryptionAlgorithm()
|
|
hrCont.UserKey = receivedValue.Username
|
|
hrCont.Password = passWordMd5Str
|
|
hrCont.Name = receivedValue.Name
|
|
hrCont.State = 1
|
|
hrCont.Time = time.Now().Unix()
|
|
hrCont.EiteTime = time.Now().Unix()
|
|
hrCont.VerificationCode = receivedValue.VerificationCode
|
|
err = overall.CONSTANT_DB_HR.Create(&hrCont).Error
|
|
if err != nil {
|
|
publicmethod.Result(104, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|