This commit is contained in:
@@ -101,19 +101,17 @@ def build_markdown_notification(
|
|||||||
parts.append(path_md)
|
parts.append(path_md)
|
||||||
parts.append("")
|
parts.append("")
|
||||||
|
|
||||||
# 2. 修改请求方式 → 走 API路径变更通知
|
# 2. 修改请求方式 → 使用独立的新模板 【API请求方式变更通知】
|
||||||
for report in method_changed_reports:
|
for report in method_changed_reports:
|
||||||
path_md = build_path_change_markdown(
|
method_md = build_method_change_markdown(
|
||||||
old_uri=report.uri,
|
uri=report.uri,
|
||||||
new_uri=report.uri,
|
old_method=report.old_http_method or "?",
|
||||||
change_type="修改请求方式",
|
new_method=report.http_method,
|
||||||
push_user=push_user,
|
push_user=push_user,
|
||||||
push_time=push_time,
|
push_time=push_time,
|
||||||
file_name=report.source_file or report.controller_class,
|
file_name=report.source_file or report.controller_class,
|
||||||
old_method=report.old_http_method,
|
|
||||||
new_method=report.http_method,
|
|
||||||
)
|
)
|
||||||
parts.append(path_md)
|
parts.append(method_md)
|
||||||
parts.append("")
|
parts.append("")
|
||||||
|
|
||||||
# 3. 修改路径 → 走 API路径变更通知
|
# 3. 修改路径 → 走 API路径变更通知
|
||||||
@@ -278,8 +276,6 @@ def build_path_change_markdown(
|
|||||||
push_user: str,
|
push_user: str,
|
||||||
push_time: str,
|
push_time: str,
|
||||||
file_name: str,
|
file_name: str,
|
||||||
old_method: Optional[str] = None,
|
|
||||||
new_method: Optional[str] = None,
|
|
||||||
) -> str:
|
) -> str:
|
||||||
"""构建 API路径变更通知,完全匹配 model1.md 模板,并加强视觉区分。
|
"""构建 API路径变更通知,完全匹配 model1.md 模板,并加强视觉区分。
|
||||||
|
|
||||||
@@ -305,15 +301,6 @@ def build_path_change_markdown(
|
|||||||
elif change_type == "删除接口":
|
elif change_type == "删除接口":
|
||||||
old_display = f"<font color=\"warning\">**`{old_uri}`**</font> ← <font color=\"warning\">**已删除**</font>"
|
old_display = f"<font color=\"warning\">**`{old_uri}`**</font> ← <font color=\"warning\">**已删除**</font>"
|
||||||
new_display = "`已删除`"
|
new_display = "`已删除`"
|
||||||
elif change_type == "修改请求方式":
|
|
||||||
# 方法变更场景:展示原方法 → 新方法
|
|
||||||
old_m = old_method or "?"
|
|
||||||
new_m = new_method or "?"
|
|
||||||
old_display = f"<font color=\"warning\">**`{old_uri}`</font> <font color=\"warning\">**[{old_m}]**</font>"
|
|
||||||
new_display = (
|
|
||||||
f"<font color=\"info\">**`{new_uri}`</font> "
|
|
||||||
f"<font color=\"warning\">**[{old_m} → {new_m}]**</font> ← <font color=\"info\">**请求方式变更**</font>"
|
|
||||||
)
|
|
||||||
else: # 修改路径
|
else: # 修改路径
|
||||||
old_display = f"<font color=\"warning\">~~`{old_uri}`~~</font> ← <font color=\"warning\">**旧路径**</font>"
|
old_display = f"<font color=\"warning\">~~`{old_uri}`~~</font> ← <font color=\"warning\">**旧路径**</font>"
|
||||||
new_display = f"<font color=\"info\">**`{new_uri}`**</font> ← <font color=\"info\">**新路径**</font>"
|
new_display = f"<font color=\"info\">**`{new_uri}`**</font> ← <font color=\"info\">**新路径**</font>"
|
||||||
@@ -337,6 +324,45 @@ def build_path_change_markdown(
|
|||||||
return "\n".join(parts).strip()
|
return "\n".join(parts).strip()
|
||||||
|
|
||||||
|
|
||||||
|
def build_method_change_markdown(
|
||||||
|
uri: str,
|
||||||
|
old_method: str,
|
||||||
|
new_method: str,
|
||||||
|
push_user: str,
|
||||||
|
push_time: str,
|
||||||
|
file_name: str,
|
||||||
|
) -> str:
|
||||||
|
"""构建【API请求方式变更通知】独立模板。
|
||||||
|
|
||||||
|
格式参考 model1.md,但专门针对 HTTP 方法变更场景设计,
|
||||||
|
突出「原请求方式 → 新请求方式」的对比。
|
||||||
|
"""
|
||||||
|
type_highlight = '<font color="warning">**修改请求方式**</font>'
|
||||||
|
class_highlight = f'<font color="info">**{file_name}**</font>'
|
||||||
|
uri_highlight = f'<font color="info">**`{uri}`**</font>'
|
||||||
|
old_m = f'<font color="warning">**{old_method}**</font>'
|
||||||
|
new_m = f'<font color="info">**{new_method}**</font>'
|
||||||
|
|
||||||
|
parts = [
|
||||||
|
"# 【API请求方式变更通知】",
|
||||||
|
"",
|
||||||
|
f" 变更类型: {type_highlight}",
|
||||||
|
f" 全路径类名: {class_highlight}",
|
||||||
|
f" 修改人: {push_user}",
|
||||||
|
f" 修改时间: {push_time}",
|
||||||
|
"",
|
||||||
|
"---",
|
||||||
|
"",
|
||||||
|
"#### 【请求方式变更详情】",
|
||||||
|
f"- **URI:** {uri_highlight}",
|
||||||
|
f"- **原请求方式:** {old_m}",
|
||||||
|
f"- **新请求方式:** {new_m} ← <font color=\"info\">**请求方式已变更**</font>",
|
||||||
|
"",
|
||||||
|
"---",
|
||||||
|
]
|
||||||
|
return "\n".join(parts).strip()
|
||||||
|
|
||||||
|
|
||||||
def send_path_change_notification(
|
def send_path_change_notification(
|
||||||
webhook_url: str,
|
webhook_url: str,
|
||||||
old_uri: str,
|
old_uri: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user