fix
This commit is contained in:
parent
94d93bf390
commit
5e251e9868
|
@ -2,7 +2,7 @@ Name: upload
|
||||||
Host: 0.0.0.0
|
Host: 0.0.0.0
|
||||||
Port: 9912
|
Port: 9912
|
||||||
Timeout: 150000 #服务超时时间
|
Timeout: 150000 #服务超时时间
|
||||||
MaxBytes: 8388608 #传输字节大小
|
MaxBytes: 104857600 #传输字节大小
|
||||||
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
|
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
|
||||||
Env: "test"
|
Env: "test"
|
||||||
Auth:
|
Auth:
|
||||||
|
|
|
@ -257,15 +257,46 @@ type (
|
||||||
IsmaxProportion bool
|
IsmaxProportion bool
|
||||||
ImgColor []string
|
ImgColor []string
|
||||||
}
|
}
|
||||||
|
LogoStandardMetaData struct {
|
||||||
|
Param LogoStandardReq `json:"param"`
|
||||||
|
Result LogoStandardRes `json:"result"`
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/* 图片裁剪 */
|
/* 图片裁剪 */
|
||||||
func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) {
|
func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) {
|
||||||
|
var ismaxProportion bool
|
||||||
|
var imgColor []string
|
||||||
|
var logoStandardMetaData LogoStandardMetaData
|
||||||
|
|
||||||
var hashKeyDataMap map[string]interface{}
|
var hashKeyDataMap map[string]interface{}
|
||||||
hashKeyDataB, _ := json.Marshal(in)
|
hashKeyDataB, _ := json.Marshal(in)
|
||||||
json.Unmarshal(hashKeyDataB, &hashKeyDataMap)
|
json.Unmarshal(hashKeyDataB, &hashKeyDataMap)
|
||||||
var resourceId string = hash.JsonHashKey(hashKeyDataMap)
|
var resourceId string = hash.JsonHashKey(hashKeyDataMap)
|
||||||
|
|
||||||
|
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
|
||||||
|
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
|
||||||
|
if err == nil && resourceInfo.ResourceId != "" {
|
||||||
|
if resourceInfo.Metadata != nil {
|
||||||
|
json.Unmarshal([]byte(*resourceInfo.Metadata), &logoStandardMetaData)
|
||||||
|
}
|
||||||
|
// 取出参数
|
||||||
|
|
||||||
|
return &LogoStandardRes{
|
||||||
|
ResourceId: resourceInfo.ResourceId,
|
||||||
|
ResourceUrl: *resourceInfo.ResourceUrl,
|
||||||
|
IsmaxProportion: ismaxProportion,
|
||||||
|
ImgColor: imgColor,
|
||||||
|
}, nil
|
||||||
|
} else {
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var postMap = make(map[string]interface{}, 5)
|
var postMap = make(map[string]interface{}, 5)
|
||||||
postMap["is_remove_bg"] = in.IsRemoveBg
|
postMap["is_remove_bg"] = in.IsRemoveBg
|
||||||
postMap["logo_file"] = in.LogoFile
|
postMap["logo_file"] = in.LogoFile
|
||||||
|
@ -319,12 +350,12 @@ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardR
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}'
|
//$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}'
|
||||||
|
|
||||||
var fileBase = resultData["nobg_url"].(string)
|
var fileBase = resultData["nobg_url"].(string)
|
||||||
var ismaxProportion = resultData["ismax_proportion"].(bool)
|
ismaxProportion = resultData["ismax_proportion"].(bool)
|
||||||
|
|
||||||
var imgColor []string
|
|
||||||
for _, v := range resultData["img_color"].([]interface{}) {
|
for _, v := range resultData["img_color"].([]interface{}) {
|
||||||
imgColor = append(imgColor, v.(string))
|
imgColor = append(imgColor, v.(string))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user