Преглед изворни кода

解决无人机设备产品编号唯一性的问题

master
牧羊人 пре 4 година
родитељ
комит
c6723f23f0
1 измењених фајлова са 16 додато и 0 уклоњено
  1. +16
    -0
      src/main/java/com/taauav/admin/service/impl/TauvEquipmentServiceImpl.java

+ 16
- 0
src/main/java/com/taauav/admin/service/impl/TauvEquipmentServiceImpl.java Прегледај датотеку

@@ -104,6 +104,14 @@ public class TauvEquipmentServiceImpl extends BaseServiceImpl<TauvEquipmentMappe
if (equipment == null || equipment.getId() == null) {
return response.failure("实体对象不能为空");
}
// 产品需要唯一性验证
QueryWrapper<TauvEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("product_sn", equipment.getProductSn());
queryWrapper.eq("mark", 1);
Integer count = equipmentMapper.selectCount(queryWrapper);
if (count > 0) {
return response.failure("产品序号已存在");
}
boolean result = this.editData(equipment);
if (!result) {
return response.failure("编辑失败");
@@ -122,6 +130,14 @@ public class TauvEquipmentServiceImpl extends BaseServiceImpl<TauvEquipmentMappe
if (equipment == null) {
return response.failure("实体对象不能为空");
}
// 产品需要唯一性验证
QueryWrapper<TauvEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("product_sn", equipment.getProductSn());
queryWrapper.eq("mark", 1);
Integer count = equipmentMapper.selectCount(queryWrapper);
if (count > 0) {
return response.failure("产品序号已存在");
}
boolean result = this.addData(equipment);
if (!result) {
return response.failure("添加失败");

Loading…
Откажи
Сачувај