front/docs/itfx枚举说明.md
2026-06-04 19:15:28 +08:00

5.5 KiB
Raw Blame History

itfx(接口通)枚举说明

与后端 itfx-master / InterfaceForward.Domain.Shared.Enum 保持一致。
前端常量见 src/constants/itfxEnums.ts。


获取方式

运行时(下拉选项)

GET api/Dictionary/GetList?type={枚举名}

返回:

[
  { "key": 1, "value": "String" }
]
  • 有 [Description] 的枚举成员,value 取 Description
  • 否则 value 取枚举成员名

编译期(TypeScript 常量)

import {
  FieldPosition,
  ParameterType,
  ItfxDictionaryType,
} from '@/constants/itfxEnums';

枚举总览

枚举名 Dictionary type 用途
ServiceProviderType ✅ 服务商类型
RequestProtocol ✅ 请求协议
RequestMethod ✅ HTTP 方法
ContentType ✅ 请求 Content-Type
ResponseContentType ✅ 响应 Content-Type
ParameterType ✅ 参数数据类型
ParameterPlaceholder ✅ 固定参数占位符
ParameterParseTypeEnum ✅ 参数解析格式
FieldPosition ✅ 字段位置
FieldOwner ❌ 字段所属(仅 DTO)
AuthParameterFlag ✅ 授权参数标识
EffectTimeUnit ✅ Token 有效时间单位
InterfaceReturnConfigType ✅ 接口返回配置
LabelType ✅ 标签类型
OptionType ✅ 增删改操作
LogListInputTypeEnum ✅ 日志筛选

1. 服务商 / 接口基础

ServiceProviderType — 服务商类型

值 名称
1 运输服务商
2 轨迹服务商
3 关务服务商
4 保险服务商

RequestProtocol — 请求协议

值 名称
1 Http
2 Https
3 WCF
4 SOAP

RequestMethod — HTTP 方法

值 名称
1 GET
2 POST
3 PUT
4 DELETE
5 OPTIONS
6 HEAD
7 PATCH

2. 请求 / 响应 Content-Type

ContentType — 请求体类型

值 名称 脚本注意
1 FormUrlEncoded 用 obj.FormFieldList
2 FormData 表单上传
3 Json 用 obj.OriginalInterfaceMappedInput
4 Xml XML 请求体
0 None 无 HTTP Body,仅 Query / Header

ResponseContentType — 响应体类型

值 名称
1 Json
2 Xml
3 pdf
4 Base64
5 csv

3. 参数相关

ParameterType — 参数数据类型

值 名称
1 String
2 Float
3 Object
4 Boolean
5 Array
6 Integer
7 DateTime
8 DateTimeOffset

ParameterPlaceholder — 固定参数占位符

值 枚举名 实际占位符
1 FromAccount $FromAccount
2 FromBody $FromBody
3 TimeStamp $TimeStamp
4 DateTime $DateTime
5 Url $Url
6 Token $token

占位符在 ReplacePlaceholder 阶段替换,早于 PrefixScript 执行。

ParameterParseTypeEnum — 参数解析类型

值 名称
1 Json
2 Xml

FieldPosition — 字段位置

值 名称 说明
1 Header 请求头
2 Body 请求体
3 Query Query 参数
4 Url URL 路径
5 Nothing 不处理

前置脚本示例(Header):

for (int i = 0; i < obj.FixedFieldList.Count; i++) {
    if (obj.FixedFieldList[i].FieldPosition == 1
        && obj.FixedFieldList[i].FieldName == "sign") {
        obj.FixedFieldList[i].FieldValue = sign;
        break;
    }
}

FieldOwner — 字段所属

值 名称
0 ServiceProvider
1 Interface
2 AuthConfig

4. 授权 / Token

AuthParameterFlag — 授权参数标识

值 名称 说明
1 InParameter 入参
2 Token 授权令牌
3 EffectTime 有效时间
4 FixedEffectTime 固定有效时间
5 PrefixScript 前置脚本
6 PostfixScript 后置脚本

EffectTimeUnit — 有效时间单位

值 名称
1 Second
2 Minute
3 Hour

5. 接口返回 / 标签

InterfaceReturnConfigType — 接口返回配置

值 名称
1 StatusCode(状态码)
2 PdfLabel(PDF 标签上传)
3 ErrorMsg(错误信息返回)

LabelType — 标签类型

值 名称
1 Url
2 Base64

6. 通用 / 日志

OptionType — 操作类型

值 名称
0 无
1 新增
2 删除
3 修改

LogListInputTypeEnum — 日志筛选

值 名称
1 应用
2 服务商

前置 / 后置脚本相关速查

场景 关键枚举 / 字段
Header 签名 FieldPosition.Header (=1) → obj.FixedFieldList
Query 签名 FieldPosition.Query (=3) → obj.FixedFieldList
JSON Body 字段 ContentType.Json (=3) → obj.OriginalInterfaceMappedInput
Form 签名 ContentType.FormUrlEncoded (=1) → obj.FormFieldList
账户密钥 obj.GetAccountFieldValueOrNull("字段名")
时间戳占位 固定参数配 $TimeStamp,脚本阶段已替换

后端源码位置

itfx-master/src/InterfaceForward.Domain.Shared/Enum/*.cs
itfx-master/src/InterfaceForward.Domain.Shared/Dtos/FixedFieldWithValueDto.cs  (FieldOwner)
itfx-master/src/InterfaceForward.Application/Services/App/DictionaryService.cs