fix: 增加Oracle 分页插件&代码优化
This commit is contained in:
parent
504196babe
commit
e69306e530
@ -14,11 +14,22 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class MybitsPlusConfig {
|
public class MybitsPlusConfig {
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
// MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
||||||
|
// mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
|
// return mybatisPlusInterceptor;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页插件配置(Oracle 兼容)
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
// 添加分页拦截器,指定数据库类型为 Oracle
|
||||||
return mybatisPlusInterceptor;
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.ORACLE));
|
||||||
|
return interceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.yfd.platform.system.controller;
|
package com.yfd.platform.system.controller;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.yfd.platform.annotation.Log;
|
import com.yfd.platform.annotation.Log;
|
||||||
@ -46,15 +47,8 @@ public class SysRoleController {
|
|||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@Operation(summary = "查询所有角色")
|
@Operation(summary = "查询所有角色")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<SysRole> list(String rolename) {
|
public List<SysRole> list(@RequestParam(required = false) String rolename) {
|
||||||
QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
|
return roleService.selectRoleList(rolename);
|
||||||
if (StrUtil.isNotEmpty(rolename)) {
|
|
||||||
//根据角色名称模糊查询
|
|
||||||
queryWrapper.like("rolename", rolename);
|
|
||||||
}
|
|
||||||
//根据角色级别,角色编号 正序排序
|
|
||||||
queryWrapper.ne("level", "1").orderByAsc("level", "lastmodifydate");
|
|
||||||
return roleService.list(queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
|
|||||||
@ -101,4 +101,12 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
|||||||
* 返回值说明:角色 ID 列表
|
* 返回值说明:角色 ID 列表
|
||||||
***********************************/
|
***********************************/
|
||||||
List<String> getRoleIdsByUserId(String id);
|
List<String> getRoleIdsByUserId(String id);
|
||||||
|
|
||||||
|
/**********************************
|
||||||
|
* 用途说明:查询角色列表(Oracle 兼容)
|
||||||
|
* 参数说明:rolename - 角色名称
|
||||||
|
* 返回值说明:角色列表
|
||||||
|
***********************************/
|
||||||
|
List<SysRole> selectRoleList(@Param("rolename") String rolename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,4 +63,6 @@ public interface ISysRoleService extends IService<SysRole> {
|
|||||||
* 返回值说明: 是否分配成功
|
* 返回值说明: 是否分配成功
|
||||||
***********************************/
|
***********************************/
|
||||||
boolean setMenuById(String id, String menuIds);
|
boolean setMenuById(String id, String menuIds);
|
||||||
|
|
||||||
|
List<SysRole> selectRoleList(String rolename);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import com.yfd.platform.system.mapper.SysOrganizationMapper;
|
|||||||
import com.yfd.platform.system.mapper.SysRoleMapper;
|
import com.yfd.platform.system.mapper.SysRoleMapper;
|
||||||
import com.yfd.platform.system.service.ISysOrganizationService;
|
import com.yfd.platform.system.service.ISysOrganizationService;
|
||||||
import com.yfd.platform.system.service.IUserService;
|
import com.yfd.platform.system.service.IUserService;
|
||||||
|
import com.yfd.platform.utils.ObjectConverterUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -128,12 +129,15 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
|
|||||||
QueryWrapper<SysOrganization> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SysOrganization> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("parentid", parentid); //根据上级id 查询
|
queryWrapper.eq("parentid", parentid); //根据上级id 查询
|
||||||
listMap = this.listMaps(queryWrapper.orderByAsc("orgcode"));
|
listMap = this.listMaps(queryWrapper.orderByAsc("orgcode"));
|
||||||
if (!listMap.isEmpty()) { //判断是否存在子集
|
|
||||||
for (int i = 0; i < listMap.size(); i++) { //遍历表数据
|
if (!listMap.isEmpty()) {
|
||||||
|
List<Map<String, Object>> mapList = ObjectConverterUtil.convertMapFieldsToEntityFormat(SysOrganization.class, listMap);//判断是否存在子集
|
||||||
|
for (int i = 0; i < mapList.size(); i++) { //遍历表数据
|
||||||
List<Map<String, Object>> childList =
|
List<Map<String, Object>> childList =
|
||||||
child(listMap.get(i).get("id").toString()); //循环获取下一子集
|
child(mapList.get(i).get("id").toString()); //循环获取下一子集
|
||||||
listMap.get(i).put("childList", childList); //添加新列 子集
|
mapList.get(i).put("childList", childList); //添加新列 子集
|
||||||
}
|
}
|
||||||
|
return mapList;
|
||||||
}
|
}
|
||||||
return listMap;
|
return listMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,4 +160,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysRole> selectRoleList(String rolename) {
|
||||||
|
return roleMapper.selectRoleList(rolename);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,20 @@
|
|||||||
FROM sys_role_users
|
FROM sys_role_users
|
||||||
WHERE userid = #{id}
|
WHERE userid = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<!--查询角色列表(Oracle 兼容版)-->
|
||||||
|
<select id="selectRoleList" resultType="com.yfd.platform.system.domain.SysRole">
|
||||||
|
SELECT r.id, r.rolecode, r.rolename, r."LEVEL", r.description,
|
||||||
|
r.orgscope, r.optscope, r.busscope, r.isvaild,
|
||||||
|
r.lastmodifier, r.lastmodifydate, r.custom1, r.custom2, r.custom3
|
||||||
|
FROM sys_role r
|
||||||
|
<where>
|
||||||
|
<if test="rolename != null and rolename != ''">
|
||||||
|
AND r.rolename LIKE '%' || #{rolename} || '%'
|
||||||
|
</if>
|
||||||
|
AND r."LEVEL" != '1'
|
||||||
|
</where>
|
||||||
|
ORDER BY r."LEVEL" ASC, lastmodifydate ASC
|
||||||
|
</select>
|
||||||
<!--根据 角色id和用户id 删除系统角色用户对照 (admin除外)-->
|
<!--根据 角色id和用户id 删除系统角色用户对照 (admin除外)-->
|
||||||
<delete id="deleteRoleUsers">
|
<delete id="deleteRoleUsers">
|
||||||
delete from sys_role_users where userid !=(select u.id from sys_user u where u.account="admin") and roleid=#{roleid} and userid=#{urserid}
|
delete from sys_role_users where userid !=(select u.id from sys_user u where u.account="admin") and roleid=#{roleid} and userid=#{urserid}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user