WechatGroup.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\wechat;
  12. use crmeb\basic\BaseController;
  13. use crmeb\services\WechatUserGroupService;
  14. use crmeb\services\WechatUserTagService;
  15. use FormBuilder\Exception\FormBuilderException;
  16. use think\App;
  17. /**
  18. * Class WechatGroup
  19. * @package app\controller\admin\wechat
  20. * @author xaboy
  21. * @day 2020-04-27
  22. */
  23. class WechatGroup extends BaseController
  24. {
  25. /**
  26. * @var WechatUserGroupService
  27. */
  28. protected $service;
  29. /**
  30. * WechatTag constructor.
  31. * @param App $app
  32. * @param WechatUserGroupService $service
  33. */
  34. public function __construct(App $app, WechatUserGroupService $service)
  35. {
  36. parent::__construct($app);
  37. $this->service = $service;
  38. }
  39. public function lst()
  40. {
  41. return app('json')->success($this->service->lst());
  42. }
  43. /**
  44. * @return mixed
  45. * @throws FormBuilderException
  46. * @author xaboy
  47. * @day 2020-04-27
  48. */
  49. public function createForm()
  50. {
  51. return app('json')->success(formToData($this->service->form()));
  52. }
  53. /**
  54. * @return mixed
  55. * @author xaboy
  56. * @day 2020-04-27
  57. */
  58. public function create()
  59. {
  60. $name = $this->request->param('group_name');
  61. if (!$name) return app('json')->fail('请输入分组名称');
  62. $this->service->create($name);
  63. return app('json')->success('添加成功');
  64. }
  65. /**
  66. * @param $id
  67. * @return mixed
  68. * @author xaboy
  69. * @day 2020-04-27
  70. */
  71. public function update($id)
  72. {
  73. $name = $this->request->param('group_name');
  74. if (!$name) return app('json')->fail('请输入分组名称');
  75. $this->service->update($id, $name);
  76. return app('json')->success('编辑成功');
  77. }
  78. /**
  79. * @param $id
  80. * @return mixed
  81. * @throws FormBuilderException
  82. * @author xaboy
  83. * @day 2020-04-27
  84. */
  85. public function updateForm($id)
  86. {
  87. return app('json')->success(formToData($this->service->form($id, '')));
  88. }
  89. /**
  90. * @param $id
  91. * @return mixed
  92. * @author xaboy
  93. * @day 2020-04-27
  94. */
  95. public function delete($id)
  96. {
  97. $this->service->delete($id);
  98. return app('json')->success('删除成功');
  99. }
  100. }