All files / src/services api.js

100% Statements 8/8
100% Branches 4/4
100% Functions 8/8
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81            1x                     2x                       1x                           2x                           1x             2x             1x             1x    
import { post } from './http'
 
/**
 * 机构用户登录。account 即机构账号,对应后端登录参数 userid。
 */
export function loginApi(orgId, account, password) {
  return post('/auth/login', { orgid: orgId, userid: account, password })
}
 
/**
 * 按表或视图加载数据。
 * @param viewName 表名或视图名,必填。
 * @param searchCondition 查询条件,不包含 WHERE。
 * @param orderBy 排序字段,可带 ASC 或 DESC。
 * @param searchColumns 需要返回的字段列表,省略时返回全部字段。
 */
export function loadDataApi(viewName, searchCondition, orderBy, searchColumns) {
  return post('/data/loaddata', {
    view_name: viewName,
    search_condition: searchCondition,
    order_by: orderBy,
    search_columns: searchColumns,
  })
}
 
/**
 * 执行只读 SQL 查询。
 */
export function loadDataBySqlApi(sql) {
  return post('/data/loaddatabysql', { sql })
}
 
/**
 * 分页加载表或视图数据。
 */
export function pageDataApi({
  viewName,
  orderBy,
  searchColumns,
  searchCondition,
  pageNo = 1,
  pageSize = 20,
}) {
  return post('/data/page', {
    view_name: viewName,
    order_by: orderBy,
    search_columns: searchColumns,
    search_condition: searchCondition,
    page_no: pageNo,
    page_size: pageSize,
  })
}
 
/**
 * 在同一事务中保存一个或多个表的数据变更。
 */
export function saveObjectApi(requests) {
  return post('/data/saveobjt', requests)
}
 
/**
 * 获取下一个雪花 ID;传入 count 可批量获取指定数量的 ID(返回数组)。
 */
export function nextIdApi(count = 1) {
  return post('/data/nextid', { count })
}
 
/**
 * 按模块规则原子获取业务编号。
 */
export function nextCodeApi(moduleId, count = 1) {
  return post('/data/nextcode', { moduleId: String(moduleId), count })
}
 
/**
 * 读取表或视图的列结构。
 */
export function describeApi(table) {
  return post('/data/describe', { table })
}