管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-24 e26af85e049516e6ce2b082bc2bc90bf71643e95
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;
@@ -30,62 +30,27 @@
    TokenService tokenService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", paramType = "query", required = false, example = "sys_token")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(String token) {
        try {
            int count = tokenService.selectCount(token);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌", dataType = "String", 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) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<TokenEntity> rs = tokenService.selectByPage(token, 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 = "ec101de8-1403-4d8f-ad13-edab8358399b"),
            @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 = "/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 +71,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -129,7 +94,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -145,7 +110,7 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -163,7 +128,7 @@
            int count = tokenService.deleteTokens(ids);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
@@ -185,14 +150,14 @@
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
            return fail(ex, -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "根据ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1658")
    })
    @GetMapping(value = "/selectToken")
    public ResponseMsg<TokenEntity> selectToken(int id) {
@@ -201,19 +166,7 @@
            return success(tokenEntity);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询所有")
    @GetMapping(value = "/selectTokenAll")
    public ResponseMsg<List<TokenEntity>> selectTokenAll() {
        try {
            List<TokenEntity> list = tokenService.selectTokenAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
}