6 changed files with 85 additions and 3 deletions
@ -0,0 +1,23 @@ |
|||||
|
package com.elink.esua.epdc.feign; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.UploadDTO; |
||||
|
import com.elink.esua.epdc.feign.fallback.OssFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestPart; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
/** |
||||
|
* 文件对象模块 |
||||
|
* @Author LC |
||||
|
* @Date 2019/9/8 18:24 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_OSS_SERVER, fallback = OssFeignClientFallback.class) |
||||
|
public interface OssFeignClient { |
||||
|
|
||||
|
@PostMapping(value = "oss/file/upload", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||
|
Result<UploadDTO> upload(@RequestPart("file") MultipartFile file); |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.elink.esua.epdc.feign.fallback; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.UploadDTO; |
||||
|
import com.elink.esua.epdc.feign.OssFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
/** |
||||
|
* 文件对象模块 |
||||
|
* @Author LC |
||||
|
* @Date 2019/9/8 18:25 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class OssFeignClientFallback implements OssFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result<UploadDTO> upload(MultipartFile file) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_OSS_SERVER, "upload", file.getOriginalFilename()); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue