From 37d5260ee83030b82d2e4ce876109ac430f8afcb Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 25 Oct 2024 17:28:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/xiannccda/dto/event/EventLogQueryDTO.java | 8 ++++++++ .../xiannccda/dto/record/AlertRecordQueryDTO.java | 6 ++++++ .../xiannccda/repository/impl/EventLogRepository.java | 10 +++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/xiannccda/dto/event/EventLogQueryDTO.java b/src/main/java/club/joylink/xiannccda/dto/event/EventLogQueryDTO.java index 61fb824..09c6a20 100644 --- a/src/main/java/club/joylink/xiannccda/dto/event/EventLogQueryDTO.java +++ b/src/main/java/club/joylink/xiannccda/dto/event/EventLogQueryDTO.java @@ -3,10 +3,18 @@ package club.joylink.xiannccda.dto.event; import club.joylink.xiannccda.constants.common.CommonLogTypeEnum; import club.joylink.xiannccda.entity.EventLog; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; +import java.time.LocalDateTime; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; @Data public class EventLogQueryDTO extends PageDTO { private CommonLogTypeEnum logType; + + private String name; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime beginDate; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endDate; } diff --git a/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordQueryDTO.java b/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordQueryDTO.java index dcb18bf..cd022ab 100644 --- a/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordQueryDTO.java +++ b/src/main/java/club/joylink/xiannccda/dto/record/AlertRecordQueryDTO.java @@ -4,9 +4,12 @@ import club.joylink.xiannccda.constants.common.LineTypeEnum; import club.joylink.xiannccda.dto.CommonPage; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.entity.AlertRecord; +import com.alibaba.fastjson2.annotation.JSONField; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; +import com.fasterxml.jackson.annotation.JsonFormat; import java.time.LocalDateTime; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; @Data public class AlertRecordQueryDTO extends CommonPage { @@ -16,7 +19,10 @@ public class AlertRecordQueryDTO extends CommonPage { private Integer lineId; private LineTypeEnum lineType; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime beginDateTime; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime endDateTime; private Integer alertStatus; diff --git a/src/main/java/club/joylink/xiannccda/repository/impl/EventLogRepository.java b/src/main/java/club/joylink/xiannccda/repository/impl/EventLogRepository.java index 586f4fb..42877a9 100644 --- a/src/main/java/club/joylink/xiannccda/repository/impl/EventLogRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/impl/EventLogRepository.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.List; +import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -32,8 +33,15 @@ public class EventLogRepository extends ServiceImpl im @Override public Page detailPage(EventLogQueryDTO dto) { QueryWrapper qw = new QueryWrapper<>(); - qw.eq("A.event_type", dto.getLogType()); + qw.like(StringUtils.isNotEmpty(dto.getName()), "B.name", dto.getName()); + if (Objects.nonNull(dto.getBeginDate()) && Objects.nonNull(dto.getEndDate())) { + qw.between("A.create_date_time", dto.getBeginDate(), dto.getEndDate()); + } else if (Objects.nonNull(dto.getBeginDate())) { + qw.ge("A.create_date_time", dto.getBeginDate()); + } else if (Objects.nonNull(dto.getEndDate())) { + qw.le("A.create_date_time", dto.getEndDate()); + } qw.orderByDesc("A.id"); return this.baseMapper.detailPage(dto, qw); }