添加角色bug修复

This commit is contained in:
张松 2025-03-17 10:01:01 +08:00
parent 00da05c32d
commit 552f6cbb49
1 changed files with 5 additions and 2 deletions

View File

@ -92,7 +92,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean add(RoleAddDTO roleAddDTO) {
long roleCount = queryChain().eq(SysRole::getName, roleAddDTO.name()).count();
long roleCount = queryChain().eq(SysRole::getName, roleAddDTO.name())
.eq(SysRole::getShopId, StpKit.USER.getShopId())
.count();
if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在");
}
@ -120,7 +122,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
throw new ApiNotPrintException("角色不存在");
}
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId()).count();
long roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
.eq(SysRole::getShopId, StpKit.USER.getShopId()).count();
if (roleCount > 0) {
throw new ApiNotPrintException("此角色名称已存在");
}