管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-03 64bfe6434504ac9838fd91b8746deffae61c3dc6
src/main/java/com/lf/server/controller/data/MetaController.java
@@ -38,10 +38,10 @@
import java.util.List;
/**
 * 源数据
 * 元数据
 * @author WWW
 */
@Api(tags = "数据管理\\源数据管理")
@Api(tags = "数据管理\\信息管理")
@RestController
@RequestMapping("/meta")
public class MetaController extends BaseController {
@@ -166,7 +166,7 @@
    @SysLog()
    @ApiOperation(value = "查询表中数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "源数据ID", dataType = "Integer", paramType = "query", example = "115"),
            @ApiImplicitParam(name = "id", value = "元数据ID", dataType = "Integer", paramType = "query", example = "115"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10")
    })
@@ -175,12 +175,12 @@
        // noinspection AlibabaRemoveCommentedCode
        try {
            if (null == id || id < 0) {
                return fail("源数据ID不能为空或小于0", null);
                return fail("元数据ID不能为空或小于0", null);
            }
            MetaEntity meta = metaService.selectById(id);
            if (null == meta || null == meta.getTab() || !meta.getTab().contains(StaticData.POINT)) {
                return fail("找不到源数据信息", null);
                return fail("找不到元数据信息", null);
            }
            String entity = meta.getTab().substring(meta.getTab().indexOf(".") + 1).replace("_", "").toLowerCase();
@@ -193,7 +193,7 @@
            wrapper.eq("parentid", meta.getEventid());
            Page<Object> page = new Page<>(pageIndex, pageSize);
            page.addOrder(OrderItem.asc("gid"));
            page.addOrder(OrderItem.desc("gid"));
            IPage<Object> paged = baseMapper.selectPage(page, wrapper);
            return success(paged.getTotal(), paged.getRecords());
@@ -269,25 +269,9 @@
    }
    @SysLog()
    @ApiOperation(value = "删除一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/delete")
    public ResponseMsg<Integer> delete(int id) {
        try {
            int count = metaService.delete(id);
            return success(count);
        } catch (Exception ex) {
            return fail(ex, -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2")
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1")
    })
    @GetMapping(value = "/deletes")
    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) {
@@ -384,33 +368,32 @@
    @SysLog()
    @ApiOperation(value = "请求下载")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pwd", value = "密码", dataType = "String", paramType = "body", example = ""),
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "body", example = "1,2")
            @ApiImplicitParam(name = "dr", value = "请求下载实体类", dataType = "DownloadReqEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/downloadReq")
    public ResponseMsg<Object> downloadReq(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) {
    public ResponseMsg<Object> downloadReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == reqEntity || StringHelper.isEmpty(reqEntity.getPwd())) {
            if (null == dr || StringHelper.isEmpty(dr.getPwd())) {
                return fail("密码不能为空");
            }
            if (null == reqEntity.getIds() || reqEntity.getIds().isEmpty()) {
            if (null == dr.getIds() || dr.getIds().isEmpty()) {
                return fail("请选择要下载的文件");
            }
            if (!DownloadService.decryptPwd(reqEntity)) {
            if (!DownloadService.decryptPwd(dr)) {
                return fail("密码解密失败", null);
            }
            if (StringHelper.isPwdInvalid(reqEntity.getPwd())) {
            if (StringHelper.isPwdInvalid(dr.getPwd())) {
                return fail("密码不符合要求");
            }
            List<MetaEntity> list = metaService.selectMetaFiles(reqEntity.getIds());
            List<MetaEntity> list = metaService.selectMetaFiles(dr.getIds());
            if (null == list || list.isEmpty()) {
                return fail("没有找到源数据");
                return fail("没有找到元数据");
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd());
            String guid = downloadService.zipFiles(ue, list, dr.getPwd());
            return success(guid);
        } catch (Exception ex) {
@@ -496,4 +479,14 @@
            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }
    }
    @SysLog()
    @ApiOperation(value = "查看文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body")
    })
    @GetMapping(value = "/downloadForView")
    public void downloadForView(String guid, HttpServletResponse res) {
        metaService.downloadForView(guid, true, res);
    }
}