系统用户管理

This commit is contained in:
张松
2025-03-05 09:46:57 +08:00
parent f81a4a8cbf
commit dd35cc07f1
2 changed files with 15 additions and 8 deletions

View File

@@ -136,6 +136,9 @@ public class AuthorizationServiceImpl implements AuthorizationService {
// 查询角色
List<SysRole> roleList = sysRoleService.getByUserId(user.getId());
List<String> roleNames = roleList.stream().map(SysRole::getName).collect(Collectors.toList());
if (user.getIsAdmin()) {
roleNames.add("admin");
}
StpKit.USER.addRoleList(roleNames);
// 权限赋予
List<String> promissionList = sysMenuMapper.selectByUserId(user.getId(), null).stream().map(SysMenu::getPermission).filter(StrUtil::isNotBlank).collect(Collectors.toList());
@@ -143,9 +146,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
if (shopStaffPromissionList != null && !shopStaffPromissionList.isEmpty()) {
promissionList.addAll(shopStaffPromissionList);
}
if (user.getIsAdmin()) {
promissionList.add("admin");
}
StpKit.USER.addPermissionList(promissionList);
String platformType = ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType");
if (PlatformTypeEnum.PC_CLIENT.getValue().equals(platformType)) {

View File

@@ -116,9 +116,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
@Override
public Boolean edit(SysUserEditDTO sysUserEditDTO) {
long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserEditDTO.getAccount()).ne(SysUser::getId, sysUserEditDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("账号已存在");
if (StrUtil.isNotBlank(sysUserEditDTO.getAccount())) {
long count = count(new QueryWrapper().eq(SysUser::getAccount, sysUserEditDTO.getAccount()).ne(SysUser::getId, sysUserEditDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("账号已存在");
}
}
SysUser sysUser = getById(sysUserEditDTO.getId());
@@ -143,8 +145,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
if (sysUser == null) {
throw new ApiNotPrintException("用户不存在");
}
int i = sysUsersRolesMapper.deleteByQuery(new QueryWrapper().eq(SysUsersRoles::getUserId, id));
return i > 0;
boolean remove = remove(new QueryWrapper().eq(SysUser::getId, id));
if (remove) {
int i = sysUsersRolesMapper.deleteByQuery(new QueryWrapper().eq(SysUsersRoles::getUserId, id));
return i > 0;
}
return false;
}
@Override