package com.nms.swspkmas_standalone.service.impl; import com.nms.swspkmas_standalone.entity.ExamRoom; import com.nms.swspkmas_standalone.entity.vo.ExamRoomVO; import com.nms.swspkmas_standalone.exception.ApiException; import com.nms.swspkmas_standalone.mapper.ExamRoomMapper; import com.nms.swspkmas_standalone.service.ExamRoomService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.sql.Wrapper; import java.time.LocalDateTime; import java.util.List; /** *

* 考场信息 服务实现类 *

* * @author kzy * @since 2023-09-20 16:13:59 */ @Service public class ExamRoomServiceImpl extends ServiceImpl implements ExamRoomService { @Override public void addExamRoom(ExamRoomVO examRoomVO) { Long count=count(); if(count>1){ throw new ApiException("已存在考场信息"); } ExamRoom examRoom=new ExamRoom(); BeanUtils.copyProperties(examRoomVO,examRoom); save(examRoom); } @Override public void updateExamRoom(Long id, ExamRoomVO examRoomVO) { ExamRoom examRoom=getById(id); if(examRoom==null){ throw new ApiException("考场信息不存在"); } BeanUtils.copyProperties(examRoomVO,examRoom,new String[]{"id"}); examRoom.setUpdateTime(LocalDateTime.now()); updateById(examRoom); } @Override public void deleteExamRoom() { baseMapper.deleteExamRoom(); } @Override public ExamRoom getExamRoom() { List examRoomList=list(); if(examRoomList.size()>1){ throw new ApiException("考场信息存在多条记录"); } return examRoomList.size()==1?examRoomList.get(0):null; } }