ソースを参照

搭建 yudao-user-server 项目

weir 3 年 前
コミット
c81c275a97

+ 1 - 0
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()

+ 6 - 1
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) {

+ 18 - 0
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;
+    }
+}

+ 14 - 0
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 {
+
+}

+ 38 - 0
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;
+    }
+}

+ 12 - 0
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 {
+
+}

+ 12 - 0
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 {
+
+}

+ 27 - 0
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<Boolean> createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) {
+        log.debug("{}", createDTO);
+        return new AsyncResult<>(true);
+    }
+}

+ 27 - 0
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<Boolean> createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) {
+        log.debug("{}", createDTO);
+        return new AsyncResult<>(true);
+    }
+}