20260719215738

This commit is contained in:
oneao committed 2026-07-19 21:57:40 +08:00
1 parent 35aa108a34
commit cda7f16d3a
116 files changed
+11826 -3669

No files matched your search

+62 -7
View File
@@ -1,11 +1,20 @@
import { post } from "./http";
import { get, post } from "./http";
/**
* @template T
* @typedef {object} ApiResult
* @property {boolean} success 前端根据 code 补充的成功标记。
* @property {number} code 后端业务状态码,0 表示成功。
* @property {string} message 响应消息。
* @property {T} data 响应数据。
*/
/**
* 机构用户登录。
* @param {string} orgId 机构码。
* @param {string} userId 用户 ID。
* @param {string} password 密码。
* @returns {Promise<{success: boolean, code: number, message: string, data: {token: string, orgid: string, user: {id: string, name: string}}}>} 登录响应。
* @returns {Promise<ApiResult<{token: string, orgid: string, user: {id: string, name: string}}>>} 登录响应。
*/
export function loginApi(orgId, userId, password) {
return post("/auth/login", {
@@ -19,15 +28,15 @@ export function loginApi(orgId, userId, password) {
* 按表或视图加载数据。
* @param {string} viewName 表名或视图名,必填。
* @param {string} [searchCondition] 查询条件,不包含 WHERE。
* @param {string} [orderField] 排序字段,可带 ASC 或 DESC。
* @param {string} [orderBy] 排序字段,可带 ASC 或 DESC。
* @param {string[]} [searchColumns] 需要返回的字段列表,省略时返回全部字段。
* @returns {Promise<{success: boolean, code: number, message: string, data: object[]}>} 查询响应。
* @returns {Promise<ApiResult<object[]>>} 查询响应。
*/
export function loadDataApi(viewName, searchCondition, orderField, searchColumns) {
export function loadDataApi(viewName, searchCondition, orderBy, searchColumns) {
return post("/data/loaddata", {
view_name: viewName,
search_condition: searchCondition,
order_field: orderField,
order_by: orderBy,
search_columns: searchColumns,
});
}
@@ -35,8 +44,54 @@ export function loadDataApi(viewName, searchCondition, orderField, searchColumns
/**
* 执行只读 SQL 查询。
* @param {string} sql 完整的 SELECT 或 WITH 查询语句。
* @returns {Promise<{success: boolean, code: number, message: string, data: object[]}>} 查询响应。
* @returns {Promise<ApiResult<object[]>>} 查询响应。
*/
export function loadDataBySqlApi(sql) {
return post("/data/loaddatabysql", { sql });
}
/**
* 分页加载表或视图数据。
* @param {object} options 分页查询参数。
* @param {string} options.viewName 表名或视图名,必填。
* @param {string} options.orderBy 排序字段,必填,可用逗号分隔多个字段。
* @param {string[]} [options.searchColumns] 需要返回的字段列表。
* @param {string} [options.searchCondition] 查询条件,不包含 WHERE。
* @param {number} [options.pageNo=1] 页码,从 1 开始。
* @param {number} [options.pageSize=20] 每页记录数。
* @returns {Promise<ApiResult<{rows: object[], row_count: number, total: number, page_no: number, page_size: number}>>} 分页响应。
*/
export function pageDataApi({
viewName,
orderBy,
searchColumns,
searchCondition,
pageNo = 1,
pageSize = 20,
}) {
return post("/data/page", {
view_name: viewName,
search_columns: searchColumns,
search_condition: searchCondition,
order_by: orderBy,
page_no: pageNo,
page_size: pageSize,
});
}
/**
* 在同一事务中保存一个或多个表的数据变更。
* @param {{table: string, key_field: string, inserts?: object[], updates?: object[], deletes?: object[]}[]} requests 保存配置,不能为空数组。
* @returns {Promise<ApiResult<null>>} 保存响应。
*/
export function saveObjectApi(requests) {
return post("/data/saveobjt", requests);
}
/**
* 获取下一个雪花 ID。
* @returns {Promise<ApiResult<string>>} 取号响应,雪花 ID 使用字符串避免精度丢失。
*/
export function nextIdApi() {
return get("/data/nextid");
}
+4
View File
@@ -87,4 +87,8 @@ export function post(path, data, config) {
return http.post(path, data, config);
}
export function get(path, config) {
return http.get(path, config);
}
export default http;