| | |
| | | @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) { |