package com.newvideo.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.newvideo.dao.juhe.IqiyiUpdateQueueDao;
|
import com.newvideo.iqiyi.entity.IqiyiUpdateQueue;
|
import com.newvideo.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 queue where queue.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 queue where queue.name like ? order by queue.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 queue where queue.name like ?",
|
new Serializable[] { "%" + key + "%" });
|
}
|
|
}
|