some refactor
This commit is contained in:
parent
e00f2b84ea
commit
7a5a41cd14
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace frontend\modules\api\controllers;
|
namespace frontend\modules\api\controllers;
|
||||||
|
|
||||||
|
|
||||||
use common\services\ManagerService;
|
use common\services\ManagerService;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
@ -36,8 +35,7 @@ class ManagerController extends ApiController
|
|||||||
*/
|
*/
|
||||||
public function actionGetManagerEmployeesList($manager_id): array
|
public function actionGetManagerEmployeesList($manager_id): array
|
||||||
{
|
{
|
||||||
if(empty($manager_id) or !is_numeric($manager_id))
|
if (empty($manager_id) or !is_numeric($manager_id)) {
|
||||||
{
|
|
||||||
throw new NotFoundHttpException('Incorrect manager ID');
|
throw new NotFoundHttpException('Incorrect manager ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +53,7 @@ class ManagerController extends ApiController
|
|||||||
*/
|
*/
|
||||||
public function actionGetManager($manager_id): array
|
public function actionGetManager($manager_id): array
|
||||||
{
|
{
|
||||||
if(empty($manager_id) or !is_numeric($manager_id))
|
if (empty($manager_id) or !is_numeric($manager_id)) {
|
||||||
{
|
|
||||||
throw new NotFoundHttpException('Incorrect manager ID');
|
throw new NotFoundHttpException('Incorrect manager ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ class TaskController extends ApiController
|
|||||||
if ($taskModel->errors) {
|
if ($taskModel->errors) {
|
||||||
throw new ServerErrorHttpException(json_encode($taskModel->errors));
|
throw new ServerErrorHttpException(json_encode($taskModel->errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $taskModel;
|
return $taskModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,16 +41,12 @@ class TaskController extends ApiController
|
|||||||
public function actionGetTaskList($project_id = null): array
|
public function actionGetTaskList($project_id = null): array
|
||||||
{
|
{
|
||||||
$tasks = array();
|
$tasks = array();
|
||||||
if ($project_id)
|
if ($project_id) {
|
||||||
{
|
if (empty($project_id) or !is_numeric($project_id)) {
|
||||||
if(empty($project_id) or !is_numeric($project_id))
|
|
||||||
{
|
|
||||||
throw new NotFoundHttpException('Incorrect project ID');
|
throw new NotFoundHttpException('Incorrect project ID');
|
||||||
}
|
}
|
||||||
$tasks = TaskService::getTaskListByProject($project_id);
|
$tasks = TaskService::getTaskListByProject($project_id);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$tasks = TaskService::getTaskList($project_id);
|
$tasks = TaskService::getTaskList($project_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +61,7 @@ class TaskController extends ApiController
|
|||||||
*/
|
*/
|
||||||
public function actionGetTask($task_id): Task
|
public function actionGetTask($task_id): Task
|
||||||
{
|
{
|
||||||
if(empty($task_id) or !is_numeric($task_id))
|
if (empty($task_id) or !is_numeric($task_id)) {
|
||||||
{
|
|
||||||
throw new NotFoundHttpException('Incorrect task ID');
|
throw new NotFoundHttpException('Incorrect task ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +81,7 @@ class TaskController extends ApiController
|
|||||||
public function actionUpdate(): ?Task
|
public function actionUpdate(): ?Task
|
||||||
{
|
{
|
||||||
$params = Yii::$app->request->getBodyParams();
|
$params = Yii::$app->request->getBodyParams();
|
||||||
if (empty ($params['task_id']) or !TaskService::taskExists($params['task_id']))
|
if (empty ($params['task_id']) or !TaskService::taskExists($params['task_id'])) {
|
||||||
{
|
|
||||||
throw new NotFoundHttpException('The task does not exist');
|
throw new NotFoundHttpException('The task does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,19 +9,8 @@ use yii\rest\Controller;
|
|||||||
use yii\web\BadRequestHttpException;
|
use yii\web\BadRequestHttpException;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class TaskUserController extends Controller
|
class TaskUserController extends ApiController
|
||||||
{
|
{
|
||||||
public function behaviors(): array
|
|
||||||
{
|
|
||||||
$behaviors = parent::behaviors();
|
|
||||||
|
|
||||||
$behaviors['authenticator']['authMethods'] = [
|
|
||||||
HttpBearerAuth::className(),
|
|
||||||
];
|
|
||||||
|
|
||||||
return $behaviors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function verbs(): array
|
public function verbs(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Loading…
Reference in New Issue
Block a user