|
@@ -0,0 +1,100 @@
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+package com.persagy.apm.dmpalarm.service.impl;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.UUID;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
|
+import com.persagy.apm.dmpalarm.criteria.CriteriaUtils;
|
|
|
|
+import com.persagy.apm.dmpalarm.criteria.JsonCriteria;
|
|
|
|
+import com.persagy.apm.dmpalarm.model.AlarmEventType;
|
|
|
|
+import com.persagy.apm.dmpalarm.service.IAlarmEventTypeService;
|
|
|
|
+import com.persagy.apm.dmpalarm.utils.CheckRequiredParam;
|
|
|
|
+import com.persagy.apm.dmpalarm.web.MapResponse;
|
|
|
|
+import com.persagy.apm.dmpalarm.web.PagedResponse;
|
|
|
|
+
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author gaoyu
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Service("dmpAlarmEventTypeService")
|
|
|
|
+public class AlarmEventTypeServiceImpl extends BaseServiceImpl<BaseMapper<AlarmEventType>, AlarmEventType>
|
|
|
|
+ implements IAlarmEventTypeService {
|
|
|
|
+ @Resource
|
|
|
|
+ private CriteriaUtils criteriaUtils;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PagedResponse<AlarmEventType> query(JsonCriteria criteria) {
|
|
|
|
+ QueryWrapper<AlarmEventType> queryWrapper = criteriaUtils.handleAlarmConditions(criteria, AlarmEventType.class);
|
|
|
|
+ try {
|
|
|
|
+ return criteriaUtils.getPagedResponse(criteria, AlarmEventType.class, queryWrapper, getBaseMapper());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("alarmEventType query page error JsonCriteria is {}", criteria.toString(), e);
|
|
|
|
+ }
|
|
|
|
+ return new PagedResponse<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MapResponse update(AlarmEventType entity) {
|
|
|
|
+ MapResponse response = new MapResponse();
|
|
|
|
+ AlarmParam alarmParam = prepareParam(response);
|
|
|
|
+ String checkResult = CheckRequiredParam.check(entity, "id", "eventId", "eventName", "category");
|
|
|
|
+ if (!StringUtils.isEmpty(checkResult)) {
|
|
|
|
+ response.setFail(checkResult);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ if (alarmParam == null) {
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ entity.setModifier(alarmParam.userId);
|
|
|
|
+ entity.setModifiedTime(new Date());
|
|
|
|
+ saveOrUpdate(entity);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MapResponse create(AlarmEventType entity) {
|
|
|
|
+ MapResponse response = new MapResponse();
|
|
|
|
+ AlarmParam alarmParam = prepareParam(response);
|
|
|
|
+ if (alarmParam == null) {
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ // 必填项校验
|
|
|
|
+ String checkResult = CheckRequiredParam.check(entity, "id", "eventId", "eventName", "category");
|
|
|
|
+ if (!StringUtils.isEmpty(checkResult)) {
|
|
|
|
+ response.setFail(checkResult);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ entity.setId(UUID.randomUUID().toString());
|
|
|
|
+ entity.setCreator(alarmParam.userId);
|
|
|
|
+ entity.setCreationTime(new Date());
|
|
|
|
+ entity.setValid(0);
|
|
|
|
+ save(entity);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MapResponse delete(AlarmEventType entity) {
|
|
|
|
+ MapResponse response = new MapResponse();
|
|
|
|
+ String checkResult = CheckRequiredParam.check(entity, "id");
|
|
|
|
+ if (!StringUtils.isEmpty(checkResult)) {
|
|
|
|
+ response.setFail(checkResult);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+ entity.setValid(1);
|
|
|
|
+ updateById(entity);
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|