feat(database): 初始化客户订单表结构
- 创建 customer_order 表,包含订单基本信息、客户信息、收货地址、支付信息等字段 - 设置订单状态和支付状态的默认值及注释说明 - 添加索引以优化查询性能,包括订单号、商品ID、状态和创建时间 - 指定表的存储引擎为 InnoDB,字符集为 utf8mb4 feat(common): 新增SKU状态枚举类 - 定义 SkuStatus 枚举,包含 ACTIVE 和 INACTIVE 两种状态 - 提供 getCode 和 getDescription 方法获取状态码和描述 - 实现 fromCode 静态方法用于根据状态码获取对应的枚举实例 docs(startup): 编写后端服务启动说明文档 - 添加启动后端服务的详细步骤和注意事项 - 说明正确的启动类位置及如何验证启动是否成功 - 提供常见问题诊断方法和解决方案 - 包含使用IDE、Maven命令和打包后的启动方式 feat(util): 新增字符串工具类 - 实现 isEmpty、isNotEmpty、isBlank、isNotBlank 等判断方法 - 提供 trim 方法去除字符串两端空白 - 添加 defaultIfEmpty 方法在字符串为空时返回默认值 docs(architecture): 编写系统架构完整性说明文档 - 描述后端和前端的完整架构组成及检查清单 - 说明系统的统一规范、代码复用、可扩展性和可维护性特点 - 展示包结构总览和最佳实践建议 - 对系统完整性进行评分并给出总结评价 docs(troubleshooting): 编写后端启动问题排查指南 - 针对前端无法连接后端的问题提供详细的排查流程 - 介绍多种启动后端服务的方法及常见失败原因 - 提供快速诊断命令和日志检查建议 - 列出需要提供的错误信息以便进一步协助 feat(config): 新增Web配置类支持跨域访问 - 配置 CORS 跨域资源共享规则,允许所有来源访问 /api/** 路径 - 设置允许的请求方法、请求头和凭证信息 - 添加日志记录跨域配置的过程和结果
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.mtkj.mtpay.common.enums;
|
||||
|
||||
/**
|
||||
* SKU状态枚举
|
||||
*/
|
||||
public enum SkuStatus {
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
ACTIVE("ACTIVE", "启用"),
|
||||
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
INACTIVE("INACTIVE", "禁用");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
|
||||
SkuStatus(String code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static SkuStatus fromCode(String code) {
|
||||
for (SkuStatus status : values()) {
|
||||
if (status.code.equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
31
mt-pay/src/main/java/com/mtkj/mtpay/config/WebConfig.java
Normal file
31
mt-pay/src/main/java/com/mtkj/mtpay/config/WebConfig.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.mtkj.mtpay.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Web配置类
|
||||
* 配置跨域、拦截器等
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 配置跨域
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
log.info("配置跨域访问,路径: /api/**, 允许所有来源");
|
||||
registry.addMapping("/api/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
log.info("跨域配置完成");
|
||||
}
|
||||
}
|
||||
|
||||
50
mt-pay/src/main/java/com/mtkj/mtpay/util/StringUtils.java
Normal file
50
mt-pay/src/main/java/com/mtkj/mtpay/util/StringUtils.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.mtkj.mtpay.util;
|
||||
|
||||
/**
|
||||
* 字符串工具类
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
/**
|
||||
* 判断字符串是否为空
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否不为空
|
||||
*/
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为空白
|
||||
*/
|
||||
public static boolean isBlank(String str) {
|
||||
return str == null || str.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否不为空白
|
||||
*/
|
||||
public static boolean isNotBlank(String str) {
|
||||
return !isBlank(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除字符串两端空白
|
||||
*/
|
||||
public static String trim(String str) {
|
||||
return str == null ? null : str.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果字符串为空,返回默认值
|
||||
*/
|
||||
public static String defaultIfEmpty(String str, String defaultValue) {
|
||||
return isEmpty(str) ? defaultValue : str;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user