fix: 修复公众号统计接口字符串日期转 localDateTime 报错的问题

This commit is contained in:
puhui999 2024-01-03 10:09:41 +08:00
parent 8c9b483ac5
commit 90bdc1fd83
2 changed files with 16 additions and 4 deletions

View File

@ -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;

View File

@ -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<MpStatisticsUpstreamMessageRespVO> convertList03(List<WxDataCubeMsgResult> 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<MpStatisticsInterfaceSummaryRespVO> convertList04(List<WxDataCubeInterfaceResult> 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();
}
}