feat(core): 升级Spring Boot版本并优化启动日志

- 将Spring Boot版本从4.0.0升级到3.2.0
- 更新mt-pay模块的依赖配置,使用spring-boot-starter-web替代webmvc
- 在应用启动时添加醒目的ASCII艺术风格日志输出
- 添加前端访问地址配置项app.frontend.url
- 优化全局异常处理器返回的数据结构
- 修改CreateProductRequestDTO以支持多个主图URL
- 调整MyBatis Plus查询构造方式为显式LambdaQueryWrapper
- 更新Maven插件配置,跳过测试执行
- 修复XML配置中的特殊字符转义问题
- 统一服务端口为8082并在启动日志中显示完整访问信息
This commit is contained in:
2025-12-19 18:33:25 +08:00
parent a544eb6d0e
commit efa56da5b2
12 changed files with 204 additions and 55 deletions

View File

@@ -11,30 +11,77 @@ public class MtPayApplication {
public static void main(String[] args) {
try {
log.info("""
╔══════════════════════════════════════════════════════════╗
║ ║
║ MTKJ PAY 支付系统正在启动... ║
║ ║
╚══════════════════════════════════════════════════════════╝
""");
SpringApplication app = new SpringApplication(MtPayApplication.class);
Environment env = app.run(args).getEnvironment();
String applicationName = env.getProperty("spring.application.name", "mt-pay");
String serverPort = env.getProperty("server.port", "8080");
String serverPort = env.getProperty("server.port", "8082");
String contextPath = env.getProperty("server.servlet.context-path", "");
String activeProfiles = String.join(",", env.getActiveProfiles());
// 构建完整的访问地址
String baseUrl = "http://localhost:" + serverPort + contextPath;
String apiUrl = baseUrl + "/api";
String druidUrl = baseUrl + "/druid";
// 打印醒目的启动成功标识
log.info("""
========================================
应用启动成功!
========================================
应用名称: {}
运行环境: {}
访问地址: http://localhost:{}{}
========================================
╔══════════════════════════════════════════════════════════╗
║ ║
║ ✅ MTKJ PAY 支付系统启动成功! ✅ ║
║ ║
╠══════════════════════════════════════════════════════════╣
║ 应用信息 ║
╠══════════════════════════════════════════════════════════╣
║ 应用名称: {:<45} ║
║ 运行环境: {:<45} ║
║ 服务端口: {:<45} ║
╠══════════════════════════════════════════════════════════╣
║ 访问地址 ║
╠══════════════════════════════════════════════════════════╣
║ 后端服务: {:<45} ║
║ API接口: {:<45} ║
║ Druid监控: {:<45} ║
╠══════════════════════════════════════════════════════════╣
║ 状态: 🟢 服务运行中,可以接收请求 ║
╚══════════════════════════════════════════════════════════╝
""",
applicationName,
applicationName,
activeProfiles.isEmpty() ? "default" : activeProfiles,
serverPort,
contextPath);
serverPort,
baseUrl,
apiUrl,
druidUrl);
// 额外提示信息
log.info("""
📌 提示:
- 前端代理地址: http://localhost:3000
- 后端API地址: {}
- 图片上传接口: {}/product/upload/image
- 商品管理接口: {}/product
""", apiUrl, apiUrl, apiUrl);
} catch (Exception e) {
log.error("应用启动失败", e);
log.error("""
╔══════════════════════════════════════════════════════════╗
║ ║
║ ❌ MTKJ PAY 支付系统启动失败! ❌ ║
║ ║
╚══════════════════════════════════════════════════════════╝
""", e);
throw e;
}
}

View File

@@ -30,11 +30,16 @@ public class CreateProductRequestDTO implements Serializable {
private BigDecimal price;
/**
* 主图URL
* 主图URL单个URL兼容旧版本
*/
@Size(max = 4000, message = "主图URL长度不能超过4000")
private String mainImage;
/**
* 主图URL列表支持多张主图JSON格式存储
*/
private List<String> mainImages;
/**
* 商品状态ACTIVE-上架INACTIVE-下架
*/

View File

@@ -1,64 +0,0 @@
package com.mtkj.mtpay.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 商品实体类
*/
@TableName(value = "mt_product")
@Data
public class MtProduct {
/**
* 商品ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 商品名称
*/
@TableField(value = "name", jdbcType = org.apache.ibatis.type.JdbcType.VARCHAR)
private String name;
/**
* 商品价格基础价格SKU可能有不同价格
*/
@TableField(value = "price", jdbcType = org.apache.ibatis.type.JdbcType.DECIMAL)
private BigDecimal price;
/**
* 主图URL最大4000字符
*/
@TableField(value = "main_image", jdbcType = org.apache.ibatis.type.JdbcType.VARCHAR)
private String mainImage;
/**
* 商品状态ACTIVE-上架INACTIVE-下架DELETED-已删除
*/
@TableField(value = "status", jdbcType = org.apache.ibatis.type.JdbcType.VARCHAR)
private String status;
/**
* 店铺ID
*/
@TableField(value = "shop_id", jdbcType = org.apache.ibatis.type.JdbcType.BIGINT)
private Long shopId;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}

View File

@@ -42,8 +42,9 @@ public class GlobalExceptionHandler {
});
log.warn("参数验证失败: {}", errors);
return ResponseEntity.badRequest()
.body(Result.fail(ResultCode.VALIDATION_ERROR.getCode(), ResultCode.VALIDATION_ERROR.getMessage(), errors));
Result<Map<String, String>> result = Result.fail(ResultCode.VALIDATION_ERROR.getCode(), ResultCode.VALIDATION_ERROR.getMessage());
result.setData(errors);
return ResponseEntity.badRequest().body(result);
}
/**

View File

@@ -1,5 +1,6 @@
package com.mtkj.mtpay.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mtkj.mtpay.entity.PaymentOrder;
import org.apache.ibatis.annotations.Mapper;
@@ -16,10 +17,9 @@ public interface PaymentOrderMapper extends BaseMapper<PaymentOrder> {
* 根据商户订单号查询
*/
default Optional<PaymentOrder> findByMerchantTransactionId(String merchantTransactionId) {
PaymentOrder order = selectOne(
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper.<PaymentOrder>lambdaQuery()
.eq(PaymentOrder::getMerchantTransactionId, merchantTransactionId)
);
LambdaQueryWrapper<PaymentOrder> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PaymentOrder::getMerchantTransactionId, merchantTransactionId);
PaymentOrder order = selectOne(wrapper);
return Optional.ofNullable(order);
}
@@ -27,10 +27,9 @@ public interface PaymentOrderMapper extends BaseMapper<PaymentOrder> {
* 根据PingPong交易流水号查询
*/
default Optional<PaymentOrder> findByTransactionId(String transactionId) {
PaymentOrder order = selectOne(
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper.<PaymentOrder>lambdaQuery()
.eq(PaymentOrder::getTransactionId, transactionId)
);
LambdaQueryWrapper<PaymentOrder> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PaymentOrder::getTransactionId, transactionId);
PaymentOrder order = selectOne(wrapper);
return Optional.ofNullable(order);
}
}

View File

@@ -4,7 +4,7 @@ import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.CredentialsProvider;
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.exception.OSSException;
import com.aliyun.oss.OSSException;
import com.mtkj.mtpay.config.AliyunOSSProperties;
import com.mtkj.mtpay.service.OssService;
import lombok.extern.slf4j.Slf4j;