feat(role): 新增获取用户角色接口

- 在RoleController中新增getUserRole方法,用于获取所有用户角色
- 添加RoleService接口及其实现类RoleServiceImpl
- 创建RoleResponse DTO并优化UserProfileResponse中的角色映射逻辑
- 引入RoleService依赖并配置相关注解以支持新功能
- 实现角色数据的查询与转换,返回标准ApiResult格式结果
This commit is contained in:
Chaos
2025-11-26 06:25:31 +08:00
parent 2a94f493e6
commit 79ef40bd34
5 changed files with 58 additions and 6 deletions

View File

@@ -0,0 +1,18 @@
package cn.nopj.chaos_api.service.impl;
import cn.nopj.chaos_api.domain.entity.Role;
import cn.nopj.chaos_api.dto.response.RoleResponse;
import cn.nopj.chaos_api.mapper.RoleMapper;
import cn.nopj.chaos_api.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
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();
}
}