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

import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.dtos.role.RoleDataRightInfoDTO;
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.service.IRoleDataRightService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: RoleDataRightController
 * @Description: 角色数据权限
 * @Author: WangGeng
 * @Date: 2021/2/21 10:01
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "角色数据权限")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/role/data-right")
public class RoleDataRightController {

    @Autowired
    private IRoleDataRightService roleDataRightService;

    @ApiOperation(value = "更新角色数据权限", notes = "更新角色数据权限接口")
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PutMapping("update/{roleId}")
    @CheckRequestBodyAnnotation
    public SuccessResult update(@PathVariable("roleId") String roleId, @RequestBody RoleDataRightVO roleDataRightVO) {
        roleDataRightService.update(roleId, roleDataRightVO);
        return new SuccessResult();
    }

    @ApiOperation(value = "角色数据权限详情", notes = "角色数据权限详情接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("get/{roleId}")
    public RoleDataRightInfoDTO get(@PathVariable("roleId") String roleId) {
        return roleDataRightService.get(roleId);
    }

}
