Commit 7fb73128 authored by 李博今's avatar 李博今

教室被使用不可删除

parent ce185e52
......@@ -149,5 +149,7 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
@Update("update b_arrange set del_flag = 1 where business_id = #{0}")
int deleteArrange(String businessId);
@Select("select count(*) from b_schedule_dto where room_code = ( select `code` from b_rooms where business_id = #{businessId})")
int countThisRoomNum(String businessId);
}
package org.rcisoft.business.brooms.service.impl;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.barrange.dao.BArrangeRepository;
import org.rcisoft.business.brooms.utils.Upload2DataBase;
import org.rcisoft.business.bslschedule.dao.BSlScheduleRepository;
import org.rcisoft.business.bslschedule.entity.BSlSchedule;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.Result;
......@@ -39,6 +42,11 @@ public class BRoomsServiceImpl implements BRoomsService {
@Autowired
private BRoomsRepository bRoomsRepository;
@Autowired
private BSlScheduleRepository bSlScheduleRepository;
@Autowired
private BArrangeRepository bArrangeRepository;
/**
* 保存 bRooms
......@@ -70,12 +78,17 @@ public class BRoomsServiceImpl implements BRoomsService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(BRooms bRooms){
UserUtil.setCurrentMergeOperation(bRooms);
bRooms.setDeleted();
int line = bRoomsRepository.logicalDelete(bRooms);
log.info(UserUtil.getUserInfoProp(bRooms.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
bRooms.getBusinessId()+"的信息");
return new PersistModel(line);
if(bArrangeRepository.countThisRoomNum(bRooms.getBusinessId()) != 0
|| bSlScheduleRepository.countThisRoomNum(bRooms.getBusinessId()) != 0){
throw new ServiceException(ResultServiceEnums.ROOM_HAS_USED);
}else{
UserUtil.setCurrentMergeOperation(bRooms);
bRooms.setDeleted();
int line = bRoomsRepository.logicalDelete(bRooms);
log.info(UserUtil.getUserInfoProp(bRooms.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
bRooms.getBusinessId()+"的信息");
return new PersistModel(line);
}
}
/**
......
......@@ -51,5 +51,8 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> {
int updateStatusBySubAgencyId(@Param("subAgencyId") String subAgencyId, @Param("status") String status);
int countStudentNum(String classesId);
@Select("select count(*) from b_sl_schedule where room_code = ( select `code` from b_rooms where business_id = #{businessId})")
int countThisRoomNum(String businessId);
}
......@@ -181,6 +181,8 @@ public enum ResultServiceEnums {
EXISE_ROOM_CODE(96,"此教室编号已存在,添加失败"),
CURRENT_TERM(97,"当前学期不可删除"),
ROOM_HAS_USED(98,"当前教室正在被使用,不可删除"),
;
private Integer code;
......
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