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
+9 -24
View File
@@ -2,35 +2,20 @@
declare(strict_types=1);
use think\facade\Route;
use app\api\controller\Index;
use app\api\controller\User;
use app\api\controller\V1Auth;
use app\api\controller\v1\Auth;
/**
* API 应用路由
*/
// ==================== v1 版本接口 ====================
// v1 认证接口(公开)
Route::post('v1/auth/login', [Auth::class, 'login']);
Route::post('v1/auth/register', [Auth::class, 'register']);
Route::post('v1/auth/refresh', [Auth::class, 'refresh']);
// 健康检查 (公开)
Route::get('v1/health', [Index::class, 'health']);
// 认证接口 (公开)
Route::post('v1/auth/login', [V1Auth::class, 'login']);
Route::post('v1/auth/register', [V1Auth::class, 'register']);
Route::post('v1/auth/refresh', [V1Auth::class, 'refresh']);
// 认证接口 (需登录)
// v1 认证接口(需登录)
Route::group('v1/auth', function () {
Route::get('me', [V1Auth::class, 'me']);
Route::post('logout', [V1Auth::class, 'logout']);
Route::post('password', [V1Auth::class, 'password']);
Route::get('me', [Auth::class, 'me']);
Route::post('logout', [Auth::class, 'logout']);
Route::post('password', [Auth::class, 'password']);
})->middleware(\app\api\middleware\Auth::class);
// ==================== 兼容旧版路由 ====================
Route::get('index', [Index::class, 'index']);
Route::get('health', [Index::class, 'health']);
Route::post('user/login', [V1Auth::class, 'login']);
Route::post('user/register', [V1Auth::class, 'register']);
Route::get('user/info', [V1Auth::class, 'me'])->middleware(\app\api\middleware\Auth::class);