From 3c138d6e3949254406c35da544baed035ff80fc8 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 18 Oct 2024 17:45:45 +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 --- .../xiannccda/aop/SystemEventAspect.java | 10 +++++-- .../controller/AlertRecordController.java | 4 +-- .../xiannccda/controller/UserController.java | 1 + .../xiannccda/dto/event/EventLogQueryDTO.java | 4 +++ .../xiannccda/mapper/EventLogMapper.java | 4 ++- .../repository/impl/EventLogRepository.java | 7 ++++- .../xiannccda/service/AlertTipService.java | 2 ++ .../mybatis/mapper/EventLogMapper.xml | 28 ++++++++++--------- 8 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java b/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java index 1fc38c8..f5bcf03 100644 --- a/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java +++ b/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java @@ -5,6 +5,7 @@ import club.joylink.xiannccda.constants.common.CommonLogTypeEnum; import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType; import club.joylink.xiannccda.constants.SystemContext; import club.joylink.xiannccda.event.OperateEvent; +import com.google.common.collect.Maps; import jakarta.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; @@ -22,6 +23,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.security.oauth2.jwt.JwtDecoder; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.context.request.RequestContextHolder; @@ -45,8 +47,8 @@ public class SystemEventAspect { Jwt jwt = jwtDecoder.decode(returnObj.toString()); String userId = jwt.getClaimAsString("sub"); obj.setUserId(Long.parseLong(userId)); - SystemContext.publishEvent(obj); } + SystemContext.publishEvent(obj); } } @@ -66,11 +68,15 @@ public class SystemEventAspect { if (Objects.nonNull(commonLogAnno)) { GetMapping getMapping = ms.getMethod().getDeclaredAnnotation(GetMapping.class); PostMapping postMapping = ms.getMethod().getDeclaredAnnotation(PostMapping.class); - Map params = null; + DeleteMapping deleteMapping = ms.getMethod().getDeclaredAnnotation(DeleteMapping.class); + Map params = Map.of(); if (Objects.nonNull(getMapping)) { params = getRequestParam(getMapping.value(), joinPoint.getArgs()); } else if (Objects.nonNull(postMapping)) { params = getRequestParam(postMapping.value(), joinPoint.getArgs()); + } else if (Objects.nonNull(deleteMapping)) { + params = getRequestParam(deleteMapping.value(), joinPoint.getArgs()); + } HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); String uri = request.getRequestURI(); diff --git a/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java b/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java index b87d5d0..19c9fd9 100644 --- a/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java +++ b/src/main/java/club/joylink/xiannccda/controller/AlertRecordController.java @@ -83,12 +83,12 @@ public class AlertRecordController { } - @PostMapping("/page/detail") + @GetMapping("/page/detail") @SecurityRequirement(name = "jwt") @Operation(summary = "分页查询报警记录详情") @ApiResponse(description = "报警记录详情") @CommonLogAnno(name = "报警信息-列表数据2", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY) - public Page pageQueryAlertDetail(@RequestBody AlertRecordQueryDTO queryDTO) { + public Page pageQueryAlertDetail(AlertRecordQueryDTO queryDTO) { return alertRecordService.pageQueryAlertDetail(queryDTO); } diff --git a/src/main/java/club/joylink/xiannccda/controller/UserController.java b/src/main/java/club/joylink/xiannccda/controller/UserController.java index bb1209d..9cf4c18 100644 --- a/src/main/java/club/joylink/xiannccda/controller/UserController.java +++ b/src/main/java/club/joylink/xiannccda/controller/UserController.java @@ -55,6 +55,7 @@ public class UserController { @PostMapping("/info") @Operation(summary = "用户信息") + @SecurityRequirement(name = "jwt") @ApiResponse(description = "用户信息") public UserInfoAuthDTO userInfo(Principal user) { return this.userService.userInfo((JwtAuthenticationToken) user); 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 11ed526..61fb824 100644 --- a/src/main/java/club/joylink/xiannccda/dto/event/EventLogQueryDTO.java +++ b/src/main/java/club/joylink/xiannccda/dto/event/EventLogQueryDTO.java @@ -1,8 +1,12 @@ 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 lombok.Data; +@Data public class EventLogQueryDTO extends PageDTO { + private CommonLogTypeEnum logType; } diff --git a/src/main/java/club/joylink/xiannccda/mapper/EventLogMapper.java b/src/main/java/club/joylink/xiannccda/mapper/EventLogMapper.java index 622c6f9..bce41d4 100644 --- a/src/main/java/club/joylink/xiannccda/mapper/EventLogMapper.java +++ b/src/main/java/club/joylink/xiannccda/mapper/EventLogMapper.java @@ -6,9 +6,11 @@ import club.joylink.xiannccda.dto.user.UserDetailDTO; import club.joylink.xiannccda.dto.user.UserQueryDTO; import club.joylink.xiannccda.entity.EventLog; import club.joylink.xiannccda.entity.User; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** *

@@ -21,5 +23,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface EventLogMapper extends BaseMapper { - Page detailPage(EventLogQueryDTO dto); + Page detailPage(Page page, @Param("ew") QueryWrapper dto); } 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 9c1d35e..6242fdb 100644 --- a/src/main/java/club/joylink/xiannccda/repository/impl/EventLogRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/impl/EventLogRepository.java @@ -10,6 +10,7 @@ import club.joylink.xiannccda.mapper.LineInfoMapper; import club.joylink.xiannccda.repository.IEventLogRepository; import club.joylink.xiannccda.repository.ILineInfoRepository; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -30,6 +31,10 @@ public class EventLogRepository extends ServiceImpl im @Override public Page detailPage(EventLogQueryDTO dto) { - return this.baseMapper.detailPage(dto); + QueryWrapper qw = new QueryWrapper<>(); + + qw.eq("A.event_type", dto.getLogType()); + + return this.baseMapper.detailPage(dto, qw); } } diff --git a/src/main/java/club/joylink/xiannccda/service/AlertTipService.java b/src/main/java/club/joylink/xiannccda/service/AlertTipService.java index b839319..677f32f 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertTipService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertTipService.java @@ -79,6 +79,8 @@ public class AlertTipService { entity.setDrivingInfo(saveDTO.getDrivingInfo()); entity.setSubmissionInfo(saveDTO.getSubmissionInfo()); entity.setId(saveDTO.getId()); + entity.setLineId(saveDTO.getLineId()); + entity.setLineType(saveDTO.getLineType()); if (CollectionUtils.isNotEmpty(saveDTO.getTipTimeIds())) { String selectIds = this.timeConfigService.getCache().stream().filter(d -> saveDTO.getTipTimeIds().contains(d.getTimeType())).map(d -> d.getId().toString()) .collect(Collectors.joining(StringPool.COMMA)); diff --git a/src/main/resources/mybatis/mapper/EventLogMapper.xml b/src/main/resources/mybatis/mapper/EventLogMapper.xml index a63058d..23144fd 100644 --- a/src/main/resources/mybatis/mapper/EventLogMapper.xml +++ b/src/main/resources/mybatis/mapper/EventLogMapper.xml @@ -3,20 +3,22 @@