<?php
/**
 * Created by PhpStorm.
 * User: LYY
 * Date: 2020/10/21
 * Time: 15:01
 */

namespace backend\controllers\listnav;

use Yii;
use backend\base\CommonController;
use backend\base\Help;
use backend\server\ListnavServer;

class IndexpushController extends CommonController
{
    //列表状态信息设置
    public function actionSet()
    {
        $server = new ListnavServer();
        $state = $server->setList();
        return Help::JsonCode($state['code'], $state['msg']);
    }
    //=======================================推动区域信息===============================================================
    //首页推送地区导航栏位
    public function actionPushcity()
    {
        $list_id = Yii::$app->request->get('list_id');
        return $this->render('pushcity', ['list_id' => $list_id]);
    }

    public function actionPushcityform()
    {
        $server = new ListnavServer();
        $state = $server->getListCity();
        return Help::JsonData(0, $state['msg'], $state['count'], $state['data']);
    }

    //推送地区导航栏位添加
    public function actionAddpushcity()
    {
        $list_id = Yii::$app->request->get('list_id');
        return $this->render('pushcityadd', ['list_id' => $list_id]);
    }

    public function actionAddpushcityform()
    {
        $server = new ListnavServer();
        $state = $server->addListCity();
        return Help::JsonCode($state['code'], $state['msg']);
    }

    //=======================================================推送资讯信息===============================================
    public function actionPushnews()
    {
        $list_id = Yii::$app->request->get('list_id');
        return $this->render('pushnews', ['list_id' => $list_id]);
    }

    public function actionPushnewsform()
    {
        $server = new ListnavServer();
        $state = $server->getListNews();
        return Help::JsonData(0, $state['msg'], $state['count'], $state['data']);
    }

    public function actionPushnewsadd()
    {
        $list_id = Yii::$app->request->get('list_id');
        $newlist = (new ListnavServer())->getNewsList();
        return $this->render('pushnewsadd', ['list_id' => $list_id, 'new_list' => $newlist]);
    }

    public function actionPushnewsaddform()
    {
        $server = new ListnavServer();
        $state = $server->addListNews();
        return Help::JsonCode($state['code'], $state['msg']);
    }

    //=======================================================自定义导航烂推送位=========================================
    public function actionPushtitle()
    {
        $list_id = Yii::$app->request->get('list_id');
        return $this->render('pushtitle', ['list_id' => $list_id]);
    }


    public function actionPushtitleform()
    {
        $server = new ListnavServer();
        $state = $server->getListTitle();
        return Help::JsonData(0, $state['msg'], $state['count'], $state['data']);
    }

    public function actionPushtitleadd()
    {
        $list_id = Yii::$app->request->get('list_id');
        return $this->render('pushtitleadd', ['list_id' => $list_id]);
    }

    public function actionPushtitleaddform()
    {
        $server = new ListnavServer();
        $state = $server->addListTitle();
        return Help::JsonCode($state['code'], $state['msg']);
    }
}