<?php
class userVideoModule extends Model
{
    public function __construct()
    {
        parent::__construct("sl_user_video");
    }
    //查询用户是否收藏过该小视屏  如果收藏  则取消收藏
    public function userCollection($arr){
        $one = $this->where(['user_number'=>$arr['user_number'],'video_id'=>$arr['video_id'],'type'=>1])->one();
        if ($one){
            $del = $this->where(['id'=>$one['id']])->delete();
            if ($del){
                returnSuccess($arr,config('code')['2018'],200);
            }else{
                returnFail(config('code')['1001'],[],1001);
            }
        }else{
            $insert = $this->insert($arr);
            if ($insert){
                returnSuccess($arr,config('code')['2019'],200);
            }else{
                returnFail(config('code')['1001'],[],1001);
            }
        }
    }
}