增加区块和部门接口

This commit is contained in:
qinjie 2024-11-23 21:12:05 +08:00
parent d9362860f3
commit 1731a9b6aa
4 changed files with 18 additions and 8 deletions

View File

@ -29,10 +29,10 @@ public class Block extends Model<Block> {
private String details; private String details;
/** 创建时间 */ /** 创建时间 */
private LocalDateTime createTime; private String createTime;
/** 更新时间 */ /** 更新时间 */
private LocalDateTime updateTime; private String updateTime;
/** 关联部门 */ /** 关联部门 */
private DepartmentVO department; private DepartmentVO department;

View File

@ -145,6 +145,8 @@ public class BlockServiceImpl extends ServiceImpl<BlockDao, Block> implements B
@Override @Override
@Transactional(rollbackFor = Throwable.class) @Transactional(rollbackFor = Throwable.class)
public void deleteBlockById(Long id) { public void deleteBlockById(Long id) {
//TODO 校验区块是否被气井关联
blockDao.deleteBlockById(id); blockDao.deleteBlockById(id);
blockDepartmentService.remove(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getBlockId, id)); blockDepartmentService.remove(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getBlockId, id));
} }

View File

@ -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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isu.gaswellwatch.config.SnowflakeConfig; 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.service.DepartmentService;
import com.isu.gaswellwatch.dao.DepartmentDao; import com.isu.gaswellwatch.dao.DepartmentDao;
import com.isu.gaswellwatch.dto.*; import com.isu.gaswellwatch.dto.*;
@ -28,6 +30,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentDao, Department
@Resource @Resource
private DepartmentDao companyDao; private DepartmentDao companyDao;
@Resource
private BlockDepartmentService blockDepartmentService;
@Override @Override
public Page<DepartmentVO> page(Integer currentPage, Integer pageSize, String name, String code){ public Page<DepartmentVO> page(Integer currentPage, Integer pageSize, String name, String code){
Page<DepartmentVO> page = companyDao.page(new Page<>(currentPage, pageSize),name,code); Page<DepartmentVO> page = companyDao.page(new Page<>(currentPage, pageSize),name,code);
@ -56,11 +61,14 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentDao, Department
@Override @Override
public void delete(Long id){ public void delete(Long id){
//TODO 如果部门绑定了气井 不能删除 //如果部门绑定了区块 不能删除
BlockDepartment blockDepartment = blockDepartmentService.getOne(new LambdaQueryWrapper<BlockDepartment>().eq(BlockDepartment::getDepartmentId, id));
//删除 if(blockDepartment != null){
throw new BusinessException("该部门已被区块绑定,不能删除");
}else {
removeById(id); removeById(id);
} }
}
} }

View File

@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="pageForQuery" resultMap="BlockVO"> <select id="pageForQuery" resultMap="BlockVO">
<include refid="selectBlockVo"/> <include refid="selectBlockVo"/>
<where> <where>
<if test="name != ''"> and t1.name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and t1.name like concat('%', #{name}, '%')</if>
</where> </where>
order by t1.id desc order by t1.id desc
</select> </select>
@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectBlockVo"/> <include refid="selectBlockVo"/>
left join block_department bd on t1.id = bd.block_id left join block_department bd on t1.id = bd.block_id
<where> <where>
<if test="departmentId != ''"> bd.department_id = #{departmentId}</if> <if test="departmentId != null and departmentId != ''"> bd.department_id = #{departmentId}</if>
</where> </where>
</select> </select>