|
@@ -1,10 +1,15 @@
|
|
package cn.iocoder.yudao.module.system.service.social;
|
|
package cn.iocoder.yudao.module.system.service.social;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
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.SocialUserBindReqDTO;
|
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
|
|
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.controller.admin.socail.vo.user.SocialUserUpdateReqVO;
|
|
|
|
+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.SocialUserBindDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO;
|
|
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper;
|
|
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper;
|
|
@@ -18,14 +23,14 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.validation.constraints.NotNull;
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
+import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
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.collection.CollectionUtils.convertSet;
|
|
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
|
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
|
-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;
|
|
|
|
|
|
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 社交用户 Service 实现类
|
|
* 社交用户 Service 实现类
|
|
@@ -107,14 +112,15 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
}
|
|
}
|
|
|
|
|
|
// TODO 芋艿:调整下单测
|
|
// TODO 芋艿:调整下单测
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 授权获得对应的社交用户
|
|
* 授权获得对应的社交用户
|
|
* 如果授权失败,则会抛出 {@link ServiceException} 异常
|
|
* 如果授权失败,则会抛出 {@link ServiceException} 异常
|
|
*
|
|
*
|
|
- * @param type 社交平台的类型 {@link SocialTypeEnum}
|
|
|
|
|
|
+ * @param type 社交平台的类型 {@link SocialTypeEnum}
|
|
* @param userType 用户类型
|
|
* @param userType 用户类型
|
|
- * @param code 授权码
|
|
|
|
- * @param state state
|
|
|
|
|
|
+ * @param code 授权码
|
|
|
|
+ * @param state state
|
|
* @return 授权用户
|
|
* @return 授权用户
|
|
*/
|
|
*/
|
|
@NotNull
|
|
@NotNull
|
|
@@ -146,4 +152,47 @@ public class SocialUserServiceImpl implements SocialUserService {
|
|
return socialUser;
|
|
return socialUser;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // ==================== 社交用户 CRUD ====================
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateSocialUser(SocialUserUpdateReqVO updateReqVO) {
|
|
|
|
+ // 校验存在
|
|
|
|
+ validateSocialUserExists(updateReqVO.getId());
|
|
|
|
+ // 更新
|
|
|
|
+ SocialUserDO updateObj = SocialUserConvert.INSTANCE.convert(updateReqVO);
|
|
|
|
+ socialUserMapper.updateById(updateObj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteSocialUser(Long id) {
|
|
|
|
+ // 校验存在
|
|
|
|
+ validateSocialUserExists(id);
|
|
|
|
+ // 删除
|
|
|
|
+ socialUserMapper.deleteById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void validateSocialUserExists(Long id) {
|
|
|
|
+ if (socialUserMapper.selectById(id) == null) {
|
|
|
|
+ throw exception(SOCIAL_USER_NOT_EXISTS);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public SocialUserDO getSocialUser(Long id) {
|
|
|
|
+ return socialUserMapper.selectById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<SocialUserDO> getSocialUserList(Collection<Long> ids) {
|
|
|
|
+ if (CollUtil.isEmpty(ids)) {
|
|
|
|
+ return ListUtil.empty();
|
|
|
|
+ }
|
|
|
|
+ return socialUserMapper.selectBatchIds(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PageResult<SocialUserDO> getSocialUserPage(SocialUserPageReqVO pageReqVO) {
|
|
|
|
+ return socialUserMapper.selectPage(pageReqVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|