@lovrabet/sdk 1.1.15 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -29
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/src/models/abstract-base-model.d.ts +3 -3
- package/dist/src/models/openapi-model.d.ts +2 -1
- package/dist/src/models/webapi-model.d.ts +2 -1
- package/dist/src/types/index.d.ts +24 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseModelMethods, ListParams, ListResponse, ModelConfig, ClientConfig } from '../types';
|
|
1
|
+
import type { BaseModelMethods, ListParams, ListResponse, ModelConfig, ClientConfig, SortList } from '../types';
|
|
2
2
|
import type { HttpClient } from '../http/http-client';
|
|
3
3
|
/**
|
|
4
4
|
* 抽象基础模型类
|
|
@@ -13,8 +13,8 @@ export declare abstract class AbstractBaseModel implements BaseModelMethods {
|
|
|
13
13
|
constructor(modelName: string, httpClient: HttpClient, globalConfig: ClientConfig);
|
|
14
14
|
private resolveModelConfig;
|
|
15
15
|
protected abstract getApiPath(method: string): string;
|
|
16
|
-
protected abstract buildRequestBody(method: string, data: any): any;
|
|
17
|
-
getList<T = any>(params?: ListParams): Promise<ListResponse<T>>;
|
|
16
|
+
protected abstract buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
17
|
+
getList<T = any>(params?: ListParams, sortList?: SortList): Promise<ListResponse<T>>;
|
|
18
18
|
getOne<T = any>(id: string | number): Promise<T>;
|
|
19
19
|
create<T = any>(data: Record<string, any>): Promise<T>;
|
|
20
20
|
update<T = any>(id: string | number, data: Record<string, any>): Promise<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractBaseModel } from './abstract-base-model';
|
|
2
|
+
import type { SortList } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* OpenAPI 模型实现
|
|
4
5
|
* 处理 OpenAPI 模式下的 URL 生成和请求体构建
|
|
@@ -13,5 +14,5 @@ export declare class OpenApiModel extends AbstractBaseModel {
|
|
|
13
14
|
* 认证信息(token、timeStamp)由 HttpClient 自动添加到请求头(Header)中
|
|
14
15
|
* 请求体只包含业务数据
|
|
15
16
|
*/
|
|
16
|
-
protected buildRequestBody(method: string, data: any): any;
|
|
17
|
+
protected buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
17
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractBaseModel } from './abstract-base-model';
|
|
2
|
+
import type { SortList } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* WebAPI 模型实现
|
|
4
5
|
* 处理 WebAPI 模式下的 URL 生成和请求体构建
|
|
@@ -11,5 +12,5 @@ export declare class WebApiModel extends AbstractBaseModel {
|
|
|
11
12
|
/**
|
|
12
13
|
* WebAPI 模式的请求体构建策略
|
|
13
14
|
*/
|
|
14
|
-
protected buildRequestBody(method: string, data: any): any;
|
|
15
|
+
protected buildRequestBody(method: string, data: any, sortList?: SortList): any;
|
|
15
16
|
}
|
|
@@ -13,6 +13,28 @@
|
|
|
13
13
|
* @description 支持的运行环境,用于区分不同的 API 端点
|
|
14
14
|
*/
|
|
15
15
|
export type Environment = 'online' | 'daily';
|
|
16
|
+
/**
|
|
17
|
+
* 排序方向枚举
|
|
18
|
+
* @description 定义数据排序的方向
|
|
19
|
+
*/
|
|
20
|
+
export declare enum SortOrder {
|
|
21
|
+
/** 升序 */
|
|
22
|
+
ASC = "asc",
|
|
23
|
+
/** 降序 */
|
|
24
|
+
DESC = "desc"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 排序配置类型
|
|
28
|
+
* @description 定义排序规则的 key-value 格式,key 为字段名,value 为排序方向
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const sortList: SortList = [
|
|
32
|
+
* { "id": SortOrder.DESC },
|
|
33
|
+
* { "name": SortOrder.ASC }
|
|
34
|
+
* ];
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export type SortList = Record<string, SortOrder>[];
|
|
16
38
|
/**
|
|
17
39
|
* 列表查询参数接口
|
|
18
40
|
* @description 用于分页查询的通用参数接口
|
|
@@ -148,9 +170,10 @@ export interface BaseModelMethods {
|
|
|
148
170
|
* 获取数据列表
|
|
149
171
|
* @template T 返回数据的类型
|
|
150
172
|
* @param params 查询参数,包含分页等信息
|
|
173
|
+
* @param sortList 排序配置列表,可选参数
|
|
151
174
|
* @returns 返回分页数据
|
|
152
175
|
*/
|
|
153
|
-
getList<T = any>(params?: ListParams): Promise<ListResponse<T>>;
|
|
176
|
+
getList<T = any>(params?: ListParams, sortList?: SortList): Promise<ListResponse<T>>;
|
|
154
177
|
/**
|
|
155
178
|
* 获取单条数据
|
|
156
179
|
* @template T 返回数据的类型
|