cxgj/modules/admin/controllers/cms/PageController.php
2023-11-27 09:45:13 +08:00

154 lines
4.5 KiB
PHP

<?php
/**
* @author Any
* @description KISS
* @date 2021年7月28日
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\admin\controllers\cms;
use yii\helpers\VarDumper;
use app\modules\admin\controllers\Controller;
use app\modules\admin\behaviors\LoginBehavior;
use app\models\common\cms\CommonPageActionForm;
use app\models\common\cms\CommonPageEditForm;
use app\models\common\cms\CommonPageListForm;
use app\models\cms\Page;
class PageController extends Controller
{
public function behaviors()
{
return array_merge(parent::behaviors(), [
'login' => [
'class' => LoginBehavior::className(),
],
]);
}
public function actionIndex()
{
if(\Yii::$app->request->isAjax){
$form = new CommonPageListForm();
$form->attributes = \Yii::$app->request->get();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->search();
return $this->responseHandler($data);
}
return $this->render('index');
}
public function actionEdit($id = 0)
{
$model = Page::findOne([
'cx_mch_id' => $this->cx_mch_id,
'is_delete' => 0,
'id' => $id,
]);
if($model == null)
$model = new Page();
if(\Yii::$app->request->isPost){
$form = new CommonPageEditForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$form->model = $model;
$data = $form->save();
return $this->responseHandler($data);
}
$return_url = \Yii::$app->request->referrer;
return $this->render('edit', [
'model' => $model,
'return_url' => $return_url,
]);
}
public function actionDelete()
{
if(!\Yii::$app->request->isPost){
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new CommonPageActionForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->delete();
return $this->responseHandler($data);
}
public function actionPublish()
{
if(!\Yii::$app->request->isPost){
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new CommonPageActionForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->publish();
return $this->responseHandler($data);
}
public function actionTrash()
{
if(!\Yii::$app->request->isPost){
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new CommonPageActionForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->trash();
return $this->responseHandler($data);
}
public function actionCancelTrash()
{
if(!\Yii::$app->request->isPost){
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new CommonPageActionForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->cancel_trash();
return $this->responseHandler($data);
}
public function actionCancelTop()
{
if(!\Yii::$app->request->isPost){
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new CommonPageActionForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->cancel_top();
return $this->responseHandler($data);
}
public function actionTop()
{
if(!\Yii::$app->request->isPost){
$data = $this->invaildRequest();
return $this->responseHandler($data);
}
$form = new CommonPageActionForm();
$form->attributes = \Yii::$app->request->post();
$form->cx_mch_id = $this->cx_mch_id;
$data = $form->top();
return $this->responseHandler($data);
}
}