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 list = roleDao.findAll(); List> resultList = new ArrayList<>(); for (Role role : list) { Map 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); } }