获得去年日期往前推十天的数据接口优化

This commit is contained in:
慕下 2024-08-20 14:01:54 +08:00
parent 3a0ac36aab
commit 5a85f52f32

View File

@ -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<Map<String, String>> 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")