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

<?php
declare(strict_types=1);
namespace App\Controller\v3;
use App\Commons\Log;
use App\Constants\v3\ErrorCode;
use App\Controller\BaseController;
use App\Model\v3\UserRelationBind;
use App\Request\v3\CommunityBindRequest;
use App\Service\v3\Interfaces\UserRelationBindServiceInterface;
use Hyperf\Di\Annotation\Inject;
class CommunityController extends BaseController
{
/**
* @Inject
* @var UserRelationBindServiceInterface
*/
protected $userCommunityService;
/**
* @Inject
* @var Log
*/
protected $log;
// public function bind(CommunityBindRequest $request)
public function bind()
{
// $data = $request->validated();
$data = $this->request->all();
$jsonData = $data['json_data'] ?? json_encode([]);
if (!$data['source_id'] || !$data['user_id']) {
$this->log->event('community_bind_error', ['request' => json_encode($data)]);
return $this->result(ErrorCode::COMMUNITY_BIND_ERROR,$data);
}
$res = $this->userCommunityService->bind(UserRelationBind::BIND_TYPE_COMMUNITY, $data['source_id'], $data['user_id'], $jsonData);
return $this->success(['id' => $res->id]);
}
}