feat: 修改第三方登录逻辑/更新数据库
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package com.schisandra.auth.application.convert;
|
||||
|
||||
|
||||
import com.schisandra.auth.application.dto.SchisandraAuthSocialUserDTO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* dto转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraAuthSocialUserDTOConverter {
|
||||
|
||||
SchisandraAuthSocialUserDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthSocialUserDTOConverter.class);
|
||||
/**
|
||||
* @description: dto转bo
|
||||
* @param: [schisandraAuthSocialUserDTO]
|
||||
* @return: com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO
|
||||
* @author: landaiqing
|
||||
* @date: 2024/6/6 22:09
|
||||
*/
|
||||
SchisandraAuthSocialUserBO convertDTOToBO(SchisandraAuthSocialUserDTO schisandraAuthSocialUserDTO);
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package com.schisandra.auth.application.convert;
|
||||
|
||||
|
||||
import com.schisandra.auth.application.dto.SchisandraAuthSocialUserMapperDTO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* dto转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraAuthSocialUserMapperDTOConverter {
|
||||
|
||||
SchisandraAuthSocialUserMapperDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthSocialUserMapperDTOConverter.class);
|
||||
/**
|
||||
* @description: DTO转BO
|
||||
* @param: [schisandraAuthSocialUserMapperDTO]
|
||||
* @return: com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO
|
||||
* @author: landaiqing
|
||||
* @date: 2024/6/6 22:09
|
||||
*/
|
||||
SchisandraAuthSocialUserMapperBO convertDTOToBO(SchisandraAuthSocialUserMapperDTO schisandraAuthSocialUserMapperDTO);
|
||||
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
package com.schisandra.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* dto
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraAuthSocialUserDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 第三方系统的唯一ID
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 第三方用户来源
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 用户的授权令牌
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 第三方用户的授权令牌的有效期
|
||||
*/
|
||||
private Integer expireIn;
|
||||
|
||||
/**
|
||||
* 刷新令牌
|
||||
*/
|
||||
private String refreshToken;
|
||||
|
||||
/**
|
||||
* 第三方用户的 open id
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 第三方用户的 ID
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 个别平台的授权信息
|
||||
*/
|
||||
private String accessCode;
|
||||
|
||||
/**
|
||||
* 第三方用户的 union id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 第三方用户授予的权限
|
||||
*/
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* 个别平台的授权信息
|
||||
*/
|
||||
private String tokenType;
|
||||
|
||||
/**
|
||||
* id token
|
||||
*/
|
||||
private String idToken;
|
||||
|
||||
/**
|
||||
* 小米平台用户的附带属性
|
||||
*/
|
||||
private String macAlgorithm;
|
||||
|
||||
/**
|
||||
* 小米平台用户的附带属性
|
||||
*/
|
||||
private String macKey;
|
||||
|
||||
/**
|
||||
* 用户的授权code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Twitter平台用户的附带属性
|
||||
*/
|
||||
private String oauthToken;
|
||||
|
||||
/**
|
||||
* Twitter平台用户的附带属性
|
||||
*/
|
||||
private String oauthTokenSecret;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -1,58 +0,0 @@
|
||||
package com.schisandra.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* dto
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraAuthSocialUserMapperDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 系统用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 社会化用户ID
|
||||
*/
|
||||
private Long socialUserId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除(0:未删除,1:已删除)
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.schisandra.auth.application.dto;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -18,7 +19,15 @@ public class SchisandraAuthUserDTO implements Serializable {
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* uuid
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* source
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
@@ -33,7 +33,7 @@ public class GiteeOauthHandler implements SchisandraOauthTypeHandler {
|
||||
|
||||
@Override
|
||||
public OauthType getHandlerType() {
|
||||
return OauthType.Gitee;
|
||||
return OauthType.GITEE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -35,7 +35,7 @@ public class GithubOauthHandler implements SchisandraOauthTypeHandler {
|
||||
|
||||
@Override
|
||||
public OauthType getHandlerType() {
|
||||
return OauthType.GitHUB;
|
||||
return OauthType.GITHUB;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -41,11 +41,15 @@ public enum OauthType {
|
||||
/**
|
||||
* Github
|
||||
*/
|
||||
GitHUB("github"),
|
||||
GITHUB("github"),
|
||||
/**
|
||||
* Gitee
|
||||
*/
|
||||
Gitee("gitee");
|
||||
GITEE("gitee"),
|
||||
/**
|
||||
* System
|
||||
*/
|
||||
SYSTEM("system");
|
||||
|
||||
public String type;
|
||||
|
||||
|
@@ -1,138 +0,0 @@
|
||||
package com.schisandra.auth.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraAuthSocialUserBO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 第三方系统的唯一ID
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 第三方用户来源
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 用户的授权令牌
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 第三方用户的授权令牌的有效期
|
||||
*/
|
||||
private Integer expireIn;
|
||||
|
||||
/**
|
||||
* 刷新令牌
|
||||
*/
|
||||
private String refreshToken;
|
||||
|
||||
/**
|
||||
* 第三方用户的 open id
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 第三方用户的 ID
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 个别平台的授权信息
|
||||
*/
|
||||
private String accessCode;
|
||||
|
||||
/**
|
||||
* 第三方用户的 union id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 第三方用户授予的权限
|
||||
*/
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* 个别平台的授权信息
|
||||
*/
|
||||
private String tokenType;
|
||||
|
||||
/**
|
||||
* id token
|
||||
*/
|
||||
private String idToken;
|
||||
|
||||
/**
|
||||
* 小米平台用户的附带属性
|
||||
*/
|
||||
private String macAlgorithm;
|
||||
|
||||
/**
|
||||
* 小米平台用户的附带属性
|
||||
*/
|
||||
private String macKey;
|
||||
|
||||
/**
|
||||
* 用户的授权code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Twitter平台用户的附带属性
|
||||
*/
|
||||
private String oauthToken;
|
||||
|
||||
/**
|
||||
* Twitter平台用户的附带属性
|
||||
*/
|
||||
private String oauthTokenSecret;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -1,58 +0,0 @@
|
||||
package com.schisandra.auth.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraAuthSocialUserMapperBO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 系统用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 社会化用户ID
|
||||
*/
|
||||
private Long socialUserId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.schisandra.auth.domain.bo;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -18,7 +19,15 @@ public class SchisandraAuthUserBO implements Serializable {
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* uuid
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* source
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@@ -1,22 +0,0 @@
|
||||
package com.schisandra.auth.domain.convert;
|
||||
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* bo转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraAuthSocialUserBOConverter {
|
||||
|
||||
SchisandraAuthSocialUserBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthSocialUserBOConverter.class);
|
||||
|
||||
SchisandraAuthSocialUser convertBOToEntity(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO);
|
||||
SchisandraAuthSocialUserBO convertEntityToBO(SchisandraAuthSocialUser schisandraAuthSocialUser);
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package com.schisandra.auth.domain.convert;
|
||||
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* bo转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraAuthSocialUserMapperBOConverter {
|
||||
|
||||
SchisandraAuthSocialUserMapperBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthSocialUserMapperBOConverter.class);
|
||||
|
||||
SchisandraAuthSocialUserMapper convertBOToEntity(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO);
|
||||
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package com.schisandra.auth.domain.service;
|
||||
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
|
||||
/**
|
||||
* 领域service
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
public interface SchisandraAuthSocialUserDomainService {
|
||||
|
||||
/**
|
||||
* 添加 信息
|
||||
*/
|
||||
Boolean add(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO);
|
||||
|
||||
/**
|
||||
* 更新 信息
|
||||
*/
|
||||
Boolean update(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO);
|
||||
|
||||
/**
|
||||
* 删除 信息
|
||||
*/
|
||||
Boolean delete(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO);
|
||||
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package com.schisandra.auth.domain.service;
|
||||
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
|
||||
|
||||
/**
|
||||
* 领域service
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
public interface SchisandraAuthSocialUserMapperDomainService {
|
||||
|
||||
/**
|
||||
* 添加 信息
|
||||
*/
|
||||
Boolean add(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO);
|
||||
|
||||
/**
|
||||
* 更新 信息
|
||||
*/
|
||||
Boolean update(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO);
|
||||
|
||||
/**
|
||||
* 删除 信息
|
||||
*/
|
||||
Boolean delete(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO);
|
||||
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package com.schisandra.auth.domain.service.impl;
|
||||
|
||||
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserBOConverter;
|
||||
import com.schisandra.auth.domain.service.SchisandraAuthSocialUserDomainService;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraAuthSocialUserDomainServiceImpl implements SchisandraAuthSocialUserDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserService schisandraAuthSocialUserService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO) {
|
||||
SchisandraAuthSocialUser schisandraAuthSocialUser = SchisandraAuthSocialUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserBO);
|
||||
schisandraAuthSocialUser.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraAuthSocialUserService.insert(schisandraAuthSocialUser) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO) {
|
||||
SchisandraAuthSocialUser schisandraAuthSocialUser = SchisandraAuthSocialUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserBO);
|
||||
return schisandraAuthSocialUserService.update(schisandraAuthSocialUser) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO) {
|
||||
SchisandraAuthSocialUser schisandraAuthSocialUser = new SchisandraAuthSocialUser();
|
||||
schisandraAuthSocialUser.setId(schisandraAuthSocialUserBO.getId());
|
||||
schisandraAuthSocialUser.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraAuthSocialUserService.update(schisandraAuthSocialUser) > 0;
|
||||
}
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package com.schisandra.auth.domain.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserMapperBOConverter;
|
||||
import com.schisandra.auth.domain.service.SchisandraAuthSocialUserMapperDomainService;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserMapperService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraAuthSocialUserMapperDomainServiceImpl implements SchisandraAuthSocialUserMapperDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserMapperService schisandraAuthSocialUserMapperService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO) {
|
||||
SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = SchisandraAuthSocialUserMapperBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserMapperBO);
|
||||
schisandraAuthSocialUserMapper.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraAuthSocialUserMapperService.insert(schisandraAuthSocialUserMapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO) {
|
||||
SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = SchisandraAuthSocialUserMapperBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserMapperBO);
|
||||
return schisandraAuthSocialUserMapperService.update(schisandraAuthSocialUserMapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO) {
|
||||
SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = new SchisandraAuthSocialUserMapper();
|
||||
schisandraAuthSocialUserMapper.setId(schisandraAuthSocialUserMapperBO.getId());
|
||||
schisandraAuthSocialUserMapper.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraAuthSocialUserMapperService.update(schisandraAuthSocialUserMapper) > 0;
|
||||
}
|
||||
}
|
@@ -7,15 +7,12 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.auth.common.entity.Result;
|
||||
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.auth.common.enums.OauthType;
|
||||
import com.schisandra.auth.common.enums.UserRoleEnum;
|
||||
import com.schisandra.auth.common.enums.UserStatusEnum;
|
||||
import com.schisandra.auth.common.redis.RedisUtil;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthUserRoleBO;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserBOConverter;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserMapperBOConverter;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthUserBOConverter;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthUserRoleBOConverter;
|
||||
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
|
||||
@@ -49,13 +46,6 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
@Resource
|
||||
private SchisandraAuthUserRoleService schisandraAuthUserRoleService;
|
||||
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserService schisandraAuthSocialUserService;
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserMapperService schisandraAuthSocialUserMapperService;
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthRoleService schisandraAuthRoleService;
|
||||
|
||||
@@ -97,7 +87,9 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
@Override
|
||||
public Boolean register(SchisandraAuthUserBO schisandraAuthUserBO) {
|
||||
SchisandraAuthUser authUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
|
||||
if (schisandraAuthUserService.insert(authUser)) {
|
||||
authUser.setSource(OauthType.SYSTEM.getType());
|
||||
Boolean insert = schisandraAuthUserService.insert(authUser);
|
||||
if (insert) {
|
||||
SchisandraAuthUserRoleBO schisandraAuthUserRoleBO = new SchisandraAuthUserRoleBO();
|
||||
schisandraAuthUserRoleBO.setUserId(authUser.getId());
|
||||
schisandraAuthUserRoleBO.setRoleId(UserRoleEnum.NORMAL_USER.getCode());
|
||||
@@ -138,13 +130,14 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 手机号验证码登录
|
||||
* @param: [schisandraAuthUserBO]
|
||||
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
|
||||
* @author zlg
|
||||
* @date: 2024/6/9 1:01
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description: 手机号验证码登录
|
||||
* @param: [schisandraAuthUserBO]
|
||||
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
|
||||
* @author zlg
|
||||
* @date: 2024/6/9 1:01
|
||||
*/
|
||||
@Override
|
||||
public SchisandraAuthUserBO loginByPhone(SchisandraAuthUserBO schisandraAuthUserBO) {
|
||||
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getUserName());
|
||||
@@ -230,50 +223,17 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
public Result insertAuthUserByOauth(AuthUser data, String type) {
|
||||
String uuid = data.getUuid();
|
||||
AuthToken token = data.getToken();
|
||||
SchisandraAuthSocialUser authSocialUser = schisandraAuthSocialUserService.selectByUuidAndType(uuid, type);
|
||||
if (ObjectUtils.isNotEmpty(authSocialUser)) {
|
||||
// 如果用户登录过就更新社会用户信息表
|
||||
SchisandraAuthSocialUserBO schisandraAuthSocialUserBO = new SchisandraAuthSocialUserBO();
|
||||
schisandraAuthSocialUserBO.setAccessToken(token.getAccessToken());
|
||||
schisandraAuthSocialUserBO.setSource(data.getSource());
|
||||
schisandraAuthSocialUserBO.setUid(token.getUid());
|
||||
schisandraAuthSocialUserBO.setOpenId(token.getOpenId());
|
||||
schisandraAuthSocialUserBO.setCode(token.getCode());
|
||||
schisandraAuthSocialUserBO.setAccessCode(token.getAccessCode());
|
||||
schisandraAuthSocialUserBO.setExpireIn(token.getExpireIn());
|
||||
schisandraAuthSocialUserBO.setIdToken(token.getIdToken());
|
||||
schisandraAuthSocialUserBO.setMacAlgorithm(token.getMacAlgorithm());
|
||||
schisandraAuthSocialUserBO.setMacKey(token.getMacKey());
|
||||
schisandraAuthSocialUserBO.setOauthToken(token.getOauthToken());
|
||||
schisandraAuthSocialUserBO.setOauthTokenSecret(token.getOauthTokenSecret());
|
||||
schisandraAuthSocialUserBO.setRefreshToken(token.getRefreshToken());
|
||||
schisandraAuthSocialUserBO.setId(authSocialUser.getId());
|
||||
SchisandraAuthSocialUser schisandraAuthSocialUser = SchisandraAuthSocialUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserBO);
|
||||
int update = schisandraAuthSocialUserService.updateByOauth(schisandraAuthSocialUser);
|
||||
if (update <= 0) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.error("schisandraAuthSocialUserService.update fail, param:{}", JSONObject.toJSONString(schisandraAuthSocialUser));
|
||||
}
|
||||
return Result.fail("Social User update fail");
|
||||
}
|
||||
// 获取用户id
|
||||
SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = new SchisandraAuthSocialUserMapper();
|
||||
schisandraAuthSocialUserMapper.setSocialUserId(authSocialUser.getId());
|
||||
SchisandraAuthSocialUserMapper result = schisandraAuthSocialUserMapperService.queryBySocialUserId(schisandraAuthSocialUserMapper);
|
||||
if (ObjectUtils.isEmpty(result)) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.error("schisandraAuthSocialUserMapperService.queryByCondition fail, param:{}", JSONObject.toJSONString(schisandraAuthSocialUserMapper));
|
||||
}
|
||||
return Result.fail("Social Mapper is empty");
|
||||
}
|
||||
Long userId = result.getUserId();
|
||||
|
||||
SchisandraAuthUser AuthUser = schisandraAuthUserService.selectByUuidAndType(uuid, type);
|
||||
if (ObjectUtils.isNotEmpty(AuthUser)) {
|
||||
Long userId = AuthUser.getId();
|
||||
// redis存储用户角色与权限信息
|
||||
userInfoPersistence(userId);
|
||||
StpUtil.login(userId, SaLoginConfig.setToken(token.getAccessToken()));
|
||||
} else {
|
||||
// 插入用户信息表
|
||||
SchisandraAuthUserBO schisandraAuthUserBO = new SchisandraAuthUserBO();
|
||||
schisandraAuthUserBO.setUuid(data.getUuid());
|
||||
schisandraAuthUserBO.setSource(data.getSource());
|
||||
schisandraAuthUserBO.setAvatar(data.getAvatar());
|
||||
schisandraAuthUserBO.setBlog(data.getBlog());
|
||||
schisandraAuthUserBO.setEmail(data.getEmail());
|
||||
@@ -293,51 +253,8 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
}
|
||||
return Result.fail("insertAuthUserByOauth.insertAuthUserByOauth fail");
|
||||
}
|
||||
// 插入社会用户信息表
|
||||
SchisandraAuthSocialUserBO schisandraAuthSocialUserBO = new SchisandraAuthSocialUserBO();
|
||||
schisandraAuthSocialUserBO.setUuid(data.getUuid());
|
||||
schisandraAuthSocialUserBO.setAccessToken(token.getAccessToken());
|
||||
schisandraAuthSocialUserBO.setSource(data.getSource());
|
||||
schisandraAuthSocialUserBO.setUid(token.getUid());
|
||||
schisandraAuthSocialUserBO.setOpenId(token.getOpenId());
|
||||
schisandraAuthSocialUserBO.setCode(token.getCode());
|
||||
schisandraAuthSocialUserBO.setAccessCode(token.getAccessCode());
|
||||
schisandraAuthSocialUserBO.setExpireIn(token.getExpireIn());
|
||||
schisandraAuthSocialUserBO.setIdToken(token.getIdToken());
|
||||
schisandraAuthSocialUserBO.setMacAlgorithm(token.getMacAlgorithm());
|
||||
schisandraAuthSocialUserBO.setMacKey(token.getMacKey());
|
||||
schisandraAuthSocialUserBO.setOauthToken(token.getOauthToken());
|
||||
schisandraAuthSocialUserBO.setOauthTokenSecret(token.getOauthTokenSecret());
|
||||
schisandraAuthSocialUserBO.setRefreshToken(token.getRefreshToken());
|
||||
schisandraAuthSocialUserBO.setScope(token.getScope());
|
||||
schisandraAuthSocialUserBO.setTokenType(token.getTokenType());
|
||||
schisandraAuthSocialUserBO.setUnionId(token.getUnionId());
|
||||
schisandraAuthSocialUserBO.setStatus(UserStatusEnum.NORMAL.getCode());
|
||||
schisandraAuthSocialUserBO.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
SchisandraAuthSocialUser schisandraAuthSocialUser = SchisandraAuthSocialUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserBO);
|
||||
int resultCode = schisandraAuthSocialUserService.insertAuthSocialUserByOauth(schisandraAuthSocialUser);
|
||||
if (resultCode <= 0) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.error("insertAuthSocialUserByOauth fail, param:{}", JSONObject.toJSONString(schisandraAuthSocialUserBO));
|
||||
}
|
||||
return Result.fail("schisandraAuthSocialUserService insert fail");
|
||||
}
|
||||
|
||||
// 建立用户与社会信息映射关系
|
||||
Long authUserId = schisandraAuthUser.getId();
|
||||
Long authSocialUserId = schisandraAuthSocialUser.getId();
|
||||
SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO = new SchisandraAuthSocialUserMapperBO();
|
||||
schisandraAuthSocialUserMapperBO.setUserId(authUserId);
|
||||
schisandraAuthSocialUserMapperBO.setSocialUserId(authSocialUserId);
|
||||
schisandraAuthSocialUserMapperBO.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = SchisandraAuthSocialUserMapperBOConverter.INSTANCE.convertBOToEntity(schisandraAuthSocialUserMapperBO);
|
||||
int code = schisandraAuthSocialUserMapperService.insertAuthSocialUserMapperByOauth(schisandraAuthSocialUserMapper);
|
||||
if (code <= 0) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.error("insertAuthSocialUserMapperByOauth fail, param:{}", JSONObject.toJSONString(schisandraAuthSocialUserMapperBO));
|
||||
}
|
||||
return Result.fail("insertAuthSocialUserMapperByOauth fail");
|
||||
}
|
||||
// 建立用户与角色映射关系
|
||||
SchisandraAuthUserRoleBO schisandraAuthUserRoleBO = new SchisandraAuthUserRoleBO();
|
||||
schisandraAuthUserRoleBO.setUserId(authUserId);
|
||||
@@ -351,10 +268,8 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
}
|
||||
return Result.fail("insertUserRole fail");
|
||||
}
|
||||
|
||||
// redis存储用户角色与权限信息
|
||||
userInfoPersistence(authUserId);
|
||||
|
||||
StpUtil.login(authUserId, SaLoginConfig.setToken(token.getAccessToken()));
|
||||
}
|
||||
return Result.ok();
|
||||
|
@@ -39,12 +39,12 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.9.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -1,18 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.dao;
|
||||
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraAuthSocialUserDao extends BaseMapper<SchisandraAuthSocialUser> {
|
||||
|
||||
}
|
||||
|
@@ -1,18 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.dao;
|
||||
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraAuthSocialUserMapperDao extends BaseMapper<SchisandraAuthSocialUserMapper> {
|
||||
|
||||
}
|
||||
|
@@ -1,167 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Data
|
||||
@Table("schisandra_auth_social_user")
|
||||
public class SchisandraAuthSocialUser implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 第三方系统的唯一ID
|
||||
*/
|
||||
@Column("uuid")
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* 第三方用户来源
|
||||
*/
|
||||
@Column("source")
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 用户的授权令牌
|
||||
*/
|
||||
@Column("access_token")
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 第三方用户的授权令牌的有效期
|
||||
*/
|
||||
@Column("expire_in")
|
||||
private Integer expireIn;
|
||||
|
||||
/**
|
||||
* 刷新令牌
|
||||
*/
|
||||
@Column("refresh_token")
|
||||
private String refreshToken;
|
||||
|
||||
/**
|
||||
* 第三方用户的 open id
|
||||
*/
|
||||
@Column("open_id")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 第三方用户的 ID
|
||||
*/
|
||||
@Column("uid")
|
||||
private String uid;
|
||||
|
||||
/**
|
||||
* 个别平台的授权信息
|
||||
*/
|
||||
@Column("access_code")
|
||||
private String accessCode;
|
||||
|
||||
/**
|
||||
* 第三方用户的 union id
|
||||
*/
|
||||
@Column("union_id")
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 第三方用户授予的权限
|
||||
*/
|
||||
@Column("scope")
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* 个别平台的授权信息
|
||||
*/
|
||||
@Column("token_type")
|
||||
private String tokenType;
|
||||
|
||||
/**
|
||||
* id token
|
||||
*/
|
||||
@Column("id_token")
|
||||
private String idToken;
|
||||
|
||||
/**
|
||||
* 小米平台用户的附带属性
|
||||
*/
|
||||
@Column("mac_algorithm")
|
||||
private String macAlgorithm;
|
||||
|
||||
/**
|
||||
* 小米平台用户的附带属性
|
||||
*/
|
||||
@Column("mac_key")
|
||||
private String macKey;
|
||||
|
||||
/**
|
||||
* 用户的授权code
|
||||
*/
|
||||
@Column("code")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* Twitter平台用户的附带属性
|
||||
*/
|
||||
@Column("oauth_token")
|
||||
private String oauthToken;
|
||||
|
||||
/**
|
||||
* Twitter平台用户的附带属性
|
||||
*/
|
||||
@Column("oauth_token_secret")
|
||||
private String oauthTokenSecret;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Column("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column("created_by")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column("created_time")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@Column(value = "is_deleted",isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -1,71 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Data
|
||||
@Table("schisandra_auth_social_user_mapper")
|
||||
public class SchisandraAuthSocialUserMapper implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 系统用户ID
|
||||
*/
|
||||
@Column("user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 社会化用户ID
|
||||
*/
|
||||
@Column("social_user_id")
|
||||
private Long socialUserId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column("created_by")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column("created_time")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column(value = "is_deleted",isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -27,8 +27,16 @@ public class SchisandraAuthUser implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* uuid
|
||||
*/
|
||||
@Column(value = "uuid")
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* source
|
||||
*/
|
||||
@Column(value = "source")
|
||||
private String source;
|
||||
|
||||
@Column(value = "user_name")
|
||||
private String userName;
|
||||
|
@@ -1,51 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.service;
|
||||
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
|
||||
|
||||
/**
|
||||
* 表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
public interface SchisandraAuthSocialUserMapperService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraAuthSocialUserMapper queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraAuthSocialUserMapper 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraAuthSocialUserMapper 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 根据条件查询角色
|
||||
*/
|
||||
SchisandraAuthSocialUserMapper queryBySocialUserId(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper);
|
||||
|
||||
int insertAuthSocialUserMapperByOauth(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper);
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.service;
|
||||
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
|
||||
/**
|
||||
* 表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
public interface SchisandraAuthSocialUserService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraAuthSocialUser queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraAuthSocialUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraAuthSocialUser schisandraAuthSocialUser);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraAuthSocialUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraAuthSocialUser schisandraAuthSocialUser);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
|
||||
SchisandraAuthSocialUser selectByUuidAndType(String uuid,String type);
|
||||
|
||||
int insertAuthSocialUserByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser);
|
||||
|
||||
int updateByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser);
|
||||
}
|
@@ -52,4 +52,6 @@ public interface SchisandraAuthUserService {
|
||||
int insertAuthUserByOauth(SchisandraAuthUser schisandraAuthUser);
|
||||
|
||||
boolean updateUserPasswordByPhone(SchisandraAuthUser schisandraAuthUser);
|
||||
|
||||
SchisandraAuthUser selectByUuidAndType(String uuid, String type);
|
||||
}
|
||||
|
@@ -1,86 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.auth.infra.basic.dao.SchisandraAuthSocialUserMapperDao;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthSocialUserMapperTableDef;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserMapperService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
*/
|
||||
@Service("SchisandraAuthSocialUserMapperService")
|
||||
public class SchisandraAuthSocialUserMapperServiceImpl implements SchisandraAuthSocialUserMapperService {
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserMapperDao schisandraAuthSocialUserMapperDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraAuthSocialUserMapper queryById(Long id) {
|
||||
return this.schisandraAuthSocialUserMapperDao.selectOneById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraAuthSocialUserMapper 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {
|
||||
return this.schisandraAuthSocialUserMapperDao.insert(schisandraAuthSocialUserMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraAuthSocialUserMapper 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {
|
||||
return this.schisandraAuthSocialUserMapperDao.update(schisandraAuthSocialUserMapper, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraAuthSocialUserMapperDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param schisandraAuthSocialUserMapper 条件
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraAuthSocialUserMapper queryBySocialUserId(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {
|
||||
|
||||
return schisandraAuthSocialUserMapperDao.selectOneByCondition(SchisandraAuthSocialUserMapperTableDef.SCHISANDRA_AUTH_SOCIAL_USER_MAPPER.SOCIAL_USER_ID.eq(schisandraAuthSocialUserMapper.getSocialUserId()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertAuthSocialUserMapperByOauth(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {
|
||||
return schisandraAuthSocialUserMapperDao.insert(schisandraAuthSocialUserMapper, true);
|
||||
}
|
||||
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
package com.schisandra.auth.infra.basic.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.auth.infra.basic.dao.SchisandraAuthSocialUserDao;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthSocialUserTableDef;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:07:57
|
||||
*/
|
||||
@Service("SchisandraAuthSocialUserService")
|
||||
public class SchisandraAuthSocialUserServiceImpl implements SchisandraAuthSocialUserService {
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserDao schisandraAuthSocialUserDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraAuthSocialUser queryById(Long id) {
|
||||
return this.schisandraAuthSocialUserDao.selectOneById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraAuthSocialUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraAuthSocialUser schisandraAuthSocialUser) {
|
||||
return this.schisandraAuthSocialUserDao.insert(schisandraAuthSocialUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraAuthSocialUser 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraAuthSocialUser schisandraAuthSocialUser) {
|
||||
return this.schisandraAuthSocialUserDao.update(schisandraAuthSocialUser, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraAuthSocialUserDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SchisandraAuthSocialUser selectByUuidAndType(String uuid, String type) {
|
||||
return schisandraAuthSocialUserDao.selectOneByCondition(
|
||||
SchisandraAuthSocialUserTableDef.SCHISANDRA_AUTH_SOCIAL_USER.UUID.eq(uuid)
|
||||
.and(SchisandraAuthSocialUserTableDef.SCHISANDRA_AUTH_SOCIAL_USER.SOURCE.eq(type)
|
||||
.and(SchisandraAuthSocialUserTableDef.SCHISANDRA_AUTH_SOCIAL_USER.IS_DELETED.eq(0))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertAuthSocialUserByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser) {
|
||||
return schisandraAuthSocialUserDao.insert(schisandraAuthSocialUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser) {
|
||||
return schisandraAuthSocialUserDao.update(schisandraAuthSocialUser, true);
|
||||
}
|
||||
|
||||
}
|
@@ -94,4 +94,11 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraAuthUser selectByUuidAndType(String uuid, String type) {
|
||||
return schisandraAuthUserDao.selectOneByCondition(SchisandraAuthUserTableDef.SCHISANDRA_AUTH_USER.UUID.eq(uuid)
|
||||
.and(SchisandraAuthUserTableDef.SCHISANDRA_AUTH_USER.SOURCE.eq(type)
|
||||
.and(SchisandraAuthUserTableDef.SCHISANDRA_AUTH_USER.IS_DELETED.eq(0))));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.auth.infra.basic.dao.SchisandraAuthSocialUserDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
|
||||
<result column="source" jdbcType="VARCHAR" property="source"/>
|
||||
<result column="access_token" jdbcType="VARCHAR" property="accessToken"/>
|
||||
<result column="expire_in" jdbcType="INTEGER" property="expireIn"/>
|
||||
<result column="refresh_token" jdbcType="VARCHAR" property="refreshToken"/>
|
||||
<result column="open_id" jdbcType="VARCHAR" property="openId"/>
|
||||
<result column="uid" jdbcType="VARCHAR" property="uid"/>
|
||||
<result column="access_code" jdbcType="VARCHAR" property="accessCode"/>
|
||||
<result column="union_id" jdbcType="VARCHAR" property="unionId"/>
|
||||
<result column="scope" jdbcType="VARCHAR" property="scope"/>
|
||||
<result column="token_type" jdbcType="VARCHAR" property="tokenType"/>
|
||||
<result column="id_token" jdbcType="VARCHAR" property="idToken"/>
|
||||
<result column="mac_algorithm" jdbcType="VARCHAR" property="macAlgorithm"/>
|
||||
<result column="mac_key" jdbcType="VARCHAR" property="macKey"/>
|
||||
<result column="code" jdbcType="VARCHAR" property="code"/>
|
||||
<result column="oauth_token" jdbcType="VARCHAR" property="oauthToken"/>
|
||||
<result column="oauth_token_secret" jdbcType="VARCHAR" property="oauthTokenSecret"/>
|
||||
<result column="status" jdbcType="TINYINT" property="status"/>
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.auth.infra.basic.dao.SchisandraAuthSocialUserMapperDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
||||
<result column="social_user_id" jdbcType="BIGINT" property="socialUserId"/>
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -5,6 +5,8 @@
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.auth.infra.basic.entity.SchisandraAuthUser">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
|
||||
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
|
||||
<result column="source" jdbcType="VARCHAR" property="source"/>
|
||||
<result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
|
||||
<result column="email" jdbcType="VARCHAR" property="email"/>
|
||||
<result column="phone" jdbcType="VARCHAR" property="phone"/>
|
||||
|
@@ -41,12 +41,12 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.9.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -42,12 +42,12 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.9.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -5,6 +5,7 @@ import com.schisandra.wechat.handler.WeChatMsgHandler;
|
||||
import com.schisandra.wechat.utils.MessageUtil;
|
||||
import com.schisandra.wechat.utils.SHA1;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -27,7 +28,8 @@ public class CallBackController {
|
||||
|
||||
@Resource
|
||||
private WeChatMsgFactory weChatMsgFactory;
|
||||
private static final String token = "LDQ20020618xxx";
|
||||
@Value("${wechat.token}")
|
||||
private String token;
|
||||
|
||||
@RequestMapping("/test")
|
||||
public String test() {
|
||||
|
@@ -36,10 +36,10 @@ public class ReceiveTextMsgHandler implements WeChatMsgHandler {
|
||||
String toUserName = messageMap.get("ToUserName");
|
||||
|
||||
Random random = new Random();
|
||||
int num = random.nextInt(1000);
|
||||
int num = random.nextInt(9000)+1000;
|
||||
String numKey = redisUtil.buildKey(LOGIN_PREFIX, String.valueOf(num));
|
||||
redisUtil.setNx(numKey, fromUserName, 5L, TimeUnit.MINUTES);
|
||||
String numContent = "您当前的验证码是:【" + num + "】 , 5分钟内有效";
|
||||
redisUtil.setNx(numKey, fromUserName, 1L, TimeUnit.MINUTES);
|
||||
String numContent = "您当前的验证码是:【" + num + "】 , 1分钟内有效";
|
||||
String replyContent = "<xml>\n" +
|
||||
" <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
|
||||
" <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +
|
||||
|
@@ -19,7 +19,7 @@ public class SubscribeMsgHandler implements WeChatMsgHandler {
|
||||
log.info("触发用户关注事件!");
|
||||
String fromUserName = messageMap.get("FromUserName");
|
||||
String toUserName = messageMap.get("ToUserName");
|
||||
String subscribeContent = "感谢您的关注,我是清语博客!";
|
||||
String subscribeContent = "感谢您的关注!";
|
||||
String content = "<xml>\n" +
|
||||
" <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
|
||||
" <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +
|
||||
|
@@ -23,3 +23,5 @@ spring:
|
||||
max-idle: 10
|
||||
# 连接池中的最小空闲连接
|
||||
min-idle: 0
|
||||
wechat:
|
||||
token: LDQ20020618xxx
|
||||
|
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
,---,
|
||||
,--.' | ,--, ,---,
|
||||
| | : ,--.'| ,---, ,---.'| __ ,-.
|
||||
.--.--. : : : | |, .--.--. ,-+-. / | | | :,' ,'/ /|
|
||||
/ / ' ,---. : | |,--.`--'_ / / ' ,--.--. ,--.'|' | | | |' | |' | ,--.--.
|
||||
| : /`./ / \ | : ' |,' ,'| | : /`./ / \ | | ,"' | ,--.__| || | ,'/ \
|
||||
| : ;_ / / ' | | /' :' | | | : ;_ .--. .-. | | | / | | / ,' |' : / .--. .-. |
|
||||
\ \ `. . ' / ' : | | || | : \ \ `. \__\/: . . | | | | |. ' / || | ' \__\/: . .
|
||||
`----. \' ; :__ | | ' | :' : |__ `----. \ ," .--.; | | | | |/ ' ; |: |; : | ," .--.; |
|
||||
/ /`--' /' | '.'|| : :_:,'| | '.'| / /`--' // / ,. | | | |--' | | '/ '| , ; / / ,. |
|
||||
'--'. / | : :| | ,' ; : ;'--'. /; : .' \| |/ | : :| ---' ; : .' \
|
||||
`--'---' \ \ / `--'' | , / `--'---' | , .-./'---' \ \ / | , .-./
|
||||
`----' ---`-' `--`---' `----' `--`---'
|
||||
|
||||
Spring Boot: ${spring-boot.formatted-version}
|
||||
五味子云存储
|
Reference in New Issue
Block a user