@echo off
chcp 65001 >nul
echo ====================================
echo 用户管理系统 - 代码结构验证
echo ====================================
echo.

echo 正在验证项目结构...
echo.

set TOTAL=0
set EXISTS=0
set MISSING=0

REM 检查文件
if exist "cmd\server\main.go" (
    echo [√] cmd\server\main.go
    set /a EXISTS+=1
) else (
    echo [×] cmd\server\main.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "go.mod" (
    echo [√] go.mod
    set /a EXISTS+=1
) else (
    echo [×] go.mod
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\domain\user.go" (
    echo [√] internal\domain\user.go
    set /a EXISTS+=1
) else (
    echo [×] internal\domain\user.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\service\auth.go" (
    echo [√] internal\service\auth.go
    set /a EXISTS+=1
) else (
    echo [×] internal\service\auth.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\service\user.go" (
    echo [√] internal\service\user.go
    set /a EXISTS+=1
) else (
    echo [×] internal\service\user.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\service\role.go" (
    echo [√] internal\service\role.go
    set /a EXISTS+=1
) else (
    echo [×] internal\service\role.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\service\permission.go" (
    echo [√] internal\service\permission.go
    set /a EXISTS+=1
) else (
    echo [×] internal\service\permission.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\service\device.go" (
    echo [√] internal\service\device.go
    set /a EXISTS+=1
) else (
    echo [×] internal\service\device.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\api\handler\auth.go" (
    echo [√] internal\api\handler\auth.go
    set /a EXISTS+=1
) else (
    echo [×] internal\api\handler\auth.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\api\handler\user.go" (
    echo [√] internal\api\handler\user.go
    set /a EXISTS+=1
) else (
    echo [×] internal\api\handler\user.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\api\handler\role.go" (
    echo [√] internal\api\handler\role.go
    set /a EXISTS+=1
) else (
    echo [×] internal\api\handler\role.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\api\handler\permission.go" (
    echo [√] internal\api\handler\permission.go
    set /a EXISTS+=1
) else (
    echo [×] internal\api\handler\permission.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\api\handler\device.go" (
    echo [√] internal\api\handler\device.go
    set /a EXISTS+=1
) else (
    echo [×] internal\api\handler\device.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\cache\cache_manager.go" (
    echo [√] internal\cache\cache_manager.go
    set /a EXISTS+=1
) else (
    echo [×] internal\cache\cache_manager.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\monitoring\metrics.go" (
    echo [√] internal\monitoring\metrics.go
    set /a EXISTS+=1
) else (
    echo [×] internal\monitoring\metrics.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "internal\api\router\router.go" (
    echo [√] internal\api\router\router.go
    set /a EXISTS+=1
) else (
    echo [×] internal\api\router\router.go
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "migrations\sqlite\V1__init.sql" (
    echo [√] migrations\sqlite\V1__init.sql
    set /a EXISTS+=1
) else (
    echo [×] migrations\sqlite\V1__init.sql
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "configs\config.yaml" (
    echo [√] configs\config.yaml
    set /a EXISTS+=1
) else (
    echo [×] configs\config.yaml
    set /a MISSING+=1
)
set /a TOTAL+=1

if exist "docker-compose.yml" (
    echo [√] docker-compose.yml
    set /a EXISTS+=1
) else (
    echo [×] docker-compose.yml
    set /a MISSING+=1
)
set /a TOTAL+=1

echo.
echo ====================================
echo 验证结果
echo ====================================
echo 总文件数: %TOTAL%
echo 存在文件: %EXISTS%
echo 缺失文件: %MISSING%
echo.

set /a PERCENT=%EXISTS%*100/%TOTAL%
echo 完成度: %PERCENT%%%

if %PERCENT% GEQ 95 (
    echo.
    echo [SUCCESS] 项目结构完整,可以进行验收!
    exit /b 0
) else if %PERCENT% GEQ 80 (
    echo.
    echo [WARNING] 项目基本完成,但还有部分功能需要补充
    exit /b 1
) else (
    echo.
    echo [ERROR] 项目完成度较低,需要继续完善
    exit /b 1
)
