邮箱管理增加查询历史报警信息接口
数据库管理增加查询历史报警信息接口
This commit is contained in:
parent
a9682bf4dc
commit
1f54fa41a7
|
@ -6,8 +6,11 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.modules.entity.SysDatabase;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sysDatabase")
|
||||
@Api(value = "数据库配置管理", tags = "数据库配置管理")
|
||||
|
@ -41,4 +44,10 @@ public class SysDatabaseController {
|
|||
return sysDatabaseService.deleteById(id);
|
||||
}
|
||||
|
||||
@GetMapping("findAlarmHistory")
|
||||
public Result findAlarmHistory(String databaseId,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
|
||||
return sysDatabaseService.findAlarmHistory(databaseId, startTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,11 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.modules.entity.SysEmail;
|
||||
import org.jeecg.modules.service.ISysEmailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sysEmail")
|
||||
@Api(value = "邮箱配置信息管理", tags = "邮箱配置信息管理")
|
||||
|
@ -47,4 +50,10 @@ public class SysEmailController {
|
|||
return sysEmailService.deleteById(id);
|
||||
}
|
||||
|
||||
@GetMapping("findAlarmHistory")
|
||||
public Result findAlarmHistory(String emailId,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
|
||||
return sysEmailService.findAlarmHistory(emailId, startTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface SysDatabaseMapper extends BaseMapper<SysDatabase> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory(@Param("databaseId") String databaseId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysEmail;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface SysEmailMapper extends BaseMapper<SysEmail> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory( @Param("emailId") String emailId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.SysEmailMapper">
|
||||
|
||||
<select id="findAlarmHistory" resultType="org.jeecg.modules.entity.AlarmHistory">
|
||||
SELECT
|
||||
se.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator
|
||||
FROM
|
||||
sys_email se
|
||||
inner join alarm_rule r on r.source_id = se.id
|
||||
inner join alarm_log l on l.rule_id = r.id
|
||||
<where>
|
||||
l.alarm_start_date between #{startDate} and #{endDate}
|
||||
<if test=" emailId != null and emailId != '' ">
|
||||
and se.id = #{emailId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.mapper.SysEmailMapper">
|
||||
|
||||
<select id="findAlarmHistory" resultType="org.jeecg.modules.entity.AlarmHistory">
|
||||
SELECT
|
||||
se.name,
|
||||
l.alarm_start_date,
|
||||
l.alarm_info,
|
||||
r.operator
|
||||
FROM
|
||||
sys_database se
|
||||
inner join alarm_rule r on r.source_id = se.id
|
||||
inner join alarm_log l on l.rule_id = r.id
|
||||
<where>
|
||||
l.alarm_start_date between #{startDate} and #{endDate}
|
||||
<if test=" databaseId != null and databaseId != '' ">
|
||||
and se.id = #{databaseId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface ISysDatabaseService extends IService<SysDatabase> {
|
||||
|
||||
|
@ -17,4 +20,6 @@ public interface ISysDatabaseService extends IService<SysDatabase> {
|
|||
|
||||
Result deleteById(String id);
|
||||
|
||||
Result findAlarmHistory(String databaseId, Date startTime, Date endTime);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.jeecg.common.api.QueryRequest;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.SysEmail;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface ISysEmailService extends IService<SysEmail> {
|
||||
|
||||
Result findPage(QueryRequest queryRequest, SysEmail sysEmail);
|
||||
|
@ -17,4 +19,6 @@ public interface ISysEmailService extends IService<SysEmail> {
|
|||
|
||||
Result deleteById(String id);
|
||||
|
||||
Result findAlarmHistory(String emailId, Date startTime, Date endTime);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysDatabase;
|
||||
import org.jeecg.modules.mapper.SysDatabaseMapper;
|
||||
import org.jeecg.modules.service.ISysDatabaseService;
|
||||
|
@ -15,7 +17,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service("sysDatabaseService")
|
||||
|
@ -101,4 +105,27 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findAlarmHistory(String databaseId, Date startTime, Date endTime) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
if (Objects.isNull(startTime)){
|
||||
result.error500("开始时间不能为空");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(endTime)){
|
||||
result.error500("结束时间不能为空");
|
||||
return result;
|
||||
}
|
||||
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||
List<AlarmHistory> alarmHistory = this.baseMapper.findAlarmHistory(databaseId, startDate, endDate);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmHistory);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.entity.AlarmHistory;
|
||||
import org.jeecg.modules.entity.SysEmail;
|
||||
import org.jeecg.modules.mapper.SysEmailMapper;
|
||||
import org.jeecg.modules.service.ISysEmailService;
|
||||
|
@ -15,7 +17,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service("sysEmailService")
|
||||
|
@ -105,4 +109,27 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findAlarmHistory(String emailId, Date startTime, Date endTime) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
if (Objects.isNull(startTime)){
|
||||
result.error500("开始时间不能为空");
|
||||
return result;
|
||||
}
|
||||
if (Objects.isNull(endTime)){
|
||||
result.error500("结束时间不能为空");
|
||||
return result;
|
||||
}
|
||||
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
|
||||
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
|
||||
List<AlarmHistory> alarmHistory = this.baseMapper.findAlarmHistory(emailId, startDate, endDate);
|
||||
result.setSuccess(true);
|
||||
result.setResult(alarmHistory);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user