MemberLabel.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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\MemberLabelService;
  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 MemberLabel extends BaseAdminController
  19. {
  20. /**
  21. * 会员标签列表
  22. * @return Response
  23. */
  24. public function lists()
  25. {
  26. $data = $this->request->params([
  27. [ 'label_name', '' ],
  28. ]);
  29. return success(( new MemberLabelService() )->getPage($data));
  30. }
  31. /**
  32. * 会员标签详情
  33. * @param int $id
  34. * @return Response
  35. */
  36. public function info(int $id)
  37. {
  38. return success(( new MemberLabelService() )->getInfo($id));
  39. }
  40. /**
  41. * 添加会员标签
  42. * @return Response
  43. */
  44. public function add()
  45. {
  46. $data = $this->request->params([
  47. [ 'label_name', '' ],
  48. [ 'memo', '' ],
  49. [ 'sort', 0 ],
  50. ]);
  51. $this->validate($data, 'app\validate\member\MemberLabel.add');
  52. $id = ( new MemberLabelService() )->add($data);
  53. return success('ADD_SUCCESS', [ 'label_id' => $id ]);
  54. }
  55. /**
  56. * 编辑会员标签
  57. */
  58. public function edit($id)
  59. {
  60. $data = $this->request->params([
  61. [ 'label_name', '' ],
  62. [ 'memo', '' ],
  63. [ 'sort', 0 ],
  64. ]);
  65. $this->validate($data, 'app\validate\member\MemberLabel.edit');
  66. ( new MemberLabelService() )->edit($id, $data);
  67. return success('EDIT_SUCCESS');
  68. }
  69. /**
  70. * 会员标签删除
  71. * @param int $id
  72. * @return Response
  73. */
  74. public function del(int $id)
  75. {
  76. ( new MemberLabelService() )->del($id);
  77. return success('DELETE_SUCCESS');
  78. }
  79. /**
  80. * 获取标签
  81. * @return Response
  82. * @throws DataNotFoundException
  83. * @throws DbException
  84. * @throws ModelNotFoundException
  85. */
  86. public function getAll()
  87. {
  88. return success(( new MemberLabelService() )->getAll());
  89. }
  90. }