admin
2021-08-27 8fee151ffae0c3818694b7318583814bf92663e2
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
package com.yeshi.buwan.service.imp.juhe;
 
import java.io.Serializable;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
 
import com.yeshi.buwan.dao.juhe.iqiyi.IqiyiUpdateQueueDao;
import com.yeshi.buwan.videos.iqiyi.entity.IqiyiUpdateQueue;
import com.yeshi.buwan.util.Constant;
 
@Service
public class IqiyiQueueService {
    static Logger logger = Logger.getLogger(IqiyiQueueService.class);
    @Resource
    private IqiyiUpdateQueueDao iqiyiUpdateQueueDao;
 
    /**
     * 添加到更新队列
     * 
     * @param name
     * @param url
     */
    public void addToUpdateQueue(String name, String url) {
        List<IqiyiUpdateQueue> list = iqiyiUpdateQueueDao.list("from IqiyiUpdateQueue mq where mq.url=?",
                new Serializable[] { url });
        if (list != null && list.size() > 1)
            return;
        IqiyiUpdateQueue queue = new IqiyiUpdateQueue();
        queue.setName(name);
        queue.setUrl(url);
        iqiyiUpdateQueueDao.create(queue);
    }
 
    public void updateUpdateQueue(IqiyiUpdateQueue queue) {
        iqiyiUpdateQueueDao.update(queue);
    }
 
    public IqiyiUpdateQueue getIqiyiUpdateQueue(long id) {
        return iqiyiUpdateQueueDao.find(IqiyiUpdateQueue.class, id);
    }
 
    public void deleteIqiyiUpdateQueue(IqiyiUpdateQueue queue) {
        iqiyiUpdateQueueDao.delete(queue);
    }
 
    // 队列列表
    public List<IqiyiUpdateQueue> listUpdateQueue() {
        List<IqiyiUpdateQueue> list = iqiyiUpdateQueueDao.list("from IqiyiUpdateQueue");
        return list;
    }
 
    public List<IqiyiUpdateQueue> listUpdateQueue(String key, int page) {
        key = key == null ? "" : key;
        List<IqiyiUpdateQueue> list = iqiyiUpdateQueueDao.list(
                "from IqiyiUpdateQueue mq where mq.name like ? order by mq.id desc",
                (page - 1) * Constant.pageCount, Constant.pageCount, new Serializable[] { "%" + key + "%" });
        return list;
    }
 
    public long countUpdateQueue(String key, int page) {
        key = key == null ? "" : key;
        return iqiyiUpdateQueueDao.getCount("from IqiyiUpdateQueue mq where mq.name like ?",
                new Serializable[] { "%" + key + "%" });
    }
 
}