Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
Hiven 2023-08-15 10:58:29 +08:00
commit aa3525c7ce
4 changed files with 61 additions and 9 deletions

View File

@ -8,10 +8,13 @@ import (
"fusenapi/constants"
"fusenapi/initalize"
"fusenapi/server/render/internal/svc"
"fusenapi/service/repositories"
"fusenapi/utils/hash"
"fusenapi/utils/websocket_data"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
"strconv"
"time"
)
// 这里请求的py接口返回数据
@ -58,8 +61,45 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
logx.Error("failed to get template info:", err)
return nil //不返回错误就删除消息
}
time.Now().UTC()
resourceKey := hash.JsonHashKey(parseInfo)
combineParam := map[string]interface{}{
"logo_url": parseInfo.RenderData.Logo,
"website": "",
"slogan": "",
"address": "",
"phone": "",
"colors": []string{},
"template_tagid": "b1a",
"is_crop": false,
"shape": "rectangle",
"ratio": 0,
"line": "",
"other": "",
"other1": "",
}
combineParamBytes, _ := json.Marshal(combineParam)
//获取刀版图
res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{
ResourceKey: resourceKey,
TemplateId: productTemplate.Id,
CombineParam: string(combineParamBytes),
UserId: parseInfo.RenderData.UserId,
GuestId: parseInfo.RenderData.GuestId,
})
if err != nil {
logx.Error("合成刀版图失败:", err)
return nil
}
combineImage := "" //刀版图
if res != nil && res.ResourceUrl != nil {
combineImage = *res.ResourceUrl
} else {
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
return nil
}
logx.Info("合成刀版图成功")
//获取渲染设置信息
element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId)
if err != nil {

View File

@ -13,5 +13,8 @@ AWS:
AccessKeyID: AKIAZB2JKUXDPNRP4YT2
Secret: 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
Token:
PythonApi: #python接口
CombineImageUrl: http://18.119.109.254:8999/LogoCombine #合成刀版图接口
BLMService:
Url: "http://18.119.109.254:8999"
LogoCombine:
#Url: "http://192.168.1.7:8999/LogoCombine"
Url: "http://18.119.109.254:8999/LogoCombine"

View File

@ -19,7 +19,10 @@ type Config struct {
}
}
}
PythonApi struct {
CombineImageUrl string //合图url
BLMService struct {
Url string
LogoCombine struct {
Url string
}
}
}

View File

@ -17,11 +17,12 @@ import (
)
type ServiceContext struct {
Config config.Config
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
RabbitMq *initalize.RabbitMqHandle
AwsSession *session.Session
Config config.Config
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
RabbitMq *initalize.RabbitMqHandle
AwsSession *session.Session
Repositories *initalize.Repositories
}
func NewServiceContext(c config.Config) *ServiceContext {
@ -34,6 +35,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: initalize.InitMysql(c.SourceMysql),
BLMServiceUrl: &c.BLMService.Url,
AwsSession: session.Must(session.NewSession(&config)),
}),
}
}