diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 37f60999..8f8afac9 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -2,7 +2,7 @@ Name: upload Host: 0.0.0.0 Port: 9912 Timeout: 150000 #服务超时时间 -MaxBytes: 8388608 #传输字节大小 +MaxBytes: 104857600 #传输字节大小 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Env: "test" Auth: diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index b5ff1763..305ffe2c 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -257,15 +257,46 @@ type ( IsmaxProportion bool ImgColor []string } + LogoStandardMetaData struct { + Param LogoStandardReq `json:"param"` + Result LogoStandardRes `json:"result"` + } ) /* 图片裁剪 */ 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{} hashKeyDataB, _ := json.Marshal(in) json.Unmarshal(hashKeyDataB, &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) postMap["is_remove_bg"] = in.IsRemoveBg postMap["logo_file"] = in.LogoFile @@ -319,12 +350,12 @@ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardR logx.Error(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"]}' 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{}) { imgColor = append(imgColor, v.(string)) }