12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace backend\controllers;
- use backend\forms\QueueForm;
- use backend\forms\TopicForm;
- use components\Exception;
- use yii\helpers\ArrayHelper;
- use Yii;
- class TopicController 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 TopicForm();
- $model->setScenario('create_topic');
- $model->load(['TopicForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->createTopic();
- } 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->getTopicList();
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- }
|