feat: OAuth

This commit is contained in:
landaiqing
2024-05-26 22:25:55 +08:00
parent 1154a53e9f
commit 90cc9e19f9
80 changed files with 1753 additions and 523 deletions

View File

@@ -23,7 +23,7 @@ public class SmsInitConfig implements SmartLifecycle {
@Resource
RedisUtil redisUtil;
private final String smsConfigPrefix="sys.config.";
private final String smsConfigPrefix="sys.config";
public void init() {
SmsConfigInfo configInfo = smsConfigRpc.getConfigInfo(SmsConfigContext.SMS_CONFIG_KEY);

View File

@@ -1,7 +1,7 @@
package com.schisandra.auth.application.config;
import com.schisandra.auth.application.factory.SmsTypeHandlerFactory;
import com.schisandra.auth.application.handler.SchisandraSmsTypeHandler;
import com.schisandra.auth.application.handler.sms.SchisandraSmsTypeHandler;
import org.dromara.sms4j.provider.config.BaseConfig;
import org.springframework.stereotype.Component;

View File

@@ -67,7 +67,7 @@ public class ReactRotateCaptchaController {
/**
* @description: 验证图片
* @param: [token, num]
* @return: com.schisandra.auth.common.entity.Result
* @return: com.schisandra.auth.common.bo.Result
* @author zlg
* @date: 2024/5/10 17:25
*/

View File

@@ -24,7 +24,7 @@ public class SchisandraAuthPermissionController {
/**
* @description: 更新权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @return: com.schisandra.auth.common.bo.Result
* @author zhang
* @date: 2024/4/17 16:44
*/
@@ -45,7 +45,7 @@ public class SchisandraAuthPermissionController {
/**
* @description: 添加权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @return: com.schisandra.auth.common.bo.Result
* @author zhang
* @date: 2024/4/17 16:55
*/
@@ -66,7 +66,7 @@ public class SchisandraAuthPermissionController {
/**
* @description: 查询权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @return: com.schisandra.auth.common.bo.Result
* @author zlg
* @date: 2024/4/17 16:54
*/
@@ -93,7 +93,7 @@ public class SchisandraAuthPermissionController {
/**
* @description: 删除权限信息
* @param: [schisandraAuthPermissionDTO]
* @return: com.schisandra.auth.common.entity.Result
* @return: com.schisandra.auth.common.bo.Result
* @author zhang
* @date: 2024/4/17 16:54
*/

View File

@@ -1,161 +0,0 @@
package com.schisandra.auth.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.schisandra.auth.application.convert.SchisandraAuthSocialUserDTOConverter;
import com.schisandra.auth.application.dto.SchisandraAuthSocialUserDTO;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
import com.schisandra.auth.domain.service.SchisandraAuthSocialUserDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* controller
*
* @author landaiqing
* @since 2024-05-23 20:07:57
*/
@RestController
@RequestMapping("/auth/")
@Slf4j
public class SchisandraAuthSocialUserController {
@Resource
private SchisandraAuthSocialUserDomainService schisandraAuthSocialUserDomainService;
/**
* 新增
*/
@RequestMapping("add")
public Result<Boolean> add(@RequestBody SchisandraAuthSocialUserDTO schisandraAuthSocialUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthSocialUserController.add.dto:{}", JSON.toJSONString(schisandraAuthSocialUserDTO));
}
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUuid(), "第三方系统的唯一ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getSource(), "第三方用户来源不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getAccessToken(), "用户的授权令牌不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getExpireIn(), "第三方用户的授权令牌的有效期不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getRefreshToken(), "刷新令牌不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOpenId(), "第三方用户的 open id不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUid(), "第三方用户的 ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getAccessCode(), "个别平台的授权信息不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUnionId(), "第三方用户的 union id不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getScope(), "第三方用户授予的权限不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getTokenType(), "个别平台的授权信息不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getIdToken(), "id token不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getMacAlgorithm(), "小米平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getMacKey(), "小米平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCode(), "用户的授权code不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOauthToken(), "Twitter平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOauthTokenSecret(), "Twitter平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getStatus(), "状态不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getIsDeleted(), "是否删除不能为空");
SchisandraAuthSocialUserBO SchisandraAuthSocialUserBO = SchisandraAuthSocialUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthSocialUserDTO);
return Result.ok(schisandraAuthSocialUserDomainService.add(SchisandraAuthSocialUserBO));
} catch (Exception e) {
log.error("SchisandraAuthSocialUserController.register.error:{}", e.getMessage(), e);
return Result.fail("新增失败");
}
}
/**
* 修改
*/
@RequestMapping("update")
public Result<Boolean> update(@RequestBody SchisandraAuthSocialUserDTO schisandraAuthSocialUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthSocialUserController.update.dto:{}", JSON.toJSONString(schisandraAuthSocialUserDTO));
}
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUuid(), "第三方系统的唯一ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getSource(), "第三方用户来源不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getAccessToken(), "用户的授权令牌不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getExpireIn(), "第三方用户的授权令牌的有效期不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getRefreshToken(), "刷新令牌不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOpenId(), "第三方用户的 open id不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUid(), "第三方用户的 ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getAccessCode(), "个别平台的授权信息不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUnionId(), "第三方用户的 union id不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getScope(), "第三方用户授予的权限不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getTokenType(), "个别平台的授权信息不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getIdToken(), "id token不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getMacAlgorithm(), "小米平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getMacKey(), "小米平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCode(), "用户的授权code不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOauthToken(), "Twitter平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOauthTokenSecret(), "Twitter平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getStatus(), "状态不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getIsDeleted(), "是否删除不能为空");
SchisandraAuthSocialUserBO schisandraAuthSocialUserBO = SchisandraAuthSocialUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthSocialUserDTO);
return Result.ok(schisandraAuthSocialUserDomainService.update(schisandraAuthSocialUserBO));
} catch (Exception e) {
log.error("SchisandraAuthSocialUserController.update.error:{}", e.getMessage(), e);
return Result.fail("更新信息失败");
}
}
/**
* 删除
*/
@RequestMapping("delete")
public Result<Boolean> delete(@RequestBody SchisandraAuthSocialUserDTO schisandraAuthSocialUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthSocialUserController.delete.dto:{}", JSON.toJSONString(schisandraAuthSocialUserDTO));
}
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUuid(), "第三方系统的唯一ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getSource(), "第三方用户来源不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getAccessToken(), "用户的授权令牌不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getExpireIn(), "第三方用户的授权令牌的有效期不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getRefreshToken(), "刷新令牌不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOpenId(), "第三方用户的 open id不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUid(), "第三方用户的 ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getAccessCode(), "个别平台的授权信息不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUnionId(), "第三方用户的 union id不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getScope(), "第三方用户授予的权限不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getTokenType(), "个别平台的授权信息不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getIdToken(), "id token不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getMacAlgorithm(), "小米平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getMacKey(), "小米平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCode(), "用户的授权code不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOauthToken(), "Twitter平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getOauthTokenSecret(), "Twitter平台用户的附带属性不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getStatus(), "状态不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserDTO.getIsDeleted(), "是否删除不能为空");
SchisandraAuthSocialUserBO schisandraAuthSocialUserBO = SchisandraAuthSocialUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthSocialUserDTO);
return Result.ok(schisandraAuthSocialUserDomainService.delete(schisandraAuthSocialUserBO));
} catch (Exception e) {
log.error("SchisandraAuthSocialUserController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除信息失败");
}
}
}

View File

@@ -1,113 +0,0 @@
package com.schisandra.auth.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.schisandra.auth.application.convert.SchisandraAuthSocialUserMapperDTOConverter;
import com.schisandra.auth.application.dto.SchisandraAuthSocialUserMapperDTO;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
import com.schisandra.auth.domain.service.SchisandraAuthSocialUserMapperDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* controller
*
* @author landaiqing
* @since 2024-05-23 20:13:10
*/
@RestController
@RequestMapping("/auth/")
@Slf4j
public class SchisandraAuthSocialUserMapperController {
@Resource
private SchisandraAuthSocialUserMapperDomainService schisandraAuthSocialUserMapperDomainService;
/**
* 新增
*/
@RequestMapping("add")
public Result<Boolean> add(@RequestBody SchisandraAuthSocialUserMapperDTO schisandraAuthSocialUserMapperDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthSocialUserMapperController.add.dto:{}", JSON.toJSONString(schisandraAuthSocialUserMapperDTO));
}
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUserId(), "系统用户ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getSocialUserId(), "社会化用户ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getIsDeleted(), "不能为空");
SchisandraAuthSocialUserMapperBO SchisandraAuthSocialUserMapperBO = SchisandraAuthSocialUserMapperDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthSocialUserMapperDTO);
return Result.ok(schisandraAuthSocialUserMapperDomainService.add(SchisandraAuthSocialUserMapperBO));
} catch (Exception e) {
log.error("SchisandraAuthSocialUserMapperController.register.error:{}", e.getMessage(), e);
return Result.fail("新增失败");
}
}
/**
* 修改
*/
@RequestMapping("update")
public Result<Boolean> update(@RequestBody SchisandraAuthSocialUserMapperDTO schisandraAuthSocialUserMapperDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthSocialUserMapperController.update.dto:{}", JSON.toJSONString(schisandraAuthSocialUserMapperDTO));
}
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUserId(), "系统用户ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getSocialUserId(), "社会化用户ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getIsDeleted(), "不能为空");
SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO = SchisandraAuthSocialUserMapperDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthSocialUserMapperDTO);
return Result.ok(schisandraAuthSocialUserMapperDomainService.update(schisandraAuthSocialUserMapperBO));
} catch (Exception e) {
log.error("SchisandraAuthSocialUserMapperController.update.error:{}", e.getMessage(), e);
return Result.fail("更新信息失败");
}
}
/**
* 删除
*/
@RequestMapping("delete")
public Result<Boolean> delete(@RequestBody SchisandraAuthSocialUserMapperDTO schisandraAuthSocialUserMapperDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthSocialUserMapperController.delete.dto:{}", JSON.toJSONString(schisandraAuthSocialUserMapperDTO));
}
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUserId(), "系统用户ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getSocialUserId(), "社会化用户ID不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthSocialUserMapperDTO.getIsDeleted(), "不能为空");
SchisandraAuthSocialUserMapperBO schisandraAuthSocialUserMapperBO = SchisandraAuthSocialUserMapperDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthSocialUserMapperDTO);
return Result.ok(schisandraAuthSocialUserMapperDomainService.delete(schisandraAuthSocialUserMapperBO));
} catch (Exception e) {
log.error("SchisandraAuthSocialUserMapperController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除信息失败");
}
}
}

