feat:报警编码信息管理
This commit is contained in:
parent
2d840bcd8b
commit
4c16d4527d
jeecg-boot-base-core/src/main/java/org/jeecg/modules/base
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system
|
@ -0,0 +1,12 @@
|
|||
package org.jeecg.modules.base.bizVo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
@Data
|
||||
public class AlertSystemVo extends QueryRequest {
|
||||
|
||||
private String code;
|
||||
|
||||
private String content;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.jeecg.modules.base.entity.configuration;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("CONFIGURATION.GARDS_ALERT_SYSTEM")
|
||||
public class GardsAlertSystem implements Serializable {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
private String type;
|
||||
|
||||
private String code;
|
||||
|
||||
private String content;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date moddate;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String typeStr;
|
||||
|
||||
public GardsAlertSystem(){ moddate = new Date(); }
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.bizVo.AlertSystemVo;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsAlertSystem;
|
||||
import org.jeecg.modules.system.service.IGardsAlertSystemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("alertSystem")
|
||||
public class GardsAlertSystemController {
|
||||
|
||||
@Autowired
|
||||
private IGardsAlertSystemService alertSystemService;
|
||||
|
||||
@GetMapping(value = "list")
|
||||
public Result<?> findPage(AlertSystemVo alertSystemVo) {
|
||||
return alertSystemService.findPage(alertSystemVo);
|
||||
}
|
||||
|
||||
@PostMapping(value = "saveOrUpdate")
|
||||
public Result<?> saveOrUpdate(@RequestBody GardsAlertSystem alertSystem) {
|
||||
return alertSystemService.saveOrUpdate1(alertSystem);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "delete")
|
||||
public Result<?> delete(@RequestParam("id") String id) {
|
||||
return alertSystemService.delete(id);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam("ids") String ids) {
|
||||
return alertSystemService.delete(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsAlertSystem;
|
||||
|
||||
@Mapper
|
||||
public interface GardsAlertSystemMapper extends BaseMapper<GardsAlertSystem> {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.bizVo.AlertSystemVo;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsAlertSystem;
|
||||
|
||||
public interface IGardsAlertSystemService extends IService<GardsAlertSystem> {
|
||||
|
||||
Result<?> findPage(AlertSystemVo alertSystemVo);
|
||||
|
||||
Result<?> saveOrUpdate1(GardsAlertSystem alertSystem);
|
||||
|
||||
Result<?> delete(String id);
|
||||
|
||||
Result<?> deleteBatch(String ids);
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.modules.base.bizVo.AlertSystemVo;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsAlertSystem;
|
||||
import org.jeecg.modules.system.mapper.GardsAlertSystemMapper;
|
||||
import org.jeecg.modules.system.service.IGardsAlertSystemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@DS("ora")
|
||||
public class GardsAlertSystemServiceImpl extends ServiceImpl<GardsAlertSystemMapper, GardsAlertSystem> implements IGardsAlertSystemService {
|
||||
|
||||
@Autowired
|
||||
private SysDictServiceImpl dictService;
|
||||
|
||||
@Override
|
||||
public Result<?> findPage(AlertSystemVo alertSystemVo) {
|
||||
Integer pageNo = alertSystemVo.getPageNo();
|
||||
Integer pageSize = alertSystemVo.getPageSize();
|
||||
IPage<GardsAlertSystem> page = new Page<>(pageNo, pageSize);
|
||||
// 封装查询条件
|
||||
String code = alertSystemVo.getCode();
|
||||
String content = alertSystemVo.getContent();
|
||||
LambdaQueryWrapper<GardsAlertSystem> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(code), GardsAlertSystem::getCode, code);
|
||||
wrapper.like(StrUtil.isNotBlank(content), GardsAlertSystem::getContent, content);
|
||||
page = this.page(page, wrapper);
|
||||
List<DictModel> items = dictService.getItems("");
|
||||
Map<String, String> typeMap = items.stream().collect(Collectors
|
||||
.toMap(DictModel::getValue, DictModel::getText, (oldValue, newValue) -> newValue));
|
||||
page.getRecords().forEach(item -> {
|
||||
String type = item.getType();
|
||||
item.setTypeStr(typeMap.get(type));
|
||||
});
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public Result<?> saveOrUpdate1(GardsAlertSystem alertSystem) {
|
||||
String code = alertSystem.getCode();
|
||||
LambdaQueryWrapper<GardsAlertSystem> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(GardsAlertSystem::getCode, code);
|
||||
if (CollUtil.isNotEmpty(this.list(wrapper)))
|
||||
return Result.error("Code " + code + "is exist!");
|
||||
boolean success = this.saveOrUpdate(alertSystem);
|
||||
if (success)
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> delete(String id) {
|
||||
boolean success = this.removeById(id);
|
||||
if (success)
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
return Result.OK(Prompt.DELETE_ERR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public Result<?> deleteBatch(String ids) {
|
||||
boolean success = removeBatchByIds(ListUtil.toList(StrUtil.split(ids, StrUtil.COMMA)));
|
||||
if (success)
|
||||
return Result.OK(Prompt.DELETE_SUCC);
|
||||
return Result.OK(Prompt.DELETE_ERR);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user