| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace internship\controller;
- use n2n\web\http\controller\ControllerAdapter;
- use n2n\context\attribute\Inject;
- use internship\model\CategoryDao;
- use n2n\web\http\controller\ParamBody;
- use internship\bo\Article;
- use n2n\web\http\PageNotFoundException;
- class CategoryApiController extends ControllerAdapter {
- #[Inject]
- private CategoryDao $categoryDao;
- function getDoCategory(int $categoryId): void {
- $category = $this->categoryDao->getCategoryById($categoryId);
- if ($category === null) {
- throw new PageNotFoundException();
- } else {
- $this->sendJson($category);
- }
- }
- function getDoCategories(): void {
- $categories = $this->categoryDao->getCategories();
- $this->sendJson($categories);
- }
- function postDoCategory(ParamBody $body): void {
- }
- function putDoCategory(int $articleId, ParamBody $body): void {
- }
- function deleteDoCategory(int $articleId): void {
- }
- }
|