角色 问题
This commit is contained in:
@@ -125,8 +125,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getRoleMenu(long userId, Integer id, Integer type) {
|
||||
SysRole role = queryChain().eq(SysRole::getId, id).eq(SysRole::getCreateUserId, userId).one();
|
||||
public List<Long> getRoleMenu(long shopId, Integer id, Integer type) {
|
||||
SysRole role = queryChain().eq(SysRole::getId, id).eq(SysRole::getCreateUserId, shopId).one();
|
||||
if (role == null) {
|
||||
throw new CzgException("角色不存在");
|
||||
}
|
||||
@@ -195,8 +195,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean editPermission(long userId, RolePermissionDTO rolePermissionDTO) {
|
||||
long count = count(new QueryWrapper().eq(SysRole::getId, rolePermissionDTO.getRoleId()).eq(SysRole::getCreateUserId, userId));
|
||||
public Boolean editPermission(long shopId, RolePermissionDTO rolePermissionDTO) {
|
||||
long count = count(new QueryWrapper().eq(SysRole::getId, rolePermissionDTO.getRoleId()).eq(SysRole::getCreateUserId, shopId));
|
||||
if (count == 0) {
|
||||
throw new CzgException("角色不存在");
|
||||
}
|
||||
@@ -226,8 +226,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
sysRole.setName(roleAddDTO.name());
|
||||
sysRole.setLevel(roleAddDTO.level());
|
||||
sysRole.setDescription(roleAddDTO.description());
|
||||
sysRole.setShopId(StpKit.USER.getLoginIdAsLong());
|
||||
sysRole.setCreateUserId(StpKit.USER.getLoginIdAsLong());
|
||||
sysRole.setShopId(StpKit.USER.getShopId());
|
||||
sysRole.setCreateUserId(StpKit.USER.getShopId());
|
||||
sysRole.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
boolean save = save(sysRole);
|
||||
if (save) {
|
||||
@@ -267,13 +267,18 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean edit(RoleEditDTO roleEditDTO) {
|
||||
SysRole role = queryChain().eq(SysRole::getId, roleEditDTO.getId()).eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong()).one();
|
||||
SysRole role = queryChain().eq(SysRole::getId, roleEditDTO.getId()).eq(SysRole::getCreateUserId, StpKit.USER.getShopId()).one();
|
||||
if (role == null) {
|
||||
throw new CzgException("角色不存在");
|
||||
}
|
||||
|
||||
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
|
||||
.eq(SysRole::getShopId, StpKit.USER.getShopId()).count();
|
||||
long roleCount;
|
||||
if (role.getShopId() == null) {
|
||||
roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
|
||||
.isNull(SysRole::getShopId).count();
|
||||
} else {
|
||||
roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
|
||||
.eq(SysRole::getShopId, StpKit.USER.getShopId()).count();
|
||||
}
|
||||
if (roleCount > 0) {
|
||||
throw new CzgException("此角色名称已存在");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user