refactor: 消息转换器

V0.5.x
jay 2023-06-15 15:06:23 +08:00
parent 880b454438
commit 36a23cc99a
2 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,8 @@ package cc.iotkit.manager.controller;
import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request; import cc.iotkit.common.api.Request;
import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.manager.dto.bo.ChangeStateBo; import cc.iotkit.manager.dto.bo.ChangeStateBo;
import cc.iotkit.manager.dto.bo.protocolcomponent.ProtocolComponentBo; import cc.iotkit.manager.dto.bo.protocolcomponent.ProtocolComponentBo;
import cc.iotkit.manager.dto.bo.protocolconverter.ProtocolConverterBo; import cc.iotkit.manager.dto.bo.protocolconverter.ProtocolConverterBo;
@ -90,13 +92,13 @@ public class ProtocolController {
@ApiOperation("新增转换脚本") @ApiOperation("新增转换脚本")
@PostMapping("/converter/add") @PostMapping("/converter/add")
public boolean addConverter(@Validated @RequestBody Request<ProtocolConverterBo> converter) { public boolean addConverter(@Validated(AddGroup.class) @RequestBody Request<ProtocolConverterBo> converter) {
return protocolService.addConverter(converter.getData()); return protocolService.addConverter(converter.getData());
} }
@ApiOperation("修改转换脚本") @ApiOperation("修改转换脚本")
@PostMapping("/converter/edit") @PostMapping("/converter/edit")
public boolean editConverter(@Validated @RequestBody Request<ProtocolConverterBo> req) { public boolean editConverter(@Validated(EditGroup.class) @RequestBody Request<ProtocolConverterBo> req) {
return protocolService.editConverter(req.getData()); return protocolService.editConverter(req.getData());
} }

View File

@ -3,6 +3,8 @@ package cc.iotkit.manager.dto.bo.protocolconverter;
import cc.iotkit.model.protocol.ProtocolConverter; import cc.iotkit.model.protocol.ProtocolConverter;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -33,6 +35,7 @@ public class ProtocolConverterBo extends BaseDto {
private static final long serialVersionUID = -1L; private static final long serialVersionUID = -1L;
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@NotBlank(message = "id不能为空", groups = {EditGroup.class})
private String id; private String id;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@ -44,6 +47,7 @@ public class ProtocolConverterBo extends BaseDto {
@ApiModelProperty(value = "转换器名称") @ApiModelProperty(value = "转换器名称")
@Size(max = 255, message = "转换器名称长度不正确") @Size(max = 255, message = "转换器名称长度不正确")
@NotBlank(message = "转换器名称不能为空", groups = {AddGroup.class})
private String name; private String name;
@ApiModelProperty(value = "脚本内容") @ApiModelProperty(value = "脚本内容")