Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
4523274443
|
@ -15,8 +15,8 @@ AWS:
|
||||||
Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm
|
Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm
|
||||||
Token:
|
Token:
|
||||||
BLMService:
|
BLMService:
|
||||||
# Url: "http://18.119.109.254:8999"
|
Url: "http://18.119.109.254:8999"
|
||||||
Url: "http://192.168.1.7:8999"
|
# Url: "http://192.168.1.7:8999"
|
||||||
LogoCombine:
|
LogoCombine:
|
||||||
#Url: "http://192.168.1.7:8999/LogoCombine"
|
#Url: "http://192.168.1.7:8999/LogoCombine"
|
||||||
Url: "http://18.119.109.254:8999/LogoCombine"
|
Url: "http://18.119.109.254:8999/LogoCombine"
|
|
@ -2,6 +2,7 @@ Name: upload
|
||||||
Host: 0.0.0.0
|
Host: 0.0.0.0
|
||||||
Port: 9912
|
Port: 9912
|
||||||
Timeout: 150000 #服务超时时间
|
Timeout: 150000 #服务超时时间
|
||||||
|
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:
|
||||||
|
|
|
@ -95,6 +95,12 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
||||||
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image")
|
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 限制上传文件大小 50k
|
||||||
|
maxSize := 100 * 1024
|
||||||
|
if fileHeader.Size > int64(maxSize) {
|
||||||
|
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,The file size exceeds the maximum limit of 100k")
|
||||||
|
}
|
||||||
|
|
||||||
// 读取数据流
|
// 读取数据流
|
||||||
ioData, err := io.ReadAll(fileObject)
|
ioData, err := io.ReadAll(fileObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -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