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.

30 lines
796 B

5 years ago
5 years ago
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\v3;
  4. use App\Controller\BaseController;
  5. use App\Model\v3\UserRelationBind;
  6. use App\Request\v3\CommunityBindRequest;
  7. use App\Service\v3\Interfaces\UserRelationBindServiceInterface;
  8. use Hyperf\Di\Annotation\Inject;
  9. class CommunityController extends BaseController
  10. {
  11. /**
  12. * @Inject
  13. * @var UserRelationBindServiceInterface
  14. */
  15. protected $userCommunityService;
  16. public function bind(CommunityBindRequest $request)
  17. {
  18. $data = $request->validated();
  19. $jsonData = $data['json_data'] ?? json_encode([]);
  20. $res = $this->userCommunityService->bind(UserRelationBind::BIND_TYPE_COMMUNITY, $data['source_id'], $data['user_id'], $jsonData);
  21. return $this->success(['id' => $res->id]);
  22. }
  23. }