From 90bdc1fd83ae642a377ea5d506fb71d767ac0a49 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 3 Jan 2024 10:09:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E5=8F=B7=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=97=A5=E6=9C=9F=E8=BD=AC=20localDateTime=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/vo/MpStatisticsGetReqVO.java | 4 ++-- .../convert/statistics/MpStatisticsConvert.java | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java index 4d7a84aba..be8bca04d 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -17,7 +17,7 @@ public class MpStatisticsGetReqVO { @NotNull(message = "公众号账号的编号不能为空") private Long accountId; - @Schema(description = "查询时间范围") + @Schema(description = "查询时间范围", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @NotNull(message = "查询时间范围不能为空") private LocalDateTime[] date; diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java index 174b0fdc3..9d4d7e3de 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java @@ -11,10 +11,16 @@ import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; + @Mapper public interface MpStatisticsConvert { @@ -27,7 +33,7 @@ public interface MpStatisticsConvert { List convertList03(List list); @Mappings({ - @Mapping(source = "refDate", target = "refDate", dateFormat = "yyyy-MM-dd"), + @Mapping(target = "refDate", expression = "java(dateFormat0(bean.getRefDate()))"), @Mapping(source = "msgUser", target = "messageUser"), @Mapping(source = "msgCount", target = "messageCount"), }) @@ -35,6 +41,12 @@ public interface MpStatisticsConvert { List convertList04(List list); - @Mapping(source = "refDate", target = "refDate", dateFormat = "yyyy-MM-dd") + @Mapping(target = "refDate", expression = "java(dateFormat0(bean.getRefDate()))") MpStatisticsInterfaceSummaryRespVO convert(WxDataCubeInterfaceResult bean); + + @Named("dateFormat0") + default LocalDateTime dateFormat0(String date) { + return LocalDate.parse(date, DateTimeFormatter.ofPattern(FORMAT_YEAR_MONTH_DAY)).atStartOfDay(); + } + }