管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-09 f0ecfaaeccbeb123b3d3f0a3e159a34ab4fd820c
src/main/java/com/lf/server/controller/data/upload/UploadController.java
@@ -5,6 +5,7 @@
import com.lf.server.entity.ctrl.TabMapperEntity;
import com.lf.server.entity.ctrl.UploadEntity;
import com.lf.server.entity.data.MetaEntity;
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.WebHelper;
import com.lf.server.service.all.BaseUploadService;
@@ -29,7 +30,7 @@
 */
@Api(tags = "数据管理\\数据上传")
@RestController
@RequestMapping("/dataLoader")
@RequestMapping("/dataUpload")
public class UploadController extends QueryController {
    @Autowired
    protected DataLoaderService dataLoaderService;
@@ -56,6 +57,67 @@
    }
    @SysLog()
    @ApiOperation(value = "上传文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query")
    })
    @ResponseBody
    @PostMapping(value = "/uploadFiles")
    public ResponseMsg<Object> uploadFiles(String path, HttpServletRequest req, HttpServletResponse res) {
        try {
            List<MetaFileEntity> list = baseUploadService.uploadData(null, path, req, res);
            if (null == list || list.isEmpty()) {
                return fail("没有找到上传文件", null);
            }
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query")
    })
    @GetMapping(value = "/selectFiles")
    public ResponseMsg<List<MetaFileEntity>> selectFiles(String path) {
        try {
            List<MetaFileEntity> list = baseUploadService.selectFiles(path, EXT_LIST);
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "MetaEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/deleteFiles")
    public ResponseMsg<Object> deleteFiles(@RequestBody List<MetaFileEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            if (null == list || list.isEmpty()) {
                return fail("没有找到文件", null);
            }
            int rows = baseUploadService.deleteFiles(list);
            return success("成功", rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询映射")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query")
@@ -76,26 +138,10 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query")
    })
    @GetMapping(value = "/selectFiles")
    public ResponseMsg<List<MetaEntity>> selectFiles(String path) {
        try {
            List<MetaEntity> list = baseUploadService.selectFiles(path, EXT_LIST);
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query")
    })
    @GetMapping(value = "/selectFiles2")
    public ResponseMsg<List<MetaEntity>> selectFiles2(String path) {
    public ResponseMsg<List<MetaFileEntity>> selectFiles2(String path) {
        try {
            List<MetaEntity> list = baseUploadService.selectFiles(path, null);
            List<MetaFileEntity> list = baseUploadService.selectFiles(path, null);
            return success(list);
        } catch (Exception ex) {
@@ -166,56 +212,6 @@
            dataLoaderService.insertFiles(me, entity.getFileEntities(), entity.getTabEntities());
            return success("成功", entity.getTabEntities());
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "上传文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query")
    })
    @ResponseBody
    @PostMapping(value = "/uploadFiles")
    public ResponseMsg<Object> uploadFiles(String path, HttpServletRequest req, HttpServletResponse res) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            List<MetaEntity> list = baseUploadService.uploadData(null, path, req, res);
            if (null == list || list.isEmpty()) {
                return fail("没有找到上传文件", null);
            }
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "MetaEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/deleteFiles")
    public ResponseMsg<Object> deleteFiles(@RequestBody List<MetaEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
            if (null == list || list.isEmpty()) {
                return fail("没有找到文件", null);
            }
            int rows = baseUploadService.deleteFiles(list);
            return success("成功", rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }