This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/api/controller/User.php
2020-04-25 22:20:29 +08:00

44 lines
913 B
PHP

<?php
namespace app\api\controller;
use app\api\model\User as UserModel;
/**
* 用户管理
* Class User
* @package app\api
*/
class User extends Controller
{
/**
* 用户自动登录
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function login()
{
$model = new UserModel;
return $this->renderSuccess([
'user_id' => $model->login($this->request->post()),
'token' => $model->getToken()
]);
}
/**
* 当前用户详情
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function detail()
{
// 当前用户信息
$userInfo = $this->getUser();
return $this->renderSuccess(compact('userInfo'));
}
}