online-exam/src/main/java/com/zhangmeng/online/exam/controller/RoleController.java

45 lines
1.2 KiB
Java

package com.zhangmeng.online.exam.controller;
import com.zhangmeng.online.exam.dao.RoleDao;
import com.zhangmeng.online.exam.dto.Result;
import com.zhangmeng.online.exam.entity.Role;
import com.zhangmeng.online.exam.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author zm
* @date 2025/3/6 17:27
* @version: 1.0
*/
@RestController
@RequestMapping("/role")
public class RoleController {
@Autowired
private RoleDao roleDao;
@RequestMapping("/list")
public Result list() {
List<Role> list = roleDao.findAll();
List<Map<String, Object>> resultList = new ArrayList<>();
for (Role role : list) {
Map<String, Object> map = new HashMap<>();
map.put("id", role.getId());
map.put("name", role.getName());
map.put("desc", role.getDescription());
map.put("type_name", role.getType().name());
resultList.add(map);
}
return Result.success(resultList);
}
}