This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2024-12-05 22:29:27 +08:00
.idea add local mysql 2024-12-05 22:29:27 +08:00
src 添加帖子模型、服务和路由,重构数据库连接管理,优化环境变量配置 2024-11-28 00:19:40 +08:00
.env add local mysql 2024-12-05 22:29:27 +08:00
.gitignore init 2024-11-03 23:22:03 +08:00
Cargo.lock 添加帖子模型、服务和路由,重构数据库连接管理,优化环境变量配置 2024-11-28 00:19:40 +08:00
Cargo.toml 添加帖子模型、服务和路由,重构数据库连接管理,优化环境变量配置 2024-11-28 00:19:40 +08:00
init.sql add local mysql 2024-12-05 22:29:27 +08:00
README.md 重构用户模型,删除不再使用的用户输入模型,添加 dotenv 依赖以支持环境变量配置,更新用户服务以使用新的用户结构,优化数据库连接字符串构建 2024-11-24 23:07:19 +08:00

Rust分层架构

  1. 表示层Presentation Layer负责处理 HTTP 请求和响应,通常包含路由和控制器。
  2. 业务逻辑层Business Logic Layer包含服务和业务逻辑实现核心应用功能。
  3. 数据访问层Data Access Layer与数据库或其他存储系统进行交互。
  4. 模型层Model Layer定义应用程序的数据结构。
src/
|-- main.rs
|-- routes/      # 表示层
|   |-- mod.rs
|   |-- user_routes.rs
|-- services/    # 业务逻辑层
|   |-- mod.rs
|   |-- user_service.rs
|-- repositories/ # 数据访问层
|   |-- mod.rs
|   |-- user_repository.rs
|-- models/      # 模型层
    |-- mod.rs
    |-- user.rs
cargo build
cargo run

# Windows
export RUST_LOG=info