package cn.lihu.jh.module.ecg.service.queue;
|
|
import org.springframework.stereotype.Service;
|
import org.springframework.validation.annotation.Validated;
|
|
import cn.lihu.jh.module.ecg.controller.admin.queue.vo.*;
|
import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
|
import cn.lihu.jh.framework.common.pojo.PageResult;
|
import cn.lihu.jh.framework.common.util.object.BeanUtils;
|
|
import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper;
|
|
import javax.annotation.Resource;
|
|
import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
|
|
/**
|
* 排队 Service 实现类
|
*
|
* @author 芋道源码
|
*/
|
@Service
|
@Validated
|
public class QueueServiceImpl implements QueueService {
|
|
@Resource
|
private queueMapper queueMapper;
|
|
@Override
|
public Integer createqueue(QueueSaveReqVO createReqVO) {
|
// 插入
|
QueueDO queue = BeanUtils.toBean(createReqVO, QueueDO.class);
|
queueMapper.insert(queue);
|
// 返回
|
return queue.getId();
|
}
|
|
@Override
|
public void updatequeue(QueueSaveReqVO updateReqVO) {
|
// 校验存在
|
validatequeueExists(updateReqVO.getId());
|
// 更新
|
QueueDO updateObj = BeanUtils.toBean(updateReqVO, QueueDO.class);
|
queueMapper.updateById(updateObj);
|
}
|
|
@Override
|
public void deletequeue(Integer id) {
|
// 校验存在
|
validatequeueExists(id);
|
// 删除
|
queueMapper.deleteById(id);
|
}
|
|
private void validatequeueExists(Integer id) {
|
if (queueMapper.selectById(id) == null) {
|
throw exception(QUEUE_NOT_EXISTS);
|
}
|
}
|
|
@Override
|
public QueueDO getqueue(Integer id) {
|
return queueMapper.selectById(id);
|
}
|
|
@Override
|
public PageResult<QueueDO> getqueuePage(QueuePageReqVO pageReqVO) {
|
return queueMapper.selectPage(pageReqVO);
|
}
|
|
}
|