增加获取所有角色列表接口

This commit is contained in:
TinyAnts 2022-08-09 17:39:36 +08:00
parent e0937b5d2f
commit 71c78f2837
3 changed files with 52 additions and 3 deletions

View File

@ -12,6 +12,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 系统角色管理
@ -23,6 +25,18 @@ public class AuthRoleController {
@Resource
ISystemAuthRoleService iSystemAuthRoleService;
/**
* 角色所有
*
* @author fzr
* @return Object
*/
@GetMapping("/all")
public Object all() {
List<Map<String, Object>> list = iSystemAuthRoleService.all();
return AjaxResult.success(list);
}
/**
* 角色列表
*

View File

@ -6,11 +6,22 @@ import com.hxkj.admin.vo.system.SystemAuthRoleVo;
import com.hxkj.common.core.PageResult;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.util.Map;
/**
* 系统角色服务接口类
*/
public interface ISystemAuthRoleService {
/**
* 角色所有
*
* @author fzr
* @return List<SystemAuthRoleVo>
*/
List<Map<String, Object>> all();
/**
* 角色列表
*

View File

@ -23,9 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
/**
* 系统角色服务实现类
@ -42,6 +40,32 @@ public class SystemAuthRoleServiceImpl implements ISystemAuthRoleService {
@Resource
ISystemAuthPermService iSystemAuthPermService;
/**
* 角色所有
*
* @author fzr
* @return List<SystemAuthRoleVo>
*/
@Override
public List<Map<String, Object>> all() {
QueryWrapper<SystemAuthRole> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id,name,create_time,update_time");
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
List<SystemAuthRole> systemAuthRoles = systemAuthRoleMapper.selectList(queryWrapper);
List<Map<String, Object>> list = new ArrayList<>();
for (SystemAuthRole systemAuthRole : systemAuthRoles) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", systemAuthRole.getId());
map.put("name", systemAuthRole.getName());
map.put("createTime", TimeUtil.timestampToDate(systemAuthRole.getCreateTime()));
map.put("updateTime", TimeUtil.timestampToDate(systemAuthRole.getUpdateTime()));
list.add(map);
}
return list;
}
/**
* 角色列表
*