亮哥你好呀
parent
cb073f2a58
commit
94198b487c
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: nacos.cloud.muyu.icu:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: muyu-cloud
|
||||
namespace: muyu-cloud-zxs
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
@ -20,6 +24,7 @@ import java.util.List;
|
|||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_dept")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysDept extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -27,6 +32,7 @@ public class SysDept extends BaseEntity {
|
|||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
|
@ -77,11 +83,13 @@ public class SysDept extends BaseEntity {
|
|||
/**
|
||||
* 父部门名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 子部门
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
@ -73,26 +75,31 @@ public class SysRole extends BaseEntity {
|
|||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 用户是否存在此角色标识 默认不存在
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private boolean flag = false;
|
||||
|
||||
/**
|
||||
* 菜单组
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] menuIds;
|
||||
|
||||
/**
|
||||
* 部门组(数据权限)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] deptIds;
|
||||
|
||||
/**
|
||||
* 角色菜单权限
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Set<String> permissions;
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: nacos.cloud.muyu.icu:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: muyu-cloud
|
||||
namespace: muyu-cloud-zxs
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: nacos.cloud.muyu.icu:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: muyu-cloud
|
||||
namespace: muyu-cloud-zxs
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: nacos.cloud.muyu.icu:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: muyu-cloud
|
||||
namespace: muyu-cloud-zxs
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.muyu.common.security.annotation.RequiresPermissions;
|
|||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.system.service.SysDeptService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -24,6 +25,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
@Tag(name = "SysDeptController", description = "部门管理")
|
||||
public class SysDeptController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
@ -20,82 +24,98 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_menu")
|
||||
public class SysMenu extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@TableField()
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 父菜单名称
|
||||
*/
|
||||
@TableField()
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
@TableField()
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
@TableField()
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
@TableField()
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
@TableField()
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
@TableField()
|
||||
private String query;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
*/
|
||||
@TableField()
|
||||
private String isFrame;
|
||||
|
||||
/**
|
||||
* 是否缓存(0缓存 1不缓存)
|
||||
*/
|
||||
@TableField()
|
||||
private String isCache;
|
||||
|
||||
/**
|
||||
* 类型(M目录 C菜单 F按钮)
|
||||
*/
|
||||
@TableField()
|
||||
private String menuType;
|
||||
|
||||
/**
|
||||
* 显示状态(0显示 1隐藏)
|
||||
*/
|
||||
@TableField()
|
||||
private String visible;
|
||||
|
||||
/**
|
||||
* 菜单状态(0正常 1停用)
|
||||
*/
|
||||
@TableField()
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 权限字符串
|
||||
*/
|
||||
@TableField()
|
||||
private String perms;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
@TableField()
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.xss.Xss;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -21,12 +24,14 @@ import jakarta.validation.constraints.Size;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_notice")
|
||||
public class SysNotice extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 公告ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long noticeId;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
@ -20,6 +23,7 @@ import jakarta.validation.constraints.Size;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_post")
|
||||
public class SysPost extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -27,6 +31,7 @@ public class SysPost extends BaseEntity {
|
|||
* 岗位序号
|
||||
*/
|
||||
@Excel(name = "岗位序号", cellType = ColumnType.NUMERIC)
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long postId;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -14,6 +17,7 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_role_dept")
|
||||
public class SysRoleDept {
|
||||
/**
|
||||
* 角色ID
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -15,6 +18,7 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_role_menu")
|
||||
public class SysRoleMenu {
|
||||
/**
|
||||
* 角色ID
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -14,6 +17,7 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_user_online")
|
||||
public class SysUserOnline {
|
||||
/**
|
||||
* 会话编号
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -14,6 +17,7 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_user_post")
|
||||
public class SysUserPost {
|
||||
/**
|
||||
* 用户ID
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -14,6 +17,7 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("sys_user_role")
|
||||
public class SysUserRole {
|
||||
/**
|
||||
* 用户ID
|
||||
|
|
|
@ -11,14 +11,6 @@ import java.util.List;
|
|||
* @author muyu
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
*
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public List<SysRole> selectRoleList (SysRole role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
|
@ -67,9 +59,9 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
|||
* 校验角色名称是否唯一
|
||||
*
|
||||
* @param roleName 角色名称
|
||||
*
|
||||
* @return 角色信息
|
||||
*/
|
||||
|
||||
public SysRole checkRoleNameUnique (String roleName);
|
||||
|
||||
/**
|
||||
|
@ -79,16 +71,9 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
|||
*
|
||||
* @return 角色信息
|
||||
*/
|
||||
|
||||
public SysRole checkRoleKeyUnique (String roleKey);
|
||||
|
||||
/**
|
||||
* 修改角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRole (SysRole role);
|
||||
|
||||
/**
|
||||
* 新增角色信息
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.domain.SysRoleMenu;
|
||||
import feign.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -47,4 +48,8 @@ public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int batchRoleMenu (List<SysRoleMenu> roleMenuList);
|
||||
|
||||
// 批量保存角色与菜单的关联
|
||||
boolean saveBatch(@Param("roleMenuList") List<SysRoleMenu> roleMenuList);
|
||||
|
||||
}
|
||||
|
|
|
@ -128,19 +128,17 @@ public interface SysRoleService extends IService<SysRole> {
|
|||
* 修改角色状态
|
||||
*
|
||||
* @param role 角色信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRoleStatus (SysRole role);
|
||||
public boolean updateRoleStatus (SysRole role);
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int authDataScope (SysRole role);
|
||||
public boolean authDataScope (SysRole role);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
|
|
|
@ -29,13 +29,15 @@ import java.util.stream.Collectors;
|
|||
* @author muyu
|
||||
*/
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
||||
implements SysDeptService {
|
||||
@Autowired
|
||||
private SysDeptMapper deptMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.constant.UserConstants;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
|
@ -45,14 +47,23 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @param params 角色信息
|
||||
*
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysRole> selectRoleList (SysRole role) {
|
||||
return roleMapper.selectRoleList(role);
|
||||
public List<SysRole> selectRoleList (SysRole params) {
|
||||
LambdaQueryWrapper<SysRole> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(params.getRoleId() != null && params.getRoleId() != 0, SysRole::getRoleId, params.getRoleId());
|
||||
wrapper.like(StringUtils.isNotBlank(params.getRoleName()), SysRole::getRoleName, params.getRoleName());
|
||||
wrapper.eq(StringUtils.isNotBlank(params.getStatus()), SysRole::getStatus, params.getStatus());
|
||||
|
||||
wrapper.like(StringUtils.isNotBlank(params.getRoleKey()), SysRole::getRoleKey, params.getRoleKey());
|
||||
wrapper.ge(params.getParams().get("beginTime") != null, SysRole::getCreateTime, params.getParams().get("beginTime"));
|
||||
wrapper.le(params.getParams().get("endTime") != null, SysRole::getCreateTime, params.getParams().get("endTime"));
|
||||
wrapper.orderBy(true, true, SysRole::getRoleSort);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,52 +230,80 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
roleMapper.insertRole(role);
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @param sysRole 角色信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateRole (SysRole role) {
|
||||
// 修改角色信息
|
||||
roleMapper.updateRole(role);
|
||||
public int updateRole (SysRole sysRole) {
|
||||
LambdaUpdateWrapper<SysRole> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
||||
// 条件判断并更新字段
|
||||
updateWrapper.eq(SysRole::getRoleId, sysRole.getRoleId());
|
||||
|
||||
if (sysRole.getRoleName() != null && !sysRole.getRoleName().isEmpty()) {
|
||||
updateWrapper.set(SysRole::getRoleName, sysRole.getRoleName());
|
||||
}
|
||||
if (sysRole.getRoleKey() != null && !sysRole.getRoleKey().isEmpty()) {
|
||||
updateWrapper.set(SysRole::getRoleKey, sysRole.getRoleKey());
|
||||
}
|
||||
if (sysRole.getRoleSort() != null) {
|
||||
updateWrapper.set(SysRole::getRoleSort, sysRole.getRoleSort());
|
||||
}
|
||||
if (sysRole.getDataScope() != null && !sysRole.getDataScope().isEmpty()) {
|
||||
updateWrapper.set(SysRole::getDataScope, sysRole.getDataScope());
|
||||
}
|
||||
if (sysRole.getStatus() != null && !sysRole.getStatus().isEmpty()) {
|
||||
updateWrapper.set(SysRole::getStatus, sysRole.getStatus());
|
||||
}
|
||||
if (sysRole.getRemark() != null) {
|
||||
updateWrapper.set(SysRole::getRemark, sysRole.getRemark());
|
||||
}
|
||||
if (sysRole.getUpdateBy() != null && !sysRole.getUpdateBy().isEmpty()) {
|
||||
updateWrapper.set(SysRole::getUpdateBy, sysRole.getUpdateBy());
|
||||
}
|
||||
|
||||
// 更新时间
|
||||
updateWrapper.set(SysRole::getUpdateTime, new java.util.Date());
|
||||
|
||||
// 执行更新
|
||||
this.update(updateWrapper);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
||||
return insertRoleMenu(role);
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(sysRole.getRoleId());
|
||||
return insertRoleMenu(sysRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色状态
|
||||
*
|
||||
* @param role 角色信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRoleStatus (SysRole role) {
|
||||
return roleMapper.updateRole(role);
|
||||
public boolean updateRoleStatus (SysRole role) {
|
||||
boolean updateResult = updateById(role); // 通过 roleId 更新角色信息
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int authDataScope (SysRole role) {
|
||||
public boolean authDataScope (SysRole role) {
|
||||
// 修改角色信息
|
||||
roleMapper.updateRole(role);
|
||||
boolean updateResult = updateById(role); // 通过 roleId 更新角色信息
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
|
||||
// 新增角色和部门信息(数据权限)
|
||||
return insertRoleDept(role);
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,7 +312,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleMenu (SysRole role) {
|
||||
int rows = 1;
|
||||
// 假设role.getMenuIds()返回角色关联的菜单ID列表
|
||||
List<Long> menuIds = List.of(role.getMenuIds());
|
||||
if (menuIds == null || menuIds.isEmpty()){
|
||||
return 0;
|
||||
}
|
||||
// 新增用户与角色管理
|
||||
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
|
||||
for (Long menuId : role.getMenuIds()) {
|
||||
|
@ -282,10 +325,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
rows = roleMenuMapper.batchRoleMenu(list);
|
||||
}
|
||||
return rows;
|
||||
// 使用MyBatis-Plus的saveBatch方法批量插入角色与菜单的关联关系
|
||||
boolean saveResult = roleMenuMapper.saveBatch(list);
|
||||
|
||||
return saveResult ? list.size() : 0; // 返回成功插入的数量
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: nacos.cloud.muyu.icu:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: muyu-cloud
|
||||
namespace: muyu-cloud-zxs
|
||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -39,32 +39,6 @@
|
|||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleList" parameterType="com.muyu.common.system.domain.SysRole" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.del_flag = '0'
|
||||
<if test="roleId != null and roleId != 0">
|
||||
AND r.role_id = #{roleId}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
AND r.role_name like concat('%', #{roleName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
<if test="roleKey != null and roleKey != ''">
|
||||
AND r.role_key like concat('%', #{roleKey}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
||||
|
@ -130,23 +104,6 @@
|
|||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateRole" parameterType="com.muyu.common.system.domain.SysRole">
|
||||
update sys_role
|
||||
<set>
|
||||
<if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
|
||||
<if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if>
|
||||
<if test="roleSort != null">role_sort = #{roleSort},</if>
|
||||
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
|
||||
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
|
||||
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where role_id = #{roleId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteRoleById" parameterType="Long">
|
||||
update sys_role
|
||||
set del_flag = '2'
|
||||
|
|
|
@ -34,5 +34,11 @@
|
|||
(#{item.roleId},#{item.menuId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="saveBatch">
|
||||
insert into sys_role_menu(role_id, menu_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.roleId},#{item.menuId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: nacos.cloud.muyu.icu:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: muyu-cloud
|
||||
namespace: muyu-cloud-zxs
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
Loading…
Reference in New Issue