| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ns", value = "名称空间", dataType = "String", paramType = "query", example = "bd"), |
| | | @ApiImplicitParam(name = "tab", value = "表名", dataType = "String", paramType = "query", example = "b_hy20w_s23"), |
| | | @ApiImplicitParam(name = "code", value = "编码", dataType = "String", paramType = "query", example = "1"), |
| | | @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<DomainEntity>> selectByPageAndCount(String ns, String tab, String code, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<DomainEntity>> selectByPageAndCount(String ns, String tab, String name, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = domainService.selectCount(ns, tab, code); |
| | | int count = domainService.selectCount(ns, tab, name); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<DomainEntity> rs = domainService.selectByPage(ns, tab, code, pageSize, pageSize * (pageIndex - 1)); |
| | | List<DomainEntity> rs = domainService.selectByPage(ns, tab, name, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | * |
| | | * @param ns 名称空间 |
| | | * @param tab 表名 |
| | | * @param code 编码 |
| | | * @param name 名称 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String ns, String tab, String code); |
| | | public Integer selectCount(String ns, String tab, String name); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param ns 名称空间 |
| | | * @param tab 表名 |
| | | * @param code 编码 |
| | | * @param name 名称 |
| | | * @param limit 记录表 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<DomainEntity> selectByPage(String ns, String tab, String code, Integer limit, Integer offset); |
| | | public List<DomainEntity> selectByPage(String ns, String tab, String name, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | |
| | | DomainMapper domainMapper; |
| | | |
| | | @Override |
| | | public Integer selectCount(String ns, String tab, String code) { |
| | | code = StringHelper.getLikeStr(code); |
| | | public Integer selectCount(String ns, String tab, String name) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return domainMapper.selectCount(ns, tab, code); |
| | | return domainMapper.selectCount(ns, tab, name); |
| | | } |
| | | |
| | | @Override |
| | | public List<DomainEntity> selectByPage(String ns, String tab, String code, Integer limit, Integer offset) { |
| | | code = StringHelper.getLikeStr(code); |
| | | public List<DomainEntity> selectByPage(String ns, String tab, String name, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return domainMapper.selectByPage(ns, tab, code, limit, offset); |
| | | return domainMapper.selectByPage(ns, tab, name, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <if test="tab != null"> |
| | | and b.tab = #{tab} |
| | | </if> |
| | | <if test="code != null"> |
| | | and a.dom_code like #{code} |
| | | <if test="name != null"> |
| | | and (dom_desc like #{name} or dom_name like #{name}) |
| | | </if> |
| | | </select> |
| | | |
| | |
| | | <if test="tab != null"> |
| | | and b.tab = #{tab} |
| | | </if> |
| | | <if test="code != null"> |
| | | and a.dom_code like #{code} |
| | | <if test="name != null"> |
| | | and (dom_desc like #{name} or dom_name like #{name}) |
| | | </if> |
| | | order by a.id |
| | | limit #{limit} offset #{offset} |