package com.xindazhou.user.api.permission;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.user.controller.admin.permission.vo.role.RoleSaveReqVO;
import com.xindazhou.user.dal.dataobject.permission.RoleDO;
import com.xindazhou.user.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

/**
 * 角色 RPC 接口
 *
 * @author xindazhou
 */
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 角色")
public interface RoleApi {

    String PREFIX = "/rpc-api/user/role";

    @GetMapping(PREFIX + "/list-by-ids")
    @Operation(summary = "根据 ID 列表获取角色")
    @Parameter(name = "ids", description = "角色编号数组", example = "1,2", required = true)
    CommonResult<List<RoleDO>> getRoleList(@RequestParam("ids") Collection<Long> ids);

    @GetMapping(PREFIX + "/list")
    @Operation(summary = "获取所有角色列表")
    CommonResult<List<RoleDO>> getRoleList();

    @GetMapping(PREFIX + "/list-from-cache")
    @Operation(summary = "从缓存获取角色列表")
    @Parameter(name = "ids", description = "角色编号数组", example = "1,2", required = true)
    CommonResult<List<RoleDO>> getRoleListFromCache(@RequestParam("ids") Collection<Long> ids);

    @PostMapping(PREFIX + "/create")
    @Operation(summary = "创建角色")
    CommonResult<Long> createRole(@RequestBody RoleSaveReqVO reqVO, @RequestParam("type") Integer type);

    @GetMapping(PREFIX + "/list-by-status")
    @Operation(summary = "根据状态获取角色列表")
    @Parameter(name = "statuses", description = "状态数组", example = "0,1", required = true)
    CommonResult<List<RoleDO>> getRoleListByStatus(@RequestParam("statuses") Collection<Integer> statuses);

}

