fix:增加物模型属性标识符校验

V0.5.x
xiwa 2023-07-09 18:00:22 +08:00
parent eae8dba660
commit 0ae3275c1b
3 changed files with 13 additions and 5 deletions

View File

@ -58,9 +58,7 @@ public class ProductController {
@PostMapping(value = "/add")
@Log(title = "产品", businessType = BusinessType.INSERT)
public ProductVo create(@Validated(AddGroup.class) @RequestBody Request<ProductBo> request) {
return productService.addEntity(request.getData());
}
@ApiOperation(value = "编辑产品")

View File

@ -135,6 +135,19 @@ public class ProductServiceImpl implements IProductService {
ThingModel oldData = thingModelData.findByProductKey(productKey);
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) {
//定义时序数据库物模型数据结构
dbStructureData.defineThingModel(thingModel);

View File

@ -72,7 +72,4 @@ sql 日志打印的话加个拦截器简化sql
## **代码生成器**
目前代码生成器改成了jpa,但是还存在大量错误
## **物模型**
物模型标识符命名增加合法性验证