fix: 接口参数占位符 $Token 大小写,并修复 Query/Header 空值删除无法落库
All checks were successful
Build and Deploy Front / deploy (push) Successful in 5m51s
All checks were successful
Build and Deploy Front / deploy (push) Successful in 5m51s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
50b3eac99c
commit
2612a225ad
@ -3905,7 +3905,7 @@
|
|||||||
<li><strong>参数名</strong>:与服务商文档、curl、Mapping Body / Body 参数树、前置脚本写入字段名保持一致(如 <code>_aop_signature</code>、<code>notifyBizEventDTO</code>)。</li>
|
<li><strong>参数名</strong>:与服务商文档、curl、Mapping Body / Body 参数树、前置脚本写入字段名保持一致(如 <code>_aop_signature</code>、<code>notifyBizEventDTO</code>)。</li>
|
||||||
<li><strong>参数值</strong>:使用<strong>占位符</strong>或留空,不要填写 curl 中的真实签名/业务样例;转发前由 Like API 替换。</li>
|
<li><strong>参数值</strong>:使用<strong>占位符</strong>或留空,不要填写 curl 中的真实签名/业务样例;转发前由 Like API 替换。</li>
|
||||||
<li><code>$FromMappingBody</code>(FormUrlEncoded):Query 上承载业务 JSON 的字段(如 <code>*DTO</code>)填此占位符,映射结果来自 <strong>Mapping Body</strong> 参数树;POST 参数仅在 URL、无 Body 时,DTO 应配置在 Query 而非 Body 表单。</li>
|
<li><code>$FromMappingBody</code>(FormUrlEncoded):Query 上承载业务 JSON 的字段(如 <code>*DTO</code>)填此占位符,映射结果来自 <strong>Mapping Body</strong> 参数树;POST 参数仅在 URL、无 Body 时,DTO 应配置在 Query 而非 Body 表单。</li>
|
||||||
<li><code>$FromAccount</code>:按参数名从<strong>服务商账户</strong>取值;<code>$TimeStamp</code> / <code>$DateTime</code>:时间;<code>$token</code>:令牌;<code>$Url</code>:当前请求地址。</li>
|
<li><code>$FromAccount</code>:按参数名从<strong>服务商账户</strong>取值;<code>$TimeStamp</code> / <code>$DateTime</code>:时间;<code>$Token</code>:令牌;<code>$Url</code>:当前请求地址。</li>
|
||||||
<li><strong>留空</strong>:签名类参数(如 <code>sign</code>、<code>_aop_signature</code>)由<strong>前置脚本</strong>写入。</li>
|
<li><strong>留空</strong>:签名类参数(如 <code>sign</code>、<code>_aop_signature</code>)由<strong>前置脚本</strong>写入。</li>
|
||||||
<li><strong>参数描述</strong>:可记录备注或 curl 片段,便于对照映射,不参与转发。</li>
|
<li><strong>参数描述</strong>:可记录备注或 curl 片段,便于对照映射,不参与转发。</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -100,7 +100,7 @@ export const ParameterPlaceholderText: Record<number, string> = {
|
|||||||
[ParameterPlaceholder.TimeStamp]: '$TimeStamp',
|
[ParameterPlaceholder.TimeStamp]: '$TimeStamp',
|
||||||
[ParameterPlaceholder.DateTime]: '$DateTime',
|
[ParameterPlaceholder.DateTime]: '$DateTime',
|
||||||
[ParameterPlaceholder.Url]: '$Url',
|
[ParameterPlaceholder.Url]: '$Url',
|
||||||
[ParameterPlaceholder.Token]: '$token',
|
[ParameterPlaceholder.Token]: '$Token',
|
||||||
[ParameterPlaceholder.FromMappingBody]: '$FromMappingBody',
|
[ParameterPlaceholder.FromMappingBody]: '$FromMappingBody',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -399,6 +399,14 @@ function isSameFormKvRow(row: any, baseline: NormalizedParamRow): boolean {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPersistableFormKvRow(p: any) {
|
||||||
|
// 删除只依赖 id;参数值允许留空(签名类由前置脚本写入)
|
||||||
|
if (Number(p?.optionType) === 2) {
|
||||||
|
return Number(p?.id) > 0;
|
||||||
|
}
|
||||||
|
return !!(p.name && String(p.name).trim() !== '');
|
||||||
|
}
|
||||||
|
|
||||||
function buildFormKvParameterList(
|
function buildFormKvParameterList(
|
||||||
changes: any[],
|
changes: any[],
|
||||||
tableData: any[],
|
tableData: any[],
|
||||||
@ -406,24 +414,23 @@ function buildFormKvParameterList(
|
|||||||
isEditMode: boolean,
|
isEditMode: boolean,
|
||||||
original: OriginalParamSnapshot,
|
original: OriginalParamSnapshot,
|
||||||
) {
|
) {
|
||||||
const isValid = (p: any) =>
|
|
||||||
p.name && String(p.name).trim() !== '' && p.value && String(p.value).trim() !== '';
|
|
||||||
|
|
||||||
const changeById = new Map(changes.map((c) => [Number(c.id), c]));
|
const changeById = new Map(changes.map((c) => [Number(c.id), c]));
|
||||||
const removedIds = new Set(
|
const removedIds = new Set(
|
||||||
changes.filter((c) => c.optionType === 2).map((c) => Number(c.id)),
|
changes.filter((c) => c.optionType === 2).map((c) => Number(c.id)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isEditMode) {
|
if (!isEditMode) {
|
||||||
if (changes.length) return changes;
|
if (changes.length) return changes.filter(isPersistableFormKvRow);
|
||||||
return (tableData || [])
|
return (tableData || [])
|
||||||
.map((item) => mapFormKvRow(stripFormKvMeta(item), 1, fieldPosition))
|
.map((item) => mapFormKvRow(stripFormKvMeta(item), 1, fieldPosition))
|
||||||
.filter(isValid);
|
.filter(isPersistableFormKvRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: any[] = [];
|
const result: any[] = [];
|
||||||
changes.filter((c) => c.optionType === 2).forEach((c) => result.push(c));
|
changes.filter((c) => c.optionType === 2).forEach((c) => result.push(c));
|
||||||
|
|
||||||
|
const presentServerIds = new Set<number>();
|
||||||
|
|
||||||
(tableData || []).forEach((item) => {
|
(tableData || []).forEach((item) => {
|
||||||
const rest = stripFormKvMeta(item);
|
const rest = stripFormKvMeta(item);
|
||||||
const id = normalizeRowId(rest);
|
const id = normalizeRowId(rest);
|
||||||
@ -435,6 +442,8 @@ function buildFormKvParameterList(
|
|||||||
const tracked = changeById.get(id);
|
const tracked = changeById.get(id);
|
||||||
if (tracked && tracked.optionType !== 2) {
|
if (tracked && tracked.optionType !== 2) {
|
||||||
result.push(tracked);
|
result.push(tracked);
|
||||||
|
const trackedServerId = Number(tracked.id);
|
||||||
|
if (trackedServerId > 0) presentServerIds.add(trackedServerId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +452,7 @@ function buildFormKvParameterList(
|
|||||||
const baseline = serverId ? original.rowById.get(serverId) : undefined;
|
const baseline = serverId ? original.rowById.get(serverId) : undefined;
|
||||||
|
|
||||||
if (serverId && baseline) {
|
if (serverId && baseline) {
|
||||||
|
presentServerIds.add(serverId);
|
||||||
if (!isSameFormKvRow(rest, baseline)) {
|
if (!isSameFormKvRow(rest, baseline)) {
|
||||||
result.push(mapFormKvRow(rest, 3, fieldPosition, serverId));
|
result.push(mapFormKvRow(rest, 3, fieldPosition, serverId));
|
||||||
}
|
}
|
||||||
@ -454,7 +464,22 @@ function buildFormKvParameterList(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.filter(isValid);
|
// VXE removeRecords 丢失时,仍按「原始快照有、当前表无」补删,避免库里残留
|
||||||
|
original.ids.forEach((serverId) => {
|
||||||
|
if (removedIds.has(serverId) || presentServerIds.has(serverId)) return;
|
||||||
|
const baseline = original.rowById.get(serverId);
|
||||||
|
if (!baseline?.name) return;
|
||||||
|
result.push({
|
||||||
|
id: serverId,
|
||||||
|
name: baseline.name,
|
||||||
|
value: baseline.alias || '',
|
||||||
|
description: baseline.description || '',
|
||||||
|
optionType: 2,
|
||||||
|
fieldPosition,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return result.filter(isPersistableFormKvRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapFormKvChanges(
|
function mapFormKvChanges(
|
||||||
@ -476,9 +501,7 @@ function mapFormKvChanges(
|
|||||||
...(actionRows.updateRecords || []).map((r) => mapRow(r, 3)),
|
...(actionRows.updateRecords || []).map((r) => mapRow(r, 3)),
|
||||||
];
|
];
|
||||||
|
|
||||||
return list.filter(
|
return list.filter(isPersistableFormKvRow);
|
||||||
(p) => p.name && String(p.name).trim() !== '' && p.value && String(p.value).trim() !== '',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InterfaceDetailSnapshot {
|
export interface InterfaceDetailSnapshot {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user