houzhongjian
2024-10-16 7da8f196dee8e3c526c009a4bc7f5983ece6bb97
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
package com.iailab.module.system.api.social;
 
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.framework.common.util.object.BeanUtils;
import com.iailab.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
import com.iailab.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
import com.iailab.module.system.service.social.SocialClientService;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
 
import static com.iailab.framework.common.pojo.CommonResult.success;
 
/**
 * 社交应用的 API 实现类
 *
 * @author iailab
 */
@RestController
@Validated
public class SocialClientApiImpl implements SocialClientApi {
 
    @Resource
    private SocialClientService socialClientService;
 
    @Override
    public CommonResult<String> getAuthorizeUrl(Integer socialType, Integer userType, String redirectUri) {
        return success(socialClientService.getAuthorizeUrl(socialType, userType, redirectUri));
    }
 
    @Override
    public CommonResult<SocialWxJsapiSignatureRespDTO> createWxMpJsapiSignature(Integer userType, String url) {
        WxJsapiSignature signature = socialClientService.createWxMpJsapiSignature(userType, url);
        return success(BeanUtils.toBean(signature, SocialWxJsapiSignatureRespDTO.class));
    }
 
    @Override
    public CommonResult<SocialWxPhoneNumberInfoRespDTO> getWxMaPhoneNumberInfo(Integer userType, String phoneCode) {
        WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode);
        return success(BeanUtils.toBean(info, SocialWxPhoneNumberInfoRespDTO.class));
    }
 
}