管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-25 f269210744150f6d1482e374e92a6023b79e4e6b
src/main/java/com/lf/server/controller/data/MetaController.java
@@ -41,7 +41,7 @@
 * 元数据
 * @author WWW
 */
@Api(tags = "数据管理\\源数据管理")
@Api(tags = "数据管理\\信息管理")
@RestController
@RequestMapping("/meta")
public class MetaController extends BaseController {
@@ -66,30 +66,61 @@
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "dirid", value = "目录ID", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "depcode", value = "单位编码", dataType = "String", paramType = "query", example = "00"),
            @ApiImplicitParam(name = "dircode", value = "目录编码", dataType = "String", paramType = "query", example = "00"),
            @ApiImplicitParam(name = "verid", value = "版本ID", dataType = "Integer", paramType = "query", example = "0"),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageAndCount")
    public ResponseMsg<List<MetaEntity>> selectByPageAndCount(Integer depid, Integer dirid, Integer verid, String name, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<MetaEntity>> selectByPageAndCount(String depcode, String dircode, Integer verid, String name, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = metaService.selectCount(depid, dirid, verid, name);
            int count = metaService.selectCount(depcode, dircode, verid, name);
            if (count == 0) {
                return success(0, null);
            }
            List<MetaEntity> rs = metaService.selectByPage(depid, dirid, verid, name, pageSize, pageSize * (pageIndex - 1));
            List<MetaEntity> rs = metaService.selectByPage(depcode, dircode, verid, name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "根据父ID分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "metaid", value = "父ID", dataType = "String", paramType = "query", example = "0"),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectPageAndCountByPid")
    public ResponseMsg<List<MetaEntity>> selectPageAndCountByPid(Integer metaid, String name, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            if (null == metaid || metaid < 1) {
                return fail("父ID不能为空且大于1", null);
            }
            int count = metaService.selectCountByPid(metaid, name);
            if (count == 0) {
                return success(0, null);
            }
            List<MetaEntity> rs = metaService.selectPageByPid(metaid, name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
@@ -112,20 +143,7 @@
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询所有")
    @GetMapping(value = "/selectAll")
    public ResponseMsg<List<MetaEntity>> selectAll() {
        try {
            List<MetaEntity> list = metaService.selectAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -141,7 +159,7 @@
            return success(entity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -175,12 +193,12 @@
            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());
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -201,7 +219,7 @@
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -223,7 +241,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -246,30 +264,14 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @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.getMessage(), -1);
            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) {
@@ -282,7 +284,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -304,7 +306,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -328,7 +330,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -351,15 +353,15 @@
                return fail("用户未登录", null);
            }
            int count = downloadService.selectCountForUser(ue.getCreateUser(), 3, name);
            int count = downloadService.selectCountForUser(ue.getId(), 3, name);
            if (count == 0) {
                return success(0, null);
            }
            List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getCreateUser(), 3, name, pageSize, pageSize * (pageIndex - 1));
            List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getId(), 3, name, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -396,7 +398,7 @@
            return success(guid);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -434,7 +436,7 @@
            return success(file.exists());
        } catch (Exception ex) {
            return fail(ex.getMessage(), false);
            return fail(ex, false);
        }
    }
@@ -478,4 +480,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);
    }
}