fix:请求算法,添加错误提示

This commit is contained in:
momo 2023-08-25 10:37:07 +08:00
parent 4fb4def7d8
commit 12097036ba

View File

@ -96,13 +96,16 @@ type (
LogoUrl string `json:"logo_url"` // 合图参数
}
LogoCombineRes struct {
ResourceId string
ResourceUrl *string
Metadata *string
ResourceId string
ResourceUrl *string
Metadata *string
DiffTimeLogoCombine time.Duration
DiffTimeUploadFile time.Duration
}
)
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
logc.Infof(ctx, "合图--处理--开始时间:%v", time.Now().UTC())
// 查询logo最新基础信息
var metadata *string
var logoUrl *string
@ -194,13 +197,18 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
postMap["module_data"] = moduleDataMap
postMap["param_data"] = combineParam
logc.Infof(ctx, "算法请求--合图--开始时间:%v", time.Now().UTC())
logc.Infof(ctx, "合图--算法请求--合图--开始时间:%v", time.Now().UTC())
var startTimeLogoCombine = time.Now() //合图--处理--开始时间
var resultBLM constants.BLMServiceUrlResult
err = curl.NewClient(ctx, &curl.Config{
BaseUrl: *l.BLMServiceUrl,
Url: constants.BLMServiceUrlLogoCombine,
}).PostJson(postMap, &resultBLM)
logc.Infof(ctx, "算法请求--合图--结束时间:%v", time.Now().UTC())
logc.Infof(ctx, "合图--算法请求--合图--结束时间:%v", time.Now().UTC())
endTimeLogoCombine := time.Now() //合图--处理--开始时间
diffTimeLogoCombine := endTimeLogoCombine.Sub(startTimeLogoCombine) //合图--处理--中间差
if err != nil {
logx.Error(err)
@ -229,6 +237,10 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
MysqlConn: l.MysqlConn,
AwsSession: l.AwsSession,
}
logc.Infof(ctx, "合图--上传文件--开始时间:%v", time.Now().UTC())
var startTimeUploadFile = time.Now() //合图--上传--开始时间
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
Source: "combine-image",
FileHash: resourceId,
@ -238,13 +250,21 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
UserId: in.UserId,
GuestId: in.GuestId,
})
logc.Infof(ctx, "合图--上传文件--开始时间:%v", time.Now().UTC())
endTimeUploadFile := time.Now() //合图--处理--开始时间
diffTimeUploadFile := endTimeUploadFile.Sub(startTimeUploadFile) //合图--处理--中间差
if err != nil {
logx.Error(err)
return nil, err
}
logc.Infof(ctx, "合图--处理--结束时间:%v", time.Now().UTC())
return &LogoCombineRes{
ResourceId: uploadRes.ResourceId,
ResourceUrl: &uploadRes.ResourceUrl,
ResourceId: uploadRes.ResourceId,
ResourceUrl: &uploadRes.ResourceUrl,
DiffTimeLogoCombine: diffTimeLogoCombine,
DiffTimeUploadFile: diffTimeUploadFile,
}, nil
}