diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/admin/saledata/SaleDataApi.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/admin/saledata/SaleDataApi.java index d7cbe87e4..8b5f6e07e 100644 --- a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/admin/saledata/SaleDataApi.java +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/admin/saledata/SaleDataApi.java @@ -11,6 +11,8 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -40,7 +42,14 @@ public class SaleDataApi { @GetMapping("/lastyear/{startTime}") @Operation(summary = "获得去年日期往前推十天的数据") public List> lastyearNum(@PathVariable("startTime") String startTime) { - return saleDataService.findCheckticketcountBytime(startTime); + String resultStr = startTime.replaceAll("-", ""); + // 正则表达式匹配 yyyyMMdd 格式 + Pattern pattern = Pattern.compile("^\\d{8}$"); + Matcher matcher = pattern.matcher(resultStr); + if (matcher.matches()){ + return saleDataService.findCheckticketcountBytime(resultStr); + } + return null; } @GetMapping("/gender")