mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	新增社交用户 RUD
This commit is contained in:
		@@ -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<Boolean> 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<Boolean> 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<SocialUserRespVO> 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<PageResult<SocialUserRespVO>> getSocialUserPage(@Valid SocialUserPageReqVO pageVO) {
 | 
			
		||||
        PageResult<SocialUserDO> pageResult = socialUserService.getSocialUserPage(pageVO);
 | 
			
		||||
        return success(SocialUserConvert.INSTANCE.convertPage(pageResult));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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<SocialUserRespVO> convertList(List<SocialUserDO> list);
 | 
			
		||||
 | 
			
		||||
    PageResult<SocialUserRespVO> convertPage(PageResult<SocialUserDO> page);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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<SocialUserDO> {
 | 
			
		||||
 | 
			
		||||
@@ -25,4 +24,12 @@ public interface SocialUserMapper extends BaseMapperX<SocialUserDO> {
 | 
			
		||||
                .eq(SocialUserDO::getOpenid, openid));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default PageResult<SocialUserDO> selectPage(SocialUserPageReqVO reqVO) {
 | 
			
		||||
        return selectPage(reqVO, new LambdaQueryWrapperX<SocialUserDO>()
 | 
			
		||||
                .eqIfPresent(SocialUserDO::getType, reqVO.getType())
 | 
			
		||||
                .likeIfPresent(SocialUserDO::getNickname, reqVO.getNickname())
 | 
			
		||||
                .betweenIfPresent(SocialUserDO::getCreateTime, reqVO.getCreateTime())
 | 
			
		||||
                .orderByDesc(SocialUserDO::getId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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<SocialUserDO> getSocialUserList(Collection<Long> ids);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得社交用户分页
 | 
			
		||||
     *
 | 
			
		||||
     * @param pageReqVO 分页查询
 | 
			
		||||
     * @return 社交用户分页
 | 
			
		||||
     */
 | 
			
		||||
    PageResult<SocialUserDO> getSocialUserPage(SocialUserPageReqVO pageReqVO);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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<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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user