admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
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
package com.yeshi.fanli.service.impl.mq;
 
import java.util.Date;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.mq.MQUnSendInfoMapper;
import com.yeshi.fanli.entity.mq.MQUnSendInfo;
import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
import com.yeshi.fanli.util.StringUtil;
 
@Service
public class MQUnSendInfoServiceImpl implements MQUnSendInfoService {
 
    @Resource
    private MQUnSendInfoMapper mqUnSendInfoMapper;
 
    @Override
    public void addMQUnSendInfo(MQUnSendInfo info) throws MQUnSendInfoException {
        if (StringUtil.isNullOrEmpty(info.getTag()) || StringUtil.isNullOrEmpty(info.getTopic())
                || StringUtil.isNullOrEmpty(info.getBody()) || StringUtil.isNullOrEmpty(info.getKey())) {
            throw new MQUnSendInfoException(1, "信息不完整");
        }
        MQUnSendInfo oldInfo = mqUnSendInfoMapper.selectByTopicTagAndKey(info.getTopic(), info.getTag(), info.getKey());
        if (oldInfo != null)
            return;
        if (info.getLastSendTime() == null)
            info.setLastSendTime(new Date());
        mqUnSendInfoMapper.insertSelective(info);
    }
 
    @Override
    public List<MQUnSendInfo> listByMaxSendTime(Date maxSendTime, int page, int pageSize) {
        return mqUnSendInfoMapper.listByMaxSendTime(maxSendTime, (page - 1) * pageSize, pageSize);
    }
 
    @Override
    public void deleteByPrimaryKey(Long id) {
        mqUnSendInfoMapper.deleteByPrimaryKey(id);
    }
 
    @Override
    public void updateSendTime(Long id, Date sendTime) {
        MQUnSendInfo info = new MQUnSendInfo();
        info.setId(id);
        info.setLastSendTime(sendTime);
        mqUnSendInfoMapper.updateByPrimaryKeySelective(info);
    }
}