Merge branch 'prod' into test
This commit is contained in:
@@ -105,9 +105,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Override
|
||||
public Page<SysRole> getList(Long shopId, PageDTO pageDTO, String key, String startTime, String endTime) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
// if (!StpKit.USER.isAdmin()) {
|
||||
queryWrapper.eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong());
|
||||
// }
|
||||
queryWrapper.eq(SysRole::getShopId, shopId);
|
||||
|
||||
if (StrUtil.isNotBlank(key)) {
|
||||
queryWrapper.and(column(SysRole::getName).like(key).or(column(SysRole::getDescription).like(key)));
|
||||
@@ -127,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("角色不存在");
|
||||
}
|
||||
@@ -197,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("角色不存在");
|
||||
}
|
||||
@@ -228,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) {
|
||||
@@ -269,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("此角色名称已存在");
|
||||
}
|
||||
@@ -297,20 +300,4 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
}
|
||||
throw new CzgException("保存失败");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SysRolesMenus menus = new SysRolesMenus();
|
||||
menus.setRoleId(1L);
|
||||
menus.setMenuId(1L);
|
||||
menus.setType(1);
|
||||
SysRolesMenus menus2 = new SysRolesMenus();
|
||||
menus.setRoleId(1L);
|
||||
menus.setMenuId(1L);
|
||||
menus.setType(1);
|
||||
Set<SysRolesMenus> rolesMenus = new HashSet<>();
|
||||
rolesMenus.add(menus);
|
||||
rolesMenus.add(menus2);
|
||||
System.out.println(rolesMenus);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user