Browse Source

支持异常情况报告功能,包括大量访问请求、异常数据输入

master
zhouyl 1 year ago
parent
commit
67e81be04c
  1. 6
      tp-admin/src/main/java/com/inscloudtech/web/controller/system/SysExceptionReportController.java
  2. 2
      tp-system/src/main/java/com/inscloudtech/system/service/SysExceptionReportService.java
  3. 6
      tp-system/src/main/java/com/inscloudtech/system/service/impl/SysExceptionReportServiceImpl.java
  4. 10
      tp-system/src/main/java/com/inscloudtech/system/service/impl/SysRequestLogServiceImpl.java

6
tp-admin/src/main/java/com/inscloudtech/web/controller/system/SysExceptionReportController.java

@ -13,7 +13,7 @@ import com.inscloudtech.common.core.page.TableDataInfo;
import com.inscloudtech.common.enums.BusinessType; import com.inscloudtech.common.enums.BusinessType;
import com.inscloudtech.system.domain.SysExceptionReport; import com.inscloudtech.system.domain.SysExceptionReport;
import com.inscloudtech.system.domain.SysRequestLog; import com.inscloudtech.system.domain.SysRequestLog;
import com.inscloudtech.system.service.ISysExceptionReportService;
import com.inscloudtech.system.service.SysExceptionReportService;
import com.inscloudtech.system.service.SysRequestLogService; import com.inscloudtech.system.service.SysRequestLogService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -24,12 +24,12 @@ import org.springframework.web.bind.annotation.*;
* @author zfcf * @author zfcf
* @date 2024-08-28 * @date 2024-08-28
*/ */
@RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/functional/exceptionReport") @RequestMapping("/functional/exceptionReport")
public class SysExceptionReportController { public class SysExceptionReportController {
private final ISysExceptionReportService iSysExceptionReportService;
private final SysExceptionReportService iSysExceptionReportService;
private final SysRequestLogService sysRequestLogService; private final SysRequestLogService sysRequestLogService;

2
tp-system/src/main/java/com/inscloudtech/system/service/ISysExceptionReportService.java → tp-system/src/main/java/com/inscloudtech/system/service/SysExceptionReportService.java

@ -11,7 +11,7 @@ import com.inscloudtech.system.domain.SysRequestLog;
* @author inscloudtech * @author inscloudtech
* @date 2024-08-08 * @date 2024-08-08
*/ */
public interface ISysExceptionReportService extends IService<SysExceptionReport> {
public interface SysExceptionReportService extends IService<SysExceptionReport> {
} }

6
tp-system/src/main/java/com/inscloudtech/system/service/impl/SysExceptionReportServiceImpl.java

@ -5,13 +5,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.inscloudtech.common.core.domain.event.ExceptionReportEvent; import com.inscloudtech.common.core.domain.event.ExceptionReportEvent;
import com.inscloudtech.system.domain.SysExceptionReport; import com.inscloudtech.system.domain.SysExceptionReport;
import com.inscloudtech.system.mapper.SysExceptionReportMapper; import com.inscloudtech.system.mapper.SysExceptionReportMapper;
import com.inscloudtech.system.service.ISysExceptionReportService;
import com.inscloudtech.system.service.SysExceptionReportService;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
public class SysExceptionReportServiceImpl extends ServiceImpl<SysExceptionReportMapper, SysExceptionReport> implements ISysExceptionReportService {
@Service
public class SysExceptionReportServiceImpl extends ServiceImpl<SysExceptionReportMapper, SysExceptionReport> implements SysExceptionReportService {
@Async @Async
@EventListener @EventListener

10
tp-system/src/main/java/com/inscloudtech/system/service/impl/SysRequestLogServiceImpl.java

@ -9,9 +9,11 @@ import com.inscloudtech.common.utils.ip.AddressUtils;
import com.inscloudtech.system.domain.SysExceptionReport; import com.inscloudtech.system.domain.SysExceptionReport;
import com.inscloudtech.system.domain.SysRequestLog; import com.inscloudtech.system.domain.SysRequestLog;
import com.inscloudtech.system.mapper.SysRequestLogMapper; import com.inscloudtech.system.mapper.SysRequestLogMapper;
import com.inscloudtech.system.service.ISysExceptionReportService;
import com.inscloudtech.system.service.SysExceptionReportService;
import com.inscloudtech.system.service.SysRequestLogService; import com.inscloudtech.system.service.SysRequestLogService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -26,10 +28,10 @@ import java.util.List;
* @date 2024-08-28 * @date 2024-08-28
*/ */
@Service @Service
@AllArgsConstructor
@RequiredArgsConstructor
public class SysRequestLogServiceImpl extends ServiceImpl<SysRequestLogMapper, SysRequestLog> implements SysRequestLogService { public class SysRequestLogServiceImpl extends ServiceImpl<SysRequestLogMapper, SysRequestLog> implements SysRequestLogService {
private final ISysExceptionReportService exceptionReportService;
private final SysExceptionReportService sysExceptionReportService;
/** /**
* 预警时间阈值(分钟) * 预警时间阈值(分钟)
@ -60,7 +62,7 @@ public class SysRequestLogServiceImpl extends ServiceImpl<SysRequestLogMapper, S
report.setType("大量访问请求"); report.setType("大量访问请求");
addList.add(report); addList.add(report);
} }
exceptionReportService.saveBatch(addList);
sysExceptionReportService.saveBatch(addList);
} }
} }

Loading…
Cancel
Save