开发服务端报警配置模块.

pull/10/head
chen.ma 3 years ago
parent 5bfe3f3987
commit 76d9a6b1be

@ -0,0 +1,15 @@
package cn.hippo4j.config.mapper;
import cn.hippo4j.config.model.AlarmInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* Alarm info mapper.
*
* @author chen.ma
* @date 2021/11/17 22:04
*/
@Mapper
public interface AlarmInfoMapper extends BaseMapper<AlarmInfo> {
}

@ -0,0 +1,75 @@
package cn.hippo4j.config.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* .
*
* @author chen.ma
* @date 2021/11/17 22:03
*/
@Data
@TableName("alarm")
public class AlarmInfo {
/**
* id
*/
private Long id;
/**
* id
*/
private String tenantId;
/**
* id
*/
private String itemId;
/**
* 线id
*/
private String tpId;
/**
*
*/
private String platform;
/**
*
*/
private String secretKey;
/**
*
*/
@TableField("`interval`")
private Integer interval;
/**
*
*/
private String receives;
/**
*
*/
private Date gmtCreate;
/**
*
*/
private Date gmtModified;
/**
*
*/
private Integer delFlag;
}

@ -0,0 +1,29 @@
package cn.hippo4j.config.model.biz.alarm;
import cn.hippo4j.config.model.AlarmInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* Alarm list resp dto.
*
* @author chen.ma
* @date 2021/11/17 22:53
*/
@Data
@AllArgsConstructor
public class AlarmListRespDTO {
/**
* 线ID
*/
private String threadPoolId;
/**
*
*/
private List<AlarmInfo> alarmNotifyList;
}

@ -0,0 +1,22 @@
package cn.hippo4j.config.model.biz.alarm;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import java.util.List;
/**
* Alarm query req dto.
*
* @author chen.ma
* @date 2021/11/17 22:52
*/
@Data
public class AlarmQueryReqDTO extends Page {
/**
* groupKeys
*/
private List<String> groupKeys;
}

@ -0,0 +1,24 @@
package cn.hippo4j.config.service.biz;
import cn.hippo4j.config.model.biz.alarm.AlarmListRespDTO;
import cn.hippo4j.config.model.biz.alarm.AlarmQueryReqDTO;
import java.util.List;
/**
* .
*
* @author chen.ma
* @date 2021/11/17 22:01
*/
public interface AlarmService {
/**
* .
*
* @param reqDTO
* @return
*/
List<AlarmListRespDTO> listAlarmConfig(AlarmQueryReqDTO reqDTO);
}

@ -0,0 +1,48 @@
package cn.hippo4j.config.service.biz.impl;
import cn.hippo4j.common.toolkit.GroupKey;
import cn.hippo4j.config.mapper.AlarmInfoMapper;
import cn.hippo4j.config.model.AlarmInfo;
import cn.hippo4j.config.model.biz.alarm.AlarmListRespDTO;
import cn.hippo4j.config.model.biz.alarm.AlarmQueryReqDTO;
import cn.hippo4j.config.service.biz.AlarmService;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* .
*
* @author chen.ma
* @date 2021/11/17 22:02
*/
@Service
@AllArgsConstructor
public class AlarmServiceImpl implements AlarmService {
private final AlarmInfoMapper alarmInfoMapper;
@Override
public List<AlarmListRespDTO> listAlarmConfig(AlarmQueryReqDTO reqDTO) {
List<AlarmListRespDTO> alarmListRespList = Lists.newArrayList();
reqDTO.getGroupKeys().forEach(each -> {
String[] parseKey = GroupKey.parseKey(each);
LambdaQueryWrapper<AlarmInfo> queryWrapper = Wrappers.lambdaQuery(AlarmInfo.class)
.eq(AlarmInfo::getTenantId, parseKey[2])
.eq(AlarmInfo::getItemId, parseKey[1])
.eq(AlarmInfo::getTpId, parseKey[0]);
List<AlarmInfo> alarmInfos = alarmInfoMapper.selectList(queryWrapper);
if (CollUtil.isNotEmpty(alarmInfos)) {
alarmListRespList.add(new AlarmListRespDTO(parseKey[0], alarmInfos));
}
});
return alarmListRespList;
}
}

@ -0,0 +1,36 @@
package cn.hippo4j.console.controller;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results;
import cn.hippo4j.config.model.biz.alarm.AlarmListRespDTO;
import cn.hippo4j.config.model.biz.alarm.AlarmQueryReqDTO;
import cn.hippo4j.config.service.biz.AlarmService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* .
*
* @author chen.ma
* @date 2021/11/17 22:00
*/
@RestController
@AllArgsConstructor
@RequestMapping(Constants.BASE_PATH + "/alarm")
public class AlarmController {
private final AlarmService alarmService;
@PostMapping("/list/config")
public Result<List<AlarmListRespDTO>> listAlarmConfig(@RequestBody AlarmQueryReqDTO reqDTO) {
List<AlarmListRespDTO> resultData = alarmService.listAlarmConfig(reqDTO);
return Results.success(resultData);
}
}
Loading…
Cancel
Save