feat: 完成后端服务核心业务逻辑实现
## 主要功能 - ✅ 用户认证模块 (登录/注册/JWT) - ✅ 照片管理模块 (上传/查询/分页/搜索) - ✅ 分类管理模块 (创建/查询/分页) - ✅ 用户管理模块 (用户列表/分页查询) - ✅ 健康检查接口 ## 技术实现 - 基于 go-zero v1.8.0 标准架构 - Handler → Logic → Model 三层架构 - SQLite/PostgreSQL 数据库支持 - JWT 认证机制 - bcrypt 密码加密 - 统一响应格式 - 自定义模型方法 (分页/搜索) ## API 接口 - POST /api/v1/auth/login - 用户登录 - POST /api/v1/auth/register - 用户注册 - GET /api/v1/health - 健康检查 - GET /api/v1/photos - 照片列表 - POST /api/v1/photos - 上传照片 - GET /api/v1/categories - 分类列表 - POST /api/v1/categories - 创建分类 - GET /api/v1/users - 用户列表 ## 配置完成 - 开发环境配置 (SQLite) - 生产环境支持 (PostgreSQL) - JWT 认证配置 - 文件上传配置 - Makefile 构建脚本 服务已验证可正常构建和启动。
This commit is contained in:
@ -1,105 +0,0 @@
|
||||
# 开发环境配置
|
||||
app:
|
||||
name: "Photography Portfolio Dev"
|
||||
version: "1.0.0"
|
||||
environment: "development"
|
||||
port: 8080
|
||||
debug: true
|
||||
|
||||
# 数据库配置
|
||||
database:
|
||||
host: "localhost"
|
||||
port: 5432
|
||||
username: "postgres"
|
||||
password: "password"
|
||||
database: "photography_dev"
|
||||
ssl_mode: "disable"
|
||||
max_open_conns: 50
|
||||
max_idle_conns: 5
|
||||
conn_max_lifetime: 300
|
||||
|
||||
# Redis配置
|
||||
redis:
|
||||
host: "localhost"
|
||||
port: 6379
|
||||
password: ""
|
||||
database: 1
|
||||
pool_size: 10
|
||||
min_idle_conns: 2
|
||||
|
||||
# JWT配置
|
||||
jwt:
|
||||
secret: "dev-secret-key-not-for-production"
|
||||
expires_in: "24h"
|
||||
refresh_expires_in: "168h"
|
||||
|
||||
# 存储配置
|
||||
storage:
|
||||
type: "local"
|
||||
local:
|
||||
base_path: "./uploads"
|
||||
base_url: "http://localhost:8080/uploads"
|
||||
s3:
|
||||
region: "us-east-1"
|
||||
bucket: "photography-dev-bucket"
|
||||
access_key: ""
|
||||
secret_key: ""
|
||||
endpoint: ""
|
||||
|
||||
# 上传配置
|
||||
upload:
|
||||
max_file_size: 104857600 # 100MB
|
||||
allowed_types:
|
||||
- "image/jpeg"
|
||||
- "image/jpg"
|
||||
- "image/png"
|
||||
- "image/gif"
|
||||
- "image/webp"
|
||||
- "image/tiff"
|
||||
- "image/bmp"
|
||||
thumbnail_sizes:
|
||||
- name: "thumbnail"
|
||||
width: 200
|
||||
height: 200
|
||||
- name: "medium"
|
||||
width: 800
|
||||
height: 600
|
||||
- name: "large"
|
||||
width: 1920
|
||||
height: 1080
|
||||
|
||||
# 日志配置
|
||||
logger:
|
||||
level: "debug"
|
||||
format: "text"
|
||||
output: "stdout"
|
||||
filename: "logs/dev.log"
|
||||
max_size: 50
|
||||
max_age: 7
|
||||
compress: false
|
||||
|
||||
# CORS配置
|
||||
cors:
|
||||
allowed_origins:
|
||||
- "http://localhost:3000"
|
||||
- "http://localhost:3001"
|
||||
- "http://localhost:5173"
|
||||
allowed_methods:
|
||||
- "GET"
|
||||
- "POST"
|
||||
- "PUT"
|
||||
- "DELETE"
|
||||
- "PATCH"
|
||||
- "OPTIONS"
|
||||
allowed_headers:
|
||||
- "Content-Type"
|
||||
- "Authorization"
|
||||
- "X-Requested-With"
|
||||
- "Origin"
|
||||
allow_credentials: true
|
||||
|
||||
# 限流配置
|
||||
rate_limit:
|
||||
enabled: false
|
||||
requests_per_minute: 1000
|
||||
burst: 2000
|
||||
@ -1,101 +0,0 @@
|
||||
# 生产环境配置
|
||||
app:
|
||||
name: "Photography Portfolio"
|
||||
version: "1.0.0"
|
||||
environment: "production"
|
||||
port: 8080
|
||||
debug: false
|
||||
|
||||
# 数据库配置
|
||||
database:
|
||||
host: "localhost"
|
||||
port: 5432
|
||||
username: "postgres"
|
||||
password: "${DB_PASSWORD}"
|
||||
database: "photography"
|
||||
ssl_mode: "require"
|
||||
max_open_conns: 200
|
||||
max_idle_conns: 20
|
||||
conn_max_lifetime: 3600
|
||||
|
||||
# Redis配置
|
||||
redis:
|
||||
host: "localhost"
|
||||
port: 6379
|
||||
password: "${REDIS_PASSWORD}"
|
||||
database: 0
|
||||
pool_size: 50
|
||||
min_idle_conns: 10
|
||||
|
||||
# JWT配置
|
||||
jwt:
|
||||
secret: "${JWT_SECRET}"
|
||||
expires_in: "24h"
|
||||
refresh_expires_in: "168h"
|
||||
|
||||
# 存储配置
|
||||
storage:
|
||||
type: "local" # 生产环境建议使用 s3 或 oss
|
||||
local:
|
||||
base_path: "/var/www/photography/uploads"
|
||||
base_url: "https://photography.iriver.top/uploads"
|
||||
s3:
|
||||
region: "${AWS_REGION}"
|
||||
bucket: "${AWS_BUCKET}"
|
||||
access_key: "${AWS_ACCESS_KEY_ID}"
|
||||
secret_key: "${AWS_SECRET_ACCESS_KEY}"
|
||||
endpoint: "${AWS_ENDPOINT}"
|
||||
|
||||
# 上传配置
|
||||
upload:
|
||||
max_file_size: 104857600 # 100MB
|
||||
allowed_types:
|
||||
- "image/jpeg"
|
||||
- "image/jpg"
|
||||
- "image/png"
|
||||
- "image/gif"
|
||||
- "image/webp"
|
||||
- "image/tiff"
|
||||
thumbnail_sizes:
|
||||
- name: "thumbnail"
|
||||
width: 200
|
||||
height: 200
|
||||
- name: "medium"
|
||||
width: 800
|
||||
height: 600
|
||||
- name: "large"
|
||||
width: 1920
|
||||
height: 1080
|
||||
|
||||
# 日志配置
|
||||
logger:
|
||||
level: "info"
|
||||
format: "json"
|
||||
output: "file"
|
||||
filename: "/var/log/photography/app.log"
|
||||
max_size: 100
|
||||
max_age: 30
|
||||
compress: true
|
||||
|
||||
# CORS配置
|
||||
cors:
|
||||
allowed_origins:
|
||||
- "https://photography.iriver.top"
|
||||
- "https://admin.photography.iriver.top"
|
||||
allowed_methods:
|
||||
- "GET"
|
||||
- "POST"
|
||||
- "PUT"
|
||||
- "DELETE"
|
||||
- "OPTIONS"
|
||||
allowed_headers:
|
||||
- "Content-Type"
|
||||
- "Authorization"
|
||||
- "X-Requested-With"
|
||||
allow_credentials: true
|
||||
|
||||
# 限流配置
|
||||
rate_limit:
|
||||
enabled: true
|
||||
requests_per_minute: 60
|
||||
burst: 120
|
||||
@ -1,76 +0,0 @@
|
||||
app:
|
||||
name: "photography-backend"
|
||||
version: "1.0.0"
|
||||
environment: "development"
|
||||
port: 8080
|
||||
debug: true
|
||||
|
||||
database:
|
||||
host: "localhost"
|
||||
port: 5432
|
||||
username: "postgres"
|
||||
password: "password"
|
||||
database: "photography"
|
||||
ssl_mode: "disable"
|
||||
max_open_conns: 100
|
||||
max_idle_conns: 10
|
||||
conn_max_lifetime: 300
|
||||
|
||||
redis:
|
||||
host: "localhost"
|
||||
port: 6379
|
||||
password: ""
|
||||
database: 0
|
||||
pool_size: 100
|
||||
min_idle_conns: 10
|
||||
|
||||
jwt:
|
||||
secret: "your-secret-key-change-in-production"
|
||||
expires_in: "24h"
|
||||
refresh_expires_in: "168h"
|
||||
|
||||
storage:
|
||||
type: "local" # local, s3, minio
|
||||
local:
|
||||
base_path: "./uploads"
|
||||
base_url: "http://localhost:8080/uploads"
|
||||
s3:
|
||||
region: "us-east-1"
|
||||
bucket: "photography-uploads"
|
||||
access_key: ""
|
||||
secret_key: ""
|
||||
endpoint: ""
|
||||
|
||||
upload:
|
||||
max_file_size: 52428800 # 50MB
|
||||
allowed_types: ["image/jpeg", "image/png", "image/gif", "image/webp", "image/tiff"]
|
||||
thumbnail_sizes:
|
||||
- name: "small"
|
||||
width: 300
|
||||
height: 300
|
||||
- name: "medium"
|
||||
width: 800
|
||||
height: 600
|
||||
- name: "large"
|
||||
width: 1200
|
||||
height: 900
|
||||
|
||||
logger:
|
||||
level: "debug"
|
||||
format: "json"
|
||||
output: "file"
|
||||
filename: "logs/app.log"
|
||||
max_size: 100
|
||||
max_age: 7
|
||||
compress: true
|
||||
|
||||
cors:
|
||||
allowed_origins: ["http://localhost:3000", "https://photography.iriver.top"]
|
||||
allowed_methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
|
||||
allowed_headers: ["Origin", "Content-Length", "Content-Type", "Authorization"]
|
||||
allow_credentials: true
|
||||
|
||||
rate_limit:
|
||||
enabled: true
|
||||
requests_per_minute: 100
|
||||
burst: 50
|
||||
Reference in New Issue
Block a user