tangzy
2021-07-14 8389893d974f5daf47719c8b7eb33d0b83ac318a
1.附件上传
3 files modified
18 ■■■■■ changed files
src/main/java/org/springblade/modules/resource/controller/AttachController.java 4 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/entity/Attach.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/controller/AttachController.java
@@ -67,7 +67,9 @@
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入attach")
    public R<IPage<Attach>> list(Attach attach, Query query) {
    public R<IPage<Attach>> list(Attach attach, Query query, String deptid, String type) {
        attach.setDeptid(deptid);
        attach.setType(type);
        IPage<Attach> pages = attachService.page(Condition.getPage(query), Condition.getQueryWrapper(attach));
        return R.data(pages);
    }
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -171,10 +171,10 @@
     */
    @SneakyThrows
    @PostMapping("/put-file-attach")
    public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) {
    public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type) {
        String fileName = file.getOriginalFilename();
        BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
        bladeFile.setAttachId(attachId);
        return R.data(bladeFile);
    }
@@ -188,9 +188,9 @@
     */
    @SneakyThrows
    @PostMapping("/put-file-attach-by-name")
    public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) {
    public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type) {
        BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
        Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
        bladeFile.setAttachId(attachId);
        return R.data(bladeFile);
    }
@@ -203,7 +203,7 @@
     * @param bladeFile 对象存储文件
     * @return attachId
     */
    private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile) {
    private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type) {
        String fileExtension = FileUtil.getFileExtension(fileName);
        Attach attach = new Attach();
        attach.setDomain(bladeFile.getDomain());
@@ -212,6 +212,8 @@
        attach.setOriginalName(bladeFile.getOriginalName());
        attach.setAttachSize(fileSize);
        attach.setExtension(fileExtension);
        attach.setDeptid(deptid);
        attach.setType(type);
        attachService.save(attach);
        return attach.getId();
    }
src/main/java/org/springblade/modules/resource/entity/Attach.java
@@ -66,6 +66,8 @@
     */
    @ApiModelProperty(value = "附件大小")
    private Long attachSize;
    private String deptid;
    private String type;
}