Files
workspace/code/fms/.workbuddy/skills/fms-dev/references/api-reference.md
T
2026-08-02 22:05:44 +08:00

3.3 KiB
Raw Blame History

FMS API 详细参数参考

DataController 端点参数

POST /data/loaddata

Body: {
  "view_name": "string (required) — 表名或视图名",
  "search_condition": "string (optional) — WHERE 条件表达式,如 b_id = 1 AND b_name LIKE N'%关键词%'",
  "order_by": "string (optional) — 排序,如 b_id ASC 或 b_xh ASC, b_id DESC",
  "search_columns": ["string"] (optional) — 查询列,默认 *"
}
Response: { code: 0, message: "操作成功", data: [{...row}] }

POST /data/page

Body: {
  "view_name": "string (required)",
  "order_by": "string (required) — 支持逗号分隔多字段",
  "page_no": int (optional, default 1),
  "page_size": int (optional, default 20),
  "search_condition": "string (optional)",
  "search_columns": ["string"] (optional)
}
Response: {
  code: 0,
  data: {
    rows: [{...row}],
    row_count: int,
    total: int,
    page_no: int,
    page_size: int
  }
}

POST /data/saveobjt

Body: [{
  "table": "string (required) — 目标表名",
  "key_field": "string (required) — 主键字段名,通常为 b_id",
  "inserts": [{...row}] (optional) — 新增行,key_field 值 < 0 时自动分配雪花ID",
  "updates": [{...row}] (optional) — 修改行,必须包含 key_field 值",
  "deletes": [{...row}] (optional) — 删除行,必须包含 key_field 值",
}]
Response: { code: 0, message: "操作成功", data: null }

执行顺序:deletes → updates → inserts。整体在一个事务中。

POST /data/loaddatabysql

Body: { "sql": "string (required) — 仅允许 SELECT 或 WITH 开头" }
Response: { code: 0, data: [{...row}] }

安全检查:

  • 必须以 SELECT 或 WITH 开头
  • 禁止 INSERT/UPDATE/DELETE/DROP/ALTER/CREATE/EXEC/GRANT 等 DML/DDL
  • 禁止 SQL 注释(--、/* */)
  • 禁止分号

GET /data/nextid

Query: ?count=int (optional, default 1)
Response: {
  code: 0,
  data: "1234567890123456" (count=1) | ["id1", "id2"] (count>1)
}

GET /data/nextcode

Query: ?moduleId=long&count=int (optional, default 1)
Response: {
  code: 0,
  data: "PREFIX2025080200001" (count=1) | ["code1", "code2"] (count>1)
}

POST /data/describe

Body: { "table": "string" }
Response: { code: 0, data: [{ name: "b_id", type: "bigint", nullable: false, size: 19 }] }

AuthController

POST /auth/login

Body: {
  "orgid": "string (required) — 机构码",
  "userid": "string (required) — 账号",
  "password": "string (optional) — 密码"
}
Response (成功): {
  code: 0,
  data: {
    token: "eyJ...",
    orgid: "ORG001",
    user: { id: 1001, account: "admin", name: "管理员" }
  }
}
Response (失败): { code: 401, message: "机构码、账号或密码错误" }

FileController

GET /file/config

Response: { code: 0, data: { storageType: "local" | "aliyun-oss" } }

POST /file/upload (local 模式)

Content-Type: multipart/form-data
Fields: { files: File[], father: string, moduleId: string, cateId?: string }
Response: { code: 0, data: [{...fileRecord}] }

POST /file/upload-credential (OSS 模式)

Response: { code: 0, data: { accessId, accessKey, host, policy, signature, expire } }

POST /file/save-record (OSS 回调)

Body: { subid: string, father: string, mx_moduleid: string, mx_cate_id?: string }

POST /file/delete

Body: { subid: string }