diff --git a/app/Controller/TeacherController.php b/app/Controller/TeacherController.php index 2c96385..b4fa403 100644 --- a/app/Controller/TeacherController.php +++ b/app/Controller/TeacherController.php @@ -10,11 +10,14 @@ use App\Exception\BusinessException; use App\Model\Teacher; use App\Validator\TeacherValidator; use Hyperf\Di\Annotation\Inject; +use Hyperf\HttpServer\Annotation\Controller; +use Hyperf\HttpServer\Annotation\DeleteMapping; +use Hyperf\HttpServer\Annotation\GetMapping; +use Hyperf\HttpServer\Annotation\PostMapping; +use Hyperf\HttpServer\Annotation\PutMapping; use Hyperf\HttpServer\Contract\RequestInterface; -/** - * @Controller(prefix="/api/v1/teacher") - */ +#[Controller(prefix: '/api/v1/')] class TeacherController extends AetherController { #[Inject] @@ -22,8 +25,8 @@ class TeacherController extends AetherController /** * 创建教师. - * @PostMapping(path="") */ + #[PostMapping(path: 'teacher')] public function create(RequestInterface $request): array { $data = $request->all(); @@ -41,8 +44,8 @@ class TeacherController extends AetherController /** * 获取教师详情. - * @GetMapping(path="/{id}") */ + #[GetMapping(path: 'teacher/{id}')] public function get(int $id): array { $teacher = Teacher::find($id); @@ -55,8 +58,8 @@ class TeacherController extends AetherController /** * 更新教师信息. - * @PutMapping(path="/{id}") */ + #[PutMapping(path: 'teacher/{id}')] public function update(int $id, RequestInterface $request): array { $data = $request->all(); @@ -80,8 +83,8 @@ class TeacherController extends AetherController /** * 删除教师. - * @DeleteMapping(path="/{id}") */ + #[DeleteMapping(path: 'teacher/{id}')] public function delete(int $id): array { $teacher = Teacher::find($id); @@ -95,8 +98,8 @@ class TeacherController extends AetherController /** * 教师列表. - * @GetMapping(path="/list") */ + #[GetMapping(path: 'teachers')] public function list(RequestInterface $request): array { $data = $request->all(); @@ -139,8 +142,8 @@ class TeacherController extends AetherController /** * 搜索教师. - * @GetMapping(path="/search") */ + #[GetMapping(path: 'teacher')] public function search(RequestInterface $request): array { $keyword = $request->input('keyword', '');