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.
35 lines
1.2 KiB
35 lines
1.2 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\admin\model\Task;
|
|
use app\admin\model\User as UserModel;
|
|
use app\admin\model\UserAgent;
|
|
use app\api\middleware\LcJWTAuth;
|
|
use think\response\Json;
|
|
|
|
class User extends ApiController
|
|
{
|
|
|
|
public function getUserData():Json
|
|
{
|
|
if (!$this->request->isPost()) {
|
|
return $this->renderError('不支持GET请求');
|
|
}
|
|
$model = new UserModel();
|
|
$field = 'password,salt,last_login_time,create_time,update_time,delete_time';
|
|
$row = $model->where('uid', $this->request->uid)->withoutField($field)->find();
|
|
if ($row->isEmpty()) {
|
|
return $this->renderError($model->getError() ?: '用户不存在');
|
|
}
|
|
if ($row['status'] != 1) return $this->renderError('用户被禁用');
|
|
unset($row['status']);
|
|
if ($row['gender']) {
|
|
$row['gender'] = $model->genderArr[$row['gender']] ?? '';
|
|
}
|
|
$row['task_count'] = Task::where([['assign_uid' , '=', $row['uid']], ['status' ,'in', [1,2]]])->count();
|
|
$row['agent'] = (new UserAgent)->where(['uid' => $row['uid'], 'status' => 1])->count();
|
|
return $this->renderSuccess($row->toArray());
|
|
}
|
|
|
|
}
|
|
|