package cn.ey.biz.module.system.api.permission;

import cn.ey.biz.common.pojo.R;
import cn.ey.biz.module.system.api.permission.dto.DataRoleRespDTO;
import cn.ey.biz.module.system.api.user.dto.AdminUserRespDTO;
import cn.ey.biz.module.system.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;

@FeignClient(name = ApiConstants.NAME)
@Api(tags = "RPC 服务 - 角色")
public interface RoleApi {

    String PREFIX = ApiConstants.PREFIX + "/role";

    @GetMapping(PREFIX + "/valid")
    @ApiOperation("校验角色是否合法")
    @ApiImplicitParam(name = "ids", value = "角色编号数组", example = "1,2", required = true, allowMultiple = true)
    R<Boolean> validRoles(@RequestParam("ids") Collection<Long> ids);

    @GetMapping(PREFIX + "/get-user-data-role")
    @ApiOperation("根据用户获取数据角色")
    R<List<DataRoleRespDTO>>  getUserDataRole(@RequestParam("userId") String userId);

    @GetMapping(PREFIX + "/users-by-role-code")
    @ApiOperation("根据角色Code获取用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型:1功能角色,2数据角色", example = "1", dataTypeClass = String.class),
            @ApiImplicitParam(name = "codes", value = "角色code", example = "2", dataTypeClass = String.class)})
    R<List<AdminUserRespDTO>> getUsersByRoleCode(@RequestParam("type") String type,@RequestParam("codes") List<String> codes);

}
