ShopGroup.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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\shop\admin;
  12. use app\service\admin\shop\admin\ShopSiteGroupService;
  13. use core\base\BaseAdminController;
  14. use Exception;
  15. use think\Response;
  16. /**
  17. * 站点分组
  18. * Class ShopGroup
  19. * @package addon\mall\app\adminapi\controller\mall\shop
  20. */
  21. class ShopGroup extends BaseAdminController
  22. {
  23. /**
  24. * 站点列表
  25. * @return Response
  26. */
  27. public function lists()
  28. {
  29. $data = $this->request->params([
  30. ['keywords', ''],
  31. ]);
  32. return success((new ShopSiteGroupService())->getPage($data));
  33. }
  34. /**
  35. * 分组详情
  36. * @param int $group_id
  37. * @return Response
  38. */
  39. public function info(int $group_id)
  40. {
  41. return success((new ShopSiteGroupService())->getInfo($group_id));
  42. }
  43. /**
  44. * 添加分组
  45. * @return Response
  46. * @throws Exception
  47. */
  48. public function add()
  49. {
  50. $data = $this->request->params([
  51. ['group_name', ''],
  52. ['group_desc', ''],
  53. ['addon', []],
  54. ]);
  55. $this->validate($data, 'app\validate\shop\ShopGroup.add');
  56. $group_id = (new ShopSiteGroupService())->add($data);
  57. return success('ADD_SUCCESS', ['group_id' => $group_id]);
  58. }
  59. /**
  60. * 编辑分组
  61. * @param $group_id
  62. * @return Response
  63. */
  64. public function edit($group_id)
  65. {
  66. $data = $this->request->params([
  67. ['group_name', ''],
  68. ['group_desc', ''],
  69. ['addon', []],
  70. ]);
  71. $data['group_id'] = $group_id;
  72. $this->validate($data, 'app\validate\shop\ShopGroup.edit');
  73. (new ShopSiteGroupService())->edit($group_id, $data);
  74. return success('EDIT_SUCCESS');
  75. }
  76. /**
  77. * 删除分组
  78. * @param $group_id
  79. * @return Response
  80. */
  81. public function del($group_id)
  82. {
  83. (new ShopSiteGroupService())->del($group_id);
  84. return success('DELETE_SUCCESS');
  85. }
  86. /**
  87. * 所有分组
  88. * @return Response
  89. */
  90. public function all()
  91. {
  92. $data = $this->request->params([
  93. ['app', ''],
  94. ]);
  95. return success((new ShopSiteGroupService())->getAll());
  96. }
  97. }