VideosServiceImpl.java 2.89 KB
package com.cnlive.shenhe.serviceImpl;

import com.cnlive.shenhe.entity.ShySites;
import com.cnlive.shenhe.entity.ShyVideos;
import com.cnlive.shenhe.mapper.ShySitesMapper;
import com.cnlive.shenhe.mapper.ShyVideosMapper;
import com.cnlive.shenhe.utils.CommonUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Auther: chenhao
 * @Date: 2018/11/30 14:23
 * @Description:
 */
@Service
public class VideosServiceImpl {
    @Autowired
    ShyVideosMapper shyVideosMapper;
    @Autowired
    ShySitesMapper shySitesMapper;

    public int impotVideo(ShyVideos shyVideos) {
        int result = shyVideosMapper.insert(shyVideos);
        return result;
    }

    public List<ShySites> getBusiness(ShySites shySites) {
        List<ShySites> sitesList = shySitesMapper.select(shySites);
        return sitesList;
    }

    public int updateVideo(Integer id, String auditor_id, Integer state, String attr_tags, String msg) {
        ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(id);
        shyVideos.setAuditor_id(auditor_id);
        shyVideos.setState(state);
        shyVideos.setVideo_tags(attr_tags);
        shyVideos.setMsg(msg);
        return shyVideosMapper.updateByPrimaryKeySelective(shyVideos);
    }

    public PageInfo<ShyVideos> getListContent(String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String orderByClause, Integer spid) {
        Example example = new Example(ShyVideos.class);
        Example.Criteria criteria = example.createCriteria();
        if (CommonUtils.isNotEmpty(orderByClause)) {
            example.setOrderByClause(orderByClause);
        }
        if (CommonUtils.isNotEmpty(start_date) && CommonUtils.isNotEmpty(end_date)) {
            criteria.andGreaterThanOrEqualTo("video_upload_time", start_date);
            criteria.andLessThanOrEqualTo("video_upload_time", end_date);
        }
        if (CommonUtils.isNotEmpty(video_title)) {
            criteria.andLike("video_title", "%" + video_title + "%");
        }
        if (CommonUtils.isNotNull(state)) {
            criteria.andEqualTo("state", state);
        }
        if (CommonUtils.isNotNull(spid)) {
            criteria.andEqualTo("spid", spid);
        }
        //默认按上传时间倒序排序
        example.setOrderByClause("video_upload_time desc");
        PageHelper.startPage(page, pageSize, true);
        List<ShyVideos> shyVideosList = shyVideosMapper.selectByExample(example);
        PageInfo<ShyVideos> pageInfo = new PageInfo<>(shyVideosList);
        return pageInfo;
    }

    public Object getDetailsContent(Integer id) {
        ShyVideos DetailsshyVideos = shyVideosMapper.selectByPrimaryKey(id);
        return DetailsshyVideos;
    }

}