This commit is contained in:
Aether
2025-09-25 08:48:23 +08:00
parent 8be88311d4
commit f286e18e71
9 changed files with 57 additions and 347 deletions

View File

@@ -26,11 +26,6 @@ class TeacherController extends AetherController
#[Inject]
protected RequestInterface $request;
protected function getService(): AetherCrudService
{
return $this->service;
}
/**
* 教师列表.
*/
@@ -78,4 +73,9 @@ class TeacherController extends AetherController
{
return AetherResponse::success($this->service->delete($id), '教师删除成功');
}
protected function getService(): AetherCrudService
{
return $this->service;
}
}

View File

@@ -28,16 +28,6 @@ class CampusService extends AetherCrudService implements CampusServiceInterface
#[Inject]
protected CampusValidator $validator;
protected function getModel(): AetherModel
{
return $this->model;
}
protected function getValidator(): AetherValidator
{
return $this->validator;
}
public function getCampusById(int $id): array
{
$campus = Campus::find($id);
@@ -81,4 +71,14 @@ class CampusService extends AetherCrudService implements CampusServiceInterface
->get(['id', 'name', 'city'])
->toArray();
}
protected function getModel(): AetherModel
{
return $this->model;
}
protected function getValidator(): AetherValidator
{
return $this->validator;
}
}

View File

@@ -28,16 +28,6 @@ class TeacherService extends AetherCrudService implements TeacherServiceInterfac
#[Inject]
protected TeacherValidator $validator;
protected function getModel(): AetherModel
{
return $this->model;
}
protected function getValidator(): AetherValidator
{
return $this->validator;
}
public function getTeacherById(int $id): array
{
$teacher = Teacher::find($id);
@@ -106,4 +96,14 @@ class TeacherService extends AetherCrudService implements TeacherServiceInterfac
'list' => $list,
];
}
protected function getModel(): AetherModel
{
return $this->model;
}
protected function getValidator(): AetherValidator
{
return $this->validator;
}
}

View File

@@ -28,7 +28,7 @@ class CampusValidator extends AetherValidator
'parent_id.required' => '父级ID不能为空',
'level.required' => '层级不能为空',
'level.in' => '层级只能是1、2、3',
]
],
],
'update' => [
'rules' => [
@@ -43,7 +43,7 @@ class CampusValidator extends AetherValidator
'messages' => [
'id.required' => '校区ID不能为空',
'level.in' => '层级只能是1、2、3',
]
],
],
'query' => [
'rules' => [
@@ -57,8 +57,8 @@ class CampusValidator extends AetherValidator
],
'messages' => [
'level.in' => '层级只能是1、2、3',
]
]
],
],
];
}
}

View File

@@ -29,7 +29,7 @@ class TeacherValidator extends AetherValidator
'age.max' => '年龄不能大于65岁',
'gender.in' => '性别只能是1(男)或2(女)',
'avatar.url' => '头像必须是有效的URL',
]
],
],
'update' => [
'rules' => [
@@ -47,7 +47,7 @@ class TeacherValidator extends AetherValidator
'age.max' => '年龄不能大于65岁',
'gender.in' => '性别只能是1(男)或2(女)',
'avatar.url' => '头像必须是有效的URL',
]
],
],
'query' => [
'rules' => [
@@ -57,9 +57,9 @@ class TeacherValidator extends AetherValidator
'major_subject' => 'nullable|string|max:100',
'status' => 'nullable|integer|in:0,1',
'page' => 'nullable|integer|min:1',
'size' => 'nullable|integer|min:1|max'
'size' => 'nullable|integer|min:1|max',
],
]
],
];
}
}
}