.PHONY: help build run test clean vet tidy check run-check db-dir

help: ## 显示帮助信息
	@echo "======================================"
	@echo "用户管理系统 - Makefile"
	@echo "======================================"
	@echo "可用命令:"
	@echo "  make check       - 全面检查（依赖+vet+编译+测试）"
	@echo "  make build       - 构建应用"
	@echo "  make run         - 运行应用"
	@echo "  make test        - 运行测试"
	@echo "  make vet         - 代码静态检查"
	@echo "  make tidy        - 整理依赖"
	@echo "  make db-dir      - 创建数据库目录"
	@echo "  make clean       - 清理构建文件"
	@echo ""

check: tidy vet build test ## 全面检查：依赖+静态检查+编译+测试

tidy: ## 整理Go模块依赖
	@echo "整理依赖..."
	go mod tidy
	go mod download

vet: ## 运行静态代码检查
	@echo "运行静态检查..."
	go vet ./...

build: db-dir ## 构建应用
	@echo "构建应用..."
	go build -o bin/server cmd/server/main.go

run: db-dir ## 运行应用
	@echo "运行应用..."
	go run cmd/server/main.go

test: ## 运行测试
	@echo "运行测试..."
	go test -short -race ./...

db-dir: ## 创建数据库目录
	@if [ ! -d "data" ]; then mkdir data; fi

clean: ## 清理构建文件
	@echo "清理构建文件..."
	rm -rf bin/
	rm -f server.exe
