package ink.wgink.service.role.controller.api;

import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.dtos.role.RoleMenuDTO;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.service.role.pojo.vos.RoleDataRightVO;
import ink.wgink.service.role.pojo.vos.RoleMenuVO;
import ink.wgink.service.role.service.IRoleMenuService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: RoleMenuController
 * @Description: 角色菜单
 * @Author: WangGeng
 * @Date: 2021/2/23 21:41
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "角色菜单")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/role/menu")
public class RoleMenuController extends DefaultBaseController {

    @Autowired
    private IRoleMenuService roleMenuService;

    @ApiOperation(value = "更新角色菜单", notes = "更新角色菜单接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PutMapping("update/{roleId}")
    @CheckRequestBodyAnnotation
    public SuccessResult update(@PathVariable("roleId") String roleId, @RequestBody RoleMenuVO roleMenuVO) {
        roleMenuService.update(roleId, roleMenuVO);
        return new SuccessResult();
    }

    @ApiOperation(value = "角色菜单列表", notes = "角色菜单列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("list/{roleId}")
    public List<RoleMenuDTO> list(@PathVariable("roleId") String roleId) {
        return roleMenuService.list(roleId);
    }

}
