From c81c275a9727100ab48fa04a6cbe451e52b2016f Mon Sep 17 00:00:00 2001 From: weir <1261174789@qq.com> Date: Sun, 29 Aug 2021 16:44:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=AD=E5=BB=BA=20yudao-user-server=20=20?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YudaoWebSecurityConfigurerAdapter.java | 1 + .../userserver/UserServerApplication.java | 7 +++- .../infra/controller/HelloController.java | 18 +++++++++ .../infra/service/auth/SysAuthService.java | 14 +++++++ .../service/auth/impl/SysAuthServiceImpl.java | 38 +++++++++++++++++++ .../logger/InfApiAccessLogService.java | 12 ++++++ .../service/logger/InfApiErrorLogService.java | 12 ++++++ .../impl/InfApiAccessLogServiceImpl.java | 27 +++++++++++++ .../impl/InfApiErrorLogServiceImpl.java | 27 +++++++++++++ 9 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/SysAuthService.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/impl/SysAuthServiceImpl.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java index 3d678eefd..b1e432d2e 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java @@ -149,6 +149,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap .antMatchers("/druid/**").anonymous() // 短信回调 API TODO 芋艿:需要抽象出去 .antMatchers(api("/system/sms/callback/**")).anonymous() + .antMatchers(api("/user/**")).anonymous() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java index edfbc63dc..a26de72cc 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java @@ -1,9 +1,14 @@ package cn.iocoder.yudao.userserver; +import cn.iocoder.yudao.framework.dict.config.YudaoDictAutoConfiguration; +import cn.iocoder.yudao.framework.security.config.YudaoSecurityAutoConfiguration; +import cn.iocoder.yudao.framework.security.config.YudaoWebSecurityConfigurerAdapter; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication +@SpringBootApplication(exclude = { + YudaoDictAutoConfiguration.class, +}) public class UserServerApplication { public static void main(String[] args) { diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java new file mode 100644 index 000000000..617228750 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.userserver.modules.infra.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author weir + */ +@Slf4j +@RestController +public class HelloController { + + @RequestMapping("/user/hello") + public String hello(String hello) { + return "echo + " + hello; + } +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/SysAuthService.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/SysAuthService.java new file mode 100644 index 000000000..e9b530904 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/SysAuthService.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.userserver.modules.infra.service.auth; + +import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; + +/** + * 认证 Service 接口 + * + * 提供用户的账号密码登陆、token 的校验等认证相关的功能 + * + * @author 芋道源码 + */ +public interface SysAuthService extends SecurityAuthFrameworkService { + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/impl/SysAuthServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/impl/SysAuthServiceImpl.java new file mode 100644 index 000000000..6ab606c59 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/impl/SysAuthServiceImpl.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.userserver.modules.infra.service.auth.impl; + +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.userserver.modules.infra.service.auth.SysAuthService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +/** + * Auth Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Slf4j +public class SysAuthServiceImpl implements SysAuthService { + + @Override + public LoginUser verifyTokenAndRefresh(String token) { + return null; + } + + @Override + public LoginUser mockLogin(Long userId) { + return null; + } + + @Override + public void logout(String token) { + + } + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + return null; + } +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java new file mode 100644 index 000000000..bcc4f3a97 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java @@ -0,0 +1,12 @@ +package cn.iocoder.yudao.userserver.modules.infra.service.logger; + +import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; + +/** + * API 访问日志 Service 接口 + * + * @author 芋道源码 + */ +public interface InfApiAccessLogService extends ApiAccessLogFrameworkService { + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java new file mode 100644 index 000000000..2c221604e --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java @@ -0,0 +1,12 @@ +package cn.iocoder.yudao.userserver.modules.infra.service.logger; + +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; + +/** + * API 错误日志 Service 接口 + * + * @author 芋道源码 + */ +public interface InfApiErrorLogService extends ApiErrorLogFrameworkService { + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java new file mode 100644 index 000000000..c246d1cfb --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; + +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; +import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiAccessLogService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.AsyncResult; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.concurrent.Future; + +/** + * API 访问日志 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +@Slf4j +public class InfApiAccessLogServiceImpl implements InfApiAccessLogService { + + @Override + public Future createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { + log.debug("{}", createDTO); + return new AsyncResult<>(true); + } +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java new file mode 100644 index 000000000..637cb63ff --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; + +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; +import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiErrorLogService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.AsyncResult; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.concurrent.Future; + +/** + * API 错误日志 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +@Slf4j +public class InfApiErrorLogServiceImpl implements InfApiErrorLogService { + + @Override + public Future createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { + log.debug("{}", createDTO); + return new AsyncResult<>(true); + } +}