package com.ycwl.basic.controller.pc;

import com.github.pagehelper.PageInfo;
import com.ycwl.basic.annotation.IgnoreToken;
import com.ycwl.basic.model.pc.role.req.AddOrUpdateRoleReqVO;
import com.ycwl.basic.model.pc.role.req.RoleListReqVO;
import com.ycwl.basic.model.pc.role.resp.RoleListRespVO;
import com.ycwl.basic.service.pc.RoleService;
import com.ycwl.basic.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/role/v1")
@Api(tags = "系统角色管理")
public class RoleController {

    @Autowired
    RoleService roleService;

    @PostMapping(value = "/page")
    @ApiOperation(value = "角色列表分页查询")
    @IgnoreToken
    public ApiResponse<PageInfo<RoleListRespVO>> page(@RequestBody RoleListReqVO roleListReqVO) {
        return roleService.pageQuery(roleListReqVO);
    }
    @PostMapping(value = "/list")
    @ApiOperation(value = "角色列表")
    @IgnoreToken
    public ApiResponse<List<RoleListRespVO>> list(@RequestBody RoleListReqVO roleListReqVO) {
        return roleService.list(roleListReqVO);
    }

    @PostMapping(value = "/addOrUpdate")
    @ApiOperation(value = "添加或更新角色")
    @IgnoreToken
    public ApiResponse addOrUpdate(@RequestBody AddOrUpdateRoleReqVO addOrUpdateRoleReqVO) {
        return roleService.addOrUpdate(addOrUpdateRoleReqVO);
    }

    @GetMapping(value = "/delete/{id}")
    @ApiOperation(value = "删除")
    @IgnoreToken
    public ApiResponse delete(@PathVariable("id") String id) {
        return roleService.delete(id);
    }

    @GetMapping(value = "/updateReturnMenu/{id}")
    @ApiOperation(value = "编辑回显该角色当前菜单")
    @IgnoreToken
    public ApiResponse updateReturnMenu(@PathVariable("id") String id) {
        return roleService.updateReturnMenu(id);
    }



    @GetMapping(value = "/updateStatus/{id}")
    @ApiOperation(value = "更改角色类型状态")
    //@IgnoreToken
    public ApiResponse updateStatus(@PathVariable("id") String id) {
        return roleService.updateStatus(id);
    }
}

