fix:增加物模型属性标识符校验
parent
eae8dba660
commit
0ae3275c1b
|
@ -58,9 +58,7 @@ public class ProductController {
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
@Log(title = "产品", businessType = BusinessType.INSERT)
|
@Log(title = "产品", businessType = BusinessType.INSERT)
|
||||||
public ProductVo create(@Validated(AddGroup.class) @RequestBody Request<ProductBo> request) {
|
public ProductVo create(@Validated(AddGroup.class) @RequestBody Request<ProductBo> request) {
|
||||||
|
|
||||||
return productService.addEntity(request.getData());
|
return productService.addEntity(request.getData());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "编辑产品")
|
@ApiOperation(value = "编辑产品")
|
||||||
|
|
|
@ -135,6 +135,19 @@ public class ProductServiceImpl implements IProductService {
|
||||||
ThingModel oldData = thingModelData.findByProductKey(productKey);
|
ThingModel oldData = thingModelData.findByProductKey(productKey);
|
||||||
ThingModel thingModel = new ThingModel(YitIdHelper.nextId(), productKey, JsonUtils.parseObject(model, ThingModel.Model.class));
|
ThingModel thingModel = new ThingModel(YitIdHelper.nextId(), productKey, JsonUtils.parseObject(model, ThingModel.Model.class));
|
||||||
|
|
||||||
|
//验证物模型合法性
|
||||||
|
List<ThingModel.Property> properties = thingModel.getModel().getProperties();
|
||||||
|
for (ThingModel.Property property : properties) {
|
||||||
|
//属性标识符合法性校验
|
||||||
|
String identifier = property.getIdentifier();
|
||||||
|
if (StringUtils.isBlank(identifier)) {
|
||||||
|
throw new BizException("属性标识符不能为空");
|
||||||
|
}
|
||||||
|
if (!identifier.matches("^[a-zA-Z].*")) {
|
||||||
|
throw new BizException("属性标识符【" + identifier + "】不合法");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (oldData == null) {
|
if (oldData == null) {
|
||||||
//定义时序数据库物模型数据结构
|
//定义时序数据库物模型数据结构
|
||||||
dbStructureData.defineThingModel(thingModel);
|
dbStructureData.defineThingModel(thingModel);
|
||||||
|
|
Loading…
Reference in New Issue