| | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", required = false, example = "sys_token") |
| | | @ApiImplicitParam(name = "name", value = "令牌", dataType = "String", paramType = "query", required = false, example = "sys_token"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "sys_token"), |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Integer> selectCount(String token) { |
| | | public ResponseMsg<Integer> selectCount(String name,Integer type) { |
| | | try { |
| | | int count = tokenService.selectCount(token); |
| | | int count = tokenService.selectCount(name,type); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", example = "sys_token"), |
| | | @ApiImplicitParam(name = "name", value = "令牌", dataType = "String", paramType = "query", example = "sys_token"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "sys_token"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<TokenEntity>> selectByPage(String token, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<TokenEntity>> selectByPage(String name, Integer type,Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | List<TokenEntity> rs = tokenService.selectByPage(token, pageSize, pageSize * (pageIndex - 1)); |
| | | List<TokenEntity> rs = tokenService.selectByPage(name,type, pageSize, pageSize * (pageIndex - 1)); |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", example = "sys_token"), |
| | | @ApiImplicitParam(name = "name", value = "令牌", dataType = "String", paramType = "query", example = "sys_token"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "sys_token"), |
| | | @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<TokenEntity>> selectByPageAndCount(String token, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<TokenEntity>> selectByPageAndCount(String name,Integer type, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | int count = tokenService.selectCount(token); |
| | | int count = tokenService.selectCount(name,type); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | List<TokenEntity> rs = tokenService.selectByPage(token, pageSize, pageSize * (pageIndex - 1)); |
| | | List<TokenEntity> rs = tokenService.selectByPage(name,type, pageSize, pageSize * (pageIndex - 1)); |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param token 表名 |
| | | * @param name 表名 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String token); |
| | | public Integer selectCount(String name,Integer type); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param token 表名 |
| | | * @param name 表名 |
| | | * @param limit 记录表 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<TokenEntity> selectByPage(String token, Integer limit, Integer offset); |
| | | public List<TokenEntity> selectByPage(String name,Integer type, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询单条数据 |
| | |
| | | LoginService loginService; |
| | | |
| | | @Override |
| | | public Integer selectCount(String token) { |
| | | return tokenMapper.selectCount(token); |
| | | public Integer selectCount(String name, Integer type) { |
| | | return tokenMapper.selectCount(name,type); |
| | | } |
| | | |
| | | @Override |
| | | public List<TokenEntity> selectByPage(String token, Integer limit, Integer offset) { |
| | | return tokenMapper.selectByPage(token, limit, offset); |
| | | public List<TokenEntity> selectByPage(String name, Integer type, Integer limit, Integer offset) { |
| | | return tokenMapper.selectByPage(name,type, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.String"> |
| | | select count(*) from lf.sys_token |
| | | <where> |
| | | <if test="token != null"> |
| | | token = #{token} |
| | | 1=1 |
| | | <if test="name != null"> |
| | | and token = #{name} |
| | | </if> |
| | | |
| | | <if test="type != null"> |
| | | and type = #{type} |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | <select id="selectByPage" resultMap="resultMap" resultType="com.lf.server.entity.sys.TokenEntity"> |
| | | select * from lf.sys_token |
| | | <where> |
| | | <if test="token != null"> |
| | | token = #{token} |
| | | 1=1 |
| | | <if test="name != null"> |
| | | and token = #{name} |
| | | </if> |
| | | |
| | | <if test="type != null"> |
| | | and type = #{type} |
| | | </if> |
| | | </where> |
| | | order by id |