25 changed files with 253 additions and 43 deletions
@ -0,0 +1,45 @@ |
|||||||
|
package co.yixiang.app.modules.user.rest; |
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.ApiResult; |
||||||
|
import co.yixiang.modules.shop.service.YxSystemConfigService; |
||||||
|
import co.yixiang.tools.domain.QiniuContent; |
||||||
|
import co.yixiang.tools.service.QiNiuService; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
import org.springframework.web.multipart.MultipartFile; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/api/upload") |
||||||
|
public class AppUploadController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private YxSystemConfigService systemConfigService; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private QiNiuService qiNiuService; |
||||||
|
|
||||||
|
@ApiOperation("上传文件") |
||||||
|
@PostMapping |
||||||
|
public ApiResult<?> create(@RequestParam(defaultValue = "") String name, |
||||||
|
@RequestParam(defaultValue = "") String type, |
||||||
|
@RequestParam("file") MultipartFile[] files) { |
||||||
|
|
||||||
|
StringBuilder url = new StringBuilder(); |
||||||
|
for (MultipartFile file : files) { |
||||||
|
QiniuContent qiniuContent = qiNiuService.upload(file, qiNiuService.find()); |
||||||
|
if ("".equals(url.toString())) { |
||||||
|
url = url.append(qiniuContent.getUrl()); |
||||||
|
System.out.println("".equals(url.toString())); |
||||||
|
}else{ |
||||||
|
url = url.append(",").append(qiniuContent.getUrl()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return ApiResult.ok(url); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue