diff --git a/src/main/java/com/isu/gaswellwatch/entity/Block.java b/src/main/java/com/isu/gaswellwatch/entity/Block.java index 26bcc6c..73f0078 100644 --- a/src/main/java/com/isu/gaswellwatch/entity/Block.java +++ b/src/main/java/com/isu/gaswellwatch/entity/Block.java @@ -29,10 +29,10 @@ public class Block extends Model { private String details; /** 创建时间 */ - private LocalDateTime createTime; + private String createTime; /** 更新时间 */ - private LocalDateTime updateTime; + private String updateTime; /** 关联部门 */ private DepartmentVO department; diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/BlockServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/BlockServiceImpl.java index 8fe602f..25a661d 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/BlockServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/BlockServiceImpl.java @@ -145,6 +145,8 @@ public class BlockServiceImpl extends ServiceImpl implements B @Override @Transactional(rollbackFor = Throwable.class) public void deleteBlockById(Long id) { + //TODO 校验区块是否被气井关联 + blockDao.deleteBlockById(id); blockDepartmentService.remove(new LambdaQueryWrapper().eq(BlockDepartment::getBlockId, id)); } diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/DepartmentServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/DepartmentServiceImpl.java index f27e8ac..60fce5d 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/DepartmentServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/DepartmentServiceImpl.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.isu.gaswellwatch.config.SnowflakeConfig; +import com.isu.gaswellwatch.entity.BlockDepartment; +import com.isu.gaswellwatch.service.BlockDepartmentService; import com.isu.gaswellwatch.service.DepartmentService; import com.isu.gaswellwatch.dao.DepartmentDao; import com.isu.gaswellwatch.dto.*; @@ -28,6 +30,9 @@ public class DepartmentServiceImpl extends ServiceImpl page(Integer currentPage, Integer pageSize, String name, String code){ Page page = companyDao.page(new Page<>(currentPage, pageSize),name,code); @@ -56,10 +61,13 @@ public class DepartmentServiceImpl extends ServiceImpl().eq(BlockDepartment::getDepartmentId, id)); + if(blockDepartment != null){ + throw new BusinessException("该部门已被区块绑定,不能删除"); + }else { + removeById(id); + } } diff --git a/src/main/resources/mapper/BlockMapper.xml b/src/main/resources/mapper/BlockMapper.xml index 7151189..4de9661 100644 --- a/src/main/resources/mapper/BlockMapper.xml +++ b/src/main/resources/mapper/BlockMapper.xml @@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join block_department bd on t1.id = bd.block_id - bd.department_id = #{departmentId} + bd.department_id = #{departmentId}