houzhongjian
2024-10-16 7da8f196dee8e3c526c009a4bc7f5983ece6bb97
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.api.social;
H 2
3 import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.util.object.BeanUtils;
6 import com.iailab.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
7 import com.iailab.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
8 import com.iailab.module.system.service.social.SocialClientService;
9 import me.chanjar.weixin.common.bean.WxJsapiSignature;
10 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.RestController;
12
13 import javax.annotation.Resource;
14
15 import static com.iailab.framework.common.pojo.CommonResult.success;
16
17 /**
18  * 社交应用的 API 实现类
19  *
20  * @author iailab
21  */
22 @RestController
23 @Validated
24 public class SocialClientApiImpl implements SocialClientApi {
25
26     @Resource
27     private SocialClientService socialClientService;
28
29     @Override
30     public CommonResult<String> getAuthorizeUrl(Integer socialType, Integer userType, String redirectUri) {
31         return success(socialClientService.getAuthorizeUrl(socialType, userType, redirectUri));
32     }
33
34     @Override
35     public CommonResult<SocialWxJsapiSignatureRespDTO> createWxMpJsapiSignature(Integer userType, String url) {
36         WxJsapiSignature signature = socialClientService.createWxMpJsapiSignature(userType, url);
37         return success(BeanUtils.toBean(signature, SocialWxJsapiSignatureRespDTO.class));
38     }
39
40     @Override
41     public CommonResult<SocialWxPhoneNumberInfoRespDTO> getWxMaPhoneNumberInfo(Integer userType, String phoneCode) {
42         WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode);
43         return success(BeanUtils.toBean(info, SocialWxPhoneNumberInfoRespDTO.class));
44     }
45
46 }