mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 07:55:06 +08:00
feat:新增获取小程序码相关接口
This commit is contained in:
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.api.social;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -42,4 +43,9 @@ public class SocialUserApiImpl implements SocialUserApi {
|
||||
return socialUserService.getSocialUserByCode(userType, socialType, code, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
return socialUserService.getWxQrcode(reqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,14 +2,14 @@ package cn.iocoder.yudao.module.system.service.social;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
import com.xingyuv.jushauth.model.AuthUser;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
|
||||
/**
|
||||
* 社交应用 Service 接口
|
||||
@ -21,8 +21,8 @@ public interface SocialClientService {
|
||||
/**
|
||||
* 获得社交平台的授权 URL
|
||||
*
|
||||
* @param socialType 社交平台的类型 {@link SocialTypeEnum}
|
||||
* @param userType 用户类型
|
||||
* @param socialType 社交平台的类型 {@link SocialTypeEnum}
|
||||
* @param userType 用户类型
|
||||
* @param redirectUri 重定向 URL
|
||||
* @return 社交平台的授权 URL
|
||||
*/
|
||||
@ -32,9 +32,9 @@ public interface SocialClientService {
|
||||
* 请求社交平台,获得授权的用户
|
||||
*
|
||||
* @param socialType 社交平台的类型
|
||||
* @param userType 用户类型
|
||||
* @param code 授权码
|
||||
* @param state 授权 state
|
||||
* @param userType 用户类型
|
||||
* @param code 授权码
|
||||
* @param state 授权 state
|
||||
* @return 授权的用户
|
||||
*/
|
||||
AuthUser getAuthUser(Integer socialType, Integer userType, String code, String state);
|
||||
@ -45,7 +45,7 @@ public interface SocialClientService {
|
||||
* 创建微信公众号的 JS SDK 初始化所需的签名
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param url 访问的 URL 地址
|
||||
* @param url 访问的 URL 地址
|
||||
* @return 签名
|
||||
*/
|
||||
WxJsapiSignature createWxMpJsapiSignature(Integer userType, String url);
|
||||
@ -55,12 +55,20 @@ public interface SocialClientService {
|
||||
/**
|
||||
* 获得微信小程序的手机信息
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param userType 用户类型
|
||||
* @param phoneCode 手机授权码
|
||||
* @return 手机信息
|
||||
*/
|
||||
WxMaPhoneNumberInfo getWxMaPhoneNumberInfo(Integer userType, String phoneCode);
|
||||
|
||||
/**
|
||||
* 获得小程序二维码
|
||||
*
|
||||
* @param reqVO 请求信息
|
||||
* @return 小程序二维码
|
||||
*/
|
||||
byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO);
|
||||
|
||||
// =================== 客户端管理 ===================
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.cache.CacheUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
|
||||
@ -139,7 +140,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* 构建 AuthRequest 对象,支持多租户配置
|
||||
*
|
||||
* @param socialType 社交类型
|
||||
* @param userType 用户类型
|
||||
* @param userType 用户类型
|
||||
* @return AuthRequest 对象
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@ -196,7 +197,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
/**
|
||||
* 创建 clientId + clientSecret 对应的 WxMpService 对象
|
||||
*
|
||||
* @param clientId 微信公众号 appId
|
||||
* @param clientId 微信公众号 appId
|
||||
* @param clientSecret 微信公众号 secret
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
@ -227,6 +228,19 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
WxMaService service = getWxMaService(reqVO.getUserType());
|
||||
try {
|
||||
return service.getQrcodeService().createWxaCodeUnlimitBytes(reqVO.getScene(), reqVO.getPath(),
|
||||
reqVO.getIsCheckPath(), reqVO.getEnvVersion(), reqVO.getWidth(), reqVO.getIsAutoColor(),
|
||||
null, reqVO.getIsHyaline());
|
||||
} catch (WxErrorException e) {
|
||||
log.error("[getWxQrcode][reqVO({})) 获得小程序码失败]", reqVO, e);
|
||||
throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 clientId + clientSecret 对应的 WxMpService 对象
|
||||
*
|
||||
@ -248,7 +262,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
/**
|
||||
* 创建 clientId + clientSecret 对应的 WxMaService 对象
|
||||
*
|
||||
* @param clientId 微信小程序 appId
|
||||
* @param clientId 微信小程序 appId
|
||||
* @param clientSecret 微信小程序 secret
|
||||
* @return WxMaService 对象
|
||||
*/
|
||||
@ -310,8 +324,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
*
|
||||
* 原因是,不同端(userType)选择某个社交登录(socialType)时,需要通过 {@link #buildAuthRequest(Integer, Integer)} 构建对应的请求
|
||||
*
|
||||
* @param id 编号
|
||||
* @param userType 用户类型
|
||||
* @param id 编号
|
||||
* @param userType 用户类型
|
||||
* @param socialType 社交类型
|
||||
*/
|
||||
private void validateSocialClientUnique(Long id, Integer userType, Integer socialType) {
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
|
||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
|
||||
@ -86,4 +87,12 @@ public interface SocialUserService {
|
||||
*/
|
||||
PageResult<SocialUserDO> getSocialUserPage(SocialUserPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得小程序二维码
|
||||
*
|
||||
* @param reqVO 请求信息
|
||||
* @return 小程序二维码
|
||||
*/
|
||||
byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO);
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
|
||||
@ -170,4 +171,9 @@ public class SocialUserServiceImpl implements SocialUserService {
|
||||
return socialUserMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
return socialClientService.getWxQrcode(reqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user