|
|
|
@@ -3,7 +3,9 @@ package com.iformall.controller; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.file.aliyun.AliyunOSS; |
|
|
|
import com.iformall.file.wx.MerchantMediaUpload; |
|
|
|
import com.iformall.utils.ImgUtil; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
@@ -34,6 +36,9 @@ public class WxMerchantMediaUploadController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private AliyunOSS aliyunOSS; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MerchantMediaUpload mediaUpload; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 图片上传 |
|
|
|
@@ -85,10 +90,23 @@ public class WxMerchantMediaUploadController extends BaseController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ResultData data = aliyunOSS.uploadFile(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); |
|
|
|
return data; |
|
|
|
String url = aliyunOSS.upload(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); |
|
|
|
if(StringUtils.isBlank(url)){ |
|
|
|
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"上传图片异常"); |
|
|
|
} |
|
|
|
String mediaId = mediaUpload.mediaUpload(tenantEntity.getTenantId(), fileFormat, multiReq.getInputStream()); |
|
|
|
if(StringUtils.isBlank(mediaId)){ |
|
|
|
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"上传微信异常"); |
|
|
|
} |
|
|
|
Map<String,String> map = new HashMap<>(); |
|
|
|
map.put("url",url); |
|
|
|
map.put("mediaId",mediaId); |
|
|
|
return new ResultData(map); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch(MallinkException e){ |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(e.getErrorCode(),e.getMessage()); |
|
|
|
}catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); |
|
|
|
} |
|
|
|
|