ShopMemberLabel.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的多应用管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\shop\site;
  12. use app\service\admin\shop\site\ShopMemberLabelService;
  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. /**
  19. * 店铺会员标签控制层
  20. */
  21. class ShopMemberLabel extends BaseAdminController
  22. {
  23. /**
  24. * 会员标签列表
  25. * @return Response
  26. */
  27. public function lists()
  28. {
  29. $data = $this->request->params([
  30. [ 'label_name', '' ],
  31. ]);
  32. return success(( new ShopMemberLabelService() )->getPage($data));
  33. }
  34. /**
  35. * 会员标签详情
  36. * @param int $id
  37. * @return Response
  38. */
  39. public function info(int $id)
  40. {
  41. return success(( new ShopMemberLabelService() )->getInfo($id));
  42. }
  43. /**
  44. * 添加会员标签
  45. * @return Response
  46. */
  47. public function add()
  48. {
  49. $data = $this->request->params([
  50. [ 'label_name', '' ],
  51. [ 'memo', '' ],
  52. [ 'sort', 0 ],
  53. ]);
  54. $this->validate($data, 'app\validate\member\MemberLabel.add');
  55. $id = ( new ShopMemberLabelService() )->add($data);
  56. return success('ADD_SUCCESS', [ 'label_id' => $id ]);
  57. }
  58. /**
  59. * 编辑会员标签
  60. */
  61. public function edit($id)
  62. {
  63. $data = $this->request->params([
  64. [ 'label_name', '' ],
  65. [ 'memo', '' ],
  66. [ 'sort', 0 ],
  67. ]);
  68. $this->validate($data, 'app\validate\member\MemberLabel.edit');
  69. ( new ShopMemberLabelService() )->edit($id, $data);
  70. return success('EDIT_SUCCESS');
  71. }
  72. /**
  73. * 会员标签删除
  74. * @param int $id
  75. * @return Response
  76. */
  77. public function del(int $id)
  78. {
  79. ( new ShopMemberLabelService() )->del($id);
  80. return success('DELETE_SUCCESS');
  81. }
  82. /**
  83. * 获取标签
  84. * @return Response
  85. * @throws DataNotFoundException
  86. * @throws DbException
  87. * @throws ModelNotFoundException
  88. */
  89. public function getAll()
  90. {
  91. return success(( new ShopMemberLabelService() )->getAll());
  92. }
  93. }