refactor: restructure API authentication system and remove legacy files

- Updated API routes to use a unified versioning scheme under `/api/v1/auth`.
- Implemented new authentication controller for login, registration, and token management.
- Removed legacy user and index controllers, along with associated models and validation files.
- Updated documentation to reflect new API endpoints and usage.
- Cleaned up unused service and middleware files to streamline the application structure.
This commit is contained in:
nepiedg
2026-04-02 03:05:44 +00:00
parent b56df15c2b
commit e0733cf672
22 changed files with 130 additions and 681 deletions
-36
View File
@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
use think\facade\Route;
use app\api\controller\Index;
use app\api\controller\User;
use app\api\controller\V1Auth;
/**
* API 路由配置
*/
// ==================== v1 版本接口 ====================
// 健康检查 (公开)
Route::get('api/v1/health', [Index::class, 'health']);
// 认证接口 (公开)
Route::post('api/v1/auth/login', [V1Auth::class, 'login']);
Route::post('api/v1/auth/register', [V1Auth::class, 'register']);
Route::post('api/v1/auth/refresh', [V1Auth::class, 'refresh']);
// 认证接口 (需登录)
Route::group('api/v1/auth', function () {
Route::get('me', [V1Auth::class, 'me']);
Route::post('logout', [V1Auth::class, 'logout']);
Route::post('password', [V1Auth::class, 'password']);
})->middleware(\app\api\middleware\Auth::class);
// ==================== 兼容旧版路由 ====================
Route::get('api/index', [Index::class, 'index']);
Route::get('api/health', [Index::class, 'health']);
Route::post('api/user/login', [V1Auth::class, 'login']);
Route::post('api/user/register', [V1Auth::class, 'register']);
Route::get('api/user/info', [V1Auth::class, 'me'])->middleware(\app\api\middleware\Auth::class);
-17
View File
@@ -1,17 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;
Route::get('think', function () {
return 'hello,ThinkPHP8!';
});
Route::get('hello/:name', 'index/hello');