소스 검색

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

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…
취소
저장