Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
@@ -18,13 +18,14 @@ import (
|
||||
"gorm.io/gorm"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 这里请求的py接口返回数据
|
||||
type pythonApiRsp struct {
|
||||
Id string `json:"id"` //物料模板的id
|
||||
LogoUrl string `json:"logo_url"` //logo地址
|
||||
result string `json:"result"` //图片base64
|
||||
Result string `json:"result"` //图片base64
|
||||
}
|
||||
|
||||
// 消费渲染需要组装的数据
|
||||
@@ -32,6 +33,11 @@ type MqConsumerRenderAssemble struct {
|
||||
}
|
||||
|
||||
func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logx.Error("MqConsumerRenderAssemble panic:", err)
|
||||
}
|
||||
}()
|
||||
logx.Info("收到需要组装的消息:", string(data))
|
||||
var parseInfo websocket_data.AssembleRenderData
|
||||
if err := json.Unmarshal(data, &parseInfo); err != nil {
|
||||
@@ -177,10 +183,10 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
|
||||
//需要替换的参数
|
||||
replaceData := map[string]interface{}{
|
||||
"logo_url": parseInfo.RenderData.Logo,
|
||||
"website": "",
|
||||
"slogan": "",
|
||||
"address": "",
|
||||
"phone": "",
|
||||
"website": parseInfo.RenderData.Website,
|
||||
"slogan": parseInfo.RenderData.Slogan,
|
||||
"address": parseInfo.RenderData.Address,
|
||||
"phone": parseInfo.RenderData.Phone,
|
||||
"colors": []string{},
|
||||
"template_tagid": []string{"b1a"},
|
||||
"is_crop": false,
|
||||
@@ -227,7 +233,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
|
||||
/*f, _ := os.Create("a.txt")
|
||||
defer f.Close()
|
||||
f.Write(postData)*/
|
||||
httpRsp, err := curl.ApiCall(url, "POST", header, bytes.NewReader(postData), 20)
|
||||
httpRsp, err := curl.ApiCall(url, "POST", header, bytes.NewReader(postData), time.Second*20)
|
||||
if err != nil {
|
||||
logx.Error("failed to combine logo:", err)
|
||||
return "", err
|
||||
@@ -243,6 +249,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
|
||||
logx.Error("failed to parse python api rsp:", err)
|
||||
return "", err
|
||||
}
|
||||
//fmt.Println("××××××××××××××××××××:", pythonApiInfo)
|
||||
//上传刀版图
|
||||
var upload = file.Upload{
|
||||
Ctx: ctx,
|
||||
@@ -251,7 +258,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo
|
||||
}
|
||||
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
||||
FileHash: combineHash,
|
||||
FileData: pythonApiInfo.result,
|
||||
FileData: pythonApiInfo.Result,
|
||||
UploadBucket: 1,
|
||||
ApiType: 2,
|
||||
UserId: parseInfo.RenderData.UserId,
|
||||
|
||||
Reference in New Issue
Block a user