package com.yeshi.buwan.service.imp.live;
|
|
import com.yeshi.buwan.domain.live.TVLiveProgramResource;
|
import com.yeshi.buwan.dao.live.TVLiveProgramResourceDao;
|
import com.yeshi.buwan.exception.ParamsException;
|
import com.yeshi.buwan.service.inter.live.TVLiveProgramResourceService;
|
|
import javax.annotation.Resource;
|
|
import com.yeshi.buwan.util.StringUtil;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class TVLiveProgramResourceServiceImpl implements TVLiveProgramResourceService {
|
|
@Resource
|
private TVLiveProgramResourceDao tVLiveProgramResourceDao;
|
|
@Override
|
public void add(TVLiveProgramResource resource) throws ParamsException {
|
if (StringUtil.isNullOrEmpty(resource.getChannelId()) || StringUtil.isNullOrEmpty(resource.getUrl()) || resource.getType() == null)
|
throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "参数不完整");
|
if (resource.getId() == null)
|
resource.setId(TVLiveProgramResource.createId(resource.getChannelId(), resource.getType()));
|
if (resource.getCreateTime() == null)
|
resource.setCreateTime(new Date());
|
tVLiveProgramResourceDao.save(resource);
|
}
|
|
@Override
|
public List<TVLiveProgramResource> listByChannelId(String channelId, int page, int pageSize) {
|
TVLiveProgramResourceDao.DaoQuery daoQuery = new TVLiveProgramResourceDao.DaoQuery();
|
daoQuery.channelId = channelId;
|
daoQuery.start = (page - 1) * pageSize;
|
daoQuery.count = pageSize;
|
return tVLiveProgramResourceDao.list(daoQuery);
|
}
|
|
@Override
|
public List<TVLiveProgramResource> listByType(TVLiveProgramResource.TVLiveProgramResourceType type, int page, int pageSize) {
|
TVLiveProgramResourceDao.DaoQuery daoQuery = new TVLiveProgramResourceDao.DaoQuery();
|
daoQuery.type = type;
|
daoQuery.start = (page - 1) * pageSize;
|
daoQuery.count = pageSize;
|
return tVLiveProgramResourceDao.list(daoQuery);
|
}
|
}
|