177 lines
5.3 KiB
PHP
177 lines
5.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年6月30日
|
|
* @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\CommonNoticeActionForm;
|
|
use app\models\common\cms\CommonNoticeEditForm;
|
|
use app\models\common\cms\CommonNoticeListForm;
|
|
use app\models\cms\Notice;
|
|
|
|
|
|
|
|
class NoticeController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function actionIndex()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new CommonNoticeListForm();
|
|
$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 = Notice::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
]);
|
|
if($model == null)
|
|
$model = new Notice();
|
|
if(\Yii::$app->request->isPost){
|
|
$form = new CommonNoticeEditForm();
|
|
$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 CommonNoticeActionForm();
|
|
$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 CommonNoticeActionForm();
|
|
$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 CommonNoticeActionForm();
|
|
$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 CommonNoticeActionForm();
|
|
$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 CommonNoticeActionForm();
|
|
$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 CommonNoticeActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->top();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionShowIndex()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonNoticeActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->show_index();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionHideIndex()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonNoticeActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->hide_index();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
}
|
|
|