123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?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'],
- 'update' => ['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
- ];
- }
- /**
- * [修改队列]
- * @author: hanguangxu
- * @return array
- * @throws Exception
- */
- public function actionUpdate()
- {
- $model = new TopicForm();
- $model->setScenario('update_topic');
- $model->load(['TopicForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->updateTopic();
- } else {
- $model->handleError();//处理验证失败
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- }
|