WechatGroup.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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. */
  24. class WechatGroup extends BaseController
  25. {
  26. /**
  27. * @var WechatUserGroupService
  28. */
  29. protected $service;
  30. /**
  31. * WechatTag constructor.
  32. * @param App $app
  33. * @param WechatUserGroupService $service
  34. */
  35. public function __construct(App $app, WechatUserGroupService $service)
  36. {
  37. parent::__construct($app);
  38. $this->service = $service;
  39. }
  40. public function lst()
  41. {
  42. return app('json')->success($this->service->lst());
  43. }
  44. /**
  45. * @return mixed
  46. * @throws FormBuilderException
  47. * @author xaboy
  48. * @day 2020-04-27
  49. */
  50. public function createForm()
  51. {
  52. return app('json')->success(formToData($this->service->form()));
  53. }
  54. /**
  55. * @return mixed
  56. * @author xaboy
  57. * @day 2020-04-27
  58. */
  59. public function create()
  60. {
  61. $name = $this->request->param('group_name');
  62. if (!$name) return app('json')->fail('请输入分组名称');
  63. $this->service->create($name);
  64. return app('json')->success('添加成功');
  65. }
  66. /**
  67. * @param $id
  68. * @return mixed
  69. * @author xaboy
  70. * @day 2020-04-27
  71. */
  72. public function update($id)
  73. {
  74. $name = $this->request->param('group_name');
  75. if (!$name) return app('json')->fail('请输入分组名称');
  76. $this->service->update($id, $name);
  77. return app('json')->success('编辑成功');
  78. }
  79. /**
  80. * @param $id
  81. * @return mixed
  82. * @throws FormBuilderException
  83. * @author xaboy
  84. * @day 2020-04-27
  85. */
  86. public function updateForm($id)
  87. {
  88. return app('json')->success(formToData($this->service->form($id, '')));
  89. }
  90. /**
  91. * @param $id
  92. * @return mixed
  93. * @author xaboy
  94. * @day 2020-04-27
  95. */
  96. public function delete($id)
  97. {
  98. $this->service->delete($id);
  99. return app('json')->success('删除成功');
  100. }
  101. }