refactor(role): refactor role management API and service
- Remove unused imports and simplify controller annotations - Change request mapping path from /api/role to /api/roles - Update assignRolesToUser endpoint to use POST /users - Update revokeRolesFromUser endpoint to use DELETE /users - Modify getAllRoles method to return OptionResponse instead of RoleResponse - Simplify database query in RoleServiceImpl using lambda query wrapper - Add proper authorization checks for all role management endpoints - Remove redundant getUserRole method with duplicate logic
This commit is contained in:
@@ -27,7 +27,6 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DriveTypeMapper, DeviceTy
|
||||
|
||||
@Override
|
||||
public List<OptionResponse> getDeviceTypeOptions() {
|
||||
LambdaQueryWrapper<DeviceType> wrapper = new LambdaQueryWrapper<>();
|
||||
return this.lambdaQuery()
|
||||
.select(DeviceType::getId, DeviceType::getName)
|
||||
.list()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.nopj.chaos_api.service.impl;
|
||||
|
||||
import cn.nopj.chaos_api.domain.entity.Role;
|
||||
import cn.nopj.chaos_api.dto.response.OptionResponse;
|
||||
import cn.nopj.chaos_api.dto.response.RoleResponse;
|
||||
import cn.nopj.chaos_api.mapper.RoleMapper;
|
||||
import cn.nopj.chaos_api.service.RoleService;
|
||||
@@ -12,7 +13,13 @@ import java.util.List;
|
||||
@Service
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
||||
@Override
|
||||
public List<RoleResponse> getAllRoles() {
|
||||
return this.baseMapper.selectList(null).stream().map(RoleResponse::new).toList();
|
||||
public List<OptionResponse> getAllRoles() {
|
||||
|
||||
return this.lambdaQuery()
|
||||
.select(Role::getId, Role::getName)
|
||||
.list()
|
||||
.stream()
|
||||
.map(role -> new OptionResponse(role.getName(), role.getId().toString()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user