5 changed files with 103 additions and 0 deletions
@ -0,0 +1,38 @@
|
||||
package org.springblade.resource.feign; |
||||
|
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.oss.model.BladeFile; |
||||
import org.springblade.core.sms.model.SmsResponse; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RequestPart; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* 文件上传feign |
||||
*/ |
||||
@FeignClient( |
||||
value = AppConstant.APPLICATION_RESOURCE_NAME |
||||
, |
||||
fallback = IOssClientFallback.class |
||||
) |
||||
public interface IOssClient { |
||||
|
||||
String API_PREFIX = "/client"; |
||||
// 文件上传
|
||||
String FILE_UPLOAD = API_PREFIX + "/file_upload"; |
||||
|
||||
|
||||
|
||||
@PostMapping(name = FILE_UPLOAD,consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||
R<BladeFile> fileUpload(@RequestPart(value = "file") MultipartFile file); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package org.springblade.resource.feign; |
||||
|
||||
import org.springblade.core.sms.model.SmsResponse; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
@Component |
||||
public class IOssClientFallback implements IOssClient { |
||||
|
||||
|
||||
|
||||
@Override |
||||
public R fileUpload(MultipartFile files) { |
||||
return R.fail("远程调用失败"); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package org.springblade.resource.feign; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.oss.model.BladeFile; |
||||
import org.springblade.core.sms.model.SmsResponse; |
||||
import org.springblade.core.tenant.annotation.NonDS; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.resource.builder.oss.OssBuilder; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestPart; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
@NonDS |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class OssClient implements IOssClient { |
||||
|
||||
/** |
||||
* 对象存储构建类 |
||||
*/ |
||||
private final OssBuilder ossBuilder; |
||||
|
||||
|
||||
@Override |
||||
@PostMapping(name = FILE_UPLOAD,consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
||||
public R<BladeFile> fileUpload(@RequestPart("file") MultipartFile file) { |
||||
return R.data(ossBuilder.template("minio","000000").putFile(file)); |
||||
} |
||||
} |
Loading…
Reference in new issue