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.
34 lines
1.1 KiB
34 lines
1.1 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\admin\model\Task;
|
|
use app\admin\model\User as UserModel;
|
|
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请求');
|
|
}
|
|
$data = $this->postData();
|
|
$model = new UserModel();
|
|
$field = 'password,salt,last_login_time,create_time,update_time,delete_time';
|
|
$row = $model->where('uid', $data['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();
|
|
return $this->renderSuccess($row->toArray());
|
|
}
|
|
|
|
}
|
|
|