View File

@@ -26,7 +26,7 @@ import javax.annotation.Resource;
* @Version: 1.0
*/
@RestController
@RequestMapping("/auth/")
@RequestMapping("/auth/user/")
@Slf4j
public class SchisandraAuthUserController {
@Resource
@@ -35,13 +35,12 @@ public class SchisandraAuthUserController {
private SchisandraAuthUserDomainService schisandraAuthUserDomainService;
/**
* 新增
* @description: 注册
* @param: [schisandraAuthUserDTO]
* @return: com.schisandra.auth.common.entity.Result
* @author: landaiqing
* @date: 2024/5/26 17:23
*/
@RequestMapping("add")
public Result<Boolean> add(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
return Result.ok();
}
@PostMapping("register")
public Result register(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
if (log.isInfoEnabled()) {
@@ -76,81 +75,4 @@ public class SchisandraAuthUserController {
}
/**
* 修改
*/
@RequestMapping("update")
public Result update(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthUserController.update.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
Preconditions.checkNotNull(schisandraAuthUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUserName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getNickName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getEmail(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPhone(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPassword(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getGender(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getAvatar(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIntroduce(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getExtJson(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIsDeleted(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getBlog(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getLocation(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCompany(), "不能为空");
SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
return Result.ok(schisandraAuthUserDomainService.update(schisandraAuthUserBO));
} catch (Exception e) {
log.error("SchisandraAuthUserController.update.error:{}", e.getMessage(), e);
return Result.fail("更新信息失败");
}
}
/**
* 删除
*/
@RequestMapping("delete")
public Result<Boolean> delete(@RequestBody SchisandraAuthUserDTO schisandraAuthUserDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraAuthUserController.delete.dto:{}", JSON.toJSONString(schisandraAuthUserDTO));
}
Preconditions.checkNotNull(schisandraAuthUserDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUserName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getNickName(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getEmail(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPhone(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getPassword(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getGender(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getAvatar(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getStatus(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIntroduce(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getExtJson(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getIsDeleted(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getBlog(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getLocation(), "不能为空");
Preconditions.checkNotNull(schisandraAuthUserDTO.getCompany(), "不能为空");
SchisandraAuthUserBO schisandraAuthUserBO = SchisandraAuthUserDTOConverter.INSTANCE.convertDTOToBO(schisandraAuthUserDTO);
//
return Result.ok();
} catch (Exception e) {
log.error("SchisandraAuthUserController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除信息失败");
}
}
}

View File

@@ -1,27 +1,24 @@
package com.schisandra.auth.application.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.xkcoding.justauth.AuthRequestFactory;
import lombok.RequiredArgsConstructor;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.schisandra.auth.application.factory.OauthTypeHandlerFactory;
import com.schisandra.auth.application.handler.oauth.SchisandraOauthTypeHandler;
import com.schisandra.auth.common.entity.Result;
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthSource;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* ClassName:SchisandraOauthController
@@ -35,59 +32,55 @@ import java.util.stream.Collectors;
@Slf4j
@RestController
@RequestMapping("/oauth")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RequestMapping("/oauth/")
public class SchisandraOauthController {
@Resource
private OauthTypeHandlerFactory oauthTypeHandlerFactory;
private final AuthRequestFactory factory;
@Resource
private SchisandraAuthUserDomainService schisandraAuthUserDomainService;
@Value("${web.url}")
private String url;
/**
* 登录类型
* @description: 获取授权链接并跳转到第三方授权页面
* @param: []
* @return: com.schisandra.auth.common.entity.Result
* {@code @author:} landaiqing
* @date: 2024/5/26 0:26
*/
@GetMapping
public Map<String, String> loginType() {
List<String> oauthList = factory.oauthList();
return oauthList.stream().collect(Collectors
.toMap(oauth -> oauth.toLowerCase() + "登录",
oauth -> "http://127.0.0.1:3000/oauth/login/" + oauth.toLowerCase()));
@GetMapping("/render/{type}")
public Result<String> renderAuth(@PathVariable("type") String type) throws IOException {
AuthRequest authRequest = getAuthRequest(type);
String token = AuthStateUtils.createState();
String url = authRequest.authorize(token);
return Result.ok(url);
}
private AuthRequest getAuthRequest(String type) {
SchisandraOauthTypeHandler handler = oauthTypeHandlerFactory.getHandler(type);
AuthRequest authRequest = handler.getAuthRequest(type);
return authRequest;
}
/**
* 登录
*
* @param oauthType 第三方登录类型
* @param response response
* @throws IOException
* @description: 回调函数
* @param: [callback]
* @return: void
* @author: landaiqing
* @date: 2024/5/26 13:20
*/
@RequestMapping("/login/{oauthType}")
public void renderAuth(@PathVariable String oauthType, HttpServletResponse response)
throws IOException {
AuthRequest authRequest = factory.get(getAuthSource(oauthType));
response.sendRedirect(authRequest.authorize(oauthType + "::" + AuthStateUtils.createState()));
@GetMapping("/callback/{type}")
@SneakyThrows
public void login(@PathVariable("type") String type, AuthCallback callback, HttpServletResponse response) {
AuthRequest authRequest = getAuthRequest(type);
AuthResponse<AuthUser> authResponse = authRequest.login(callback);
AuthUser data = authResponse.getData();
schisandraAuthUserDomainService.insertAuthUserByOauth(data, type);
response.sendRedirect(url + "splash?token=" + StpUtil.getTokenValue());
}
/**
* 登录成功后的回调
*
* @param oauthType 第三方登录类型
* @param callback 携带返回的信息
* @return 登录成功后的信息
*/
@RequestMapping("/{oauthType}/callback")
public AuthResponse login(@PathVariable String oauthType, AuthCallback callback) {
AuthRequest authRequest = factory.get(getAuthSource(oauthType));
AuthResponse response = authRequest.login(callback);
log.info("【response】= {}", JSONUtil.toJsonStr(response));
return response;
}
private AuthSource getAuthSource(String type) {
if (StrUtil.isNotBlank(type)) {
return AuthSource.valueOf(type.toUpperCase());
} else {
throw new RuntimeException("不支持的类型");
}
}
}

View File

@@ -28,7 +28,7 @@ public class SchisandraSmsController {
/**
* @description: 发送短信验证码
* @param: [phone]
* @return: com.schisandra.auth.common.entity.Result
* @return: com.schisandra.auth.common.bo.Result
* @author zlg
* @date: 2024/5/8 22:53
*/

View File

@@ -22,7 +22,7 @@ public interface SchisandraSmsConfigDTOConvert {
/**
* @description 将bo转换为实体
* @param schisandraSmsConfigDTO
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
* @return com.schisandra.auth.infra.basic.bo.SchisandraAuthUser
* @author schisandra
* @date 2024/3/21 23:13
*/

View File

@@ -0,0 +1,41 @@
package com.schisandra.auth.application.factory;
import com.schisandra.auth.application.handler.oauth.SchisandraOauthTypeHandler;
import com.schisandra.auth.application.handler.sms.SchisandraSmsTypeHandler;
import com.schisandra.auth.common.enums.OauthType;
import com.schisandra.auth.common.enums.SmsSupplierType;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
/**
* @Classname OauthTypeHandlerFactory
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.factory
* @Author: landaiqing
* @CreateTime: 2024-05-26 14:09
* @Description: TODO
* @Version: 1.0
*/
@Component
public class OauthTypeHandlerFactory implements InitializingBean {
@Resource
private List<SchisandraOauthTypeHandler> oauthTypeHandlerList;
private HashMap<OauthType,SchisandraOauthTypeHandler> handlerMap =new HashMap<>();
public SchisandraOauthTypeHandler getHandler(String type){
OauthType oauthType = OauthType.getByType(type);
return handlerMap.get(oauthType);
}
@Override
public void afterPropertiesSet() throws Exception {
for(SchisandraOauthTypeHandler oauthTypeHandler : oauthTypeHandlerList){
handlerMap.put(oauthTypeHandler.getHandlerType(),oauthTypeHandler);
}
}
}

View File

@@ -1,6 +1,6 @@
package com.schisandra.auth.application.factory;
import com.schisandra.auth.application.handler.SchisandraSmsTypeHandler;
import com.schisandra.auth.application.handler.sms.SchisandraSmsTypeHandler;
import com.schisandra.auth.common.enums.SmsSupplierType;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
@@ -8,7 +8,6 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Classname SmsTypeHandlerFactory

View File

@@ -0,0 +1,52 @@
package com.schisandra.auth.application.handler.oauth;
import com.schisandra.auth.common.enums.OauthType;
import com.schisandra.auth.common.utils.AuthStateRedisCache;
import com.schisandra.auth.infra.entity.OauthConfigInfo;
import com.schisandra.auth.infra.rpc.OauthConfigRpc;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthRequest;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @Classname GiteeOauthHandler
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.handler.oauth
* @Author: landaiqing
* @CreateTime: 2024-05-26 13:55
* @Description: TODO
* @Version: 1.0
*/
@Component
@Slf4j
public class GiteeOauthHandler implements SchisandraOauthTypeHandler {
@Resource
private OauthConfigRpc oauthConfigRpc;
@Resource
private AuthStateRedisCache stateRedisCache;
@Override
public OauthType getHandlerType() {
return OauthType.Gitee;
}
@Override
public AuthRequest getAuthRequest(String type) {
OauthConfigInfo gitee = oauthConfigRpc.getOauthConfigInfo(type);
if (ObjectUtils.isEmpty(gitee)) {
log.error("gitee oauth 配置信息获取失败");
return null;
}
return new AuthGiteeRequest(AuthConfig.builder()
.clientId(gitee.getClientId())
.clientSecret(gitee.getClientSecret())
.redirectUri(gitee.getRedirectUri())
.build(),stateRedisCache);
}
}

View File

@@ -0,0 +1,54 @@
package com.schisandra.auth.application.handler.oauth;
import com.schisandra.auth.common.enums.OauthType;
import com.schisandra.auth.common.utils.AuthStateRedisCache;
import com.schisandra.auth.infra.entity.OauthConfigInfo;
import com.schisandra.auth.infra.rpc.OauthConfigRpc;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthGithubRequest;
import me.zhyd.oauth.request.AuthRequest;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @Classname GiteeOauthHandler
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.handler.oauth
* @Author: landaiqing
* @CreateTime: 2024-05-26 13:55
* @Description: TODO
* @Version: 1.0
*/
@Component
@Slf4j
public class GithubOauthHandler implements SchisandraOauthTypeHandler {
@Resource
private OauthConfigRpc oauthConfigRpc;
@Resource
private AuthStateRedisCache stateRedisCache;
@Override
public OauthType getHandlerType() {
return OauthType.GitHUB;
}
@Override
public AuthRequest getAuthRequest(String type) {
OauthConfigInfo gitee = oauthConfigRpc.getOauthConfigInfo(type);
if (ObjectUtils.isEmpty(gitee)) {
log.error("github oauth 配置信息获取失败");
return null;
}
return new AuthGithubRequest(AuthConfig.builder()
.clientId(gitee.getClientId())
.clientSecret(gitee.getClientSecret())
.redirectUri(gitee.getRedirectUri())
.build(),stateRedisCache);
}
}

View File

@@ -0,0 +1,13 @@
package com.schisandra.auth.application.handler.oauth;
import com.schisandra.auth.common.enums.OauthType;
import me.zhyd.oauth.request.AuthRequest;
import org.springframework.stereotype.Component;
@Component
public interface SchisandraOauthTypeHandler {
OauthType getHandlerType();
AuthRequest getAuthRequest(String type);
}

View File

@@ -1,4 +1,4 @@
package com.schisandra.auth.application.handler;
package com.schisandra.auth.application.handler.sms;
import com.schisandra.auth.application.convert.SchisandraSmsConfigDTOConvert;
import com.schisandra.auth.application.dto.SchisandraSmsConfigDTO;

View File

@@ -1,4 +1,4 @@
package com.schisandra.auth.application.handler;
package com.schisandra.auth.application.handler.sms;
import com.schisandra.auth.application.convert.SchisandraSmsConfigDTOConvert;
import com.schisandra.auth.application.dto.SchisandraSmsConfigDTO;

View File

@@ -102,13 +102,6 @@
<version>3.2.1</version>
</dependency>
<!-- oauth工具类 -->
<dependency>
<groupId>com.xkcoding</groupId>
<artifactId>justauth-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.directory.studio</groupId>
@@ -123,17 +116,11 @@
</dependency>
<dependency>
<groupId>com.xkcoding</groupId>
<artifactId>justauth-spring-boot-starter</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>hutool-http</artifactId>
<groupId>cn.hutool</groupId>
</exclusion>
</exclusions>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.16.6</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,63 @@
package com.schisandra.auth.common.enums;
import lombok.Getter;
/**
* @Classname OauthType
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.common.enums
* @Author: landaiqing
* @CreateTime: 2024-05-26 13:36
* @Description: TODO
* @Version: 1.0
*/
@Getter
public enum OauthType {
/**
* 微信登录
*/
WECHAT("wechat"),
/**
* QQ登录
*/
QQ("qq"),
/**
* 微博登录
*/
WEIBO("weibo"),
/**
* 支付宝登录
*/
ALIPAY("alipay"),
/**
* 钉钉登录
*/
DINGTALK("dingtalk"),
/**
* 企业微信登录
*/
WORK_WEIXIN("work_weixin"),
/**
* Github
*/
GitHUB("gitHub"),
/**
* Gitee
*/
Gitee("gitee");
public String type;
OauthType(String type) {
this.type = type;
}
public static OauthType getByType(String type) {
for (OauthType resultKeyEnum : OauthType.values()) {
if (resultKeyEnum.type.equals(type)) {
return resultKeyEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,29 @@
package com.schisandra.auth.common.enums;
import lombok.Getter;
@Getter
public enum UserRoleEnum {
normal_user(1,"普通用户"),
admin(2,"管理员"),
super_admin(3,"超级管理员");
public int code;
public String desc;
UserRoleEnum(int code, String desc){
this.code = code;
this.desc = desc;
}
public static UserRoleEnum getByCode(int codeVal){
for(UserRoleEnum resultCodeEnum : UserRoleEnum.values()){
if(resultCodeEnum.code == codeVal){
return resultCodeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,35 @@
package com.schisandra.auth.common.enums;
import lombok.Getter;
/**
* 删除状态枚举
*
* @author: schisandra
*/
@Getter
public enum UserStatusEnum {
UN_NORMAL(1,"异常"),
NORMAL(0,"正常"),
BANED(-1,"禁用");
public int code;
public String desc;
UserStatusEnum(int code, String desc){
this.code = code;
this.desc = desc;
}
public static UserStatusEnum getByCode(int codeVal){
for(UserStatusEnum resultCodeEnum : UserStatusEnum.values()){
if(resultCodeEnum.code == codeVal){
return resultCodeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,79 @@
package com.schisandra.auth.common.utils;
import me.zhyd.oauth.cache.AuthCacheConfig;
import me.zhyd.oauth.cache.AuthStateCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
/**
* 扩展Redis版的state缓存
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @date 2019/10/24 13:38
* @since 1.8
*/
@Component
public class AuthStateRedisCache implements AuthStateCache {
@Resource
private RedisTemplate<String, String> redisTemplate;
private ValueOperations<String, String> valueOperations;
@PostConstruct
public void init() {
valueOperations = redisTemplate.opsForValue();
}
/**
* 存入缓存默认3分钟
*
* @param key 缓存key
* @param value 缓存内容
*/
@Override
public void cache(String key, String value) {
valueOperations.set(key, value, AuthCacheConfig.timeout, TimeUnit.MILLISECONDS);
}
/**
* 存入缓存
*
* @param key 缓存key
* @param value 缓存内容
* @param timeout 指定缓存过期时间(毫秒)
*/
@Override
public void cache(String key, String value, long timeout) {
valueOperations.set(key, value, timeout, TimeUnit.MILLISECONDS);
}
/**
* 获取缓存内容
*
* @param key 缓存key
* @return 缓存内容
*/
@Override
public String get(String key) {
return valueOperations.get(key);
}
/**
* 是否存在key如果对应key的value值已过期也返回false
*
* @param key 缓存key
* @return true存在key并且value没过期falsekey不存在或者已过期
*/
@Override
public boolean containsKey(String key) {
return redisTemplate.hasKey(key);
}
}

View File

@@ -12,7 +12,7 @@ public interface SchisandraAuthPermissionBOConverter {
/**
* @description: BO 转 实体
* @param: [schisandraAuthPermissionBO]
* @return: com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission
* @return: com.schisandra.auth.infra.basic.bo.SchisandraAuthPermission
* @author zhang
* @date: 2024/4/17 16:59
*/

View File

@@ -23,7 +23,7 @@ public interface SchisandraAuthRoleBOConverter {
/**
* @description 将bo转换为实体
* @param schisandraAuthRoleBO
* @return com.schisandra.auth.infra.basic.entity.SchisandraRoleUser
* @return com.schisandra.auth.infra.basic.bo.SchisandraRoleUser
* @author schisandra
* @date 2024/3/21 23:13
*/

View File

@@ -17,5 +17,6 @@ public interface SchisandraAuthSocialUserBOConverter {
SchisandraAuthSocialUserBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthSocialUserBOConverter.class);
SchisandraAuthSocialUser convertBOToEntity(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO);
SchisandraAuthSocialUserBO convertEntityToBO(SchisandraAuthSocialUser schisandraAuthSocialUser);
}

View File

@@ -26,7 +26,7 @@ public interface SchisandraSmsConfigBOConvert {
/**
* @description 将bo转换为实体
* @param schisandraSmsConfigBO
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
* @return com.schisandra.auth.infra.basic.bo.SchisandraAuthUser
* @author schisandra
* @date 2024/3/21 23:13
*/

View File

@@ -1,9 +1,11 @@
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
* 领域service
*
* @author landaiqing
* @since 2024-05-23 20:07:57
@@ -25,4 +27,5 @@ public interface SchisandraAuthSocialUserDomainService {
*/
Boolean delete(SchisandraAuthSocialUserBO schisandraAuthSocialUserBO);
}

View File

@@ -2,55 +2,74 @@ package com.schisandra.auth.domain.service;
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
import me.zhyd.oauth.model.AuthUser;
/**
* 用户领域service
*
* @author schisandra
* @date 2024/3/21
* @author landaiqing
* @since 2024-05-23 20:00:28
*/
public interface SchisandraAuthUserDomainService {
/**
* @description 用户注册
* @param schisandraAuthUserBO
* @return java.lang.Boolean
* @description 用户注册
* @author zlg
* @date 2024/3/21 23:14
*/
Boolean register(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description: 用户登录
* @param: [schisandraAuthUserBO]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author: landaiqing
* @date: 2024/5/26 17:28
*/
SchisandraAuthUserBO login(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 更新用户信息
* @param schisandraAuthUserBO
* @return java.lang.Object
* @description 更新用户信息
* @author schisandra
* @date 2024/3/21 23:14
*/
Object update(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 查询用户信息
* @param schisandraAuthUserBO
* @author msz
* @return com.schisandra.auth.infra.basic.entity.SchisandraAuthUser
* @description: 根据第三方登录信息添加用户信息
* @param: [data, type]
* @return: void
* @author: landaiqing
* @date: 2024/5/26 17:27
*/
void insertAuthUserByOauth(AuthUser data, String type);
/**
* @description: 通过id查询用户信息
* @param: [schisandraAuthUserBO]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author: landaiqing
* @date: 2024/5/26 17:27
*/
SchisandraAuthUserBO queryById(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 添加用户信息
* @param schisandraAuthUserBO
* @author msz
* @return java.lang.object
* @description 添加用户信息
* @author msz
*/
Object insert(SchisandraAuthUserBO schisandraAuthUserBO);
/**
* @description 删除用户(物理)
* @param id
* @author msz
* @return java.lang.object
* @description 删除用户(物理)
* @author msz
*/
Object deleteById(Long id);
}

View File

@@ -7,12 +7,13 @@ 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实现了
* 领域service实现了
*
* @author landaiqing
* @since 2024-05-23 20:07:57

View File

@@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 领域service实现了
* 领域service实现了
*
* @author landaiqing
* @since 2024-05-23 20:13:10
@@ -45,5 +45,4 @@ public class SchisandraAuthSocialUserMapperDomainServiceImpl implements Schisand
schisandraAuthSocialUserMapper.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
return schisandraAuthSocialUserMapperService.update(schisandraAuthSocialUserMapper) > 0;
}
}

View File

@@ -1,18 +1,45 @@
package com.schisandra.auth.domain.service.impl;
import cn.dev33.satoken.stp.SaLoginConfig;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.fastjson.JSONObject;
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
import com.schisandra.auth.common.enums.UserRoleEnum;
import com.schisandra.auth.common.enums.UserStatusEnum;
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;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserMapperService;
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserService;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserRoleService;
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserService;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import org.apache.commons.codec.digest.Md5Crypt;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* 领域service实现了
*
* @author landaiqing
* @since 2024-05-23 20:00:28
*/
@Service
@Slf4j
public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDomainService {
@@ -23,13 +50,20 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
private SchisandraAuthUserRoleService schisandraAuthUserRoleService;
@Resource
private SchisandraAuthSocialUserService schisandraAuthSocialUserService;
@Resource
private SchisandraAuthSocialUserMapperService schisandraAuthSocialUserMapperService;
/**
* @description: 注册用户
* @param: [schisandraAuthUserBO]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author zlg
* @date: 2024/5/14 20:59
*/
* @description: 注册用户
* @param: [schisandraAuthUserBO]
* @return: com.schisandra.auth.domain.bo.SchisandraAuthUserBO
* @author zlg
* @date: 2024/5/14 20:59
*/
@Override
public Boolean register(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getPhone());
@@ -37,12 +71,12 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
return false;
} else {
SchisandraAuthUser schisandraAuthUser1 = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
if (schisandraAuthUserService.insert(schisandraAuthUser1)){
if (schisandraAuthUserService.insert(schisandraAuthUser1)) {
SchisandraAuthUserRoleBO schisandraAuthUserRoleBO = new SchisandraAuthUserRoleBO();
schisandraAuthUserRoleBO.setUserId(schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getPhone()).getId());
schisandraAuthUserRoleBO.setRoleId(1L);
return schisandraAuthUserRoleService.insert(SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO))>1;
}else {
return schisandraAuthUserRoleService.insert(SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO)) > 1;
} else {
return false;
}
}
@@ -68,6 +102,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
return count > 0;
}
/**
* @param schisandraAuthUserBO
* @return
@@ -92,7 +127,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
@Override
public Object insert(SchisandraAuthUserBO schisandraAuthUserBO) {
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
return schisandraAuthUserService.insert(schisandraAuthUser);
return schisandraAuthUserService.insert(schisandraAuthUser);
}
/**
@@ -107,4 +142,124 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
boolean flag = schisandraAuthUserService.deleteById(id);
return flag;
}
/**
* @description: 根据第三方用户信息添加用户信息
* @param: [data, type]
* @return: void
* @author: landaiqing
* @date: 2024/5/26 17:35
*/
@Override
@Transactional
public void insertAuthUserByOauth(AuthUser data, String type) {
String uuid = data.getUuid();
AuthToken token = data.getToken();
int count = schisandraAuthSocialUserService.selectByUuidAndType(uuid, type);
if (count <= 0) {
SchisandraAuthUserBO schisandraAuthUserBO = new SchisandraAuthUserBO();
schisandraAuthUserBO.setAvatar(data.getAvatar());
schisandraAuthUserBO.setBlog(data.getBlog());
schisandraAuthUserBO.setEmail(data.getEmail());
schisandraAuthUserBO.setCompany(data.getCompany());
schisandraAuthUserBO.setGender(String.valueOf(data.getGender()));
schisandraAuthUserBO.setIntroduce(data.getRemark());
schisandraAuthUserBO.setLocation(data.getLocation());
schisandraAuthUserBO.setNickName(data.getNickname());
schisandraAuthUserBO.setUserName(data.getUsername());
schisandraAuthUserBO.setStatus(UserStatusEnum.NORMAL.getCode());
schisandraAuthUserBO.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
SchisandraAuthUser schisandraAuthUser = SchisandraAuthUserBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserBO);
int result = schisandraAuthUserService.insertAuthUserByOauth(schisandraAuthUser);
if (result <= 0) {
if (log.isInfoEnabled()) {
log.error("insertAuthUserByOauth fail, param:{}", JSONObject.toJSONString(schisandraAuthUser));
}
return;
}
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;
}
Long authUserId = schisandraAuthUser.getId();
Long authSocialUserId = schisandraAuthSocialUserBO.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;
}
SchisandraAuthUserRoleBO schisandraAuthUserRoleBO = new SchisandraAuthUserRoleBO();
schisandraAuthUserRoleBO.setUserId(authUserId);
schisandraAuthUserRoleBO.setRoleId((long) UserRoleEnum.normal_user.getCode());
schisandraAuthUserRoleBO.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
SchisandraAuthUserRole schisandraAuthUserRole = SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO);
int insert = schisandraAuthUserRoleService.insert(schisandraAuthUserRole);
if (insert <= 0) {
if (log.isInfoEnabled()) {
log.error("insertUserRole fail, param:{}", JSONObject.toJSONString(schisandraAuthUserRole));
}
return;
}
StpUtil.login(data.getUuid(), SaLoginConfig.setToken(token.getAccessToken()));
}
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.setScope(token.getScope());
schisandraAuthSocialUserBO.setTokenType(token.getTokenType());
schisandraAuthSocialUserBO.setUnionId(token.getUnionId());
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;
}
StpUtil.login(data.getUuid(), SaLoginConfig.setToken(token.getAccessToken()));
}
}

View File

@@ -5,7 +5,7 @@ import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
import org.springframework.stereotype.Repository;
/**
* 表数据库访问层
* 表数据库访问层
*
* @author landaiqing
* @since 2024-05-23 20:00:28

View File

@@ -47,4 +47,5 @@ public interface SchisandraAuthSocialUserMapperService {
*/
SchisandraAuthSocialUserMapper queryByCondition(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper);
int insertAuthSocialUserMapperByOauth(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper);
}

View File

@@ -47,4 +47,9 @@ public interface SchisandraAuthSocialUserService {
*/
SchisandraAuthSocialUser queryByCondition(SchisandraAuthSocialUser schisandraAuthSocialUser);
int selectByUuidAndType(String uuid,String type);
int insertAuthSocialUserByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser);
int updateByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser);
}

View File

@@ -49,4 +49,5 @@ public interface SchisandraAuthUserService {
*/
SchisandraAuthUser queryByCondition(SchisandraAuthUser schisandraAuthUser);
int insertAuthUserByOauth(SchisandraAuthUser schisandraAuthUser);
}

View File

@@ -90,4 +90,9 @@ public class SchisandraAuthSocialUserMapperServiceImpl implements SchisandraAuth
}
@Override
public int insertAuthSocialUserMapperByOauth(SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper) {
return schisandraAuthSocialUserMapperDao.insert(schisandraAuthSocialUserMapper);
}
}

View File

@@ -2,6 +2,8 @@ package com.schisandra.auth.infra.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.schisandra.auth.infra.basic.dao.SchisandraAuthSocialUserDao;
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
@@ -12,7 +14,7 @@ import javax.annotation.Resource;
import java.util.Objects;
/**
* 表服务实现类
* 表服务实现类
*
* @author landaiqing
* @since 2024-05-23 20:07:57
@@ -100,10 +102,27 @@ public class SchisandraAuthSocialUserServiceImpl implements SchisandraAuthSocial
.eq(Objects.nonNull(schisandraAuthSocialUser.getCreatedTime()), SchisandraAuthSocialUser::getCreatedTime, schisandraAuthSocialUser.getCreatedTime())
.eq(Objects.nonNull(schisandraAuthSocialUser.getUpdateBy()), SchisandraAuthSocialUser::getUpdateBy, schisandraAuthSocialUser.getUpdateBy())
.eq(Objects.nonNull(schisandraAuthSocialUser.getUpdateTime()), SchisandraAuthSocialUser::getUpdateTime, schisandraAuthSocialUser.getUpdateTime())
.eq(Objects.nonNull(schisandraAuthSocialUser.getIsDeleted()), SchisandraAuthSocialUser::getIsDeleted, schisandraAuthSocialUser.getIsDeleted())
;
.eq(Objects.nonNull(schisandraAuthSocialUser.getIsDeleted()), SchisandraAuthSocialUser::getIsDeleted, schisandraAuthSocialUser.getIsDeleted());
return schisandraAuthSocialUserDao.selectOne(queryWrapper);
}
@Override
public int selectByUuidAndType(String uuid, String type) {
return schisandraAuthSocialUserDao.selectCount(new QueryWrapper<SchisandraAuthSocialUser>()
.eq("uuid", uuid).eq("source", type).eq("is_deleted", 0));
}
@Override
public int insertAuthSocialUserByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser) {
return schisandraAuthSocialUserDao.insert(schisandraAuthSocialUser);
}
@Override
public int updateByOauth(SchisandraAuthSocialUser schisandraAuthSocialUser) {
return schisandraAuthSocialUserDao.update(schisandraAuthSocialUser, new UpdateWrapper<SchisandraAuthSocialUser>()
.eq("access_token", schisandraAuthSocialUser.getAccessToken())
.eq("refresh_token", schisandraAuthSocialUser.getRefreshToken()));
}
}

View File

@@ -106,4 +106,9 @@ public class SchisandraAuthUserServiceImpl implements SchisandraAuthUserService
}
@Override
public int insertAuthUserByOauth(SchisandraAuthUser schisandraAuthUser) {
return schisandraAuthUserDao.insert(schisandraAuthUser);
}
}

View File

@@ -0,0 +1,69 @@
package com.schisandra.auth.infra.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* dto
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Data
public class OauthConfigInfo implements Serializable {
/**
* 类型
*/
private String clientType;
/**
* Client Id
*/
private String clientId;
/**
* Client Secret
*/
private String clientSecret;
/**
* 应用回调地址
*/
private String redirectUri;
/**
* Key
*/
private String stackOverflowKey;
/**
* 团队名
*/
private String domainPrefix;
/**
* 目录(租户) ID
*/
private String tenantId;
/**
*
*/
private String alipayPublicKey;
/**
*
*/
private String agentId;
/**
* 状态
*/
private String status;
}

View File

@@ -7,7 +7,7 @@ import java.io.Serializable;
/**
* @Classname SmsConfigInfo
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.application.rpc.entity
* @BelongsPackage: com.schisandra.auth.application.rpc.bo
* @Author: landaiqing
* @CreateTime: 2024-05-11 23:50
* @Description: TODO

View File

@@ -0,0 +1,45 @@
package com.schisandra.auth.infra.rpc;
import com.schisandra.auth.infra.entity.OauthConfigInfo;
import com.schisandra.system.api.SchisandraSystemFeignService;
import com.schisandra.system.entity.Result;
import com.schisandra.system.entity.SchisandraSysOauthDTO;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @Classname OauthConfigRpc
* @BelongsProject: schisandra-cloud-storage
* @BelongsPackage: com.schisandra.auth.infra.rpc
* @Author: landaiqing
* @CreateTime: 2024-05-25 23:52
* @Description: TODO
* @Version: 1.0
*/
@Component
public class OauthConfigRpc {
@Resource
private SchisandraSystemFeignService schisandraSystemFeignService;
public OauthConfigInfo getOauthConfigInfo(String type) {
Result<SchisandraSysOauthDTO> result = schisandraSystemFeignService.getOauthConfigByType(type);
OauthConfigInfo oauthConfigInfo = new OauthConfigInfo();
if (!result.getSuccess()) {
return oauthConfigInfo;
}
SchisandraSysOauthDTO data = result.getData();
oauthConfigInfo.setAgentId(data.getAgentId());
oauthConfigInfo.setClientId(data.getClientId());
oauthConfigInfo.setClientSecret(data.getClientSecret());
oauthConfigInfo.setClientType(data.getClientType());
oauthConfigInfo.setStatus(data.getStatus());
oauthConfigInfo.setRedirectUri(data.getRedirectUri());
oauthConfigInfo.setDomainPrefix(data.getDomainPrefix());
oauthConfigInfo.setTenantId(data.getTenantId());
oauthConfigInfo.setAlipayPublicKey(data.getAlipayPublicKey());
oauthConfigInfo.setStackOverflowKey(data.getStackOverflowKey());
return oauthConfigInfo;
}
}

View File

@@ -2,7 +2,7 @@ package com.schisandra.auth.infra.rpc;
import com.schisandra.auth.infra.entity.SmsConfigInfo;
import com.schisandra.system.api.SmsConfigFeignService;
import com.schisandra.system.api.SchisandraSystemFeignService;
import com.schisandra.system.entity.Result;
import com.schisandra.system.entity.SchisandraSysConfigDTO;
import org.springframework.stereotype.Component;
@@ -21,10 +21,10 @@ import javax.annotation.Resource;
@Component
public class SmsConfigRpc {
@Resource
private SmsConfigFeignService smsConfigFeignService;
private SchisandraSystemFeignService schisandraSystemFeignService;
public SmsConfigInfo getConfigInfo(String key) {
Result<SchisandraSysConfigDTO> result = smsConfigFeignService.getConfigByKey(key);
Result<SchisandraSysConfigDTO> result = schisandraSystemFeignService.getConfigByKey(key);
SmsConfigInfo smsConfigInfo = new SmsConfigInfo();
if (!result.getSuccess()) {
return smsConfigInfo;

View File

@@ -5,6 +5,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* 鉴权微服务启动类
@@ -16,6 +17,7 @@ import org.springframework.context.annotation.ComponentScan;
@ComponentScan("com.schisandra")
@MapperScan("com.schisandra.**.dao")
@EnableFeignClients(basePackages = "com.schisandra")
@EnableTransactionManagement
public class AuthApplication {
public static void main(String[] args) {
SpringApplication.run(AuthApplication.class);

View File

@@ -85,15 +85,16 @@ mybatis-plus:
global-config:
banner: false
justauth:
enabled: true
type:
gitee:
client-id: 31b0e97dbf04c99ef1850d9ba50966a0fcd5cf84ee976d838b4894c2248dbce9
client-secret: bae8d25c7ef11b3a4b409a5069d029a20eb393e3179d13b38ab20ee376a21127
redirect-uri: http://127.0.0.1:3000/oauth/gitee/callback
cache:
type: redis
prefix: 'SOCIAL::STATE::'
timeout: 1h
# 前端地址
web:
url: http://127.0.0.1:5173/
feign:
client:
config:
default:
connectTimeout: 60000
readTimeout: 60000
ribbon:
ConnectTimeout: 60000
ReadTimeout: 60000

View File

@@ -11,6 +11,7 @@ spring:
group: DEFAULT_GROUP
namespace:
file-extension: yaml
timeout: 60000
discovery:
enabled: true
server-addr: 1.95.0.111:8848

View File

@@ -21,7 +21,7 @@ mappers:
- fileId: 003
template: genCode/template/EntityTemplate.java.vm
packageName: com.loser.user.${module}.entity
packageName: com.loser.user.${module}.bo
name: ${pre}
ext: java

View File

@@ -19,7 +19,7 @@ mappers:
ext: java
- fileId: 004
template: genCode/template/DemoBO.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/bo
name: ${modelName}BO
ext: java
- fileId: 005
@@ -44,7 +44,7 @@ mappers:
ext: java
- fileId: 009
template: genCode/template/DemoTable.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/bo
name: ${modelName}
ext: java
- fileId: 010

View File

@@ -8,7 +8,7 @@
# 数据库连接信息
jdbc:
dbName: schisandra-cloud-storage
tableName: schisandra_auth_social_user_mapper
tableName: schisandra_sys_oauth
url: jdbc:mysql://1.95.0.111:3306/
username: root
password: LDQ20020618xxx
@@ -22,9 +22,9 @@ params:
# 作者
author: landaiqing
# 模块
module: auth
module: system
# controller 通用前缀
api: /auth
api: /system/oauth/
# 生成对象是否移除前缀
removePre: false
# 使用内置函数赋值给变量 FunctionUtils 中替换

View File

@@ -19,7 +19,7 @@ mappers:
ext: java
- fileId: 004
template: genCode/template/DemoBO.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/bo
name: ${modelName}BO
ext: java
- fileId: 005
@@ -44,7 +44,7 @@ mappers:
ext: java
- fileId: 009
template: genCode/template/DemoTable.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/bo
name: ${modelName}
ext: java
- fileId: 010

View File

@@ -19,7 +19,7 @@ mappers:
ext: java
- fileId: 004
template: genCode/template/DemoBO.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/bo
name: ${modelName}BO
ext: java
- fileId: 005
@@ -44,7 +44,7 @@ mappers:
ext: java
- fileId: 009
template: genCode/template/DemoTable.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/bo
name: ${modelName}
ext: java
- fileId: 010

View File

@@ -19,7 +19,7 @@ mappers:
ext: java
- fileId: 004
template: genCode/template/DemoBO.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-domain/src/main/java/com/schisandra/${module}/domain/bo
name: ${modelName}BO
ext: java
- fileId: 005
@@ -44,7 +44,7 @@ mappers:
ext: java
- fileId: 009
template: genCode/template/DemoTable.java.vm
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/entity
filePath: /schisandra-cloud-storage-${module}/schisandra-cloud-storage-${module}-infra/src/main/java/com/schisandra/${module}/infra/basic/bo
name: ${modelName}
ext: java
- fileId: 010

View File

@@ -2,7 +2,7 @@ package com.schisandra.system.api;
import com.schisandra.system.entity.Result;
import com.schisandra.system.entity.SchisandraSysConfigDTO;
import feign.Param;
import com.schisandra.system.entity.SchisandraSysOauthDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -10,7 +10,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient("schisandra-cloud-storage-system-dev")
public interface SmsConfigFeignService {
public interface SchisandraSystemFeignService {
@RequestMapping(value = "/system/getConfigByKey",method = RequestMethod.GET)
Result<SchisandraSysConfigDTO> getConfigByKey(@RequestParam(value = "key") String key);
@PostMapping("/system/oauth/getOauthConfigByType")
Result<SchisandraSysOauthDTO> getOauthConfigByType(@RequestParam("type") String type);
}

View File

@@ -0,0 +1,98 @@
package com.schisandra.system.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* dto
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Data
public class SchisandraSysOauthDTO implements Serializable {
/**
*
*/
private Long id;
/**
* 类型
*/
private String clientType;
/**
* Client Id
*/
private String clientId;
/**
* Client Secret
*/
private String clientSecret;
/**
* 应用回调地址
*/
private String redirectUri;
/**
* Key
*/
private String stackOverflowKey;
/**
* 团队名
*/
private String domainPrefix;
/**
* 目录(租户) ID
*/
private String tenantId;
/**
*
*/
private String alipayPublicKey;
/**
*
*/
private String agentId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private String updateBy;
/**
* 是否删除 0 未删除 1已删除
*/
private Integer isDeleted;
/**
* 状态
*/
private String status;
}

View File

@@ -6,14 +6,12 @@ import com.google.common.base.Preconditions;
import com.schisandra.system.application.convert.SchisandraSysConfigDTOConverter;
import com.schisandra.system.application.dto.SchisandraSysConfigDTO;
import com.schisandra.system.common.entity.Result;
import com.schisandra.system.domain.entity.SchisandraSysConfigBO;
import com.schisandra.system.domain.bo.SchisandraSysConfigBO;
import com.schisandra.system.domain.service.SchisandraSysConfigDomainService;
import feign.Param;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* controller

View File

@@ -6,7 +6,7 @@ import com.google.common.base.Preconditions;
import com.schisandra.system.application.convert.SchisandraSysLogDTOConverter;
import com.schisandra.system.application.dto.SchisandraSysLogDTO;
import com.schisandra.system.common.entity.Result;
import com.schisandra.system.domain.entity.SchisandraSysLogBO;
import com.schisandra.system.domain.bo.SchisandraSysLogBO;
import com.schisandra.system.domain.service.SchisandraSysLogDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;

View File

@@ -0,0 +1,145 @@
package com.schisandra.system.application.controller;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Preconditions;
import com.schisandra.system.application.convert.SchisandraSysOauthDTOConverter;
import com.schisandra.system.application.dto.SchisandraSysOauthDTO;
import com.schisandra.system.common.entity.Result;
import com.schisandra.system.domain.bo.SchisandraSysOauthBO;
import com.schisandra.system.domain.service.SchisandraSysOauthDomainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* controller
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@RestController
@RequestMapping("/system/oauth/")
@Slf4j
public class SchisandraSysOauthController {
@Resource
private SchisandraSysOauthDomainService schisandraSysOauthDomainService;
/**
* 新增
*/
@RequestMapping("add")
public Result<Boolean> add(@RequestBody SchisandraSysOauthDTO schisandraSysOauthDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraSysOauthController.add.dto:{}", JSON.toJSONString(schisandraSysOauthDTO));
}
Preconditions.checkNotNull(schisandraSysOauthDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientType(), "类型不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientId(), "Client Id不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientSecret(), "Client Secret不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getRedirectUri(), "应用回调地址不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getStackOverflowKey(), "Key不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getDomainPrefix(), "团队名不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getTenantId(), "目录(租户) ID不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getAlipayPublicKey(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getAgentId(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getStatus(), "状态不能为空");
SchisandraSysOauthBO SchisandraSysOauthBO = SchisandraSysOauthDTOConverter.INSTANCE.convertDTOToBO(schisandraSysOauthDTO);
return Result.ok(schisandraSysOauthDomainService.add(SchisandraSysOauthBO));
} catch (Exception e) {
log.error("SchisandraSysOauthController.register.error:{}", e.getMessage(), e);
return Result.fail("新增失败");
}
}
/**
* 修改
*/
@RequestMapping("update")
public Result<Boolean> update(@RequestBody SchisandraSysOauthDTO schisandraSysOauthDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraSysOauthController.update.dto:{}", JSON.toJSONString(schisandraSysOauthDTO));
}
Preconditions.checkNotNull(schisandraSysOauthDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientType(), "类型不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientId(), "Client Id不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientSecret(), "Client Secret不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getRedirectUri(), "应用回调地址不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getStackOverflowKey(), "Key不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getDomainPrefix(), "团队名不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getTenantId(), "目录(租户) ID不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getAlipayPublicKey(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getAgentId(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getStatus(), "状态不能为空");
SchisandraSysOauthBO schisandraSysOauthBO = SchisandraSysOauthDTOConverter.INSTANCE.convertDTOToBO(schisandraSysOauthDTO);
return Result.ok(schisandraSysOauthDomainService.update(schisandraSysOauthBO));
} catch (Exception e) {
log.error("SchisandraSysOauthController.update.error:{}", e.getMessage(), e);
return Result.fail("更新信息失败");
}
}
/**
* 删除
*/
@RequestMapping("delete")
public Result<Boolean> delete(@RequestBody SchisandraSysOauthDTO schisandraSysOauthDTO) {
try {
if (log.isInfoEnabled()) {
log.info("SchisandraSysOauthController.delete.dto:{}", JSON.toJSONString(schisandraSysOauthDTO));
}
Preconditions.checkNotNull(schisandraSysOauthDTO.getId(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientType(), "类型不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientId(), "Client Id不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getClientSecret(), "Client Secret不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getRedirectUri(), "应用回调地址不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getStackOverflowKey(), "Key不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getDomainPrefix(), "团队名不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getTenantId(), "目录(租户) ID不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getAlipayPublicKey(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getAgentId(), "不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getCreatedBy(), "创建人不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getCreatedTime(), "创建时间不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getUpdateTime(), "更新时间不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getUpdateBy(), "更新人不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
Preconditions.checkNotNull(schisandraSysOauthDTO.getStatus(), "状态不能为空");
SchisandraSysOauthBO schisandraSysOauthBO = SchisandraSysOauthDTOConverter.INSTANCE.convertDTOToBO(schisandraSysOauthDTO);
return Result.ok(schisandraSysOauthDomainService.delete(schisandraSysOauthBO));
} catch (Exception e) {
log.error("SchisandraSysOauthController.delete.error:{}", e.getMessage(), e);
return Result.fail("删除信息失败");
}
}
@PostMapping("getOauthConfigByType")
public Result<SchisandraSysOauthDTO> getOauthConfigByType(@RequestParam("type") String type) {
if (log.isInfoEnabled()) {
log.info("SchisandraSysOauthController.getOauthConfig.key:{}", type);
}
SchisandraSysOauthBO schisandraSysOauthBO = schisandraSysOauthDomainService.getOauthConfigByType(type);
SchisandraSysOauthDTO schisandraSysOauthDTO = SchisandraSysOauthDTOConverter.INSTANCE.convertBOToDTO(schisandraSysOauthBO);
return Result.ok(schisandraSysOauthDTO);
}
}

View File

@@ -2,7 +2,7 @@ package com.schisandra.system.application.convert;
import com.schisandra.system.application.dto.SchisandraSysConfigDTO;
import com.schisandra.system.domain.entity.SchisandraSysConfigBO;
import com.schisandra.system.domain.bo.SchisandraSysConfigBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@@ -2,7 +2,7 @@ package com.schisandra.system.application.convert;
import com.schisandra.system.application.dto.SchisandraSysLogDTO;
import com.schisandra.system.domain.entity.SchisandraSysLogBO;
import com.schisandra.system.domain.bo.SchisandraSysLogBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@@ -0,0 +1,23 @@
package com.schisandra.system.application.convert;
import com.schisandra.system.application.dto.SchisandraSysOauthDTO;
import com.schisandra.system.domain.bo.SchisandraSysOauthBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* dto转换器
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Mapper
public interface SchisandraSysOauthDTOConverter {
SchisandraSysOauthDTOConverter INSTANCE = Mappers.getMapper(SchisandraSysOauthDTOConverter.class);
SchisandraSysOauthBO convertDTOToBO(SchisandraSysOauthDTO schisandraSysOauthDTO);
SchisandraSysOauthDTO convertBOToDTO(SchisandraSysOauthBO schisandraSysOauth);
}

View File

@@ -0,0 +1,98 @@
package com.schisandra.system.application.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* dto
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Data
public class SchisandraSysOauthDTO implements Serializable {
/**
*
*/
private Long id;
/**
* 类型
*/
private String clientType;
/**
* Client Id
*/
private String clientId;
/**
* Client Secret
*/
private String clientSecret;
/**
* 应用回调地址
*/
private String redirectUri;
/**
* Key
*/
private String stackOverflowKey;
/**
* 团队名
*/
private String domainPrefix;
/**
* 目录(租户) ID
*/
private String tenantId;
/**
*
*/
private String alipayPublicKey;
/**
*
*/
private String agentId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private String updateBy;
/**
* 是否删除 0 未删除 1已删除
*/
private Integer isDeleted;
/**
* 状态
*/
private String status;
}

View File

@@ -0,0 +1,98 @@
package com.schisandra.system.domain.bo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* bo
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Data
public class SchisandraSysOauthBO implements Serializable {
/**
*
*/
private Long id;
/**
* 类型
*/
private String clientType;
/**
* Client Id
*/
private String clientId;
/**
* Client Secret
*/
private String clientSecret;
/**
* 应用回调地址
*/
private String redirectUri;
/**
* Key
*/
private String stackOverflowKey;
/**
* 团队名
*/
private String domainPrefix;
/**
* 目录(租户) ID
*/
private String tenantId;
/**
*
*/
private String alipayPublicKey;
/**
*
*/
private String agentId;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 更新人
*/
private String updateBy;
/**
* 是否删除 0 未删除 1已删除
*/
private Integer isDeleted;
/**
* 状态
*/
private String status;
}

View File

@@ -1,6 +1,6 @@
package com.schisandra.system.domain.convert;
import com.schisandra.system.domain.entity.SchisandraSysConfigBO;
import com.schisandra.system.domain.bo.SchisandraSysConfigBO;
import com.schisandra.system.infra.basic.entity.SchisandraSysConfig;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@@ -1,7 +1,7 @@
package com.schisandra.system.domain.convert;
import com.schisandra.system.domain.entity.SchisandraSysLogBO;
import com.schisandra.system.domain.bo.SchisandraSysLogBO;
import com.schisandra.system.infra.basic.entity.SchisandraSysLog;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@@ -0,0 +1,23 @@
package com.schisandra.system.domain.convert;
import com.schisandra.system.domain.bo.SchisandraSysOauthBO;
import com.schisandra.system.infra.basic.entity.SchisandraSysOauth;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* bo转换器
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Mapper
public interface SchisandraSysOauthBOConverter {
SchisandraSysOauthBOConverter INSTANCE = Mappers.getMapper(SchisandraSysOauthBOConverter.class);
SchisandraSysOauth convertBOToEntity(SchisandraSysOauthBO schisandraSysOauthBO);
SchisandraSysOauthBO convertEntityToBO(SchisandraSysOauth schisandraSysOauth);
}

View File

@@ -1,6 +1,6 @@
package com.schisandra.system.domain.service;
import com.schisandra.system.domain.entity.SchisandraSysConfigBO;
import com.schisandra.system.domain.bo.SchisandraSysConfigBO;
/**
* 领域service

View File

@@ -1,6 +1,6 @@
package com.schisandra.system.domain.service;
import com.schisandra.system.domain.entity.SchisandraSysLogBO;
import com.schisandra.system.domain.bo.SchisandraSysLogBO;
/**
* 领域service

View File

@@ -0,0 +1,31 @@
package com.schisandra.system.domain.service;
import com.schisandra.system.domain.bo.SchisandraSysOauthBO;
/**
* 领域service
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
public interface SchisandraSysOauthDomainService {
/**
* 添加 信息
*/
Boolean add(SchisandraSysOauthBO schisandraSysOauthBO);
/**
* 更新 信息
*/
Boolean update(SchisandraSysOauthBO schisandraSysOauthBO);
/**
* 删除 信息
*/
Boolean delete(SchisandraSysOauthBO schisandraSysOauthBO);
SchisandraSysOauthBO getOauthConfigByType(String type);
}

View File

@@ -3,7 +3,7 @@ package com.schisandra.system.domain.service.impl;
import com.schisandra.system.common.enums.IsDeletedFlagEnum;
import com.schisandra.system.domain.convert.SchisandraSysConfigBOConverter;
import com.schisandra.system.domain.entity.SchisandraSysConfigBO;
import com.schisandra.system.domain.bo.SchisandraSysConfigBO;
import com.schisandra.system.domain.service.SchisandraSysConfigDomainService;
import com.schisandra.system.infra.basic.entity.SchisandraSysConfig;
import com.schisandra.system.infra.basic.service.SchisandraSysConfigService;

View File

@@ -1,9 +1,8 @@
package com.schisandra.system.domain.service.impl;
import com.schisandra.system.common.enums.IsDeletedFlagEnum;
import com.schisandra.system.domain.convert.SchisandraSysLogBOConverter;
import com.schisandra.system.domain.entity.SchisandraSysLogBO;
import com.schisandra.system.domain.bo.SchisandraSysLogBO;
import com.schisandra.system.domain.service.SchisandraSysLogDomainService;
import com.schisandra.system.infra.basic.entity.SchisandraSysLog;
import com.schisandra.system.infra.basic.service.SchisandraSysLogService;

View File

@@ -0,0 +1,56 @@
package com.schisandra.system.domain.service.impl;
import com.schisandra.system.common.enums.IsDeletedFlagEnum;
import com.schisandra.system.domain.bo.SchisandraSysOauthBO;
import com.schisandra.system.domain.convert.SchisandraSysOauthBOConverter;
import com.schisandra.system.domain.service.SchisandraSysOauthDomainService;
import com.schisandra.system.infra.basic.entity.SchisandraSysOauth;
import com.schisandra.system.infra.basic.service.SchisandraSysOauthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 领域service实现了
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Service
@Slf4j
public class SchisandraSysOauthDomainServiceImpl implements SchisandraSysOauthDomainService {
@Resource
private SchisandraSysOauthService schisandraSysOauthService;
@Override
public Boolean add(SchisandraSysOauthBO schisandraSysOauthBO) {
SchisandraSysOauth schisandraSysOauth = SchisandraSysOauthBOConverter.INSTANCE.convertBOToEntity(schisandraSysOauthBO);
schisandraSysOauth.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
return schisandraSysOauthService.insert(schisandraSysOauth) > 0;
}
@Override
public Boolean update(SchisandraSysOauthBO schisandraSysOauthBO) {
SchisandraSysOauth schisandraSysOauth = SchisandraSysOauthBOConverter.INSTANCE.convertBOToEntity(schisandraSysOauthBO);
return schisandraSysOauthService.update(schisandraSysOauth) > 0;
}
@Override
public Boolean delete(SchisandraSysOauthBO schisandraSysOauthBO) {
SchisandraSysOauth schisandraSysOauth = new SchisandraSysOauth();
schisandraSysOauth.setId(schisandraSysOauthBO.getId());
schisandraSysOauth.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
return schisandraSysOauthService.update(schisandraSysOauth) > 0;
}
@Override
public SchisandraSysOauthBO getOauthConfigByType(String type) {
SchisandraSysOauth schisandraSysOauth= schisandraSysOauthService.getOauthConfigByType(type);
SchisandraSysOauthBO schisandraSysOauthBO = SchisandraSysOauthBOConverter.INSTANCE.convertEntityToBO(schisandraSysOauth);
return schisandraSysOauthBO;
}
}

View File

@@ -0,0 +1,18 @@
package com.schisandra.system.infra.basic.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.schisandra.system.infra.basic.entity.SchisandraSysOauth;
import org.springframework.stereotype.Repository;
/**
* 表数据库访问层
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Repository
public interface SchisandraSysOauthDao extends BaseMapper<SchisandraSysOauth> {
}

View File

@@ -0,0 +1,119 @@
package com.schisandra.system.infra.basic.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
/**
* 实体类
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Data
@TableName("schisandra_sys_oauth")
public class SchisandraSysOauth implements Serializable {
/**
*
*/
@TableId(value = "`id`", type = IdType.AUTO)
private Long id;
/**
* 类型
*/
@TableField("`client_type`")
private String clientType;
/**
* Client Id
*/
@TableField("`client_id`")
private String clientId;
/**
* Client Secret
*/
@TableField("`client_secret`")
private String clientSecret;
/**
* 应用回调地址
*/
@TableField("`redirect_uri`")
private String redirectUri;
/**
* Key
*/
@TableField("`stack_overflow_Key`")
private String stackOverflowKey;
/**
* 团队名
*/
@TableField("`domain_prefix`")
private String domainPrefix;
/**
* 目录(租户) ID
*/
@TableField("`tenant_id`")
private String tenantId;
/**
*
*/
@TableField("`alipay_public_key`")
private String alipayPublicKey;
/**
*
*/
@TableField("`agent_id`")
private String agentId;
/**
* 创建人
*/
@TableField("`created_by`")
private String createdBy;
/**
* 创建时间
*/
@TableField("`created_time`")
private Date createdTime;
/**
* 更新时间
*/
@TableField("`update_time`")
private Date updateTime;
/**
* 更新人
*/
@TableField("`update_by`")
private String updateBy;
/**
* 是否删除 0 未删除 1已删除
*/
@TableField("`is_deleted`")
private Integer isDeleted;
/**
* 状态
*/
@TableField("`status`")
private String status;
}

View File

@@ -0,0 +1,51 @@
package com.schisandra.system.infra.basic.service;
import com.schisandra.system.infra.basic.entity.SchisandraSysOauth;
/**
* 表服务接口
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
public interface SchisandraSysOauthService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
SchisandraSysOauth queryById(Long id);
/**
* 新增数据
*
* @param schisandraSysOauth 实例对象
* @return 实例对象
*/
int insert(SchisandraSysOauth schisandraSysOauth);
/**
* 修改数据
*
* @param schisandraSysOauth 实例对象
* @return 实例对象
*/
int update(SchisandraSysOauth schisandraSysOauth);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Long id);
/**
* 根据条件查询角色
*/
SchisandraSysOauth queryByCondition(SchisandraSysOauth schisandraSysOauth);
SchisandraSysOauth getOauthConfigByType(String type);
}

View File

@@ -0,0 +1,109 @@
package com.schisandra.system.infra.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.schisandra.system.infra.basic.dao.SchisandraSysOauthDao;
import com.schisandra.system.infra.basic.entity.SchisandraSysOauth;
import com.schisandra.system.infra.basic.service.SchisandraSysOauthService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Objects;
/**
* 表服务实现类
*
* @author landaiqing
* @since 2024-05-25 23:08:26
*/
@Service("SchisandraSysOauthService")
public class SchisandraSysOauthServiceImpl implements SchisandraSysOauthService {
@Resource
private SchisandraSysOauthDao schisandraSysOauthDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public SchisandraSysOauth queryById(Long id) {
return this.schisandraSysOauthDao.selectById(id);
}
/**
* 新增数据
*
* @param schisandraSysOauth 实例对象
* @return 实例对象
*/
@Override
public int insert(SchisandraSysOauth schisandraSysOauth) {
return this.schisandraSysOauthDao.insert(schisandraSysOauth);
}
/**
* 修改数据
*
* @param schisandraSysOauth 实例对象
* @return 实例对象
*/
@Override
public int update(SchisandraSysOauth schisandraSysOauth) {
return this.schisandraSysOauthDao.updateById(schisandraSysOauth);
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long id) {
return this.schisandraSysOauthDao.deleteById(id) > 0;
}
/**
* 条件查询
*
* @param schisandraSysOauth 条件
* @return 实例对象
*/
@Override
public SchisandraSysOauth queryByCondition(SchisandraSysOauth schisandraSysOauth) {
LambdaQueryWrapper<SchisandraSysOauth> queryWrapper = Wrappers.<SchisandraSysOauth>lambdaQuery()
.eq(Objects.nonNull(schisandraSysOauth.getId()), SchisandraSysOauth::getId, schisandraSysOauth.getId())
.eq(Objects.nonNull(schisandraSysOauth.getClientType()), SchisandraSysOauth::getClientType, schisandraSysOauth.getClientType())
.eq(Objects.nonNull(schisandraSysOauth.getClientId()), SchisandraSysOauth::getClientId, schisandraSysOauth.getClientId())
.eq(Objects.nonNull(schisandraSysOauth.getClientSecret()), SchisandraSysOauth::getClientSecret, schisandraSysOauth.getClientSecret())
.eq(Objects.nonNull(schisandraSysOauth.getRedirectUri()), SchisandraSysOauth::getRedirectUri, schisandraSysOauth.getRedirectUri())
.eq(Objects.nonNull(schisandraSysOauth.getStackOverflowKey()), SchisandraSysOauth::getStackOverflowKey, schisandraSysOauth.getStackOverflowKey())
.eq(Objects.nonNull(schisandraSysOauth.getDomainPrefix()), SchisandraSysOauth::getDomainPrefix, schisandraSysOauth.getDomainPrefix())
.eq(Objects.nonNull(schisandraSysOauth.getTenantId()), SchisandraSysOauth::getTenantId, schisandraSysOauth.getTenantId())
.eq(Objects.nonNull(schisandraSysOauth.getAlipayPublicKey()), SchisandraSysOauth::getAlipayPublicKey, schisandraSysOauth.getAlipayPublicKey())
.eq(Objects.nonNull(schisandraSysOauth.getAgentId()), SchisandraSysOauth::getAgentId, schisandraSysOauth.getAgentId())
.eq(Objects.nonNull(schisandraSysOauth.getCreatedBy()), SchisandraSysOauth::getCreatedBy, schisandraSysOauth.getCreatedBy())
.eq(Objects.nonNull(schisandraSysOauth.getCreatedTime()), SchisandraSysOauth::getCreatedTime, schisandraSysOauth.getCreatedTime())
.eq(Objects.nonNull(schisandraSysOauth.getUpdateTime()), SchisandraSysOauth::getUpdateTime, schisandraSysOauth.getUpdateTime())
.eq(Objects.nonNull(schisandraSysOauth.getUpdateBy()), SchisandraSysOauth::getUpdateBy, schisandraSysOauth.getUpdateBy())
.eq(Objects.nonNull(schisandraSysOauth.getIsDeleted()), SchisandraSysOauth::getIsDeleted, schisandraSysOauth.getIsDeleted())
.eq(Objects.nonNull(schisandraSysOauth.getStatus()), SchisandraSysOauth::getStatus, schisandraSysOauth.getStatus())
;
return schisandraSysOauthDao.selectOne(queryWrapper);
}
@Override
public SchisandraSysOauth getOauthConfigByType(String type) {
return schisandraSysOauthDao.selectOne(new QueryWrapper<SchisandraSysOauth>()
.eq("client_type",type)
.eq("is_deleted",0));
}
}

View File

@@ -0,0 +1,24 @@
<?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.system.infra.basic.dao.SchisandraSysOauthDao">
<resultMap id="BaseResultMap" type="com.schisandra.system.infra.basic.entity.SchisandraSysOauth">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="client_type" jdbcType="VARCHAR" property="clientType"/>
<result column="client_id" jdbcType="VARCHAR" property="clientId"/>
<result column="client_secret" jdbcType="VARCHAR" property="clientSecret"/>
<result column="redirect_uri" jdbcType="VARCHAR" property="redirectUri"/>
<result column="stack_overflow_Key" jdbcType="VARCHAR" property="stackOverflowKey"/>
<result column="domain_prefix" jdbcType="VARCHAR" property="domainPrefix"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="alipay_public_key" jdbcType="VARCHAR" property="alipayPublicKey"/>
<result column="agent_id" jdbcType="VARCHAR" property="agentId"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
</resultMap>
</mapper>

View File

@@ -75,3 +75,15 @@ sa-token:
token-prefix: schisandra
is-print: false
feign:
client:
config:
default:
connectTimeout: 60000
readTimeout: 60000
ribbon:
ConnectTimeout: 60000
ReadTimeout: 60000

View File

@@ -11,6 +11,7 @@ spring:
group: DEFAULT_GROUP
namespace:
file-extension: yaml
timeout: 60000
discovery:
enabled: true
server-addr: 1.95.0.111:8848