You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\v3;
  4. use App\Commons\Log;
  5. use App\Constants\v3\ErrorCode;
  6. use App\Controller\BaseController;
  7. use App\Model\v3\UserRelationBind;
  8. use App\Request\v3\CommunityBindRequest;
  9. use App\Service\v3\Interfaces\UserRelationBindServiceInterface;
  10. use Hyperf\Di\Annotation\Inject;
  11. class CommunityController extends BaseController
  12. {
  13. /**
  14. * @Inject
  15. * @var UserRelationBindServiceInterface
  16. */
  17. protected $userCommunityService;
  18. /**
  19. * @Inject
  20. * @var Log
  21. */
  22. protected $log;
  23. // public function bind(CommunityBindRequest $request)
  24. public function bind()
  25. {
  26. // $data = $request->validated();
  27. $data = $this->request->all();
  28. $jsonData = $data['json_data'] ?? json_encode([]);
  29. if (!$data['source_id'] || !$data['user_id']) {
  30. $this->log->event('community_bind_error', ['request' => json_encode($data)]);
  31. return $this->success(['request_params' => $data]);
  32. }
  33. $res = $this->userCommunityService->bind(UserRelationBind::BIND_TYPE_COMMUNITY, $data['source_id'], $data['user_id'], $jsonData);
  34. return $this->success(['id' => $res->id]);
  35. }
  36. }