feat: 修复角色分页
This commit is contained in:
parent
09854fac6d
commit
c1158932fa
@ -7,6 +7,8 @@ import lombok.Data;
|
||||
public class SysRole implements Serializable {
|
||||
private Long roleId;
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
@ -164,6 +164,76 @@ public class SysRoleExample {
|
||||
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() {
|
||||
addCriterion("`name` is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<mapper namespace="io.dataease.base.mapper.SysRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="io.dataease.base.domain.SysRole">
|
||||
<id column="role_id" jdbcType="BIGINT" property="roleId" />
|
||||
<result column="code" jdbcType="VARCHAR" property="code" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
@ -69,7 +70,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<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>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.SysRoleExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -102,12 +103,12 @@
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.base.domain.SysRole">
|
||||
insert into sys_role (role_id, `name`, description,
|
||||
create_by, update_by, create_time,
|
||||
update_time)
|
||||
values (#{roleId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
|
||||
#{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||
#{updateTime,jdbcType=BIGINT})
|
||||
insert into sys_role (role_id, code, `name`,
|
||||
description, create_by, update_by,
|
||||
create_time, update_time)
|
||||
values (#{roleId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{description,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.SysRole">
|
||||
insert into sys_role
|
||||
@ -115,6 +116,9 @@
|
||||
<if test="roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="code != null">
|
||||
code,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
@ -138,6 +142,9 @@
|
||||
<if test="roleId != null">
|
||||
#{roleId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="code != null">
|
||||
#{code,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -170,6 +177,9 @@
|
||||
<if test="record.roleId != null">
|
||||
role_id = #{record.roleId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.code != null">
|
||||
code = #{record.code,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -196,6 +206,7 @@
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update sys_role
|
||||
set role_id = #{record.roleId,jdbcType=BIGINT},
|
||||
code = #{record.code,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
create_by = #{record.createBy,jdbcType=VARCHAR},
|
||||
@ -209,6 +220,9 @@
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.SysRole">
|
||||
update sys_role
|
||||
<set>
|
||||
<if test="code != null">
|
||||
code = #{code,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -232,7 +246,8 @@
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.SysRole">
|
||||
update sys_role
|
||||
set `name` = #{name,jdbcType=VARCHAR},
|
||||
set code = #{code,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
create_by = #{createBy,jdbcType=VARCHAR},
|
||||
update_by = #{updateBy,jdbcType=VARCHAR},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
import io.dataease.base.domain.SysRole;
|
||||
import io.dataease.controller.sys.request.RoleGridRequest;
|
||||
import io.dataease.controller.sys.response.RoleNodeResponse;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@ -12,11 +12,13 @@ import java.util.Map;
|
||||
public interface ExtSysRoleMapper {
|
||||
|
||||
|
||||
List<RoleNodeResponse> query(@Param("request")RoleGridRequest request);
|
||||
List<SysRole> query(@Param("request")RoleGridRequest request);
|
||||
|
||||
int deleteRoleMenu(@Param("roleId") Long roleId);
|
||||
|
||||
int batchInsertRoleMenu(@Param("maps") List<Map<String, Long>> maps);
|
||||
|
||||
List<RoleUserItem> queryAll();
|
||||
|
||||
List<Long> menuIds(@Param("roleId") Long roleId);
|
||||
}
|
||||
|
||||
@ -2,23 +2,16 @@
|
||||
<!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">
|
||||
|
||||
<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">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="query" resultMap="BaseResultMap">
|
||||
select r.*, m.menu_id
|
||||
from sys_role r left join sys_roles_menus m on r.role_id = m.role_id
|
||||
<select id="query" resultMap="io.dataease.base.mapper.SysRoleMapper.BaseResultMap">
|
||||
select r.*
|
||||
from sys_role r
|
||||
<where>
|
||||
<if test="request.name != null">
|
||||
AND r.name like CONCAT('%', #{request.name},'%')
|
||||
@ -43,6 +36,10 @@
|
||||
select role_id as id, name from sys_role
|
||||
</select>
|
||||
|
||||
<select id="menuIds" resultType="java.lang.Long">
|
||||
select menu_id from sys_roles_menus where role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -8,7 +8,6 @@ import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.sys.request.RoleGridRequest;
|
||||
import io.dataease.controller.sys.request.RoleMenusRequest;
|
||||
import io.dataease.controller.sys.response.RoleNodeResponse;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import io.dataease.service.sys.SysRoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -50,9 +49,16 @@ public class SysRoleController {
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
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;
|
||||
import io.dataease.base.mapper.ext.ExtSysRoleMapper;
|
||||
import io.dataease.controller.sys.request.RoleGridRequest;
|
||||
import io.dataease.controller.sys.request.RoleMenusRequest;
|
||||
import io.dataease.controller.sys.response.RoleNodeResponse;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -32,6 +31,7 @@ public class SysRoleService {
|
||||
private SysUsersRolesMapper sysUsersRolesMapper;
|
||||
|
||||
|
||||
|
||||
public int add(SysRole role){
|
||||
Long now = System.currentTimeMillis();
|
||||
role.setCreateTime(now);
|
||||
@ -56,12 +56,16 @@ public class SysRoleService {
|
||||
}
|
||||
|
||||
|
||||
public List<RoleNodeResponse> query(RoleGridRequest request){
|
||||
List<RoleNodeResponse> result = extSysRoleMapper.query(request);
|
||||
public List<SysRole> query(RoleGridRequest request){
|
||||
List<SysRole> result = extSysRoleMapper.query(request);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Long> menuIds(Long roleId){
|
||||
return extSysRoleMapper.menuIds(roleId);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public int batchSaveRolesMenus(RoleMenusRequest request){
|
||||
|
||||
@ -45,4 +45,11 @@ export function addRoleMenus(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 @@
|
||||
<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="code" label="代码" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建日期">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
@ -58,6 +59,10 @@
|
||||
<el-input v-model="form.name" style="width: 380px;" />
|
||||
</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-input v-model="form.description" style="width: 380px;" rows="5" type="textarea" />
|
||||
</el-form-item>
|
||||
@ -83,7 +88,7 @@ import {
|
||||
listenGoBack,
|
||||
removeGoBackListener
|
||||
} 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'
|
||||
export default {
|
||||
@ -230,7 +235,11 @@ export default {
|
||||
})
|
||||
},
|
||||
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) {
|
||||
if (newVal === oldVal) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user