Teacher.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\TeacherServer;
  5. class Teacher extends BaseController
  6. {
  7. /**
  8. * Notes:获取教师列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/10/25
  12. */
  13. public function getTeacherList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = TeacherServer::getTeacherList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有教师
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/10/25
  25. */
  26. public function getTeacherAll()
  27. {
  28. $result = TeacherServer::getTeacherAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改教师
  33. * @return \support\Response
  34. * User: ZQ
  35. * Date: 2022/10/25
  36. */
  37. public function updateTeacher()
  38. {
  39. $teacher_id = $this->request->post('teacher_id');
  40. $teacher_name = $this->request->post('teacher_name');
  41. $teacher_img = $this->request->post('teacher_img');
  42. $teacher_title = $this->request->post('teacher_title','');
  43. $teacher_positional = $this->request->post('teacher_positional');
  44. $admin_id = $this->request->admin_id;
  45. $this->validateCheck('life\TeacherValidate', ['teacher_id'=>$teacher_id,'teacher_name'=>$teacher_name,'teacher_img'=>$teacher_img,'teacher_title'=>$teacher_title], 'update');
  46. $result = TeacherServer::updateTeacher($teacher_id, $teacher_name, $teacher_img, $teacher_title, $teacher_positional, $admin_id);
  47. return json_success($result, '修改成功');
  48. }
  49. /**
  50. * Notes:删除教师
  51. * @return \support\Response
  52. * User: ZQ
  53. * Date: 2022/10/25
  54. */
  55. public function delTeacher()
  56. {
  57. $teacher_id = $this->request->get('teacher_id');
  58. $admin_id = $this->request->admin_id;
  59. $this->validateCheck('life\TeacherValidate', ['teacher_id' => $teacher_id], 'info');
  60. $result = TeacherServer::delTeacher($teacher_id,$admin_id);
  61. if ($result){
  62. return json_success($result, '删除成功');
  63. }else{
  64. throw new \Exception('删除失败!');
  65. }
  66. }
  67. /**
  68. * Notes:添加教师
  69. * @return \support\Response
  70. * User: ZQ
  71. * Date: 2022/10/25
  72. */
  73. public function addTeacher()
  74. {
  75. $teacher_name = $this->request->post('teacher_name');
  76. $teacher_img = $this->request->post('teacher_img');
  77. $teacher_title = $this->request->post('teacher_title');
  78. $teacher_positional = $this->request->post('teacher_positional');
  79. $admin_id = $this->request->admin_id;
  80. $this->validateCheck('life\TeacherValidate', ['teacher_name'=>$teacher_name,'teacher_img'=>$teacher_img,'teacher_title'=>$teacher_title], 'create');
  81. $result = TeacherServer::insertTeacher($teacher_name, $teacher_img, $teacher_title, $teacher_positional, $admin_id);
  82. return json_success($result, '添加成功');
  83. }
  84. /**
  85. * Notes:查询教师详情
  86. * @return \support\Response
  87. * User: ZQ
  88. * Date: 2022/10/25
  89. */
  90. public function teacherInfo()
  91. {
  92. $teacher_id = $this->request->get('teacher_id');
  93. $this->validateCheck('life\TeacherValidate', ['teacher_id' => $teacher_id], 'info');
  94. $result = TeacherServer::teacherInfo($teacher_id);
  95. return json_success($result, '成功');
  96. }
  97. }