管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-12 f2e5a592b8b74035bb1c943b4dca81e28be785a6
1
已修改6个文件
109 ■■■■■ 文件已修改
src/main/java/com/lf/server/controller/sys/RoleController.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/sys/RoleEntity.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/sys/RoleMapper.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/sys/TokenMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/RoleService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sys/RoleMapper.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/RoleController.java
@@ -35,13 +35,13 @@
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", required = false, example = "sys_role"),
            @ApiImplicitParam(name = "depName", value = "名称", dataType = "String", paramType = "query", example = "sys_role")
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "Admin"),
            @ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(String name, String depName) {
    public ResponseMsg<Integer> selectCount(String name, Integer depid) {
        try {
            int count = roleService.selectCount(name, depName);
            int count = roleService.selectCount(name, depid);
            return success(count);
        } catch (Exception ex) {
@@ -52,18 +52,20 @@
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "sys_role"),
            @ApiImplicitParam(name = "depName", value = "名称", dataType = "String", paramType = "query", example = "sys_role"),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "Admin"),
            @ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1"),
            @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<RoleEntity>> selectByPage(String name, String depName, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<RoleEntity>> selectByPage(String name, Integer depid, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<RoleEntity> rs = roleService.selectByPage(name, depName, pageSize, pageSize * (pageIndex - 1));
            List<RoleEntity> rs = roleService.selectByPage(name, depid, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
@@ -73,24 +75,24 @@
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "depName", value = "名称", dataType = "String", paramType = "query", example = "sys_role"),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "Admin"),
            @ApiImplicitParam(name = "depid", value = "单位ID", dataType = "Integer", paramType = "query", example = "1"),
            @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<RoleEntity>> selectByPageAndCount(String name, String depName, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<RoleEntity>> selectByPageAndCount(String name, Integer depid, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = roleService.selectCount(name, depName);
            int count = roleService.selectCount(name, depid);
            if (count == 0) {
                return success(0, null);
            }
            List<RoleEntity> rs = roleService.selectByPage(name, depName, pageSize, pageSize * (pageIndex - 1));
            List<RoleEntity> rs = roleService.selectByPage(name, depid, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
src/main/java/com/lf/server/entity/sys/RoleEntity.java
@@ -32,6 +32,10 @@
    private String depName;
    private String createName;
    private String updateName;
    public int getId() {
        return id;
    }
@@ -111,4 +115,20 @@
    public void setDepName(String depName) {
        this.depName = depName;
    }
    public String getCreateName() {
        return createName;
    }
    public void setCreateName(String createName) {
        this.createName = createName;
    }
    public String getUpdateName() {
        return updateName;
    }
    public void setUpdateName(String updateName) {
        this.updateName = updateName;
    }
}
src/main/java/com/lf/server/mapper/sys/RoleMapper.java
@@ -17,22 +17,22 @@
    /**
     * 查询记录数
     *
     * @param name 名称
     * @param depName 名称
     * @param name  名称
     * @param depid 单位ID
     * @return 记录数
     */
    public Integer selectCount(String name, String depName);
    public Integer selectCount(String name, Integer depid);
    /**
     * 分页查询
     *
     * @param name 名称
     * @param depName 名称
     * @param name   名称
     * @param depid  单位ID
     * @param limit  记录表
     * @param offset 偏移量
     * @return 列表
     */
    public List<RoleEntity> selectByPage(String name,String depName, Integer limit, Integer offset);
    public List<RoleEntity> selectByPage(String name, Integer depid, Integer limit, Integer offset);
    /**
     * 插入一条
src/main/java/com/lf/server/mapper/sys/TokenMapper.java
@@ -18,20 +18,22 @@
    /**
     * 查询记录数
     *
     * @param name 表名
     * @return 记录数
     * @param name
     * @param type
     * @return
     */
    public Integer selectCount(String name,Integer type);
    public Integer selectCount(String name, Integer type);
    /**
     * 分页查询
     *
     * @param name  表名
     * @param limit  记录表
     * @param offset 偏移量
     * @return 列表
     * @param name
     * @param type
     * @param limit
     * @param offset
     * @return
     */
    public List<TokenEntity> selectByPage(String name,Integer type, Integer limit, Integer offset);
    public List<TokenEntity> selectByPage(String name, Integer type, Integer limit, Integer offset);
    /**
     * 查询单条数据
src/main/java/com/lf/server/service/sys/RoleService.java
@@ -18,13 +18,13 @@
    RoleMapper roleMapper;
    @Override
    public Integer selectCount(String name, String depName) {
        return roleMapper.selectCount(name, depName);
    public Integer selectCount(String name, Integer depid) {
        return roleMapper.selectCount(name, depid);
    }
    @Override
    public List<RoleEntity> selectByPage(String name, String depName, Integer limit, Integer offset) {
        return roleMapper.selectByPage(name, depName, limit, offset);
    public List<RoleEntity> selectByPage(String name, Integer depid, Integer limit, Integer offset) {
        return roleMapper.selectByPage(name, depid, limit, offset);
    }
    @Override
src/main/resources/mapper/sys/RoleMapper.xml
@@ -1,46 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lf.server.mapper.sys.RoleMapper">
    <!-- 统计行数 -->
    <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.String">
        select count(*) from lf.sys_role
        select count(*) from lf.sys_role a
        <where>
            1=1
            <if test="name != null">
                and a.name = #{name}
            </if>
            <if test="depName != null">
                and b.name = #{depName}
            <if test="depid != null">
                and a.depid = #{depid}
            </if>
        </where>
    </select>
    <!-- 分页查询 -->
    <select id="selectByPage" resultType="com.lf.server.entity.sys.RoleEntity">
        select a.*,b.name as dep_name
        from lf.sys_role a inner join lf.sys_dep b
        on a.depid = b.id
        select a.*,fn_rec_query(a.depid, 'dep') depName,fn_uname(a.create_user) createName,fn_uname(a.update_user) updateName from lf.sys_role a
        <where>
            1=1
            <if test="name != null">
                and a.name = #{name}
            </if>
            <if test="depName != null">
                and b.name = #{depName}
            <if test="depid != null">
                and a.depid = #{depid}
            </if>
        </where>
        order by id
        order by a.id
        limit #{limit} offset #{offset}
    </select>
    <select id="selectRoleAll" resultType="com.lf.server.entity.sys.RoleEntity">
        select * from lf.sys_role order by id;
        select a.*,fn_rec_query(a.depid, 'dep') depName,fn_uname(a.create_user) createName,fn_uname(a.update_user) updateName from lf.sys_role a order by a.id;
    </select>
    <select id="selectRole" resultType="com.lf.server.entity.sys.RoleEntity">
        select * from lf.sys_role where id = #{id}
        select a.*,fn_rec_query(a.depid, 'dep') depName,fn_uname(a.create_user) createName,fn_uname(a.update_user) updateName from lf.sys_role a where a.id = #{id}
    </select>
    <insert id="insertRole"   parameterType="com.lf.server.entity.sys.RoleEntity">