lrj
昨天 9f8395fab13ca4b230a0f7d62636e209745c91d4
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
57
58
package com.rongyichuang.auth.api;
 
import com.rongyichuang.auth.dto.LoginRequest;
import com.rongyichuang.auth.dto.LoginResponse;
import com.rongyichuang.auth.dto.PhoneDecryptResponse;
import com.rongyichuang.auth.dto.WxLoginRequest;
import com.rongyichuang.auth.dto.WxLoginResponse;
import com.rongyichuang.auth.service.AuthService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.MutationMapping;
import org.springframework.stereotype.Controller;
 
/**
 * 认证GraphQL API
 */
@Controller
public class AuthGraphqlApi {
 
    @Autowired
    private AuthService authService;
 
    /**
     * Web端用户登录
     */
    @MutationMapping
    public LoginResponse webLogin(@Argument LoginRequest input) {
        return authService.login(input);
    }
 
    /**
     * 微信小程序登录
     */
    @MutationMapping
    public WxLoginResponse wxLogin(@Argument WxLoginRequest input) throws JsonProcessingException, JsonMappingException {
        return authService.wxLogin(input);
    }
 
    /**
     * 解密微信手机号(旧版API)
     */
    @MutationMapping
    public PhoneDecryptResponse decryptPhoneNumber(@Argument String encryptedData, 
                                                   @Argument String iv, 
                                                   @Argument String sessionKey) {
        return authService.decryptPhoneNumber(encryptedData, iv, sessionKey);
    }
 
    /**
     * 获取微信手机号(新版API)
     */
    @MutationMapping
    public PhoneDecryptResponse getPhoneNumberByCode(@Argument String code) {
        return authService.getPhoneNumberByCode(code);
    }
}