管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-27 cec8c5738686bd16d17ae37455b85069e6babe29
src/main/java/com/lf/server/controller/sys/TokenController.java
@@ -1,6 +1,6 @@
package com.lf.server.controller.sys;
import com.lf.server.aspect.SysLog;
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.sys.TokenEntity;
@@ -32,60 +32,63 @@
    @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) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", example = "sys_token"),
            @ApiImplicitParam(name = "name", value = "令牌", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "0"),
            @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);
            return fail(ex, 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);
            return fail(ex, null);
        }
    }
@@ -106,7 +109,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -129,7 +132,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -145,7 +148,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -163,7 +166,7 @@
            int count = tokenService.deleteTokens(ids);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -185,7 +188,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -201,7 +204,7 @@
            return success(tokenEntity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -213,7 +216,7 @@
            List<TokenEntity> list = tokenService.selectTokenAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
}