aa
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
@@ -173,7 +171,7 @@ success:
|
||||
{
|
||||
callResult.Code = model.ErrCodeSuccess
|
||||
if len(result) > 0 {
|
||||
callResult.Data = result[0].String()
|
||||
callResult.Data = result[0].Interface()
|
||||
}
|
||||
c.Data["json"] = callResult
|
||||
c.ServeJSON()
|
||||
@@ -356,35 +354,34 @@ func (c *ApiController) DoPrint(dataMap map[string]interface{}) (data, errCode s
|
||||
}
|
||||
|
||||
//获取某打印消息
|
||||
func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (data, errCode string, err error) {
|
||||
func (c *ApiController) GetPrintMsg(dataMap map[string]interface{}) (printMsg *cms.GetPrintMsgResult, 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 buildParamErrCodeAndErr(keyMsgID)
|
||||
return printMsg, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
|
||||
} else {
|
||||
if msgID = dataMap[keyMsgID].(string); msgID == "" {
|
||||
return buildParamErrCodeAndErr(keyMsgID)
|
||||
return printMsg, model.ErrCodeOpenAPIParamErrNormal, fmt.Errorf("参数[%s]错误,请传入正确的值!", keyMsgID)
|
||||
}
|
||||
}
|
||||
appID = utils.Str2Int(dataMap[keyAppID].(string))
|
||||
if printMsg, err := cms.GetPrintMsg(appID, msgID); err != nil {
|
||||
return "", model.ErrCodeGeneralFailed, err
|
||||
if printMsg, err = cms.GetPrintMsg(appID, msgID); err != nil {
|
||||
return printMsg, model.ErrCodeGeneralFailed, err
|
||||
} else if printMsg == nil {
|
||||
return "", model.ErrCodeGeneralFailed, fmt.Errorf("未查询到该消息! msg_id: %v", msgID)
|
||||
return printMsg, model.ErrCodeGeneralFailed, fmt.Errorf("未查询到该消息! msg_id: %v", msgID)
|
||||
} else {
|
||||
bf := bytes.NewBuffer([]byte{})
|
||||
jsonEncoder := json.NewEncoder(bf)
|
||||
jsonEncoder.SetEscapeHTML(false)
|
||||
if err2 := jsonEncoder.Encode(printMsg); err2 == nil {
|
||||
data = strings.Replace(bf.String(), "\n", "", strings.LastIndex(bf.String(), "\n"))
|
||||
} else {
|
||||
return "", model.ErrCodeGeneralFailed, err
|
||||
}
|
||||
//bf := bytes.NewBuffer([]byte{})
|
||||
//jsonEncoder := json.NewEncoder(bf)
|
||||
//jsonEncoder.SetEscapeHTML(false)
|
||||
//if err2 := jsonEncoder.Encode(printMsg); err2 == nil {
|
||||
// data = strings.Replace(bf.String(), "\n", "", strings.LastIndex(bf.String(), "\n"))
|
||||
//} else {
|
||||
return printMsg, model.ErrCodeGeneralFailed, err
|
||||
}
|
||||
return data, errCode, err
|
||||
return printMsg, errCode, err
|
||||
}
|
||||
func unicode2utf8(source string) string {
|
||||
var res = []string{""}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
)
|
||||
|
||||
type CallResult struct {
|
||||
Code string `json:"code"`
|
||||
Desc string `json:"desc"`
|
||||
Data string `json:"data"`
|
||||
Code string `json:"code"`
|
||||
Desc string `json:"desc"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
func buildParamRequiredErr(str []string) (err error) {
|
||||
|
||||
Reference in New Issue
Block a user