HomeBanner.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\admin\controller\home;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\home\HomeBannerServer;
  5. class HomeBanner extends BaseController
  6. {
  7. /**
  8. * Notes:获取项目列表
  9. * @return \support\Response
  10. * User: YCP
  11. * Date: 2022/11/1
  12. */
  13. public function getBannerList()
  14. {
  15. $result = HomeBannerServer::getBannerList();
  16. return json_success($result, '成功');
  17. }
  18. /**
  19. * Notes:修改项目
  20. * @return \support\Response
  21. * User: YCP
  22. * Date: 2022/11/1
  23. */
  24. public function updateBanner()
  25. {
  26. $params = $this->request->post();
  27. $admin_id = $this->request->admin_id;
  28. $this->validateCheck('home\HomeBannerValidate',
  29. [
  30. 'banner_id' => $params['banner_id']?? '',
  31. 'banner_category_id' => $params['banner_category_id']?? '',
  32. 'banner_name' => $params['banner_name']?? '',
  33. 'banner_img' => $params['banner_img']?? '',
  34. ],
  35. 'update');
  36. $result = HomeBannerServer::updateBanner($params, $admin_id);
  37. return json_success($result, '修改成功');
  38. }
  39. /**
  40. * Notes:删除项目
  41. * @return \support\Response
  42. * User: YCP
  43. * Date: 2022/11/1
  44. */
  45. public function delBanner()
  46. {
  47. $banner_id = $this->request->get('banner_id');
  48. $admin_id = $this->request->admin_id;
  49. $this->validateCheck('home\HomeBannerValidate', ['banner_id' => $banner_id], 'info');
  50. $result = HomeBannerServer::delBanner($banner_id,$admin_id);
  51. if ($result){
  52. return json_success($result, '删除成功');
  53. }else{
  54. throw new \Exception('删除失败!');
  55. }
  56. }
  57. /**
  58. * Notes:添加项目
  59. * @return \support\Response
  60. * User: YCP
  61. * Date: 2022/11/1
  62. */
  63. public function addBanner()
  64. {
  65. $params = $this->request->post();
  66. $admin_id = $this->request->admin_id;
  67. $this->validateCheck('home\HomeBannerValidate',
  68. [
  69. 'banner_category_id' => $params['banner_category_id']?? '',
  70. 'banner_name' => $params['banner_name']?? '',
  71. 'banner_img' => $params['banner_img']?? '',
  72. ],
  73. 'create');
  74. $result = HomeBannerServer::insertBanner($params, $admin_id);
  75. return json_success($result, '添加成功');
  76. }
  77. /**
  78. * Notes:查询项目详情
  79. * @return \support\Response
  80. * User: YCP
  81. * Date: 2022/11/1
  82. */
  83. public function bannerInfo()
  84. {
  85. $banner_id = $this->request->get('banner_id');
  86. $this->validateCheck('home\HomeBannerValidate', ['banner_id' => $banner_id], 'info');
  87. $result = HomeBannerServer::bannerInfo($banner_id);
  88. return json_success($result, '成功');
  89. }
  90. }