提交 c1158932 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

feat: 修复角色分页

上级 09854fac
...@@ -7,6 +7,8 @@ import lombok.Data; ...@@ -7,6 +7,8 @@ import lombok.Data;
public class SysRole implements Serializable { public class SysRole implements Serializable {
private Long roleId; private Long roleId;
private String code;
private String name; private String name;
private String description; private String description;
......
...@@ -164,6 +164,76 @@ public class SysRoleExample { ...@@ -164,6 +164,76 @@ public class SysRoleExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andNameIsNull() { public Criteria andNameIsNull() {
addCriterion("`name` is null"); addCriterion("`name` is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<mapper namespace="io.dataease.base.mapper.SysRoleMapper"> <mapper namespace="io.dataease.base.mapper.SysRoleMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.SysRole"> <resultMap id="BaseResultMap" type="io.dataease.base.domain.SysRole">
<id column="role_id" jdbcType="BIGINT" property="roleId" /> <id column="role_id" jdbcType="BIGINT" property="roleId" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" /> <result column="description" jdbcType="VARCHAR" property="description" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> <result column="create_by" jdbcType="VARCHAR" property="createBy" />
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
role_id, `name`, description, create_by, update_by, create_time, update_time role_id, code, `name`, description, create_by, update_by, create_time, update_time
</sql> </sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.SysRoleExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.dataease.base.domain.SysRoleExample" resultMap="BaseResultMap">
select select
...@@ -102,12 +103,12 @@ ...@@ -102,12 +103,12 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="io.dataease.base.domain.SysRole"> <insert id="insert" parameterType="io.dataease.base.domain.SysRole">
insert into sys_role (role_id, `name`, description, insert into sys_role (role_id, code, `name`,
create_by, update_by, create_time, description, create_by, update_by,
update_time) create_time, update_time)
values (#{roleId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, values (#{roleId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{description,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=BIGINT}) #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
</insert> </insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.SysRole"> <insert id="insertSelective" parameterType="io.dataease.base.domain.SysRole">
insert into sys_role insert into sys_role
...@@ -115,6 +116,9 @@ ...@@ -115,6 +116,9 @@
<if test="roleId != null"> <if test="roleId != null">
role_id, role_id,
</if> </if>
<if test="code != null">
code,
</if>
<if test="name != null"> <if test="name != null">
`name`, `name`,
</if> </if>
...@@ -138,6 +142,9 @@ ...@@ -138,6 +142,9 @@
<if test="roleId != null"> <if test="roleId != null">
#{roleId,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT},
</if> </if>
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="name != null"> <if test="name != null">
#{name,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
</if> </if>
...@@ -170,6 +177,9 @@ ...@@ -170,6 +177,9 @@
<if test="record.roleId != null"> <if test="record.roleId != null">
role_id = #{record.roleId,jdbcType=BIGINT}, role_id = #{record.roleId,jdbcType=BIGINT},
</if> </if>
<if test="record.code != null">
code = #{record.code,jdbcType=VARCHAR},
</if>
<if test="record.name != null"> <if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR},
</if> </if>
...@@ -196,6 +206,7 @@ ...@@ -196,6 +206,7 @@
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update sys_role update sys_role
set role_id = #{record.roleId,jdbcType=BIGINT}, set role_id = #{record.roleId,jdbcType=BIGINT},
code = #{record.code,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR}, description = #{record.description,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR}, create_by = #{record.createBy,jdbcType=VARCHAR},
...@@ -209,6 +220,9 @@ ...@@ -209,6 +220,9 @@
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.SysRole"> <update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.SysRole">
update sys_role update sys_role
<set> <set>
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="name != null"> <if test="name != null">
`name` = #{name,jdbcType=VARCHAR}, `name` = #{name,jdbcType=VARCHAR},
</if> </if>
...@@ -232,7 +246,8 @@ ...@@ -232,7 +246,8 @@
</update> </update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.SysRole"> <update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.SysRole">
update sys_role update sys_role
set `name` = #{name,jdbcType=VARCHAR}, set code = #{code,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR}, description = #{description,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR}, create_by = #{createBy,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR}, update_by = #{updateBy,jdbcType=VARCHAR},
......
package io.dataease.base.mapper.ext; package io.dataease.base.mapper.ext;
import io.dataease.base.domain.SysRole;
import io.dataease.controller.sys.request.RoleGridRequest; import io.dataease.controller.sys.request.RoleGridRequest;
import io.dataease.controller.sys.response.RoleNodeResponse;
import io.dataease.controller.sys.response.RoleUserItem; import io.dataease.controller.sys.response.RoleUserItem;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -12,11 +12,13 @@ import java.util.Map; ...@@ -12,11 +12,13 @@ import java.util.Map;
public interface ExtSysRoleMapper { public interface ExtSysRoleMapper {
List<RoleNodeResponse> query(@Param("request")RoleGridRequest request); List<SysRole> query(@Param("request")RoleGridRequest request);
int deleteRoleMenu(@Param("roleId") Long roleId); int deleteRoleMenu(@Param("roleId") Long roleId);
int batchInsertRoleMenu(@Param("maps") List<Map<String, Long>> maps); int batchInsertRoleMenu(@Param("maps") List<Map<String, Long>> maps);
List<RoleUserItem> queryAll(); List<RoleUserItem> queryAll();
List<Long> menuIds(@Param("roleId") Long roleId);
} }
...@@ -2,23 +2,16 @@ ...@@ -2,23 +2,16 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.dataease.base.mapper.ext.ExtSysRoleMapper"> <mapper namespace="io.dataease.base.mapper.ext.ExtSysRoleMapper">
<resultMap id="BaseResultMap" type="io.dataease.controller.sys.response.RoleNodeResponse" extends="io.dataease.base.mapper.SysRoleMapper.BaseResultMap">
<result column="menuIds" property="menu_ids"/>
<collection property="menuIds" ofType="long">
<constructor>
<arg column="menu_id"/>
</constructor>
</collection>
</resultMap>
<resultMap id="roleItemMap" type="io.dataease.controller.sys.response.RoleUserItem"> <resultMap id="roleItemMap" type="io.dataease.controller.sys.response.RoleUserItem">
<id property="id" column="id"/> <id property="id" column="id"/>
<result property="name" column="name"/> <result property="name" column="name"/>
</resultMap> </resultMap>
<select id="query" resultMap="BaseResultMap"> <select id="query" resultMap="io.dataease.base.mapper.SysRoleMapper.BaseResultMap">
select r.*, m.menu_id select r.*
from sys_role r left join sys_roles_menus m on r.role_id = m.role_id from sys_role r
<where> <where>
<if test="request.name != null"> <if test="request.name != null">
AND r.name like CONCAT('%', #{request.name},'%') AND r.name like CONCAT('%', #{request.name},'%')
...@@ -43,6 +36,10 @@ ...@@ -43,6 +36,10 @@
select role_id as id, name from sys_role select role_id as id, name from sys_role
</select> </select>
<select id="menuIds" resultType="java.lang.Long">
select menu_id from sys_roles_menus where role_id = #{roleId}
</select>
</mapper> </mapper>
...@@ -8,7 +8,6 @@ import io.dataease.commons.utils.PageUtils; ...@@ -8,7 +8,6 @@ import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager; import io.dataease.commons.utils.Pager;
import io.dataease.controller.sys.request.RoleGridRequest; import io.dataease.controller.sys.request.RoleGridRequest;
import io.dataease.controller.sys.request.RoleMenusRequest; import io.dataease.controller.sys.request.RoleMenusRequest;
import io.dataease.controller.sys.response.RoleNodeResponse;
import io.dataease.controller.sys.response.RoleUserItem; import io.dataease.controller.sys.response.RoleUserItem;
import io.dataease.service.sys.SysRoleService; import io.dataease.service.sys.SysRoleService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -50,9 +49,16 @@ public class SysRoleController { ...@@ -50,9 +49,16 @@ public class SysRoleController {
@ApiOperation("查询角色") @ApiOperation("查询角色")
@PostMapping("/roleGrid/{goPage}/{pageSize}") @PostMapping("/roleGrid/{goPage}/{pageSize}")
public Pager<List<RoleNodeResponse>> roleGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody RoleGridRequest request) { public Pager<List<SysRole>> roleGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody RoleGridRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, sysRoleService.query(request)); Pager<List<SysRole>> listPager = PageUtils.setPageInfo(page, sysRoleService.query(request));
return listPager;
}
@ApiOperation("查询角色对应的菜单ID")
@PostMapping("/menuIds/{roleId}")
public List<Long> menuIdsByRoleId(@PathVariable("roleId") Long roleId){
return sysRoleService.menuIds(roleId);
} }
......
package io.dataease.controller.sys.response;
import io.dataease.base.domain.SysRole;
import lombok.Data;
import java.util.List;
@Data
public class RoleNodeResponse extends SysRole {
private List<Long> menuIds;
private List<Long> dataIds;
}
...@@ -8,7 +8,6 @@ import io.dataease.base.mapper.SysUsersRolesMapper; ...@@ -8,7 +8,6 @@ import io.dataease.base.mapper.SysUsersRolesMapper;
import io.dataease.base.mapper.ext.ExtSysRoleMapper; import io.dataease.base.mapper.ext.ExtSysRoleMapper;
import io.dataease.controller.sys.request.RoleGridRequest; import io.dataease.controller.sys.request.RoleGridRequest;
import io.dataease.controller.sys.request.RoleMenusRequest; import io.dataease.controller.sys.request.RoleMenusRequest;
import io.dataease.controller.sys.response.RoleNodeResponse;
import io.dataease.controller.sys.response.RoleUserItem; import io.dataease.controller.sys.response.RoleUserItem;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -32,6 +31,7 @@ public class SysRoleService { ...@@ -32,6 +31,7 @@ public class SysRoleService {
private SysUsersRolesMapper sysUsersRolesMapper; private SysUsersRolesMapper sysUsersRolesMapper;
public int add(SysRole role){ public int add(SysRole role){
Long now = System.currentTimeMillis(); Long now = System.currentTimeMillis();
role.setCreateTime(now); role.setCreateTime(now);
...@@ -56,12 +56,16 @@ public class SysRoleService { ...@@ -56,12 +56,16 @@ public class SysRoleService {
} }
public List<RoleNodeResponse> query(RoleGridRequest request){ public List<SysRole> query(RoleGridRequest request){
List<RoleNodeResponse> result = extSysRoleMapper.query(request); List<SysRole> result = extSysRoleMapper.query(request);
return result; return result;
} }
public List<Long> menuIds(Long roleId){
return extSysRoleMapper.menuIds(roleId);
}
@Transactional @Transactional
public int batchSaveRolesMenus(RoleMenusRequest request){ public int batchSaveRolesMenus(RoleMenusRequest request){
......
...@@ -45,4 +45,11 @@ export function addRoleMenus(data) { ...@@ -45,4 +45,11 @@ export function addRoleMenus(data) {
data data
}) })
} }
export default { addRole, editRole, delRole, roleGrid, allRoles, addRoleMenus }
export function menuIds(roleId) {
return request({
url: '/api/role/menuIds/' + roleId,
method: 'post'
})
}
export default { addRole, editRole, delRole, roleGrid, allRoles, addRoleMenus, menuIds }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<el-table border highlight-current-row class="adjust-table" :data="tableData" style="width: 100%;" @row-click="rowClick"> <el-table border highlight-current-row class="adjust-table" :data="tableData" style="width: 100%;" @row-click="rowClick">
<el-table-column prop="name" label="名称" /> <el-table-column prop="name" label="名称" />
<el-table-column prop="code" label="代码" />
<el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期"> <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span>{{ scope.row.createTime | timestampFormatDate }}</span>
...@@ -58,6 +59,10 @@ ...@@ -58,6 +59,10 @@
<el-input v-model="form.name" style="width: 380px;" /> <el-input v-model="form.name" style="width: 380px;" />
</el-form-item> </el-form-item>
<el-form-item label="角色代码" prop="code">
<el-input v-model="form.code" style="width: 380px;" />
</el-form-item>
<el-form-item label="描述信息" prop="description"> <el-form-item label="描述信息" prop="description">
<el-input v-model="form.description" style="width: 380px;" rows="5" type="textarea" /> <el-input v-model="form.description" style="width: 380px;" rows="5" type="textarea" />
</el-form-item> </el-form-item>
...@@ -83,7 +88,7 @@ import { ...@@ -83,7 +88,7 @@ import {
listenGoBack, listenGoBack,
removeGoBackListener removeGoBackListener
} from '@/metersphere/common/js/utils' } from '@/metersphere/common/js/utils'
import { addRole, editRole, delRole, roleGrid, addRoleMenus } from '@/api/system/role' import { addRole, editRole, delRole, roleGrid, addRoleMenus, menuIds } from '@/api/system/role'
import { getMenusTree, getChild } from '@/api/system/menu' import { getMenusTree, getChild } from '@/api/system/menu'
export default { export default {
...@@ -230,7 +235,11 @@ export default { ...@@ -230,7 +235,11 @@ export default {
}) })
}, },
rowClick(row, column, event) { rowClick(row, column, event) {
this.currentRow = row menuIds(row.roleId).then(res => {
const menuIds = res.data
row.menuIds = menuIds
this.currentRow = row
})
}, },
currentRowChange(newVal, oldVal) { currentRowChange(newVal, oldVal) {
if (newVal === oldVal) { if (newVal === oldVal) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论