VideosControllerApi.java 2.85 KB
package com.cnlive.shenhe.api;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.entity.ShySites;
import com.cnlive.shenhe.entity.ShyVideos;
import com.cnlive.shenhe.serviceImpl.UsersServiceImpl;
import com.cnlive.shenhe.serviceImpl.VideosServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
 * @Auther: chenhao
 * @Date: 2018/12/6 11:17
 * @Description: 视频送审接口
 */
@Controller
@RequestMapping("/videosApi")
public class VideosControllerApi {
    @Autowired
    AuditPass Pass;
    @Autowired
    VideosServiceImpl videosService;
    @Autowired
    UsersServiceImpl usersService;


    @PostMapping("/import")
    @ResponseBody
    public ResponseBean impotVideo(@RequestBody  JSONObject json){
        ShySites shySites = new ShySites();
        ShyVideos shyVideos = new ShyVideos();
        shyVideos.setState(CommonConst.AUDIT_INTT);
        //判断是否白名单
        shySites.setSpid(json.getInteger("spId"));
        List<ShySites> shySitesList = videosService.getBusiness(shySites);
        if(!shySitesList.isEmpty()){
            if(CommonUtils.isNotEmpty(shySitesList.get(0).getWrite_business())){
                String write_business = shySitesList.get(0).getWrite_business();
                String[] business = write_business.split(",");
                List<String> asList = Arrays.asList(business);
                if(asList.contains(CommonConst.BUSINESS_VIDEO+"")){
                    shyVideos.setState(CommonConst.AUDIT_SUCCESS);
                    Pass.auditPass(json.getString("videoId"),CommonConst.AUDIT_SUCCESS,"","");
                }else {
                    shyVideos.setState(CommonConst.AUDIT_INTT);
                }
            }
        }
        //封装数据入库
        shyVideos.setVideo_id(json.getString("videoId"));
        shyVideos.setVideo_title(json.getString("videoTitle"));
        shyVideos.setVideo_url(json.getString("videoUrl"));
        shyVideos.setVideo_imgs(json.getString("videoCoverUrl"));
        shyVideos.setVideo_desc(json.getString("videoIntro"));
        shyVideos.setVideo_keyword(json.getString("videoKeyword"));
        shyVideos.setVideo_priority(json.getString("priority"));
        shyVideos.setCallback(json.getString("callback"));
        shyVideos.setSpid(Integer.parseInt(json.getString("spId")));
        int i = videosService.impotVideo(shyVideos);
        if(i>0){
            return  new ResponseBean(ErrorEnum.SUCCESS);
        }else {
            return  new ResponseBean(ErrorEnum.ERROR);
        }
    }
}