admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
src/main/java/com/yeshi/buwan/service/imp/live/TVLiveChannelServiceImpl.java
@@ -43,8 +43,36 @@
            channel.setUpdateTime(new Date());
        }
        tvLiveChannelDao.save(channel);
        return channel;
    }
    @Override
    public TVLiveChannel addChannel(TVLiveChannel channel) throws ParamsException, Exception {
        if (channel == null || StringUtil.isNullOrEmpty(channel.getName())) {
            throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "名称不能为空");
        }
        if (StringUtil.isNullOrEmpty(channel.gethPicture())) {
            throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "横图不能为空");
        }
        if (channel.getId() == null) {
            channel.setId(StringUtil.Md5(channel.getName()));
        }
        if (channel.getState() == null) {
            channel.setState(TVLiveChannel.STATE_NORMAL);
        }
        if (tvLiveChannelDao.get(channel.getId()) != null) {
            throw new Exception("频道已经存在");
        }
        return save(channel);
    }
    @Override
@@ -88,5 +116,18 @@
        daoQuery.name = name;
        return tvLiveChannelDao.count(daoQuery);
    }
    @Override
    public TVLiveChannel selectByPrimaryKey(String id) {
        return tvLiveChannelDao.get(id);
    }
    @Override
    public void savePrograms(String id, List<TVLiveChannel.TVLiveProgram> tvLivePrograms) {
        TVLiveChannel channel = new TVLiveChannel();
        channel.setId(id);
        channel.setProgramList(tvLivePrograms);
        tvLiveChannelDao.updateSelective(channel);
    }
}