MemberLevel.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\member;
  12. use app\service\admin\member\MemberLevelService;
  13. use core\base\BaseAdminController;
  14. use think\db\exception\DataNotFoundException;
  15. use think\db\exception\DbException;
  16. use think\db\exception\ModelNotFoundException;
  17. use think\Response;
  18. class MemberLevel extends BaseAdminController
  19. {
  20. /**
  21. * 会员等级分页列表
  22. * @return Response
  23. */
  24. public function pages()
  25. {
  26. $data = $this->request->params([
  27. [ 'level_name', '' ],
  28. ]);
  29. return success(( new MemberLevelService() )->getPage($data));
  30. }
  31. /**
  32. * 会员等级列表
  33. * @return Response
  34. */
  35. public function lists()
  36. {
  37. $data = $this->request->params([
  38. [ 'level_name', '' ],
  39. ]);
  40. return success(( new MemberLevelService() )->getList($data));
  41. }
  42. /**
  43. * 会员等级详情
  44. * @param int $id
  45. * @return Response
  46. */
  47. public function info(int $id)
  48. {
  49. return success(( new MemberLevelService() )->getInfo($id));
  50. }
  51. /**
  52. * 添加会员等级
  53. * @return Response
  54. */
  55. public function add()
  56. {
  57. $data = $this->request->params([
  58. [ 'level_name', '' ],
  59. [ 'growth', 0 ],
  60. [ 'remark', '' ],
  61. [ 'level_benefits', [] ],
  62. [ 'level_gifts', [] ]
  63. ]);
  64. $this->validate($data, 'app\validate\member\MemberLevel.add');
  65. $id = ( new MemberLevelService() )->add($data);
  66. return success('ADD_SUCCESS', [ 'label_id' => $id ]);
  67. }
  68. /**
  69. * 编辑会员等级
  70. */
  71. public function edit($id)
  72. {
  73. $data = $this->request->params([
  74. [ 'level_name', '' ],
  75. [ 'growth', 0 ],
  76. [ 'remark', '' ],
  77. [ 'level_benefits', [] ],
  78. [ 'level_gifts', [] ],
  79. ]);
  80. $this->validate($data, 'app\validate\member\MemberLevel.edit');
  81. ( new MemberLevelService() )->edit($id, $data);
  82. return success('EDIT_SUCCESS');
  83. }
  84. /**
  85. * 会员等级删除
  86. * @param int $id
  87. * @return Response
  88. */
  89. public function del(int $id)
  90. {
  91. ( new MemberLevelService() )->del($id);
  92. return success('DELETE_SUCCESS');
  93. }
  94. /**
  95. * 获取全部会员等级
  96. * @return Response
  97. * @throws DataNotFoundException
  98. * @throws DbException
  99. * @throws ModelNotFoundException
  100. */
  101. public function getAll()
  102. {
  103. return success(( new MemberLevelService() )->getAll());
  104. }
  105. }