composer包
This commit is contained in:
11
app/Exception/CampusNotFound.php
Normal file
11
app/Exception/CampusNotFound.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
use Aether\Exception\AetherException;
|
||||
|
||||
class CampusNotFound extends AetherException
|
||||
{
|
||||
protected $code = 404001;
|
||||
protected $message = '文章不存在';
|
||||
}
|
||||
14
app/Exception/TeacherNotFound.php
Normal file
14
app/Exception/TeacherNotFound.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
use Aether\Exception\AetherException;
|
||||
|
||||
class TeacherNotFound extends AetherException
|
||||
{
|
||||
protected $code = 40400;
|
||||
|
||||
protected $message = '教师不存在';
|
||||
}
|
||||
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\JsonRpc\Service;
|
||||
|
||||
use Aether\Exception\BusinessException;
|
||||
use App\Exception\CampusNotFound;
|
||||
use App\Exception\TeacherNotFound;
|
||||
use App\Model\Campus;
|
||||
use App\Model\Teacher;
|
||||
use App\Validator\CampusValidator;
|
||||
@@ -45,7 +47,7 @@ class DataService implements DataServiceInterface
|
||||
{
|
||||
$campus = $this->campusModel->find($id);
|
||||
if (! $campus || $campus->status != 1) {
|
||||
throw new BusinessException('校区不存在或已禁用', 10001);
|
||||
throw new CampusNotFound('校区不存在或已禁用');
|
||||
}
|
||||
return $campus->toArray();
|
||||
}
|
||||
@@ -122,7 +124,7 @@ class DataService implements DataServiceInterface
|
||||
{
|
||||
$teacher = $this->teacherModel->find($id);
|
||||
if (! $teacher || $teacher->status != 1) {
|
||||
throw new BusinessException('教师不存在或已禁用', 10001);
|
||||
throw new TeacherNotFound();
|
||||
}
|
||||
return $teacher->toArray();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user