feat : user
This commit is contained in:
61
app/Service/Api/User/InviteListService.php
Normal file
61
app/Service/Api/User/InviteListService.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\User;
|
||||
|
||||
use App\Model\User;
|
||||
use App\Model\UserInvite;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Api\GetUserInfoTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class InviteListService extends BaseService
|
||||
{
|
||||
use GetUserInfoTrait;
|
||||
|
||||
/**
|
||||
* @var UserInvite $userInviteModel
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserInvite $userInviteModel;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
#[Inject]
|
||||
protected User $userModel;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
$limit = $this->request->input('limit', 20);
|
||||
|
||||
$list = $this->userInviteModel
|
||||
->where('invitee_user_id', $this->userId)
|
||||
->orderBy('id', 'desc')
|
||||
->paginate($limit)
|
||||
->toArray();
|
||||
|
||||
if (!empty($list['data'])) {
|
||||
$userIds = array_column($list['data'], 'user_id');
|
||||
$userInfoArr = $this->userModel->getInfoByIds($userIds);
|
||||
|
||||
foreach ($list['data'] as &$item) {
|
||||
$item['user_nick_name'] = $userInfoArr[$item['user_id']]['nick_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$userInfo = $this->getUserInfo($this->userId);
|
||||
|
||||
return $this->return->success('success',['list' => $list,'invite_code'=> $userInfo['invite_code']]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user