diff --git a/http-client.env.json b/http-client.env.json index a73a267ef..2f18d251c 100644 --- a/http-client.env.json +++ b/http-client.env.json @@ -4,7 +4,7 @@ "token": "test1", "adminTenentId": "1", - "userApi": "http://127.0.0.1:48080/app-api", + "appApi": "http://127.0.0.1:48080/app-api", "appToken": "test1", "appTenentId": "1" } diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/AuthorizeRequestsCustomizer.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/AuthorizeRequestsCustomizer.java new file mode 100644 index 000000000..5c8629076 --- /dev/null +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/AuthorizeRequestsCustomizer.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.framework.security.config; + +import cn.iocoder.yudao.framework.web.config.WebProperties; +import org.springframework.core.Ordered; +import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +import javax.annotation.Resource; + +/** + * 自定义的 URL 的安全配置 + * 目的:每个 Maven Module 可以自定义规则! + * + * @author 芋道源码 + */ +public abstract class AuthorizeRequestsCustomizer + implements Customizer.ExpressionInterceptUrlRegistry>, Ordered { + + @Resource + private WebProperties webProperties; + + protected String buildAdminApi(String url) { + return webProperties.getAdminApi().getPrefix() + url; + } + + protected String buildAppApi(String url) { + return webProperties.getAppApi().getPrefix() + url; + } + + @Override + public int getOrder() { + return 0; + } + +} 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 ba19b8bd2..8231306a9 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 @@ -26,6 +26,8 @@ import org.springframework.security.web.util.matcher.RequestMatcher; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.function.Consumer; /** * 自定义的 Spring Security 配置适配器实现 @@ -62,14 +64,22 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap @Resource private JWTAuthenticationTokenFilter authenticationTokenFilter; +// /** +// * 自定义的权限映射 Bean +// * +// * @see #configure(HttpSecurity) +// */ +// @Resource +// private Customizer.ExpressionInterceptUrlRegistry> +// authorizeRequestsCustomizer; + /** - * 自定义的权限映射 Bean + * 自定义的权限映射 Bean 们 * * @see #configure(HttpSecurity) */ @Resource - private Customizer.ExpressionInterceptUrlRegistry> - authorizeRequestsCustomizer; + private List authorizeRequestsCustomizers; /** * 由于 Spring Security 创建 AuthenticationManager 对象时,没声明 @Bean 注解,导致无法被注入 @@ -126,44 +136,31 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap StrUtil.equalsAny(request.getRequestURI(), buildAdminApi("/system/logout"), buildAppApi("/member/logout"))); - // 设置每个请求的权限 ①:全局共享规则 - httpSecurity.authorizeRequests() - // 登录的接口,可匿名访问 - .antMatchers(buildAdminApi("/system/login"), buildAdminApi("/member/login")).anonymous() + // 设置每个请求的权限 + httpSecurity + // ①:全局共享规则 + .authorizeRequests() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() - // 文件的获取接口,可匿名访问 - .antMatchers(buildAdminApi("/infra/file/get/**")).anonymous() - // Swagger 接口文档 - .antMatchers("/swagger-ui.html").anonymous() - .antMatchers("/swagger-resources/**").anonymous() - .antMatchers("/webjars/**").anonymous() - .antMatchers("/*/api-docs").anonymous() - // Spring Boot Actuator 的安全配置 - .antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous() - // Druid 监控 TODO 芋艿:等对接了 druid admin 后,在调整下。 - .antMatchers("/druid/**").anonymous() - // oAuth2 auth2/login/gitee TODO 芋艿:貌似可以删除 - .antMatchers(buildAdminApi("/auth2/login/**")).anonymous() - .antMatchers(buildAdminApi("/auth2/authorization/**")).anonymous() - .antMatchers("/api/callback/**").anonymous() - // 设置每个请求的权限 ②:每个项目的自定义规则 TODO 芋艿:改造成多个,方便每个模块自定义规则 - .and().authorizeRequests(authorizeRequestsCustomizer) - // 设置每个请求的权限 ③:兜底规则,必须认证 - .authorizeRequests().anyRequest().authenticated() + // 设置 App API 无需认证 + .antMatchers(buildAppApi("/**")).permitAll() + // ②:每个项目的自定义规则 + .and().authorizeRequests(registry -> // 下面,循环设置自定义规则 + authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(registry))) + // ③:兜底规则,必须认证 + .authorizeRequests() + .anyRequest().authenticated() ; + // 添加 JWT Filter httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); } private String buildAdminApi(String url) { - // TODO 芋艿:多模块 return webProperties.getAdminApi().getPrefix() + url; } private String buildAppApi(String url) { - // TODO 芋艿:多模块 return webProperties.getAppApi().getPrefix() + url; } diff --git a/yudao-module-infra/yudao-module-infra-impl/pom.xml b/yudao-module-infra/yudao-module-infra-impl/pom.xml index a26b274f3..6cefa7028 100644 --- a/yudao-module-infra/yudao-module-infra-impl/pom.xml +++ b/yudao-module-infra/yudao-module-infra-impl/pom.xml @@ -90,6 +90,17 @@ cn.smallbun.screw screw-core + + + + cn.iocoder.boot + yudao-spring-boot-starter-monitor + + + + de.codecentric + spring-boot-admin-starter-server + diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/config/AdminServerConfiguration.java similarity index 76% rename from yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java rename to yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/config/AdminServerConfiguration.java index f3784570d..697426e44 100644 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java +++ b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/config/AdminServerConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.server.framework.monitor.config; +package cn.iocoder.yudao.module.infra.framework.monitor.config; import de.codecentric.boot.admin.server.config.EnableAdminServer; import org.springframework.context.annotation.Configuration; diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/package-info.java similarity index 52% rename from yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java rename to yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/package-info.java index 99a6c75bd..f52e72c76 100644 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java +++ b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/package-info.java @@ -1,4 +1,4 @@ /** * 使用 Spring Boot Admin 实现简单的监控平台 */ -package cn.iocoder.yudao.server.framework.monitor; +package cn.iocoder.yudao.module.infra.framework.monitor; diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md similarity index 100% rename from yudao-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md rename to yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md diff --git a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java new file mode 100644 index 000000000..8af44d694 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.module.infra.framework.security.config; + +import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +/** + * Infra 模块的 Security 配置 + */ +@Configuration +public class InfraSecurityConfiguration { + + @Value("${spring.boot.admin.context-path:''}") + private String adminSeverContextPath; + + @Bean("infraAuthorizeRequestsCustomizer") + public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { + return new AuthorizeRequestsCustomizer() { + + @Override + public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { + // Swagger 接口文档 + registry.antMatchers("/swagger-ui.html").anonymous() + .antMatchers("/swagger-resources/**").anonymous() + .antMatchers("/webjars/**").anonymous() + .antMatchers("/*/api-docs").anonymous(); + // Spring Boot Actuator 的安全配置 + registry.antMatchers("/actuator").anonymous() + .antMatchers("/actuator/**").anonymous(); + // Druid 监控 + registry.antMatchers("/druid/**").anonymous(); + // Spring Boot Admin Server 的安全配置 + registry.antMatchers(adminSeverContextPath).anonymous() + .antMatchers(adminSeverContextPath + "/**").anonymous(); + // 文件的获取接口,可匿名访问 + registry.antMatchers(buildAdminApi("/infra/file/get/**"), buildAppApi("/infra/file/get/**")).anonymous(); + } + + }; + } + +} diff --git a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/core/package-info.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/core/package-info.java new file mode 100644 index 000000000..7762626c9 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.infra.framework.security.core; diff --git a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java deleted file mode 100644 index 7342570b1..000000000 --- a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 yudao-module-member-impl 的封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.member.framework; diff --git a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index fcb68b271..b95408afc 100644 --- a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -202,6 +202,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { if (user != null) { reqDTO.setUserId(user.getId()); } + reqDTO.setUserType(getUserType().getValue()); reqDTO.setUsername(mobile); reqDTO.setUserAgent(ServletUtils.getUserAgent()); reqDTO.setUserIp(getClientIP()); diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/LoginLogCreateReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/LoginLogCreateReqDTO.java index 514ac2d98..d3ae4fb4f 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/LoginLogCreateReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/LoginLogCreateReqDTO.java @@ -23,7 +23,6 @@ public class LoginLogCreateReqDTO { /** * 链路追踪编号 */ - @NotEmpty(message = "链路追踪编号不能为空") private String traceId; /** diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java new file mode 100644 index 000000000..3c6866e37 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.system.framework.security.config; + +import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; + +/** + * System 模块的 Security 配置 + */ +@Configuration +public class SystemSecurityConfiguration { + + @Bean("systemAuthorizeRequestsCustomizer") + public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { + return new AuthorizeRequestsCustomizer() { + + @Override + public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { + // 登录的接口,可匿名访问 + registry.antMatchers(buildAdminApi("/system/login")).anonymous(); + // 验证码的接口 + registry.antMatchers(buildAdminApi("/system/captcha/**")).anonymous(); + // 获得租户编号的接口 + registry.antMatchers(buildAdminApi("/system/tenant/get-id-by-name")).anonymous(); + // 短信回调 API + registry.antMatchers(buildAdminApi("/system/sms/callback/**")).anonymous(); + } + + }; + } + +} diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/core/package-info.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/core/package-info.java new file mode 100644 index 000000000..04a8d8b37 --- /dev/null +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/core/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.system.framework.security.core; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index afc66ebd2..7bdb58f3a 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -164,7 +164,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { if (user != null) { reqDTO.setUserId(user.getId()); } - reqDTO.setUserType(UserTypeEnum.ADMIN.getValue()); + reqDTO.setUserType(getUserType().getValue()); reqDTO.setUsername(username); reqDTO.setUserAgent(ServletUtils.getUserAgent()); reqDTO.setUserIp(ServletUtils.getClientIP()); diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImpl.java index 78ad540ba..0b806f6da 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImpl.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.system.convert.logger.LoginLogConvert; import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO; import cn.iocoder.yudao.module.system.dal.mysql.logger.LoginLogMapper; import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.List; @@ -16,6 +17,7 @@ import java.util.List; * 登录日志 Service 实现 */ @Service +@Validated public class LoginLogServiceImpl implements LoginLogService { @Resource diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 156e73f75..0e933ce05 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -67,17 +67,6 @@ yudao-spring-boot-starter-protection - - - cn.iocoder.boot - yudao-spring-boot-starter-monitor - - - - de.codecentric - spring-boot-admin-starter-server - - diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/package-info.java b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/package-info.java new file mode 100644 index 000000000..624b6c614 --- /dev/null +++ b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.shop.controller.admin; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/app/AppShopOrderController.java similarity index 71% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java rename to yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/app/AppShopOrderController.java index 25ebd6d28..54ff4daf9 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java +++ b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/app/AppShopOrderController.java @@ -1,13 +1,13 @@ -package cn.iocoder.yudao.userserver.modules.shop.controller; +package cn.iocoder.yudao.module.shop.controller.app; -import cn.iocoder.yudao.coreservice.modules.pay.service.notify.vo.PayNotifyOrderReqVO; -import cn.iocoder.yudao.coreservice.modules.pay.service.notify.vo.PayRefundOrderReqVO; -import cn.iocoder.yudao.coreservice.modules.pay.service.order.PayOrderCoreService; -import cn.iocoder.yudao.coreservice.modules.pay.service.order.dto.PayOrderCreateReqDTO; -import cn.iocoder.yudao.coreservice.modules.pay.util.PaySeqUtils; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.userserver.modules.shop.controller.vo.ShopOrderCreateRespVO; +import cn.iocoder.yudao.module.pay.service.notify.vo.PayNotifyOrderReqVO; +import cn.iocoder.yudao.module.pay.service.notify.vo.PayRefundOrderReqVO; +import cn.iocoder.yudao.module.pay.service.order.PayOrderService; +import cn.iocoder.yudao.module.pay.service.order.dto.PayOrderCreateReqDTO; +import cn.iocoder.yudao.module.pay.util.PaySeqUtils; +import cn.iocoder.yudao.module.shop.controller.app.vo.AppShopOrderCreateRespVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -24,20 +24,20 @@ import java.time.Duration; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; -@Api(tags = "商城订单") +@Api(tags = "用户 APP - 商城订单") @RestController @RequestMapping("/shop/order") @Validated @Slf4j -public class ShopOrderController { +public class AppShopOrderController { @Resource - private PayOrderCoreService payOrderCoreService; + private PayOrderService payOrderService; @PostMapping("/create") @ApiOperation("创建商城订单") // @PreAuthenticated // TODO 暂时不加登陆验证,前端暂时没做好 - public CommonResult create() { + public CommonResult create() { // 假装创建商城订单 Long shopOrderId = System.currentTimeMillis(); @@ -50,10 +50,10 @@ public class ShopOrderController { reqDTO.setBody("内容:" + shopOrderId); reqDTO.setAmount(200); // 单位:分 reqDTO.setExpireTime(DateUtils.addTime(Duration.ofDays(1))); - Long payOrderId = payOrderCoreService.createPayOrder(reqDTO); + Long payOrderId = payOrderService.createPayOrder(reqDTO); // 拼接返回 - return success(ShopOrderCreateRespVO.builder().id(shopOrderId) + return success(AppShopOrderCreateRespVO.builder().id(shopOrderId) .payOrderId(payOrderId).build()); } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/vo/ShopOrderCreateRespVO.java b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/app/vo/AppShopOrderCreateRespVO.java similarity index 73% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/vo/ShopOrderCreateRespVO.java rename to yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/app/vo/AppShopOrderCreateRespVO.java index 682afc4e9..06a677dbb 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/vo/ShopOrderCreateRespVO.java +++ b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/controller/app/vo/AppShopOrderCreateRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.userserver.modules.shop.controller.vo; +package cn.iocoder.yudao.module.shop.controller.app.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -6,11 +6,11 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; -@ApiModel("商城订单创建 Response VO") +@ApiModel("用户 APP - 商城订单创建 Response VO") @Data @Builder @AllArgsConstructor -public class ShopOrderCreateRespVO { +public class AppShopOrderCreateRespVO { @ApiModelProperty(value = "商城订单编号", required = true, example = "1024") private Long id; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/package-info.java b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/package-info.java similarity index 62% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/package-info.java rename to yudao-server/src/main/java/cn/iocoder/yudao/module/shop/package-info.java index c592130af..f088370dd 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/package-info.java +++ b/yudao-server/src/main/java/cn/iocoder/yudao/module/shop/package-info.java @@ -5,4 +5,5 @@ * * 缩写:shop */ -package cn.iocoder.yudao.userserver.modules.shop; +// TODO 芋艿:后续会迁移到 yudao-module-mall-trade 下 +package cn.iocoder.yudao.module.shop; diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java b/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java deleted file mode 100644 index 0a698bea9..000000000 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.server.framework.security; - -import cn.iocoder.yudao.framework.web.config.WebProperties; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -import javax.annotation.Resource; - -@Configuration -public class SecurityConfiguration { - - @Resource - private WebProperties webProperties; - - @Value("${spring.boot.admin.context-path:''}") - private String adminSeverContextPath; - - @Bean - public Customizer.ExpressionInterceptUrlRegistry> authorizeRequestsCustomizer() { - return registry -> { - // 验证码的接口 - registry.antMatchers(buildAdminApi("/system/captcha/**")).anonymous(); - // 获得租户编号的接口 - registry.antMatchers(buildAdminApi("/system/tenant/get-id-by-name")).anonymous(); - // Spring Boot Admin Server 的安全配置 - registry.antMatchers(adminSeverContextPath).anonymous() - .antMatchers(adminSeverContextPath + "/**").anonymous(); - // 短信回调 API - registry.antMatchers(buildAdminApi("/system/sms/callback/**")).anonymous(); - - // 设置 App API 无需认证 - registry.antMatchers(buildAppApi("/**")).permitAll(); - }; - } - - private String buildAdminApi(String url) { - // TODO 芋艿:多模块 - return webProperties.getAdminApi().getPrefix() + url; - } - - private String buildAppApi(String url) { - // TODO 芋艿:多模块 - return webProperties.getAppApi().getPrefix() + url; - } - -} diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 825ac44e4..301a0e176 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -20,6 +20,10 @@ spring: write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 fail-on-empty-beans: false # 允许序列化无属性的 Bean + # 静态资源 + mvc: + static-path-pattern: /static/** + # 工作流 Activiti 配置 activiti: # 1. false: 默认值,activiti启动时,对比数据库表中保存的版本,如果不匹配。将抛出异常 diff --git a/yudao-user-server/src/main/resources/static/MP_verify_DKOvVzFP7vPwwHx2.txt b/yudao-server/src/main/resources/static/MP_verify_DKOvVzFP7vPwwHx2.txt similarity index 100% rename from yudao-user-server/src/main/resources/static/MP_verify_DKOvVzFP7vPwwHx2.txt rename to yudao-server/src/main/resources/static/MP_verify_DKOvVzFP7vPwwHx2.txt diff --git a/yudao-user-server/src/main/resources/static/READMD.md b/yudao-server/src/main/resources/static/READMD.md similarity index 100% rename from yudao-user-server/src/main/resources/static/READMD.md rename to yudao-server/src/main/resources/static/READMD.md diff --git a/yudao-user-server/src/main/resources/static/pay_alipay_qr.html b/yudao-server/src/main/resources/static/pay_alipay_qr.html similarity index 93% rename from yudao-user-server/src/main/resources/static/pay_alipay_qr.html rename to yudao-server/src/main/resources/static/pay_alipay_qr.html index edb364f07..83a4eab3e 100644 --- a/yudao-user-server/src/main/resources/static/pay_alipay_qr.html +++ b/yudao-server/src/main/resources/static/pay_alipay_qr.html @@ -24,11 +24,11 @@