feat: WWJCloud 企业级全栈框架 v0.3.5 完整更新
🚀 核心更新: - ✅ 完善 NestJS 企业级架构设计 - ✅ 优化配置中心和基础设施层 - ✅ 增强第三方服务集成能力 - ✅ 完善多租户架构支持 - 🎯 对标 Java Spring Boot 和 PHP ThinkPHP 📦 新增文件: - wwjcloud-nest 完整框架结构 - Docker 容器化配置 - 管理后台界面 - 数据库迁移脚本 🔑 Key: ebb38b43ec39f355f071294fd1cf9c42
This commit is contained in:
106
src/common/response/page-result.class.ts
Normal file
106
src/common/response/page-result.class.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 分页结果类
|
||||
* 与Java PageResult格式完全一致
|
||||
*
|
||||
* 格式:
|
||||
* {
|
||||
* "currentPage": 1, // 当前页
|
||||
* "perPage": 15, // 每页大小
|
||||
* "total": 100, // 总记录数
|
||||
* "data": [] // 数据列表
|
||||
* }
|
||||
*/
|
||||
export class PageResult<T> {
|
||||
/**
|
||||
* 当前请求页
|
||||
*/
|
||||
currentPage: number;
|
||||
|
||||
/**
|
||||
* 每页大小
|
||||
*/
|
||||
perPage: number;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
total: number;
|
||||
|
||||
/**
|
||||
* 记录结果
|
||||
*/
|
||||
data: T[];
|
||||
|
||||
constructor(page: number, limit: number, total: number = 0, data: T[] = []) {
|
||||
this.currentPage = page;
|
||||
this.perPage = limit;
|
||||
this.total = total;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建分页结果
|
||||
* @param page 页码
|
||||
* @param limit 每页数量
|
||||
* @returns PageResult<T>
|
||||
*/
|
||||
static build<T>(page: number, limit: number): PageResult<T> {
|
||||
return new PageResult<T>(page, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建分页结果
|
||||
* @param page 页码
|
||||
* @param limit 每页数量
|
||||
* @param total 总记录数
|
||||
* @returns PageResult<T>
|
||||
*/
|
||||
static buildWithTotal<T>(page: number, limit: number, total: number): PageResult<T> {
|
||||
return new PageResult<T>(page, limit, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建分页结果
|
||||
* @param page 页码
|
||||
* @param limit 每页数量
|
||||
* @param total 总记录数
|
||||
* @param data 数据列表
|
||||
* @returns PageResult<T>
|
||||
*/
|
||||
static buildWithData<T>(page: number, limit: number, total: number, data: T[]): PageResult<T> {
|
||||
return new PageResult<T>(page, limit, total, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据
|
||||
* @param data 数据列表
|
||||
* @returns PageResult<T>
|
||||
*/
|
||||
setData(data: T[]): PageResult<T> {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置总数
|
||||
* @param total 总记录数
|
||||
* @returns PageResult<T>
|
||||
*/
|
||||
setTotal(total: number): PageResult<T> {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为JSON格式
|
||||
* @returns object
|
||||
*/
|
||||
toJSON(): object {
|
||||
return {
|
||||
currentPage: this.currentPage,
|
||||
perPage: this.perPage,
|
||||
total: this.total,
|
||||
data: this.data,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user