Showing
4 changed files
with
44 additions
and
1 deletions
| @@ -104,7 +104,7 @@ jugg: | @@ -104,7 +104,7 @@ jugg: | ||
| 104 | #下载时的baseUrl,与domain的区别:会在url后面拼接/**作为静态资源的url,而domain是后端系统的具体域名,下载时的完整url例如:upload.domain + upload.url/xxx.jpg | 104 | #下载时的baseUrl,与domain的区别:会在url后面拼接/**作为静态资源的url,而domain是后端系统的具体域名,下载时的完整url例如:upload.domain + upload.url/xxx.jpg |
| 105 | url: /oss | 105 | url: /oss |
| 106 | #下载时的域名 | 106 | #下载时的域名 |
| 107 | - domain: http://localhost:8080 | 107 | + domain: http://erp.qgutech.com/api |
| 108 | #上传文件的路径 | 108 | #上传文件的路径 |
| 109 | location: D:\upload\upload-data | 109 | location: D:\upload\upload-data |
| 110 | # 安全上传 | 110 | # 安全上传 |
| @@ -19,6 +19,7 @@ import io.swagger.annotations.Api; | @@ -19,6 +19,7 @@ import io.swagger.annotations.Api; | ||
| 19 | import io.swagger.annotations.ApiImplicitParam; | 19 | import io.swagger.annotations.ApiImplicitParam; |
| 20 | import io.swagger.annotations.ApiOperation; | 20 | import io.swagger.annotations.ApiOperation; |
| 21 | import java.util.List; | 21 | import java.util.List; |
| 22 | +import java.util.Map; | ||
| 22 | import java.util.stream.Collectors; | 23 | import java.util.stream.Collectors; |
| 23 | import javax.validation.Valid; | 24 | import javax.validation.Valid; |
| 24 | import javax.validation.constraints.NotBlank; | 25 | import javax.validation.constraints.NotBlank; |
| @@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.PostMapping; | @@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.PostMapping; | ||
| 31 | import org.springframework.web.bind.annotation.PutMapping; | 32 | import org.springframework.web.bind.annotation.PutMapping; |
| 32 | import org.springframework.web.bind.annotation.RequestMapping; | 33 | import org.springframework.web.bind.annotation.RequestMapping; |
| 33 | import org.springframework.web.bind.annotation.RestController; | 34 | import org.springframework.web.bind.annotation.RestController; |
| 35 | +import org.springframework.web.multipart.MultipartFile; | ||
| 34 | 36 | ||
| 35 | /** | 37 | /** |
| 36 | * 文件收纳箱 Controller | 38 | * 文件收纳箱 Controller |
| @@ -66,6 +68,19 @@ public class FileBoxController extends DefaultBaseController { | @@ -66,6 +68,19 @@ public class FileBoxController extends DefaultBaseController { | ||
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | /** | 70 | /** |
| 71 | + * 上传文件公共方法 | ||
| 72 | + */ | ||
| 73 | + @ApiOperation("上传文件公共方法") | ||
| 74 | + @PostMapping("/uploadFile") | ||
| 75 | + public InvokeResult<Map<String, String>> uploadFile(@Valid MultipartFile file) { | ||
| 76 | + | ||
| 77 | + Map<String, String> map = fileBoxService.uploadFile(file); | ||
| 78 | + | ||
| 79 | + return InvokeResultBuilder.success(map); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + /** | ||
| 69 | * 查询列表 | 84 | * 查询列表 |
| 70 | */ | 85 | */ |
| 71 | @ApiOperation("查询列表") | 86 | @ApiOperation("查询列表") |
| @@ -34,7 +34,10 @@ import com.lframework.xingyun.comp.vo.sw.filebox.UpdateFileBoxVo; | @@ -34,7 +34,10 @@ import com.lframework.xingyun.comp.vo.sw.filebox.UpdateFileBoxVo; | ||
| 34 | import com.lframework.xingyun.comp.vo.sw.filebox.UploadFileBoxVo; | 34 | import com.lframework.xingyun.comp.vo.sw.filebox.UploadFileBoxVo; |
| 35 | import java.io.Serializable; | 35 | import java.io.Serializable; |
| 36 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
| 37 | +import java.util.HashMap; | ||
| 37 | import java.util.List; | 38 | import java.util.List; |
| 39 | +import java.util.Map; | ||
| 40 | + | ||
| 38 | import org.springframework.beans.factory.annotation.Autowired; | 41 | import org.springframework.beans.factory.annotation.Autowired; |
| 39 | import org.springframework.stereotype.Service; | 42 | import org.springframework.stereotype.Service; |
| 40 | import org.springframework.transaction.annotation.Transactional; | 43 | import org.springframework.transaction.annotation.Transactional; |
| @@ -210,6 +213,21 @@ public class FileBoxServiceImpl extends | @@ -210,6 +213,21 @@ public class FileBoxServiceImpl extends | ||
| 210 | } | 213 | } |
| 211 | } | 214 | } |
| 212 | 215 | ||
| 216 | + @Transactional(rollbackFor = Exception.class) | ||
| 217 | + @Override | ||
| 218 | + public Map<String, String> uploadFile(MultipartFile file) { | ||
| 219 | + UploadDto uploadDto = UploadUtil.upload(file, | ||
| 220 | + CollectionUtil.toList("filebox", SecurityUtil.getCurrentUser().getId()), true); | ||
| 221 | + //文件名 | ||
| 222 | + String name = file.getName(); | ||
| 223 | + String securityUploadRecordId = uploadDto.getSecurityUploadRecordId(); | ||
| 224 | + Map<String, String> map = new HashMap<>(); | ||
| 225 | + map.put("fileName", name); | ||
| 226 | + map.put("fileId", securityUploadRecordId); | ||
| 227 | + | ||
| 228 | + return map; | ||
| 229 | + } | ||
| 230 | + | ||
| 213 | @Override | 231 | @Override |
| 214 | public void cleanCacheByKey(Serializable key) { | 232 | public void cleanCacheByKey(Serializable key) { |
| 215 | 233 |
| @@ -7,7 +7,10 @@ import com.lframework.xingyun.comp.vo.sw.filebox.CreateFileBoxDirVo; | @@ -7,7 +7,10 @@ import com.lframework.xingyun.comp.vo.sw.filebox.CreateFileBoxDirVo; | ||
| 7 | import com.lframework.xingyun.comp.vo.sw.filebox.QueryFileBoxVo; | 7 | import com.lframework.xingyun.comp.vo.sw.filebox.QueryFileBoxVo; |
| 8 | import com.lframework.xingyun.comp.vo.sw.filebox.UpdateFileBoxVo; | 8 | import com.lframework.xingyun.comp.vo.sw.filebox.UpdateFileBoxVo; |
| 9 | import com.lframework.xingyun.comp.vo.sw.filebox.UploadFileBoxVo; | 9 | import com.lframework.xingyun.comp.vo.sw.filebox.UploadFileBoxVo; |
| 10 | +import org.springframework.web.multipart.MultipartFile; | ||
| 11 | + | ||
| 10 | import java.util.List; | 12 | import java.util.List; |
| 13 | +import java.util.Map; | ||
| 11 | 14 | ||
| 12 | /** | 15 | /** |
| 13 | * 文件收纳箱 Service | 16 | * 文件收纳箱 Service |
| @@ -63,4 +66,11 @@ public interface FileBoxService extends BaseMpService<FileBox> { | @@ -63,4 +66,11 @@ public interface FileBoxService extends BaseMpService<FileBox> { | ||
| 63 | */ | 66 | */ |
| 64 | void upload(UploadFileBoxVo vo); | 67 | void upload(UploadFileBoxVo vo); |
| 65 | 68 | ||
| 69 | + /** | ||
| 70 | + * 上传文件公共方法 | ||
| 71 | + * | ||
| 72 | + * @param file | ||
| 73 | + */ | ||
| 74 | + Map<String, String> uploadFile(MultipartFile file); | ||
| 75 | + | ||
| 66 | } | 76 | } |