@142vip/common
v0.0.1-alpha.9
Published
142vip平台通用工具包,封装常用工具函数
Downloads
19
Readme
@142vip/common
142vip平台通用工具包,封装常用工具函数
随机字符串
封装随机字符串生成函数,常用的有:
generateRandomStrgenerateRandomStrWithSpecialsgenerateRandomStrWithLetter
分页
请求
封装了分页请求中的常见的currentPage和pageSize字段。
/**
* 分页时的请求参数
* - 可继承
*/
export interface PaginationParams {
currentPage: number
pageSize: number
}响应
分页数据的响应结构,继承了 PaginationParams的请求参数中的currentPage和pageSize字段,同时添加了totalPage字段和data字段,data字段为分页数据,支持泛型。
/**
* 分页相应参数
*/
export interface PaginationResponseItem<T> extends PaginationParams {
totalPage: number
data: T[]
}当分页接口返回数据时,常见的结构为:
{
"currentPage": 1,
"pageSize": 10,
"totalPage": 1,
// data字段支持泛型,常见是数组对象
"data": []
}接口响应
通用结构
export interface VipBaseResponse {
traceId: string
code: HttpStatus
success: boolean
message: string
}请求成功
/**
* 成功时,接口返回结构
*/
export interface VipSuccessResponse<T> extends VipBaseResponse {
result: T
}请求失败
/**
* 异常时,接口返回结构
*/
export interface VipErrorResponse<T = string> extends VipBaseResponse {
// 生产环境,严禁暴露这个字段
detailErrorMessage?: T
}参考
证书
Copyright (c) 2019-present, 142vip 储凡
