Book.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\BookServer;
  5. class Book extends BaseController
  6. {
  7. /**
  8. * Notes:获取万悦书院课程列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/10/14
  12. */
  13. public function getBookList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = BookServer::getBookList($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 getBookAll()
  27. {
  28. $result = BookServer::getBookAll();
  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 updateBook()
  38. {
  39. $life_book_id = $this->request->post('life_book_id');
  40. $life_book_name = $this->request->post('life_book_name');
  41. $life_book_title = $this->request->post('life_book_title');
  42. $life_book_time = $this->request->post('life_book_time');
  43. $life_book_week = $this->request->post('life_book_week');
  44. $life_book_category_id = $this->request->post('life_book_category_id');
  45. $life_book_teacher_id = $this->request->post('life_book_teacher_id');
  46. $life_book_num = $this->request->post('life_book_num');
  47. $life_book_long = $this->request->post('life_book_long','');
  48. $life_book_week = $this->request->post('life_book_week','');
  49. $life_book_status = $this->request->post('life_book_status');
  50. $life_book_img = $this->request->post('life_book_img');
  51. $life_book_type = $this->request->post('life_book_type');
  52. $admin_id = $this->request->admin_id;
  53. $this->validateCheck('life\BookValidate', ['life_book_id'=>$life_book_id,'life_book_name'=>$life_book_name,'life_book_title'=>$life_book_title,'life_book_time'=>$life_book_time,'life_book_category_id'=>$life_book_category_id,'life_book_teacher_id'=>$life_book_teacher_id,'life_book_num'=>$life_book_num,'life_book_status'=>$life_book_status,'life_book_img'=>$life_book_img,'life_book_type'=>$life_book_type], 'update');
  54. $result = BookServer::updateBook($life_book_id, $life_book_name, $life_book_title, $life_book_time, $life_book_category_id, $life_book_teacher_id, $life_book_num, $life_book_status, $life_book_img, $life_book_type, $life_book_long, $life_book_week, $admin_id);
  55. return json_success($result, '修改成功');
  56. }
  57. /**
  58. * Notes:删除课程
  59. * @return \support\Response
  60. * User: ZQ
  61. * Date: 2022/9/13
  62. */
  63. public function delBook()
  64. {
  65. $life_book_id = $this->request->get('life_book_id');
  66. $admin_id = $this->request->admin_id;
  67. $this->validateCheck('life\BookValidate', ['life_book_id' => $life_book_id], 'info');
  68. $result = BookServer::delBook($life_book_id,$admin_id);
  69. if ($result){
  70. return json_success($result, '删除成功');
  71. }else{
  72. throw new \Exception('删除失败!');
  73. }
  74. }
  75. /**
  76. * Notes:添加课程
  77. * @return \support\Response
  78. * User: ZQ
  79. * Date: 2022/9/13
  80. */
  81. public function addBook()
  82. {
  83. $life_book_name = $this->request->post('life_book_name');
  84. $life_book_title = $this->request->post('life_book_title');
  85. $life_book_time = $this->request->post('life_book_time');
  86. $life_book_week = $this->request->post('life_book_week');
  87. $life_book_category_id = $this->request->post('life_book_category_id');
  88. $life_book_teacher_id = $this->request->post('life_book_teacher_id');
  89. $life_book_num = $this->request->post('life_book_num');
  90. $life_book_long = $this->request->post('life_book_long','');
  91. $life_book_week = $this->request->post('life_book_week','');
  92. $life_book_status = $this->request->post('life_book_status');
  93. $life_book_img = $this->request->post('life_book_img');
  94. $life_book_type = $this->request->post('life_book_type');
  95. $admin_id = $this->request->admin_id;
  96. $this->validateCheck('life\BookValidate', ['life_book_name'=>$life_book_name,'life_book_title'=>$life_book_title,'life_book_time'=>$life_book_time,'life_book_category_id'=>$life_book_category_id,'life_book_teacher_id'=>$life_book_teacher_id,'life_book_num'=>$life_book_num,'life_book_status'=>$life_book_status,'life_book_img'=>$life_book_img,'life_book_type'=>$life_book_type], 'create');
  97. $result = BookServer::insertBook($life_book_name, $life_book_title, $life_book_time, $life_book_category_id, $life_book_teacher_id, $life_book_num, $life_book_status, $life_book_img, $life_book_type, $life_book_long, $life_book_week, $admin_id);
  98. return json_success($result, '添加成功');
  99. }
  100. /**
  101. * Notes:查询课程详情
  102. * @return \support\Response
  103. * User: ZQ
  104. * Date: 2022/9/13
  105. */
  106. public function bookInfo()
  107. {
  108. $life_book_id = $this->request->get('life_book_id');
  109. $this->validateCheck('life\BookValidate', ['life_book_id' => $life_book_id], 'info');
  110. $result = BookServer::bookInfo($life_book_id);
  111. return json_success($result, '成功');
  112. }
  113. /**
  114. * Notes:课程上架下架
  115. * @return \support\Response
  116. * User: ZQ
  117. * Date: 2022/10/09
  118. */
  119. public function updateStatus()
  120. {
  121. $life_book_id = $this->request->get('life_book_id');
  122. $life_book_status = $this->request->get('life_book_status');
  123. $this->validateCheck('life\BookValidate', ['life_book_id' => $life_book_id], 'info');
  124. $result = BookServer::updateStatus($life_book_id, $life_book_status);
  125. return json_success($result, '修改成功');
  126. }
  127. }