mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-08 15:21:52 +08:00
✅ 增加 social 模块的单测覆盖率
This commit is contained in:
@@ -23,7 +23,7 @@ public class SocialUserPageReqVO extends PageParam {
|
||||
@Schema(description = "用户昵称", example = "李四")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "社交 openid", example = "oz-Jdt0kd_jdhUxJHQdBJMlOFN7w\n")
|
||||
@Schema(description = "社交 openid", example = "oz-Jdt0kd_jdhUxJHQdBJMlOFN7w")
|
||||
private String openid;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
|
@@ -142,7 +142,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @return AuthRequest 对象
|
||||
*/
|
||||
private AuthRequest buildAuthRequest(Integer socialType, Integer userType) {
|
||||
@VisibleForTesting
|
||||
AuthRequest buildAuthRequest(Integer socialType, Integer userType) {
|
||||
// 1. 先查找默认的配置项,从 application-*.yaml 中读取
|
||||
AuthRequest request = authRequestFactory.get(SocialTypeEnum.valueOfType(socialType).getSource());
|
||||
Assert.notNull(request, String.format("社交平台(%d) 不存在", socialType));
|
||||
@@ -180,7 +181,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
private WxMpService getWxMpService(Integer userType) {
|
||||
@VisibleForTesting
|
||||
WxMpService getWxMpService(Integer userType) {
|
||||
// 第一步,查询 DB 的配置项,获得对应的 WxMpService 对象
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
SocialTypeEnum.WECHAT_MP.getType(), userType);
|
||||
@@ -198,7 +200,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param clientSecret 微信公众号 secret
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
private WxMpService buildWxMpService(String clientId, String clientSecret) {
|
||||
public WxMpService buildWxMpService(String clientId, String clientSecret) {
|
||||
// 第一步,创建 WxMpRedisConfigImpl 对象
|
||||
WxMpRedisConfigImpl configStorage = new WxMpRedisConfigImpl(
|
||||
new RedisTemplateWxRedisOps(stringRedisTemplate),
|
||||
@@ -231,7 +233,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
private WxMaService getWxMaService(Integer userType) {
|
||||
@VisibleForTesting
|
||||
WxMaService getWxMaService(Integer userType) {
|
||||
// 第一步,查询 DB 的配置项,获得对应的 WxMaService 对象
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
SocialTypeEnum.WECHAT_MINI_APP.getType(), userType);
|
||||
@@ -311,7 +314,6 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
* @param userType 用户类型
|
||||
* @param socialType 社交类型
|
||||
*/
|
||||
@VisibleForTesting
|
||||
private void validateSocialClientUnique(Long id, Integer userType, Integer socialType) {
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
socialType, userType);
|
||||
|
@@ -1,14 +1,12 @@
|
||||
package cn.iocoder.yudao.module.system.service.social;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
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.controller.admin.socail.vo.user.SocialUserPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.convert.social.SocialUserConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper;
|
||||
@@ -22,14 +20,14 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.AUTH_THIRD_LOGIN_NOT_BIND;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.SOCIAL_USER_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* 社交用户 Service 实现类
|
||||
@@ -61,7 +59,7 @@ public class SocialUserServiceImpl implements SocialUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String bindSocialUser(SocialUserBindReqDTO reqDTO) {
|
||||
// 获得社交用户
|
||||
SocialUserDO socialUser = authSocialUser(reqDTO.getSocialType(), reqDTO.getUserType(),
|
||||
@@ -110,7 +108,6 @@ public class SocialUserServiceImpl implements SocialUserService {
|
||||
return new SocialUserRespDTO(socialUser.getOpenid(), socialUserBind.getUserId());
|
||||
}
|
||||
|
||||
// TODO 芋艿:调整下单测
|
||||
/**
|
||||
* 授权获得对应的社交用户
|
||||
* 如果授权失败,则会抛出 {@link ServiceException} 异常
|
||||
|
Reference in New Issue
Block a user