dengzedong
2024-10-14 bb015596297586342fc6c3e5a5df7c4a55a426a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.iailab.module.system.api.social;
 
import com.iailab.framework.common.exception.ServiceException;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.module.system.api.social.dto.SocialUserBindReqDTO;
import com.iailab.module.system.api.social.dto.SocialUserRespDTO;
import com.iailab.module.system.api.social.dto.SocialUserUnbindReqDTO;
import com.iailab.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
 
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 社交用户")
public interface SocialUserApi {
 
    String PREFIX = ApiConstants.PREFIX + "/social-user";
 
    @PostMapping(PREFIX + "/bind")
    @Operation(summary = "绑定社交用户")
    CommonResult<String> bindSocialUser(@Valid @RequestBody SocialUserBindReqDTO reqDTO);
 
    @DeleteMapping(PREFIX + "/unbind")
    @Operation(summary = "取消绑定社交用户")
    CommonResult<Boolean> unbindSocialUser(@Valid @RequestBody SocialUserUnbindReqDTO reqDTO);
 
    @GetMapping(PREFIX + "/get-by-user-id")
    @Operation(summary = "获得社交用户,基于 userId")
    @Parameters({
            @Parameter(name = "userType", description = "用户类型", example = "2", required = true),
            @Parameter(name = "userId", description = "用户编号", example = "1024", required = true),
            @Parameter(name = "socialType", description = "社交平台的类型", example = "1", required = true),
    })
    CommonResult<SocialUserRespDTO> getSocialUserByUserId(@RequestParam("userType") Integer userType,
                                                          @RequestParam("userId") Long userId,
                                                          @RequestParam("socialType") Integer socialType);
 
    @GetMapping(PREFIX + "/get-by-code")
    @Operation(summary = "获得社交用") // 在认证信息不正确的情况下,也会抛出 {@link ServiceException} 业务异常
    @Parameters({
            @Parameter(name = "userType", description = "用户类型", example = "2", required = true),
            @Parameter(name = "socialType", description = "社交平台的类型", example = "1", required = true),
            @Parameter(name = "code", description = "授权码", example = "88888", required = true),
            @Parameter(name = "state", description = "state", example = "666", required = true),
    })
    CommonResult<SocialUserRespDTO> getSocialUserByCode(@RequestParam("userType") Integer userType,
                                                        @RequestParam("socialType") Integer socialType,
                                                        @RequestParam("code") String code,
                                                        @RequestParam("state") String state);
 
}