创建模型

This commit is contained in:
2025-05-12 09:04:46 +08:00
parent fc327e9f48
commit 8ee9ab1b92
19 changed files with 594 additions and 139 deletions

View File

@@ -3,20 +3,20 @@
namespace App\Http\Controllers\Api;
use App\BaseApp\BaseController;
use App\Service\UserService;
use App\Service\AdminService;
use Exception;
use Illuminate\Http\JsonResponse;
class UserController extends BaseController
class AdminController extends BaseController
{
//
public function __construct()
{
parent::__construct();
$this->service = UserService::getInstance();
$this->insertField = [ 'account', 'nick_name', 'password', 'role_id' ];
$this->updateField = [ 'id', 'account', 'nick_name', 'role_id' ];
$this->service = AdminService::getInstance();
$this->insertField = [ 'phone', 'nick_name', 'password', 'role_id' ];
$this->updateField = [ 'id', 'phone', 'nick_name', 'role_id' ];
$this->notRequest = ['qr_code', 'avatar', 'email', 'status'];
}
@@ -72,18 +72,4 @@ class UserController extends BaseController
'获取成功'
);
}
/**
* 获取当前用户信息
* @Method GET
* @return JsonResponse
* @throws Exception
*/
public function userStats(): JsonResponse
{
return jok(
$this->service->userStats(),
'获取成功'
);
}
}

View File

@@ -25,12 +25,12 @@ class LoginController extends BaseController
public function login()
{
$this->insertField = [
'account', 'password', 'remember'
'phone', 'password', 'remember'
];
$param = $this->checkRequiredFields(request()->post());
return jok(
$this->service->login($param['account'], $param['password']),
$this->service->login($param['phone'], $param['password']),
'登录成功'
);
}
@@ -44,12 +44,12 @@ class LoginController extends BaseController
public function register()
{
$this->insertField = [
'account', 'password', 'email', 'code'
'phone', 'password', 'email', 'code'
];
$param = $this->checkRequiredFields(request()->post());
return jok(
$this->service->register($param['account'], $param['password'], $param['email'], $param['code']),
$this->service->register($param['phone'], $param['password'], $param['email'], $param['code']),
'登录成功'
);
}