WechatGroup.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-04-26
  7. *
  8. *
  9. */
  10. namespace app\controller\admin\wechat;
  11. use crmeb\basic\BaseController;
  12. use crmeb\services\WechatUserGroupService;
  13. use crmeb\services\WechatUserTagService;
  14. use FormBuilder\Exception\FormBuilderException;
  15. use think\App;
  16. /**
  17. * Class WechatGroup
  18. * @package app\controller\admin\wechat
  19. * @author xaboy
  20. * @day 2020-04-27
  21. */
  22. class WechatGroup extends BaseController
  23. {
  24. /**
  25. * @var WechatUserGroupService
  26. */
  27. protected $service;
  28. /**
  29. * WechatTag constructor.
  30. * @param App $app
  31. * @param WechatUserGroupService $service
  32. */
  33. public function __construct(App $app, WechatUserGroupService $service)
  34. {
  35. parent::__construct($app);
  36. $this->service = $service;
  37. }
  38. public function lst()
  39. {
  40. return app('json')->success($this->service->lst());
  41. }
  42. /**
  43. * @return mixed
  44. * @throws FormBuilderException
  45. * @author xaboy
  46. * @day 2020-04-27
  47. */
  48. public function createForm()
  49. {
  50. return app('json')->success(formToData($this->service->form()));
  51. }
  52. /**
  53. * @return mixed
  54. * @author xaboy
  55. * @day 2020-04-27
  56. */
  57. public function create()
  58. {
  59. $name = $this->request->param('group_name');
  60. if (!$name) return app('json')->fail('请输入分组名称');
  61. $this->service->create($name);
  62. return app('json')->success('添加成功');
  63. }
  64. /**
  65. * @param $id
  66. * @return mixed
  67. * @author xaboy
  68. * @day 2020-04-27
  69. */
  70. public function update($id)
  71. {
  72. $name = $this->request->param('group_name');
  73. if (!$name) return app('json')->fail('请输入分组名称');
  74. $this->service->update($id, $name);
  75. return app('json')->success('编辑成功');
  76. }
  77. /**
  78. * @param $id
  79. * @return mixed
  80. * @throws FormBuilderException
  81. * @author xaboy
  82. * @day 2020-04-27
  83. */
  84. public function updateForm($id)
  85. {
  86. return app('json')->success(formToData($this->service->form($id, '')));
  87. }
  88. /**
  89. * @param $id
  90. * @return mixed
  91. * @author xaboy
  92. * @day 2020-04-27
  93. */
  94. public function delete($id)
  95. {
  96. $this->service->delete($id);
  97. return app('json')->success('删除成功');
  98. }
  99. }