BookCourse.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\BookCourseServer;
  5. class BookCourse extends BaseController
  6. {
  7. /**
  8. * Notes:获取万悦书院课程目录列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/10/14
  12. */
  13. public function getBookCourseList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = BookCourseServer::getBookCourseList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有课程目录
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/10/14
  25. */
  26. public function getBookCourseAll()
  27. {
  28. $result = BookCourseServer::getBookCourseAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改万悦书院
  33. * @return \support\Response
  34. * User: ZQ
  35. * Date: 2022/10/09
  36. */
  37. public function updateBookCourse()
  38. {
  39. $course_id = $this->request->post('course_id');
  40. $course_name = $this->request->post('course_name');
  41. $course_time = $this->request->post('course_time');
  42. $course_book_id = $this->request->post('course_book_id');
  43. $course_price = $this->request->post('course_price');
  44. $course_status = $this->request->post('course_status');
  45. $admin_id = $this->request->admin_id;
  46. $this->validateCheck('life\BookCourseValidate', ['course_id'=>$course_id,'course_name'=>$course_name,'course_time'=>$course_time,'course_book_id'=>$course_book_id,'course_price'=>$course_price,'course_status'=>$course_status], 'update');
  47. $result = BookCourseServer::updateBookCourse($course_id, $course_name, $course_time, $course_book_id, $course_price, $course_status, $admin_id);
  48. return json_success($result, '修改成功');
  49. }
  50. /**
  51. * Notes:删除课程目录
  52. * @return \support\Response
  53. * User: ZQ
  54. * Date: 2022/9/13
  55. */
  56. public function delBookCourse()
  57. {
  58. $course_id = $this->request->get('course_id');
  59. $admin_id = $this->request->admin_id;
  60. $this->validateCheck('life\BookCourseValidate', ['course_id' => $course_id], 'info');
  61. $result = BookCourseServer::delBookCourse($course_id,$admin_id);
  62. if ($result){
  63. return json_success($result, '删除成功');
  64. }else{
  65. throw new \Exception('删除失败!');
  66. }
  67. }
  68. /**
  69. * Notes:添加课程目录
  70. * @return \support\Response
  71. * User: ZQ
  72. * Date: 2022/9/13
  73. */
  74. public function addBookCourse()
  75. {
  76. $course_name = $this->request->post('course_name');
  77. $course_time = $this->request->post('course_time');
  78. $course_book_id = $this->request->post('course_book_id');
  79. $course_price = $this->request->post('course_price');
  80. $course_status = $this->request->post('course_status');
  81. $admin_id = $this->request->admin_id;
  82. $this->validateCheck('life\BookCourseValidate', ['course_name'=>$course_name,'course_time'=>$course_time,'course_book_id'=>$course_book_id,'course_price'=>$course_price,'course_status'=>$course_status], 'create');
  83. $result = BookCourseServer::insertBookCourse($course_name, $course_time, $course_book_id, $course_price, $course_status, $admin_id);
  84. return json_success($result, '添加成功');
  85. }
  86. /**
  87. * Notes:查询课程目录详情
  88. * @return \support\Response
  89. * User: ZQ
  90. * Date: 2022/9/13
  91. */
  92. public function courseInfo()
  93. {
  94. $course_id = $this->request->get('course_id');
  95. $this->validateCheck('life\BookCourseValidate', ['course_id' => $course_id], 'info');
  96. $result = BookCourseServer::courseInfo($course_id);
  97. return json_success($result, '成功');
  98. }
  99. /**
  100. * Notes:课程目录上架下架
  101. * @return \support\Response
  102. * User: ZQ
  103. * Date: 2022/10/09
  104. */
  105. public function updateStatus()
  106. {
  107. $course_id = $this->request->get('course_id');
  108. $course_status = $this->request->get('course_status');
  109. $this->validateCheck('life\BookCourseValidate', ['course_id' => $course_id], 'info');
  110. $result = BookCourseServer::updateStatus($course_id, $course_status);
  111. return json_success($result, '修改成功');
  112. }
  113. }