修改查询条件
parent
551597615b
commit
52536f550d
|
|
@ -3,6 +3,7 @@ package com.zcloud.fire.check.command;
|
||||||
import com.alibaba.cola.exception.BizException;
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.zcloud.fire.check.domain.gateway.FireDeviceGateway;
|
import com.zcloud.fire.check.domain.gateway.FireDeviceGateway;
|
||||||
import com.zcloud.fire.check.persistence.dataobject.FireDeviceDO;
|
import com.zcloud.fire.check.persistence.dataobject.FireDeviceDO;
|
||||||
|
import com.zcloud.fire.check.persistence.repository.FireCheckListItemRepository;
|
||||||
import com.zcloud.fire.check.persistence.repository.FireDeviceRepository;
|
import com.zcloud.fire.check.persistence.repository.FireDeviceRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -20,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
public class FireDeviceRemoveExe {
|
public class FireDeviceRemoveExe {
|
||||||
private final FireDeviceGateway fireDeviceGateway;
|
private final FireDeviceGateway fireDeviceGateway;
|
||||||
private final FireDeviceRepository fireDeviceRepository;
|
private final FireDeviceRepository fireDeviceRepository;
|
||||||
|
private final FireCheckListItemRepository fireCheckListItemRepository;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean execute(Long id) {
|
public boolean execute(Long id) {
|
||||||
|
|
@ -33,8 +35,10 @@ public class FireDeviceRemoveExe {
|
||||||
}
|
}
|
||||||
//TODO 级联删除关联的检查表记录
|
//TODO 级联删除关联的检查表记录
|
||||||
|
|
||||||
|
Long count = fireCheckListItemRepository.countByDeviceId(fireDeviceDO.getFireDeviceId());
|
||||||
|
if(count>0){
|
||||||
|
throw new BizException("请先删除关联的检查表记录");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,5 +22,7 @@ public interface FireCheckListItemRepository extends BaseRepository<FireCheckLis
|
||||||
void deleteByFireCheckId(String fireCheckId);
|
void deleteByFireCheckId(String fireCheckId);
|
||||||
|
|
||||||
List<FireCheckListItemStatisticDO> statisticListByFireCheckIdList(List<String> fireCheckIdList);
|
List<FireCheckListItemStatisticDO> statisticListByFireCheckIdList(List<String> fireCheckIdList);
|
||||||
|
|
||||||
|
Long countByDeviceId(String fireDeviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,5 +55,12 @@ public class FireCheckListItemRepositoryImpl extends BaseRepositoryImpl<FireChec
|
||||||
public List<FireCheckListItemStatisticDO> statisticListByFireCheckIdList(List<String> fireCheckIdList) {
|
public List<FireCheckListItemStatisticDO> statisticListByFireCheckIdList(List<String> fireCheckIdList) {
|
||||||
return fireCheckListItemMapper.statisticListByFireCheckIdList(fireCheckIdList);
|
return fireCheckListItemMapper.statisticListByFireCheckIdList(fireCheckIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long countByDeviceId(String fireDeviceId) {
|
||||||
|
QueryWrapper<FireCheckListItemDO> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("fire_device_id", fireDeviceId);
|
||||||
|
return fireCheckListItemMapper.selectCount(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue