.PHONY: build run dev docker-build docker-up docker-down docker-logs clean test

# 本地开发
build:
	go build -o bin/server ./cmd/server

run: build
	./bin/server

dev:
	go run ./cmd/server

# 依赖管理
deps:
	go mod tidy
	go mod download

# Docker 操作
docker-build:
	docker compose build --no-cache

docker-up:
	docker compose up -d

docker-down:
	docker compose down

docker-logs:
	docker compose logs -f

docker-restart:
	docker compose down && docker compose up -d

# 清理
clean:
	rm -rf bin/
	docker compose down -v

# 测试
test:
	go test -v ./...

# 数据库迁移（本地开发用）
migrate:
	go run ./cmd/server migrate

# 格式化
fmt:
	go fmt ./...

# 检查
lint:
	golangci-lint run

# 帮助
help:
	@echo "Available commands:"
	@echo "  make build        - Build the binary"
	@echo "  make run          - Build and run locally"
	@echo "  make dev          - Run with go run (development)"
	@echo "  make deps         - Download dependencies"
	@echo "  make docker-build - Build Docker image"
	@echo "  make docker-up    - Start Docker containers"
	@echo "  make docker-down  - Stop Docker containers"
	@echo "  make docker-logs  - View Docker logs"
	@echo "  make clean        - Clean build artifacts and volumes"
	@echo "  make test         - Run tests"
	@echo "  make fmt          - Format code"
