admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
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
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);
    }
}