package com.tashow.cloud.systemapi.api.permission;

import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.systemapi.api.permission.dto.DeptDataPermissionRespDTO;
import com.tashow.cloud.systemapi.enums.ApiConstants;
import java.util.Collection;
import java.util.Set;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
/** RPC 服务 - 权限 */
public interface PermissionApi {

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

  @GetMapping(PREFIX + "/user-role-id-list-by-role-id")
  /** 获得拥有多个角色的用户编号集合 */
  CommonResult<Set<Long>> getUserRoleIdListByRoleIds(
      @RequestParam("roleIds") Collection<Long> roleIds);

  @GetMapping(PREFIX + "/has-any-permissions")
  /** 判断是否有权限，任一一个即可 */
  CommonResult<Boolean> hasAnyPermissions(
      @RequestParam("userId") Long userId, @RequestParam("permissions") String... permissions);

  @GetMapping(PREFIX + "/has-any-roles")
  /** 判断是否有角色，任一一个即可 */
  CommonResult<Boolean> hasAnyRoles(
      @RequestParam("userId") Long userId, @RequestParam("roles") String... roles);

  @GetMapping(PREFIX + "/get-dept-data-permission")
  /** 获得登陆用户的部门数据权限 */
  CommonResult<DeptDataPermissionRespDTO> getDeptDataPermission(
      @RequestParam("userId") Long userId);
}
