Subject.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace app\admin\controller\medical;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\medical\SubjectServer;
  5. class Subject extends BaseController
  6. {
  7. /**
  8. * Notes:获取预约科目列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/9/29
  12. */
  13. public function getSubjectList()
  14. {
  15. [$page,$limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = SubjectServer::getSubjectList($page,$limit,$keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:修改预约科目
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/9/29
  25. */
  26. public function updateSubject()
  27. {
  28. $subject_id = $this->request->post('subject_id');
  29. $subject_pid = $this->request->post('subject_pid','');
  30. $subject_name = $this->request->post('subject_name','');
  31. $subject_type = $this->request->post('subject_type','');
  32. $subject_sort = $this->request->post('subject_sort','');
  33. $this->validateCheck('medical\SubjectValidate', ['subject_id'=>$subject_id], 'update');
  34. $result = SubjectServer::updateSubject($subject_id, $subject_pid, $subject_name, $subject_type, $subject_sort);
  35. return json_success($result, '修改成功');
  36. }
  37. /**
  38. * Notes:删除预约科目
  39. * @return \support\Response
  40. * User: ZQ
  41. * Date: 2022/9/27
  42. */
  43. public function delSubject()
  44. {
  45. $subject_id = $this->request->get('subject_id');
  46. $this->validateCheck('medical\SubjectValidate', ['subject_id' => $subject_id], 'info');
  47. //查询科目下是否有子集
  48. $children = SubjectServer::childrenCheck($subject_id);
  49. if (!empty($children)){
  50. throw new \Exception('该预约科目下有子科目,请先删除子科目!');
  51. }
  52. $result = SubjectServer::delSubject($subject_id);
  53. if ($result){
  54. return json_success($result, '删除成功');
  55. }else{
  56. throw new \Exception('删除失败!');
  57. }
  58. }
  59. /**
  60. * Notes:添加预约科目
  61. * @return \support\Response
  62. * User: ZQ
  63. * Date: 2022/9/27
  64. */
  65. public function addSubject()
  66. {
  67. $subject_pid = $this->request->post('subject_pid');
  68. $subject_name = $this->request->post('subject_name');
  69. $subject_type = $this->request->post('subject_type');
  70. $subject_sort = $this->request->post('subject_sort');
  71. $this->validateCheck('medical\SubjectValidate', ['subject_pid' => $subject_pid, 'subject_name' => $subject_name, 'subject_type' => $subject_type], 'add');
  72. $result = SubjectServer::insertSubject($subject_pid, $subject_name, $subject_type, $subject_sort);
  73. return json_success($result, '添加成功');
  74. }
  75. /**
  76. * Notes:查询预约科目详情
  77. * @return \support\Response
  78. * User: ZQ
  79. * Date: 2022/9/27
  80. */
  81. public function subjectInfo()
  82. {
  83. $subject_id = $this->request->get('subject_id');
  84. $this->validateCheck('medical\SubjectValidate', ['subject_id' => $subject_id], 'info');
  85. $result = SubjectServer::subjectInfo($subject_id);
  86. if (!empty($result))
  87. return json_success($result, '成功');
  88. }
  89. /**
  90. * Notes:添加医生关联科目列表
  91. * @return \support\Response
  92. * User: yym
  93. * Date: 2022/10/26
  94. */
  95. public function getDoctorSubjectList()
  96. {
  97. return json_success(SubjectServer::getDoctorSubjectList(), '获取成功');
  98. }
  99. }