Commit df82f465 authored by maoying's avatar maoying

修改重点装备删除,删除关联表

parent c83330f9
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment; import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment;
import java.util.List;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -17,4 +20,6 @@ public interface IEquipmentFireEquipmentDao extends BaseDao<EquipmentFireEquipme ...@@ -17,4 +20,6 @@ public interface IEquipmentFireEquipmentDao extends BaseDao<EquipmentFireEquipme
@Query(value = "select count(1) from f_equipment_fire_equipment WHERE equipment_id = ?1 and fire_equipment_id = ?2", nativeQuery = true) @Query(value = "select count(1) from f_equipment_fire_equipment WHERE equipment_id = ?1 and fire_equipment_id = ?2", nativeQuery = true)
int findByEqmtIdAndFireEqmtId(Long equipmentId, Long fireEquipmentId); int findByEqmtIdAndFireEqmtId(Long equipmentId, Long fireEquipmentId);
List<EquipmentFireEquipment> findAllByEquipmentId(Long equipmentId);
} }
...@@ -132,6 +132,11 @@ public class EquipmentServiceImpl implements IEquipmentService { ...@@ -132,6 +132,11 @@ public class EquipmentServiceImpl implements IEquipmentService {
equipment=equipment1.get(); equipment=equipment1.get();
} }
if (equipment != null) { if (equipment != null) {
List<EquipmentFireEquipment> eqFireEqs = equipmentFireEquipmentDao.findAllByEquipmentId(equipment.getId());
if(!eqFireEqs.isEmpty()){
equipmentFireEquipmentDao.deleteAll(eqFireEqs);
}
this.iEquipmentDao.deleteById(Long.parseLong(id)); this.iEquipmentDao.deleteById(Long.parseLong(id));
} else { } else {
throw new Exception("找不到指定的对象:" + id); throw new Exception("找不到指定的对象:" + id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment