eight
2024-08-12 932a99f21b84bd3e64e397a68a18900a8412d200
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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);
    }
 
}