composer包

This commit is contained in:
Aether
2025-09-30 15:27:07 +08:00
parent 9a1c120c4f
commit 1c0989d52d
34 changed files with 92 additions and 2509 deletions

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Exception;
use Aether\Exception\AetherException;
class CampusNotFound extends AetherException
{
protected $code = 404001;
protected $message = '文章不存在';
}

View 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 = '教师不存在';
}

View File

@@ -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();
}