123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace app\admin\controller\life;
- use app\admin\controller\BaseController;
- use app\admin\server\life\TeacherServer;
- class Teacher extends BaseController
- {
- /**
- * Notes:获取教师列表
- * @return \support\Response
- * User: ZQ
- * Date: 2022/10/25
- */
- public function getTeacherList()
- {
- [$page, $limit] = $this->getPage();
- $keywords = $this->request->get('keywords');
- $result = TeacherServer::getTeacherList($page, $limit, $keywords);
- return json_success($result, '成功');
- }
- /**
- * Notes:获取所有教师
- * @return \support\Response
- * User: ZQ
- * Date: 2022/10/25
- */
- public function getTeacherAll()
- {
- $result = TeacherServer::getTeacherAll();
- return json_success($result, '成功');
- }
- /**
- * Notes:修改教师
- * @return \support\Response
- * User: ZQ
- * Date: 2022/10/25
- */
- public function updateTeacher()
- {
- $teacher_id = $this->request->post('teacher_id');
- $teacher_name = $this->request->post('teacher_name');
- $teacher_img = $this->request->post('teacher_img');
- $teacher_title = $this->request->post('teacher_title','');
- $teacher_positional = $this->request->post('teacher_positional');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('life\TeacherValidate', ['teacher_id'=>$teacher_id,'teacher_name'=>$teacher_name,'teacher_img'=>$teacher_img,'teacher_title'=>$teacher_title], 'update');
- $result = TeacherServer::updateTeacher($teacher_id, $teacher_name, $teacher_img, $teacher_title, $teacher_positional, $admin_id);
- return json_success($result, '修改成功');
- }
- /**
- * Notes:删除教师
- * @return \support\Response
- * User: ZQ
- * Date: 2022/10/25
- */
- public function delTeacher()
- {
- $teacher_id = $this->request->get('teacher_id');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('life\TeacherValidate', ['teacher_id' => $teacher_id], 'info');
- $result = TeacherServer::delTeacher($teacher_id,$admin_id);
- if ($result){
- return json_success($result, '删除成功');
- }else{
- throw new \Exception('删除失败!');
- }
- }
- /**
- * Notes:添加教师
- * @return \support\Response
- * User: ZQ
- * Date: 2022/10/25
- */
- public function addTeacher()
- {
- $teacher_name = $this->request->post('teacher_name');
- $teacher_img = $this->request->post('teacher_img');
- $teacher_title = $this->request->post('teacher_title');
- $teacher_positional = $this->request->post('teacher_positional');
- $admin_id = $this->request->admin_id;
- $this->validateCheck('life\TeacherValidate', ['teacher_name'=>$teacher_name,'teacher_img'=>$teacher_img,'teacher_title'=>$teacher_title], 'create');
- $result = TeacherServer::insertTeacher($teacher_name, $teacher_img, $teacher_title, $teacher_positional, $admin_id);
- return json_success($result, '添加成功');
- }
- /**
- * Notes:查询教师详情
- * @return \support\Response
- * User: ZQ
- * Date: 2022/10/25
- */
- public function teacherInfo()
- {
- $teacher_id = $this->request->get('teacher_id');
- $this->validateCheck('life\TeacherValidate', ['teacher_id' => $teacher_id], 'info');
- $result = TeacherServer::teacherInfo($teacher_id);
- return json_success($result, '成功');
- }
- }
|