|
@@ -1,5 +1,8 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.yitter.idgen.YitIdHelper;
|
|
|
import com.xy.utils.AliOssUtil;
|
|
|
import com.xy.utils.R;
|
|
|
import com.xy.vo.PolicyVo;
|
|
@@ -7,12 +10,21 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/***
|
|
|
* 对象存储实现类
|
|
@@ -46,4 +58,25 @@ public class OssServiceImpl implements OssService {
|
|
|
|
|
|
return R.ok(files);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ *指定目录上传文件
|
|
|
+ * @param fileUrl /存放目录/文件名.后缀
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation("指定目录上传文件")
|
|
|
+ @PostMapping("aliOSS/uploadFile")
|
|
|
+ public R<String> uploadFile( @RequestParam("fileUrl") String fileUrl, @RequestParam("file") MultipartFile file) {
|
|
|
+ try (InputStream inputStream = file.getInputStream()) {
|
|
|
+
|
|
|
+ String url = AliOssUtil.upload(inputStream, fileUrl);
|
|
|
+ return R.ok(url);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("文件处理时发生错误: {}", e.getMessage());
|
|
|
+ return R.fail("文件处理时发生错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|