43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { post } from "./http";
|
|
|
|
/**
|
|
* 机构用户登录。
|
|
* @param {string} orgId 机构码。
|
|
* @param {string} userId 用户 ID。
|
|
* @param {string} password 密码。
|
|
* @returns {Promise<{token: string, orgid: string, user: {id: string, name: string}}>} 登录会话。
|
|
*/
|
|
export function loginApi(orgId, userId, password) {
|
|
return post("/auth/login", {
|
|
orgid: orgId,
|
|
userid: userId,
|
|
password,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 按表或视图加载数据。
|
|
* @param {string} viewName 表名或视图名,必填。
|
|
* @param {string} [searchCondition] 查询条件,不包含 WHERE。
|
|
* @param {string} [orderField] 排序字段,可带 ASC 或 DESC。
|
|
* @param {string[]} [searchColumns] 需要返回的字段列表,省略时返回全部字段。
|
|
* @returns {Promise<object[]>} 查询结果行。
|
|
*/
|
|
export function loadDataApi(viewName, searchCondition, orderField, searchColumns) {
|
|
return post("/data/loaddata", {
|
|
view_name: viewName,
|
|
search_condition: searchCondition,
|
|
order_field: orderField,
|
|
search_columns: searchColumns,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 执行只读 SQL 查询。
|
|
* @param {string} sql 完整的 SELECT 或 WITH 查询语句。
|
|
* @returns {Promise<object[]>} 查询结果行。
|
|
*/
|
|
export function loadDataBySqlApi(sql) {
|
|
return post("/data/loaddatabysql", { sql });
|
|
}
|