mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Fixed pagination in RoleManagement
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package com.cfive.pinnacle.mapper.permission;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.cfive.pinnacle.entity.permission.Role;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色 Mapper 接口
|
||||
@@ -16,7 +17,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
IPage<Role> getAll(IPage<Role> roleIPage);
|
||||
List<Role> getAll(@Param("roleList") List<Role> roleList);
|
||||
|
||||
Role getOneById(@Param("id") long id);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@ package com.cfive.pinnacle.service.permission.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cfive.pinnacle.entity.permission.Power;
|
||||
import com.cfive.pinnacle.entity.permission.Role;
|
||||
import com.cfive.pinnacle.entity.permission.PowerRole;
|
||||
import com.cfive.pinnacle.entity.permission.*;
|
||||
import com.cfive.pinnacle.exception.DataValidationFailedException;
|
||||
import com.cfive.pinnacle.mapper.permission.RoleMapper;
|
||||
import com.cfive.pinnacle.mapper.permission.PowerRoleMapper;
|
||||
@@ -46,7 +45,10 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
|
||||
@Override
|
||||
public IPage<Role> getAllRole(Long currentPage, Long pageSize) {
|
||||
IPage<Role> roleIPage = PageDTO.of(currentPage, pageSize);
|
||||
return roleMapper.getAll(roleIPage);
|
||||
roleIPage = roleMapper.selectPage(roleIPage, Wrappers.emptyWrapper());
|
||||
roleIPage.setRecords(roleMapper.getAll(roleIPage.getRecords()));
|
||||
|
||||
return roleIPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<mapper namespace="com.cfive.pinnacle.mapper.permission.RoleMapper">
|
||||
|
||||
<select id="getAll" resultMap="roleMap">
|
||||
select t_role.id as role_id,
|
||||
select distinct t_role.id as role_id,
|
||||
t_role.name as role_name,
|
||||
t_role.enable as role_enable,
|
||||
t_role.deleted as role_deleted,
|
||||
@@ -23,13 +23,18 @@
|
||||
t.power_id as operation_power_id,
|
||||
t.element_id as operation_element_id,
|
||||
t.parent_id as operation_parent_id
|
||||
from t_role
|
||||
from (select * from t_role where deleted = 0) as t_role
|
||||
left join (select * from t_power_role where deleted = 0) as tpr on t_role.id = tpr.role_id
|
||||
left join t_power tp on tp.id = tpr.power_id
|
||||
left join t_menu tm on tp.id = tm.power_id
|
||||
left join t_element te on tp.id = te.power_id
|
||||
left join t_operation t on tp.id = t.power_id
|
||||
where t_role.deleted = 0
|
||||
<where>
|
||||
<foreach collection="roleList" item="item" index="index" open="t_role.id in (" separator="," close=")"
|
||||
nullable="true">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getOneById" resultMap="roleMap">
|
||||
select t_role.id as role_id,
|
||||
@@ -62,12 +67,15 @@
|
||||
and t_role.id = #{id}
|
||||
</select>
|
||||
|
||||
<resultMap id="roleMap" type="role">
|
||||
<resultMap id="roleBase" type="role">
|
||||
<id property="id" column="role_id"/>
|
||||
<result property="name" column="role_name"/>
|
||||
<result property="enable" column="role_enable"/>
|
||||
<result property="deleted" column="role_deleted"/>
|
||||
<result property="version" column="role_version"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="roleMap" type="role" extends="roleBase">
|
||||
<collection property="menus" ofType="menu">
|
||||
<id property="id" column="menu_id"/>
|
||||
<result property="name" column="menu_name"/>
|
||||
|
||||
Reference in New Issue
Block a user