| | |
| | | @ApiOperation(value = "根据表名分页查询表") |
| | | @GetMapping(value = "/selectTabsByPage") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "depcode", value = "单位编码", dataType = "String", paramType = "query", example = "00"), |
| | | @ApiImplicitParam(name = "dirs", value = "目录编码", dataType = "String", paramType = "query", example = "00,01"), |
| | | @ApiImplicitParam(name = "tab", value = "表名", dataType = "String", paramType = "query", example = "dlg_"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | public ResponseMsg<List<TabEntity>> selectTabsByPage(String tab, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<TabEntity>> selectTabsByPage(String depcode, String dirs, String tab, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | if (StringHelper.isSqlInjection(depcode)) { |
| | | return fail("单位代码含有非法字符", null); |
| | | } |
| | | |
| | | int count = baseQueryService.selectTabsForCount(tab); |
| | | String filter = "1=1"; |
| | | if (!StringHelper.isEmpty(depcode)) { |
| | | filter += String.format(" and depid like '%s%%'", depcode); |
| | | } |
| | | dirs = DataLibService.copeCodes(dirs, "dircode"); |
| | | if (dirs != null) { |
| | | filter += String.format(" and (%s)", dirs); |
| | | } |
| | | filter = filter.replace("1=1 and ", ""); |
| | | |
| | | int count = baseQueryService.selectTabsForCount(tab, filter); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<TabEntity> rs = baseQueryService.selectTabsByPage(tab, pageSize, pageSize * (pageIndex - 1)); |
| | | List<TabEntity> rs = baseQueryService.selectTabsByPage(tab, filter, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | |
| | | private String tableType; |
| | | |
| | | private Integer rows; |
| | | |
| | | public TabEntity() { |
| | | } |
| | | |
| | |
| | | public void setTableType(String tableType) { |
| | | this.tableType = tableType; |
| | | } |
| | | |
| | | public Integer getRows() { |
| | | return rows; |
| | | } |
| | | |
| | | public void setRows(Integer rows) { |
| | | this.rows = rows; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 根据表名查询记录数 |
| | | * |
| | | * @param tab 表名 |
| | | * @return 记录数 |
| | | * @param tab 表名 |
| | | * @param filter 过滤条件 |
| | | * @return |
| | | */ |
| | | public Integer selectTabsForCount(String tab); |
| | | public Integer selectTabsForCount(String tab, String filter); |
| | | |
| | | /** |
| | | * 根据表名分页查询 |
| | | * |
| | | * @param tab 表名 |
| | | * @param filter 过滤条件 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return |
| | | */ |
| | | public List<TabEntity> selectTabsByPage(String tab, Integer limit, Integer offset); |
| | | public List<TabEntity> selectTabsByPage(String tab, String filter, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询字段信息 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer selectTabsForCount(String tab) { |
| | | public Integer selectTabsForCount(String tab, String filter) { |
| | | tab = StringHelper.getLikeStr(tab); |
| | | |
| | | return baseQueryMapper.selectTabsForCount(tab); |
| | | return baseQueryMapper.selectTabsForCount(tab, filter); |
| | | } |
| | | |
| | | @Override |
| | | public List<TabEntity> selectTabsByPage(String tab, Integer limit, Integer offset) { |
| | | public List<TabEntity> selectTabsByPage(String tab, String filter, Integer limit, Integer offset) { |
| | | tab = StringHelper.getLikeStr(tab); |
| | | |
| | | return baseQueryMapper.selectTabsByPage(tab, limit, offset); |
| | | return baseQueryMapper.selectTabsByPage(tab, filter, limit, offset); |
| | | } |
| | | |
| | | @Override |