Package.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace app\admin\controller\package;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\package\PackageServer;
  5. class Package extends BaseController
  6. {
  7. /**
  8. * Notes:获取权益包列表
  9. * @return \support\Response
  10. * User: QJF
  11. * Date: 2022/9/19
  12. */
  13. public function getPackageList()
  14. {
  15. $keywords = $this->request->get('keywords');
  16. [$page, $limit] = $this->getPage();
  17. $result = PackageServer::getPackageList($page, $limit,$keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:添加权益包
  22. * @return \support\Response
  23. * User: QJF
  24. * Date: 2022/9/19
  25. *
  26. */
  27. public function addPackage()
  28. {
  29. $param = $this->request->post();
  30. $this->validateCheck('package\PackageValidate',
  31. [
  32. 'package_name' => $param['package_name'],
  33. 'package_img' => $param['package_img'],
  34. 'package_logo' => $param['package_logo'],
  35. 'package_type' => $param['package_type'],
  36. 'package_content' => $param['package_content'],
  37. 'package_product_ids' => $param['package_product_ids'],
  38. ],
  39. 'add');
  40. $result = PackageServer::insertPackage($param);
  41. return json_success($result, '添加成功');
  42. }
  43. /**
  44. * Notes:修改权益包
  45. * @return \support\Response
  46. * User: QJF
  47. * Date: 2022/9/19
  48. */
  49. public function updatePackage()
  50. {
  51. $param = $this->request->post();
  52. $this->validateCheck('package\PackageValidate',
  53. [
  54. 'package_id' => $param['package_id'],
  55. ], 'update');
  56. $result = PackageServer::updatePackage($param);
  57. return json_success($result, '修改成功');
  58. }
  59. /**
  60. * Notes:删除权益包
  61. * @return \support\Response
  62. * User: QJF
  63. * Date: 2022/9/19
  64. */
  65. public function delPackage()
  66. {
  67. $package_id = $this->request->get('package_id');
  68. $this->validateCheck('package\PackageValidate', ['package_id' => $package_id], 'del');
  69. $result = PackageServer::delPackage($package_id);
  70. if ($result){
  71. return json_success($result, '删除成功');
  72. }else{
  73. throw new \Exception('删除失败!');
  74. }
  75. }
  76. /**
  77. * Notes:查看权益包详情
  78. * @return \support\Response
  79. * User: QJF
  80. * Date: 2022/9/19
  81. */
  82. public function infoPackage()
  83. {
  84. $package_id = $this->request->get('package_id');
  85. $this->validateCheck('package\PackageValidate', ['package_id' => $package_id], 'info');
  86. $result = PackageServer::infoPackage($package_id);
  87. if ($result){
  88. return json_success($result, '获取成功');
  89. }else{
  90. throw new \Exception('获取失败!');
  91. }
  92. }
  93. }