From 12ae5bf128d0c405c7e907d613a8c682f90b063f Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 25 Oct 2023 16:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=A4=BE=E4=BA=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=20RUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/enums/ErrorCodeConstants.java | 1 + .../admin/socail/SocialUserController.java | 46 ++++++++++++++- .../socail/vo/user/SocialUserBaseVO.java | 45 ++++++++++++++ .../socail/vo/user/SocialUserPageReqVO.java | 30 ++++++++++ .../socail/vo/user/SocialUserRespVO.java | 22 +++++++ .../socail/vo/user/SocialUserUpdateReqVO.java | 20 +++++++ .../convert/social/SocialUserConvert.java | 14 +++++ .../dal/mysql/social/SocialUserMapper.java | 17 ++++-- .../service/social/SocialUserService.java | 58 +++++++++++++++--- .../service/social/SocialUserServiceImpl.java | 59 +++++++++++++++++-- 10 files changed, 294 insertions(+), 18 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBaseVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserPageReqVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserRespVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserUpdateReqVO.java diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index 7d7e21ab2..348edbedb 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -120,6 +120,7 @@ public interface ErrorCodeConstants { ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1_002_018_002, "社交授权失败,找不到对应的用户"); ErrorCode SOCIAL_APP_WEIXIN_MINI_APP_PHONE_CODE_ERROR = new ErrorCode(1_002_018_103, "获得手机号失败"); ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_104, "社交客户端不存在"); + ErrorCode SOCIAL_USER_NOT_EXISTS = new ErrorCode(1_002_018_105, "社交用户不存在"); // ========== 系统敏感词 1-002-019-000 ========= ErrorCode SENSITIVE_WORD_NOT_EXISTS = new ErrorCode(1_002_019_000, "系统敏感词在所有标签中都不存在"); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialUserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialUserController.java index 0a0682f69..502d65817 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialUserController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/SocialUserController.java @@ -2,18 +2,26 @@ package cn.iocoder.yudao.module.system.controller.admin.socail; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserBindReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserUnbindReqVO; +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO; +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserRespVO; +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.SocialUserDO; import cn.iocoder.yudao.module.system.service.social.SocialUserService; -import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 社交用户") @@ -39,4 +47,40 @@ public class SocialUserController { return CommonResult.success(true); } + // ==================== 社交用户 CRUD ==================== + + @PutMapping("/update") + @Operation(summary = "更新社交用户") + @PreAuthorize("@ss.hasPermission('system:social-user:update')") + public CommonResult updateSocialUser(@Valid @RequestBody SocialUserUpdateReqVO updateReqVO) { + socialUserService.updateSocialUser(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除社交用户") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('system:social-user:delete')") + public CommonResult deleteSocialUser(@RequestParam("id") Long id) { + socialUserService.deleteSocialUser(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得社交用户") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:social-user:query')") + public CommonResult getSocialUser(@RequestParam("id") Long id) { + SocialUserDO socialUser = socialUserService.getSocialUser(id); + return success(SocialUserConvert.INSTANCE.convert(socialUser)); + } + + @GetMapping("/page") + @Operation(summary = "获得社交用户分页") + @PreAuthorize("@ss.hasPermission('system:social-user:query')") + public CommonResult> getSocialUserPage(@Valid SocialUserPageReqVO pageVO) { + PageResult pageResult = socialUserService.getSocialUserPage(pageVO); + return success(SocialUserConvert.INSTANCE.convertPage(pageResult)); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBaseVO.java new file mode 100644 index 000000000..8dc7e01f6 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserBaseVO.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 社交用户 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class SocialUserBaseVO { + + @Schema(description = "社交平台的类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") + @NotNull(message = "社交平台的类型不能为空") + private Integer type; + + @Schema(description = "社交 openid", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") + @NotNull(message = "社交 openid不能为空") + private String openid; + + @Schema(description = "社交 token", example = "666") + private String token; + + @Schema(description = "原始 Token 数据,一般是 JSON 格式", example = "{}") + private String rawTokenInfo; + + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @NotNull(message = "用户昵称不能为空") + private String nickname; + + @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png") + private String avatar; + + @Schema(description = "原始用户数据,一般是 JSON 格式", example = "{}") + private String rawUserInfo; + + @Schema(description = "最后一次的认证 code", example = "666666") + private String code; + + @Schema(description = "最后一次的认证 state", example = "123456") + private String state; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserPageReqVO.java new file mode 100644 index 000000000..552234090 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserPageReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 社交用户分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class SocialUserPageReqVO extends PageParam { + + @Schema(description = "社交平台的类型", example = "30") + private Integer type; + + @Schema(description = "用户昵称", example = "李四") + private String nickname; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserRespVO.java new file mode 100644 index 000000000..4b448c714 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 社交用户 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class SocialUserRespVO extends SocialUserBaseVO { + + @Schema(description = "主键(自增策略)", requiredMode = Schema.RequiredMode.REQUIRED, example = "14569") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserUpdateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserUpdateReqVO.java new file mode 100644 index 000000000..2e81fc12e --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/socail/vo/user/SocialUserUpdateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.system.controller.admin.socail.vo.user; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 社交用户更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class SocialUserUpdateReqVO extends SocialUserBaseVO { + + @Schema(description = "主键(自增策略)", requiredMode = Schema.RequiredMode.REQUIRED, example = "14569") + @NotNull(message = "主键(自增策略)不能为空") + private Long id; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java index 7cc8066d7..6079e0eef 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/social/SocialUserConvert.java @@ -1,12 +1,18 @@ package cn.iocoder.yudao.module.system.convert.social; +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.SocialUserUnbindReqDTO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserBindReqVO; import cn.iocoder.yudao.module.system.controller.admin.socail.vo.SocialUserUnbindReqVO; +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserRespVO; +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserUpdateReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface SocialUserConvert { @@ -16,4 +22,12 @@ public interface SocialUserConvert { SocialUserUnbindReqDTO convert(Long userId, Integer userType, SocialUserUnbindReqVO reqVO); + SocialUserDO convert(SocialUserUpdateReqVO bean); + + SocialUserRespVO convert(SocialUserDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserMapper.java index 442cc4576..25352ea45 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserMapper.java @@ -1,14 +1,13 @@ package cn.iocoder.yudao.module.system.dal.mysql.social; -import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; -import java.util.Collection; -import java.util.List; - @Mapper public interface SocialUserMapper extends BaseMapperX { @@ -25,4 +24,12 @@ public interface SocialUserMapper extends BaseMapperX { .eq(SocialUserDO::getOpenid, openid)); } + default PageResult selectPage(SocialUserPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(SocialUserDO::getType, reqVO.getType()) + .likeIfPresent(SocialUserDO::getNickname, reqVO.getNickname()) + .betweenIfPresent(SocialUserDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(SocialUserDO::getId)); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserService.java index 4818f9d95..6c8a5b15f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserService.java @@ -1,12 +1,16 @@ package cn.iocoder.yudao.module.system.service.social; 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.controller.admin.socail.vo.user.SocialUserUpdateReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import javax.validation.Valid; +import java.util.Collection; import java.util.List; /** @@ -19,7 +23,7 @@ public interface SocialUserService { /** * 获得指定用户的社交用户列表 * - * @param userId 用户编号 + * @param userId 用户编号 * @param userType 用户类型 * @return 社交用户列表 */ @@ -36,10 +40,10 @@ public interface SocialUserService { /** * 取消绑定社交用户 * - * @param userId 用户编号 + * @param userId 用户编号 * @param userType 全局用户类型 - * @param type 社交平台的类型 {@link SocialTypeEnum} - * @param openid 社交平台的 openid + * @param type 社交平台的类型 {@link SocialTypeEnum} + * @param openid 社交平台的 openid */ void unbindSocialUser(Long userId, Integer userType, Integer type, String openid); @@ -49,11 +53,51 @@ public interface SocialUserService { * 在认证信息不正确的情况下,也会抛出 {@link ServiceException} 业务异常 * * @param userType 用户类型 - * @param type 社交平台的类型 - * @param code 授权码 - * @param state state + * @param type 社交平台的类型 + * @param code 授权码 + * @param state state * @return 社交用户 */ SocialUserRespDTO getSocialUser(Integer userType, Integer type, String code, String state); + // ==================== 社交用户 CRUD ==================== + + /** + * 更新社交用户 + * + * @param updateReqVO 更新信息 + */ + void updateSocialUser(@Valid SocialUserUpdateReqVO updateReqVO); + + /** + * 删除社交用户 + * + * @param id 编号 + */ + void deleteSocialUser(Long id); + + /** + * 获得社交用户 + * + * @param id 编号 + * @return 社交用户 + */ + SocialUserDO getSocialUser(Long id); + + /** + * 获得社交用户列表 + * + * @param ids 编号 + * @return 社交用户列表 + */ + List getSocialUserList(Collection ids); + + /** + * 获得社交用户分页 + * + * @param pageReqVO 分页查询 + * @return 社交用户分页 + */ + PageResult getSocialUserPage(SocialUserPageReqVO pageReqVO); + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java index 70c94d5bc..fcdfea796 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialUserServiceImpl.java @@ -1,10 +1,15 @@ 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.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.SocialUserDO; 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.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.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 实现类 @@ -107,14 +112,15 @@ public class SocialUserServiceImpl implements SocialUserService { } // TODO 芋艿:调整下单测 + /** * 授权获得对应的社交用户 * 如果授权失败,则会抛出 {@link ServiceException} 异常 * - * @param type 社交平台的类型 {@link SocialTypeEnum} + * @param type 社交平台的类型 {@link SocialTypeEnum} * @param userType 用户类型 - * @param code 授权码 - * @param state state + * @param code 授权码 + * @param state state * @return 授权用户 */ @NotNull @@ -146,4 +152,47 @@ public class SocialUserServiceImpl implements SocialUserService { 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 getSocialUserList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return socialUserMapper.selectBatchIds(ids); + } + + @Override + public PageResult getSocialUserPage(SocialUserPageReqVO pageReqVO) { + return socialUserMapper.selectPage(pageReqVO); + } + }