1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace backend\controllers;
- use backend\forms\QueueForm;
- use backend\forms\SubscribeForm;
- use backend\forms\TopicForm;
- use components\Exception;
- use yii\helpers\ArrayHelper;
- use Yii;
- class SubscribeController extends BaseController
- {
- /**
- * behaviors
- * @return array
- */
- public function behaviors()
- {
- return ArrayHelper::merge(parent::behaviors(), [
- 'verbs' => [
- 'class' => \yii\filters\VerbFilter::className(),
- 'actions' => [
- 'list' => ['GET'],
- 'create' => ['POST'],
- 'delete' => ['POST'],
- ],
- ],
- ]);
- }
- /**
- * [创建队列]
- * @author: libingke
- * @return array
- * @throws Exception
- */
- public function actionCreate()
- {
- $model = new SubscribeForm();
- $model->setScenario('create_subscribe');
- $model->load(['SubscribeForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->Subscribe();
- } else {
- $model->handleError();//处理验证失败
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- /**
- * 删除队列
- * @author: libingke
- * @return array
- * @throws Exception
- */
- public function actionDelete()
- {
- $model = new TopicForm();
- $model->setScenario('delete_topic');
- $model->load(['TopicForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->deleteTopic();
- } else {
- $model->handleError();
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- /**
- * 获取队列列表
- * @author: libingke
- */
- public function actionList()
- {
- $model = new TopicForm();
- $data = $model->getQueueList();
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- }
|