WechatGroup.php 2.2 KB

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