123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- namespace backend\controllers;
- use backend\forms\QueueForm;
- use components\Exception;
- use yii\helpers\ArrayHelper;
- use Yii;
- class QueueController 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 QueueForm();
- $model->setScenario('create_queue');
- $model->load(['QueueForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->createQueue();
- } else {
- $model->handleError();//处理验证失败
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- /**
- * 删除队列
- * @author: libingke
- * @return array
- * @throws Exception
- */
- public function actionDelete()
- {
- $model = new QueueForm();
- $model->setScenario('delete_queue');
- $model->load(['QueueForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->deleteQueue();
- } else {
- $model->handleError();
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- /**
- * 获取队列列表
- * @author: libingke
- */
- public function actionList()
- {
- $model = new QueueForm();
- $data = $model->getQueueList();
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
-
- /**
- * 移除并重置队列
- * @author: hanguangxu
- * @return array
- * @throws Exception
- */
- public function actionUpdate(){
- $model = new QueueForm();
- $model->setScenario('update_queue');
- $model->load(['QueueForm' => Yii::$app->request->post()]);
- $data = [];
- if ($model->validate()) {
- $data = $model->updateQueue();
- } else {
- $model->handleError();//处理验证失败
- }
- return [
- 'code' => 200,
- 'message' => Yii::t('error', 200),
- 'data' => $data
- ];
- }
- }
|