GroupChatController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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\api\v1\work;
  12. use app\Request;
  13. use app\services\work\WorkGroupChatMemberServices;
  14. use app\services\work\WorkGroupChatServices;
  15. use crmeb\services\wechat\config\WorkConfig;
  16. /**
  17. * 客户群
  18. * Class GroupChatController
  19. * @package app\controller\api\v1\work
  20. */
  21. class GroupChatController extends BaseWorkController
  22. {
  23. /**
  24. * GroupChatController constructor.
  25. * @param Request $request
  26. * @param WorkGroupChatServices $services
  27. */
  28. public function __construct(Request $request, WorkGroupChatServices $services)
  29. {
  30. $this->request = $request;
  31. $this->service = $services;
  32. }
  33. /**
  34. * @param WorkConfig $config
  35. * @return mixed
  36. */
  37. public function getGroupInfo(WorkConfig $config)
  38. {
  39. $chatId = $this->request->param('chat_id');
  40. if (!$chatId) {
  41. return $this->fail('缺少参数');
  42. }
  43. $corpId = $config->get('corpId');
  44. return $this->success($this->service->getGroupInfo($chatId, $corpId));
  45. }
  46. /**
  47. * 获取群成员列表
  48. * @param WorkGroupChatMemberServices $services
  49. * @param $id
  50. * @return mixed
  51. */
  52. public function getChatMemberList(WorkGroupChatMemberServices $services, $id)
  53. {
  54. if (!$id) {
  55. return $this->fail('缺少参数');
  56. }
  57. $name = $this->request->get('name', '');
  58. return $this->success($services->getChatMemberList((int)$id, $name));
  59. }
  60. }