Kaynağa Gözat

#MOD 删除excel

谭斌 2 yıl önce
ebeveyn
işleme
f3458aa98c

+ 16 - 27
sys-api-service/src/main/java/com/xy/service/FileExportServiceImpl.java

@@ -14,13 +14,17 @@ import com.xy.enums.FileExportType;
 import com.xy.mapper.FileExportMapper;
 import com.xy.util.ExcelUtils;
 import com.xy.util.FileUtils;
-import com.xy.utils.*;
+import com.xy.utils.AliOssUtil;
+import com.xy.utils.MybatisPlusQuery;
+import com.xy.utils.PageBean;
+import com.xy.utils.R;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.Cleanup;
 import lombok.RequiredArgsConstructor;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
 import java.io.FileInputStream;
@@ -48,25 +52,7 @@ public class FileExportServiceImpl extends ServiceImpl<FileExportMapper, FileExp
 
     private final FileUtils fileUtils;
 
-    @Override
-    @ApiOperation("对象查询")
-    public R<FileExportDto.Vo> obj(FileExportDto.Vo vo) {
-        FileExportDto.SelectList selectList = copy(FileExportDto.SelectList.class, vo);
-        List<FileExportDto.Vo> list = list(selectList).getData();
-        if (Emptys.check(list)) {
-            return R.ok(list.get(0));
-        }
-        return R.ok();
-    }
-
-    @Override
-    @ApiOperation("集合查询")
-    public R<List<FileExportDto.Vo>> list(FileExportDto.SelectList selectList) {
-        LambdaQueryWrapper<FileExport> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(selectList, FileExport.class).build();
-        List<FileExport> list = list(lambdaQueryWrapper);
-        return R.ok(copy(FileExportDto.Vo.class, list));
-    }
-
+   
     @Override
     @ApiOperation("分页查询")
     public R<PageBean<FileExportDto.Vo>> page(FileExportDto.Page page) {
@@ -84,13 +70,6 @@ public class FileExportServiceImpl extends ServiceImpl<FileExportMapper, FileExp
         return R.ok(BeanUtil.copyProperties(saveInfo, FileExportDto.Vo.class));
     }
 
-    @Override
-    @ApiOperation("修改")
-    public R update(@Validated FileExportDto.Update update) {
-        FileExport updateInfo = copy(FileExport.class, update);
-        updateById(updateInfo);
-        return R.ok();
-    }
 
     @Override
     @ApiOperation("更新文件导出状态")
@@ -151,4 +130,14 @@ public class FileExportServiceImpl extends ServiceImpl<FileExportMapper, FileExp
         }
     }
 
+    @ApiOperation("删除excel")
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R<Boolean> del(FileExportDto.Del del) {
+        List<Long> ids = del.getIds();
+        List<FileExport> fileExports = this.listByIds(ids);
+        fileExports.forEach(f -> AliOssUtil.delete(f.getFileName()));
+        return R.ok(this.removeBatchByIds(ids));
+    }
+
 }

+ 48 - 3
sys-api/src/main/java/com/xy/dto/FileExportDto.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import lombok.experimental.Accessors;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * <p>
@@ -25,10 +26,54 @@ public class FileExportDto {
 
     }
 
+    @Data
+    @Accessors(chain = true)
+    public static class Del {
+
+        @ApiModelProperty(value = "id")
+        private List<Long> ids;
+
+    }
 
     @Data
     @Accessors(chain = true)
-    public static class Page extends Vo {
+    public static class Page {
+
+        @ApiModelProperty(value = "创建人")
+        private Long createUser;
+
+        
+        @ApiModelProperty(value = "主键")
+        private Long id;
+
+        @ApiModelProperty(value = "文件名称")
+        private String fileName;
+
+        @ApiModelProperty(value = "文件类型(字典 file_export_type)")
+        private String fileType;
+
+        @ApiModelProperty(value = "导出状态(字典 file_export_status)")
+        private String exportStatus;
+
+        @ApiModelProperty(value = "导出成功时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime exportSuccessTime;
+
+
+        @ApiModelProperty(value = "商户ID")
+        private Long mercId;
+
+        @ApiModelProperty(value = "商户名称")
+        private String mercName;
+
+        @ApiModelProperty(value = "导出失败错误信息")
+        private String errorInfo;
+
+
+        @ApiModelProperty(value = "创建时间")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        private LocalDateTime createTime;
+
 
         @ApiModelProperty(value = "分页对象", required = true)
         private PageBean page;
@@ -119,10 +164,10 @@ public class FileExportDto {
         @ApiModelProperty(value = "文件名称")
         private String fileName;
 
-        @ApiModelProperty(value = "文件类型(字典)")
+        @ApiModelProperty(value = "文件类型(字典 file_export_type)")
         private String fileType;
 
-        @ApiModelProperty(value = "导出状态(字典)")
+        @ApiModelProperty(value = "导出状态(字典 file_export_status)")
         private String exportStatus;
 
         @ApiModelProperty(value = "导出成功时间")

+ 6 - 11
sys-api/src/main/java/com/xy/service/FileExportService.java

@@ -11,8 +11,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import java.util.List;
-
 /**
  * <p>
  * 文件导出 服务类
@@ -24,21 +22,13 @@ import java.util.List;
 @RestMappingController("/file-export")
 public interface FileExportService {
 
-
-    @PostMapping("obj")
-    R<FileExportDto.Vo> obj(@RequestBody FileExportDto.Vo vo);
-
-    @PostMapping("list")
-    R<List<FileExportDto.Vo>> list(@RequestBody FileExportDto.SelectList selectList);
-
+ 
     @PostMapping("page")
     R<PageBean<FileExportDto.Vo>> page(@RequestBody FileExportDto.Page page);
 
     @PostMapping("save")
     R<FileExportDto.Vo> save(@RequestBody @Validated FileExportDto.Save save);
 
-    @PostMapping("update")
-    R update(@RequestBody @Validated FileExportDto.Update update);
 
     @GetMapping("updateExportStatus")
     R<Boolean> updateExportStatus(@RequestParam("id") Long id, @RequestParam("exportStatus") String exportStatus);
@@ -48,4 +38,9 @@ public interface FileExportService {
 
     @PostMapping("updateExportStatusUrl")
     <T> void exportExcelAsync(@RequestBody @Validated ExcelDTO<T> excelDTO);
+
+
+    @PostMapping("del")
+    R<Boolean> del(@RequestBody @Validated FileExportDto.Del del);
+
 }