Expand description
§cool-core
cool-admin Rust 核心库,提供 CRUD 自动化、服务基类、控制器基类等功能。
§功能特性
- 🚀 基于 Salvo 的高性能 Web 框架集成
- 🗃️ 基于 SeaORM 的多数据库支持(MySQL/PostgreSQL/SQLite)
- 🔧 自动 CRUD 生成(add/delete/update/page/info/list)
- 🛡️ 统一的异常处理
- 📝 参数验证
- 🔐 JWT 认证
- 💾 Redis 缓存支持
- 📡 事件系统
- 🔌 模块化架构
§快速开始
ⓘ
use cool_core::prelude::*;
// 定义实体
#[derive(Clone, Debug, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "goods")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub title: String,
pub price: Decimal,
pub create_time: DateTimeUtc,
pub update_time: DateTimeUtc,
}
// 定义服务
pub struct GoodsService {
db: Arc<DatabaseConnection>,
}
// 定义控制器
pub struct GoodsController {
service: GoodsService,
}§模块说明
cache: 缓存模块,支持内存缓存和 Redis 缓存config: 配置模块,定义框架配置结构constant: 常量模块,定义全局常量和枚举controller: 控制器模块,提供 CRUD 控制器基类entity: 实体模块,定义实体 trait 和通用结构error: 错误处理模块,统一的异常类型和响应event: 事件模块,提供事件发布订阅机制middleware: 中间件模块,包含权限、日志等中间件module: 模块管理,支持模块注册和路由构建service: 服务模块,提供 CRUD 服务基类util: 工具模块,提供常用工具函数
Modules§
- cache
- 缓存模块
- config
- 配置模块
- constant
- 全局常量定义
- controller
- 控制器模块
- entity
- 实体模块
- eps
- EPS (Endpoint Service) 模块
- error
- 异常处理模块
- event
- 事件模块
- middleware
- 中间件模块
- module
- 模块管理(简化版)
- prelude
- 预导入模块,包含常用类型和 trait
- service
- 服务模块
- tag
- URL 标签模块
- util
- 工具模块
Structs§
- CoolApp
- 应用构建器
Constants§
- VERSION
- 框架版本
Functions§
- init_
logger - 初始化日志