This commit is contained in:
suyl
2021-07-15 10:25:26 +08:00
parent 647ed0a861
commit 802366f44c

View File

@@ -1,7 +1,9 @@
package controllers
import (
"bytes"
"crypto/md5"
"encoding/json"
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
@@ -355,28 +357,33 @@ func (c *ApiController) DoPrint(dataMap map[string]interface{}) (data, errCode s
}
//获取某打印消息
func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (printMsg *cms.GetPrintMsgResult, errCode string, err error) {
func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (data map[string]interface{}, errCode string, err error) {
var (
msgID string
appID int
)
globals.SugarLogger.Debugf("Begin API GetPrintMsg data: [%v]", utils.Format4Output(dataMap, false))
if _, ok := dataMap[keyMsgID].(string); !ok {
return printMsg, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
return data, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
} else {
if msgID = dataMap[keyMsgID].(string); msgID == "" {
return printMsg, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
return data, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
}
}
appID = utils.Str2Int(dataMap[keyAppID].(string))
if printMsg, err = cms.GetPrintMsg(appID, msgID); err != nil {
return printMsg, model.ErrCodeGeneralFailed, err
if printMsg, err := cms.GetPrintMsg(appID, msgID); err != nil {
return data, model.ErrCodeGeneralFailed, err
} else if printMsg == nil {
return printMsg, model.ErrCodeGeneralFailed, fmt.Errorf("未查询到该消息! msg_id: %v", msgID)
return data, model.ErrCodeGeneralFailed, fmt.Errorf("未查询到该消息! msg_id: %v", msgID)
} else {
return printMsg, model.ErrCodeGeneralFailed, err
bf := bytes.NewBuffer([]byte{})
jsonEncoder := json.NewEncoder(bf)
jsonEncoder.SetEscapeHTML(false)
jsonEncoder.Encode(printMsg)
json.Unmarshal([]byte(bf.String()), &data)
return data, model.ErrCodeGeneralFailed, err
}
return printMsg, errCode, err
return data, errCode, err
}
func unicode2utf8(source string) string {
var res = []string{""}