<?php
namespace app\admin\controller\life;

use app\admin\controller\BaseController;
use app\admin\server\life\CinemaServer;

class Cinema extends BaseController
{

    /**
     * Notes:获取万悦影院列表
     * @return \support\Response
     * User: ZQ
     * Date: 2022/10/09
     */
    public function getCinemaList()
    {
        [$page, $limit] = $this->getPage();
        $keywords = $this->request->get('keywords');
        $result         = CinemaServer::getCinemaList($page, $limit, $keywords);
        return json_success($result, '成功');
    }

    /**
     * Notes:获取所有
     * @return \support\Response
     * User: ZQ
     * Date: 2022/9/19
     */
    public function getCinemaAll()
    {
        $result         = CinemaServer::getCinemaAll();
        return json_success($result, '成功');
    }

    /**
     * Notes:修改万悦影院
     * @return \support\Response
     * User: ZQ
     * Date: 2022/10/09
     */
    public function updateCinema()
    {
        $cinema_id      = $this->request->post('cinema_id');
        $cinema_name    = $this->request->post('cinema_name');
        $cinema_video   = $this->request->post('cinema_video','');
        $cinema_mold    = $this->request->post('cinema_mold');
        $cinema_director= $this->request->post('cinema_director');
        $cinema_star    = $this->request->post('cinema_star');
        $cinema_introduction = $this->request->post('cinema_introduction');
        $cinema_price = $this->request->post('cinema_price');
        $cinema_performers = $this->request->post('cinema_performers');
        $cinema_seat    = $this->request->post('cinema_seat');
        $cinema_length  = $this->request->post('cinema_length');
        $cinema_week  = $this->request->post('cinema_week','');
        $cinema_time    = $this->request->post('cinema_time');
        $cinema_label   = $this->request->post('cinema_label');
        $cinema_img     = $this->request->post('cinema_img');
        $cinema_status  = $this->request->post('cinema_status');
        $admin_id = $this->request->admin_id;
        $this->validateCheck('life\CinemaValidate', ['cinema_id' => $cinema_id], 'update');
        $result       = CinemaServer::updateCinema($cinema_id, $cinema_name, $cinema_video, $cinema_mold, $cinema_director, $cinema_star, $cinema_price, $cinema_introduction, $cinema_performers, $cinema_seat, $cinema_length, $cinema_time, $cinema_label, $cinema_img, $cinema_status, $cinema_week, $admin_id);
        return json_success($result, '修改成功');

    }

    /**
     * Notes:删除影片
     * @return \support\Response
     * User: ZQ
     * Date: 2022/9/13
     */
    public function delCinema()
    {
        $cinema_id = $this->request->get('cinema_id');
        $admin_id = $this->request->admin_id;
        $this->validateCheck('life\CinemaValidate', ['cinema_id' => $cinema_id], 'info');
        $result         = CinemaServer::delCinema($cinema_id,$admin_id);
        if ($result){
            return json_success($result, '删除成功');
        }else{
            throw new \Exception('删除失败！');
        }

    }

    /**
     * Notes:添加影片
     * @return \support\Response
     * User: ZQ
     * Date: 2022/9/13
     */
    public function addCinema()
    {
        $cinema_name    = $this->request->post('cinema_name');
        $cinema_video   = $this->request->post('cinema_video','');
        $cinema_mold    = $this->request->post('cinema_mold');
        $cinema_director= $this->request->post('cinema_director');
        $cinema_star    = $this->request->post('cinema_star');
        $cinema_introduction = $this->request->post('cinema_introduction');
        $cinema_price = $this->request->post('cinema_price');
        $cinema_performers = $this->request->post('cinema_performers');
        $cinema_seat    = $this->request->post('cinema_seat');
        $cinema_length  = $this->request->post('cinema_length');
        $cinema_week  = $this->request->post('cinema_week','');
        $cinema_time    = $this->request->post('cinema_time');
        $cinema_label   = $this->request->post('cinema_label');
        $cinema_img     = $this->request->post('cinema_img');
        $cinema_status  = $this->request->post('cinema_status');
        $admin_id = $this->request->admin_id;
        $this->validateCheck('life\CinemaValidate', ['cinema_name' => $cinema_name, 'cinema_mold' => $cinema_mold, 'cinema_director' => $cinema_director, 'cinema_star' => $cinema_star, 'cinema_price' => $cinema_price, 'cinema_introduction' => $cinema_introduction, 'cinema_performers' => $cinema_performers], 'create');
        $result         = CinemaServer::insertCinema($cinema_name, $cinema_video, $cinema_mold, $cinema_director, $cinema_star, $cinema_price, $cinema_introduction, $cinema_performers, $cinema_seat, $cinema_length, $cinema_time, $cinema_label, $cinema_img, $cinema_status, $cinema_week, $admin_id);
        return json_success($result, '添加成功');
    }

    /**
     * Notes:查询影片详情
     * @return \support\Response
     * User: ZQ
     * Date: 2022/9/13
     */
    public function cinemaInfo()
    {
        $cinema_id = $this->request->get('cinema_id');
        $this->validateCheck('life\CinemaValidate', ['cinema_id' => $cinema_id], 'info');
        $result         = CinemaServer::cinemaInfo($cinema_id);
        return json_success($result, '成功');
    }

    /**
     * Notes:影片上架下架
     * @return \support\Response
     * User: ZQ
     * Date: 2022/10/09
     */
    public function updateStatus()
    {
        $cinema_id = $this->request->get('cinema_id');
        $cinema_status = $this->request->get('cinema_status');
        $this->validateCheck('life\CinemaValidate', ['cinema_id' => $cinema_id], 'info');
        $result       = CinemaServer::updateStatus($cinema_id, $cinema_status);
        return json_success($result, '修改成功');
    }

}
