EventTemplate控制器编写

This commit is contained in:
hanyong
2022-09-16 11:01:49 +08:00
parent 0d3a358959
commit 99ec05487f
8 changed files with 34 additions and 25 deletions

View File

@@ -59,8 +59,14 @@ public class DataTest {
}
public static void main(String[] args) {
InfluxDbUtils influxDBUtil = new InfluxDbUtils("root", "123456789", "http://192.168.1.18:8086", "pqsbase", "");
InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "123456", "http://192.168.1.18:8086", "pqsbase", "");
insert(influxDBUtil);
Map<String, String> tags = new HashMap<>();
long time = Long.parseLong("1657959227000");
tags.put("line_id","656da093bdb523b6ac619067a4045624");
Map<String, Object> fields = new HashMap<>();
fields.put("statis_value",1024000000.00);
influxDBUtil.insert("cld_month_flow", tags, fields, time, TimeUnit.MILLISECONDS);
//select(influxDBUtil);
}
public static void deleteDB(InfluxDbUtils influxDBUtil) {

View File

@@ -59,7 +59,10 @@ public class EventTemplateParam {
@Data
@EqualsAndHashCode(callSuper = true)
public static class EventTemplateQueryParam extends BaseParam {
@ApiModelProperty("pid")
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
private String pid;
}
}

View File

@@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "eventreport_dict")
@TableName(value = "report_template_dict")
public class EventDict extends BaseEntity {
private static final long serialVersionUID = 1L;

View File

@@ -8,6 +8,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.system.pojo.param.EventTemplateParam;
import com.njcn.system.pojo.po.EventDict;
import com.njcn.system.pojo.vo.EventTemplateTree;
import com.njcn.system.pojo.vo.EventTemplateVO;
import com.njcn.system.service.IEventTemplateService;
@@ -58,13 +59,13 @@ public class EventTemplateController extends BaseController{
* @date 2022/09/09
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/list")
@PostMapping("/getlist")
@ApiOperation("查询字典数据")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<Page<EventTemplateVO>> list(@RequestBody @Validated EventTemplateParam.EventTemplateQueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
public HttpResult<Page<EventDict>> getlist(@RequestBody @Validated EventTemplateParam.EventTemplateQueryParam queryParam) {
String methodDescribe = getMethodDescribe("getlist");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
Page<EventTemplateVO> result = iEventTemplateService.listEventTemplateData(queryParam);
Page<EventDict> result = iEventTemplateService.getlist(queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -76,7 +77,7 @@ public class EventTemplateController extends BaseController{
@PostMapping("/add")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("新增模板")
@ApiImplicitParam(name = "dictDataParam", value = "模板数据", required = true)
@ApiImplicitParam(name = "eventTemplateParam", value = "模板数据", required = true)
public HttpResult<Boolean> add(@RequestBody EventTemplateParam eventTemplateParam){
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},模板数据为:{}", methodDescribe, eventTemplateParam);
@@ -96,11 +97,11 @@ public class EventTemplateController extends BaseController{
@PostMapping("/update")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("修改字典")
@ApiImplicitParam(name = "dictDataUpdateParam", value = "字典表数据", required = true)
public HttpResult<Boolean> update(@RequestBody EventTemplateParam.EventTemplateUpdateParam eventTemplateUpdateParam){
@ApiImplicitParam(name = "eventDataUpdateParam", value = "字典表数据", required = true)
public HttpResult<Boolean> update(@RequestBody EventTemplateParam.EventTemplateUpdateParam eventDataUpdateParam){
String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},字典表数据数据为:{}", methodDescribe, eventTemplateUpdateParam);
boolean result = iEventTemplateService.update(eventTemplateUpdateParam);
LogUtil.njcnDebug(log, "{},字典表数据数据为:{}", methodDescribe, eventDataUpdateParam);
boolean result = iEventTemplateService.update(eventDataUpdateParam);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {

View File

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.system.pojo.po.EventDict;
import com.njcn.system.pojo.vo.DictDataVO;
import com.njcn.system.pojo.vo.EventTemplateVO;
import org.apache.ibatis.annotations.Param;
@@ -20,5 +19,5 @@ public interface EventTemplateMapper extends BaseMapper<EventDict> {
* @param queryWrapper 查询条件
* @return 字典数据
*/
Page<EventTemplateVO> page(@Param("page")Page<EventTemplateVO> page, @Param("ew")QueryWrapper<EventTemplateVO> queryWrapper);
Page<EventDict> page(@Param("page")Page<EventTemplateVO> page, @Param("ew")QueryWrapper<EventTemplateVO> queryWrapper);
}

View File

@@ -6,8 +6,8 @@
<!--获取字典分页列表-->
<select id="page" resultType="EventTemplateVO">
SELECT eventreport_dict.*
FROM eventreport_dict eventreport_dict
SELECT report_template_dict.*
FROM report_template_dict report_template_dict
WHERE ${ew.sqlSegment}
</select>

View File

@@ -1,10 +1,9 @@
package com.njcn.system.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.system.pojo.param.DictDataParam;
import com.njcn.system.pojo.param.EventTemplateParam;
import com.njcn.system.pojo.po.EventDict;
import com.njcn.system.pojo.vo.EventTemplateTree;
import com.njcn.system.pojo.vo.EventTemplateVO;
import java.util.List;
@@ -25,12 +24,12 @@ public interface IEventTemplateService {
* @param queryParam 查询参数
* @return 字典列表
*/
Page<EventTemplateVO> listEventTemplateData(EventTemplateParam.EventTemplateQueryParam queryParam);
Page<EventDict> getlist(EventTemplateParam.EventTemplateQueryParam queryParam);
/**
* 新增
*/
boolean add(EventTemplateParam eventDataParam);
boolean add(EventTemplateParam eventTemplateParam);
/**
* 修改

View File

@@ -47,27 +47,28 @@ public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, E
* 分页查询字典类型数据
* @author hany
* @date 2022/09/13
* @return
*/
@Override
public Page<EventTemplateVO> listEventTemplateData(EventTemplateParam.EventTemplateQueryParam queryParam) {
public Page<EventDict> getlist(EventTemplateParam.EventTemplateQueryParam queryParam) {
QueryWrapper<EventTemplateVO> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) {
//查询参数不为空,进行条件填充
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
//字典类型表,仅提供名称、编码模糊查询
queryWrapper
.and(param -> param.like("eventreport_dict.name", queryParam.getSearchValue())
.or().like("eventreport_dict.pid", queryParam.getSearchValue()));
.and(param -> param.like("report_template_dict.name", queryParam.getSearchValue())
.or().like("report_template_dict.pid", queryParam.getSearchValue()));
}
//排序
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
} else {
//没有排序参数默认根据sort字段排序没有排序字段的根据updateTime更新时间排序
queryWrapper.orderBy(true, true, "eventreport_dict.sort");
queryWrapper.orderBy(true, true, "report_template_dict.sort");
}
}
queryWrapper.ne("eventreport_dict.state", DataStateEnum.DELETED.getCode());
queryWrapper.ne("report_template_dict.state", DataStateEnum.DELETED.getCode());
//初始化分页数据
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
}