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