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

import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.systemapi.api.social.dto.SocialUserBindReqDTO;
import com.tashow.cloud.systemapi.api.social.dto.SocialUserRespDTO;
import com.tashow.cloud.systemapi.api.social.dto.SocialUserUnbindReqDTO;
import com.tashow.cloud.systemapi.enums.ApiConstants;
import jakarta.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
/** RPC 服务 - 社交用户 */
public interface SocialUserApi {

  String PREFIX = ApiConstants.PREFIX + "/social-user";

  @PostMapping(PREFIX + "/bind")
  /** 绑定社交用户 */
  CommonResult<String> bindSocialUser(@Valid @RequestBody SocialUserBindReqDTO reqDTO);

  @DeleteMapping(PREFIX + "/unbind")
  /** 取消绑定社交用户 */
  CommonResult<Boolean> unbindSocialUser(@Valid @RequestBody SocialUserUnbindReqDTO reqDTO);

  @GetMapping(PREFIX + "/get-by-user-id")
  /** 获得社交用户，基于 userId */
  CommonResult<SocialUserRespDTO> getSocialUserByUserId(
      @RequestParam("userType") Integer userType,
      @RequestParam("userId") Long userId,
      @RequestParam("socialType") Integer socialType);

  @GetMapping(PREFIX + "/get-by-code")
  /** 获得社交用 */
  // 在认证信息不正确的情况下，也会抛出 {@link ServiceException} 业务异常

  CommonResult<SocialUserRespDTO> getSocialUserByCode(
      @RequestParam("userType") Integer userType,
      @RequestParam("socialType") Integer socialType,
      @RequestParam("code") String code,
      @RequestParam("state") String state);
}
