| | |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "category", value = "服务类别", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "type", value = "服务类型", dataType = "Integer", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "data", value = "数据类型", dataType = "Integer", 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<ResEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer status, Integer category, Integer type, Integer data, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = resService.selectCount(name); |
| | | int count = resService.selectCount(name, status, category, type, data); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); |
| | | List<ResEntity> rs = resService.selectByPage(name, status, category, type, data, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param name 名称 |
| | | * @param name 名称 |
| | | * @param status 状态 |
| | | * @param category 服务类别 |
| | | * @param type 服务类型 |
| | | * @param data 数据类型 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name); |
| | | public Integer selectCount(String name, Integer status, Integer category, Integer type, Integer data); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 名称 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @param name 名称 |
| | | * @param status 状态 |
| | | * @param category 服务类别 |
| | | * @param type 服务类型 |
| | | * @param data 数据类型 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ResEntity> selectByPage(String name, Integer limit, Integer offset); |
| | | public List<ResEntity> selectByPage(String name, Integer status, Integer category, Integer type, Integer data, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | |
| | | ResMapper resMapper; |
| | | |
| | | @Override |
| | | public Integer selectCount(String name) { |
| | | public Integer selectCount(String name, Integer status, Integer category, Integer type, Integer data) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return resMapper.selectCount(name); |
| | | return resMapper.selectCount(name, status, category, type, data); |
| | | } |
| | | |
| | | @Override |
| | | public List<ResEntity> selectByPage(String name, Integer limit, Integer offset) { |
| | | public List<ResEntity> selectByPage(String name, Integer status, Integer category, Integer type, Integer data, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return resMapper.selectByPage(name, limit, offset); |
| | | return resMapper.selectByPage(name, status, category, type, data, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_res |
| | | <where> |
| | | 1 = 1 |
| | | <if test="name != null"> |
| | | upper(cn_name) like #{name} or upper(en_name) like #{name} |
| | | and (upper(cn_name) like #{name} or upper(en_name) like #{name}) |
| | | </if> |
| | | <if test="status != null"> |
| | | and status = #{status} |
| | | </if> |
| | | <if test="category != null"> |
| | | and category = #{category} |
| | | </if> |
| | | <if test="type != null"> |
| | | and type = #{type} |
| | | </if> |
| | | <if test="data != null"> |
| | | and data = #{data} |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | <select id="selectByPage" resultType="com.moon.server.entity.sys.ResEntity"> |
| | | select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName from lf.sys_res a |
| | | <where> |
| | | 1 = 1 |
| | | <if test="name != null"> |
| | | upper(cn_name) like #{name} or upper(en_name) like #{name} |
| | | and (upper(cn_name) like #{name} or upper(en_name) like #{name}) |
| | | </if> |
| | | <if test="status != null"> |
| | | and status = #{status} |
| | | </if> |
| | | <if test="category != null"> |
| | | and category = #{category} |
| | | </if> |
| | | <if test="type != null"> |
| | | and type = #{type} |
| | | </if> |
| | | <if test="data != null"> |
| | | and data = #{data} |
| | | </if> |
| | | </where> |
| | | order by a.id desc |