package com.qmth.exam.reserve.controller.admin;

import com.qmth.boot.api.annotation.Aac;
import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.exam.reserve.bean.user.RoleVO;
import com.qmth.exam.reserve.controller.BaseController;
import com.qmth.exam.reserve.enums.Role;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@Api(tags = "【管理端】角色相关接口")
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/role")
@Aac(strict = false, auth = true)
public class RoleController extends BaseController {

    private static final Logger log = LoggerFactory.getLogger(RoleController.class);

    @ApiOperation(value = "角色列表")
    @PostMapping(value = "/list")
    public List<RoleVO> list() {
        List<RoleVO> roles = new ArrayList<>();
        for (Role role : Role.values()) {
            RoleVO vo = new RoleVO();
            vo.setRoleCode(role.name());
            vo.setRoleName(role.getTitle());
            vo.setHidden(true);
            if (Role.ADMIN == role || Role.TEACHING == role) {
                vo.setHidden(false);
            }
            roles.add(vo);
        }
        return roles;
    }

}
