Commit c81c275a9727100ab48fa04a6cbe451e52b2016f
1 parent
930cdfe2
搭建 yudao-user-server 项目
Showing
9 changed files
with
155 additions
and
1 deletions
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 | @@ -149,6 +149,7 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap | ||
| 149 | .antMatchers("/druid/**").anonymous() | 149 | .antMatchers("/druid/**").anonymous() |
| 150 | // 短信回调 API TODO 芋艿:需要抽象出去 | 150 | // 短信回调 API TODO 芋艿:需要抽象出去 |
| 151 | .antMatchers(api("/system/sms/callback/**")).anonymous() | 151 | .antMatchers(api("/system/sms/callback/**")).anonymous() |
| 152 | + .antMatchers(api("/user/**")).anonymous() | ||
| 152 | // 除上面外的所有请求全部需要鉴权认证 | 153 | // 除上面外的所有请求全部需要鉴权认证 |
| 153 | .anyRequest().authenticated() | 154 | .anyRequest().authenticated() |
| 154 | .and() | 155 | .and() |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java
| 1 | package cn.iocoder.yudao.userserver; | 1 | package cn.iocoder.yudao.userserver; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.dict.config.YudaoDictAutoConfiguration; | ||
| 4 | +import cn.iocoder.yudao.framework.security.config.YudaoSecurityAutoConfiguration; | ||
| 5 | +import cn.iocoder.yudao.framework.security.config.YudaoWebSecurityConfigurerAdapter; | ||
| 3 | import org.springframework.boot.SpringApplication; | 6 | import org.springframework.boot.SpringApplication; |
| 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 5 | 8 | ||
| 6 | -@SpringBootApplication | 9 | +@SpringBootApplication(exclude = { |
| 10 | + YudaoDictAutoConfiguration.class, | ||
| 11 | +}) | ||
| 7 | public class UserServerApplication { | 12 | public class UserServerApplication { |
| 8 | 13 | ||
| 9 | public static void main(String[] args) { | 14 | public static void main(String[] args) { |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.controller; | ||
| 2 | + | ||
| 3 | +import lombok.extern.slf4j.Slf4j; | ||
| 4 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 5 | +import org.springframework.web.bind.annotation.RestController; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @author weir | ||
| 9 | + */ | ||
| 10 | +@Slf4j | ||
| 11 | +@RestController | ||
| 12 | +public class HelloController { | ||
| 13 | + | ||
| 14 | + @RequestMapping("/user/hello") | ||
| 15 | + public String hello(String hello) { | ||
| 16 | + return "echo + " + hello; | ||
| 17 | + } | ||
| 18 | +} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/SysAuthService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.service.auth; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.security.core.service.SecurityAuthFrameworkService; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 认证 Service 接口 | ||
| 7 | + * | ||
| 8 | + * 提供用户的账号密码登陆、token 的校验等认证相关的功能 | ||
| 9 | + * | ||
| 10 | + * @author 芋道源码 | ||
| 11 | + */ | ||
| 12 | +public interface SysAuthService extends SecurityAuthFrameworkService { | ||
| 13 | + | ||
| 14 | +} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/auth/impl/SysAuthServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.service.auth.impl; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.security.core.LoginUser; | ||
| 4 | +import cn.iocoder.yudao.userserver.modules.infra.service.auth.SysAuthService; | ||
| 5 | +import lombok.extern.slf4j.Slf4j; | ||
| 6 | +import org.springframework.security.core.userdetails.UserDetails; | ||
| 7 | +import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Auth Service 实现类 | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Service | ||
| 16 | +@Slf4j | ||
| 17 | +public class SysAuthServiceImpl implements SysAuthService { | ||
| 18 | + | ||
| 19 | + @Override | ||
| 20 | + public LoginUser verifyTokenAndRefresh(String token) { | ||
| 21 | + return null; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public LoginUser mockLogin(Long userId) { | ||
| 26 | + return null; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public void logout(String token) { | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | ||
| 36 | + return null; | ||
| 37 | + } | ||
| 38 | +} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.service.logger; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * API 访问日志 Service 接口 | ||
| 7 | + * | ||
| 8 | + * @author 芋道源码 | ||
| 9 | + */ | ||
| 10 | +public interface InfApiAccessLogService extends ApiAccessLogFrameworkService { | ||
| 11 | + | ||
| 12 | +} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.service.logger; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * API 错误日志 Service 接口 | ||
| 7 | + * | ||
| 8 | + * @author 芋道源码 | ||
| 9 | + */ | ||
| 10 | +public interface InfApiErrorLogService extends ApiErrorLogFrameworkService { | ||
| 11 | + | ||
| 12 | +} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; | ||
| 4 | +import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiAccessLogService; | ||
| 5 | +import lombok.extern.slf4j.Slf4j; | ||
| 6 | +import org.springframework.scheduling.annotation.AsyncResult; | ||
| 7 | +import org.springframework.stereotype.Service; | ||
| 8 | +import org.springframework.validation.annotation.Validated; | ||
| 9 | + | ||
| 10 | +import java.util.concurrent.Future; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * API 访问日志 Service 实现类 | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +@Validated | ||
| 19 | +@Slf4j | ||
| 20 | +public class InfApiAccessLogServiceImpl implements InfApiAccessLogService { | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public Future<Boolean> createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { | ||
| 24 | + log.debug("{}", createDTO); | ||
| 25 | + return new AsyncResult<>(true); | ||
| 26 | + } | ||
| 27 | +} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; | ||
| 4 | +import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiErrorLogService; | ||
| 5 | +import lombok.extern.slf4j.Slf4j; | ||
| 6 | +import org.springframework.scheduling.annotation.AsyncResult; | ||
| 7 | +import org.springframework.stereotype.Service; | ||
| 8 | +import org.springframework.validation.annotation.Validated; | ||
| 9 | + | ||
| 10 | +import java.util.concurrent.Future; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * API 错误日志 Service 实现类 | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +@Validated | ||
| 19 | +@Slf4j | ||
| 20 | +public class InfApiErrorLogServiceImpl implements InfApiErrorLogService { | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public Future<Boolean> createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { | ||
| 24 | + log.debug("{}", createDTO); | ||
| 25 | + return new AsyncResult<>(true); | ||
| 26 | + } | ||
| 27 | +} |