This commit is contained in:
@@ -240,18 +240,18 @@ def send_parameter_change_notification(
|
||||
"""
|
||||
发送 Markdown 格式的接口变更通知。
|
||||
|
||||
按变更类型拆分,分别下发企微通知:
|
||||
- 方法变更 → 【API请求方式变更通知】
|
||||
- 路径变更(新增/修改/删除) → 【API路径变更通知】
|
||||
- 参数变更 → API参数变更通知
|
||||
严格按变更类型拆分,各自独立构建和发送企微通知:
|
||||
- 方法变更 → 独立调用 build_method_change_markdown
|
||||
- 路径变更(新增/修改/删除) → 独立调用 build_path_change_markdown
|
||||
- 参数变更 → 独立调用 _format_endpoint_block
|
||||
|
||||
不同类型之间互不干扰,各自独立发送。
|
||||
不同类型之间完全互不干扰,各自走独立分支。
|
||||
"""
|
||||
if not reports and not llm_review:
|
||||
print("无接口参数变更,不发送到企业微信")
|
||||
return 0
|
||||
|
||||
# 按类型分组
|
||||
# 按类型严格分组(互不重叠)
|
||||
method_changed_reports = [r for r in reports if r.is_method_changed]
|
||||
renamed_reports = [r for r in reports if r.is_renamed_endpoint]
|
||||
new_reports = [r for r in reports if r.is_new_endpoint]
|
||||
@@ -266,39 +266,83 @@ def send_parameter_change_notification(
|
||||
|
||||
sent = 0
|
||||
|
||||
# 1. 方法变更通知
|
||||
if method_changed_reports:
|
||||
md = build_markdown_notification(method_changed_reports, push_user, push_time)
|
||||
segments = _split_markdown(md, MAX_MD_LENGTH)
|
||||
for i, segment in enumerate(segments):
|
||||
if i > 0:
|
||||
segment = f"<font color=\"comment\">(续 {i + 1}/{len(segments)})</font>\n\n" + segment
|
||||
if _post_wecom_markdown(webhook_url, segment):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(请求方式变更)")
|
||||
# ========== 1. 请求方式变更通知(独立分支) ==========
|
||||
for report in method_changed_reports:
|
||||
md = build_method_change_markdown(
|
||||
uri=report.uri,
|
||||
old_method=report.old_http_method or "?",
|
||||
new_method=report.http_method,
|
||||
push_user=push_user,
|
||||
push_time=push_time,
|
||||
file_name=report.source_file or report.controller_class,
|
||||
)
|
||||
if _post_wecom_markdown(webhook_url, md):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(请求方式变更)")
|
||||
|
||||
# 2. 路径变更通知(新增/修改/删除)
|
||||
path_reports = new_reports + renamed_reports + removed_reports
|
||||
if path_reports:
|
||||
md = build_markdown_notification(path_reports, push_user, push_time)
|
||||
segments = _split_markdown(md, MAX_MD_LENGTH)
|
||||
for i, segment in enumerate(segments):
|
||||
if i > 0:
|
||||
segment = f"<font color=\"comment\">(续 {i + 1}/{len(segments)})</font>\n\n" + segment
|
||||
if _post_wecom_markdown(webhook_url, segment):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(路径变更)")
|
||||
# ========== 2. 路径变更通知(新增/修改/删除) ==========
|
||||
# 新增接口
|
||||
for report in new_reports:
|
||||
md = build_path_change_markdown(
|
||||
old_uri="-",
|
||||
new_uri=report.uri,
|
||||
change_type="新增接口",
|
||||
push_user=push_user,
|
||||
push_time=push_time,
|
||||
file_name=report.source_file or report.controller_class,
|
||||
)
|
||||
if _post_wecom_markdown(webhook_url, md):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(新增接口)")
|
||||
|
||||
# 3. 参数变更通知
|
||||
# 修改路径
|
||||
for report in renamed_reports:
|
||||
md = build_path_change_markdown(
|
||||
old_uri=report.old_uri or "-",
|
||||
new_uri=report.uri,
|
||||
change_type="修改路径",
|
||||
push_user=push_user,
|
||||
push_time=push_time,
|
||||
file_name=report.source_file or report.controller_class,
|
||||
)
|
||||
if _post_wecom_markdown(webhook_url, md):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(修改路径)")
|
||||
|
||||
# 删除接口
|
||||
for report in removed_reports:
|
||||
md = build_path_change_markdown(
|
||||
old_uri=report.uri,
|
||||
new_uri="已删除",
|
||||
change_type="删除接口",
|
||||
push_user=push_user,
|
||||
push_time=push_time,
|
||||
file_name=report.source_file or report.controller_class,
|
||||
)
|
||||
if _post_wecom_markdown(webhook_url, md):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(删除接口)")
|
||||
|
||||
# ========== 3. 参数变更通知(独立分支) ==========
|
||||
if changed_reports:
|
||||
md = build_markdown_notification(changed_reports, push_user, push_time, llm_review)
|
||||
segments = _split_markdown(md, MAX_MD_LENGTH)
|
||||
for i, segment in enumerate(segments):
|
||||
if i > 0:
|
||||
segment = f"<font color=\"comment\">(续 {i + 1}/{len(segments)})</font>\n\n" + segment
|
||||
if _post_wecom_markdown(webhook_url, segment):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(参数变更)")
|
||||
# 构建参数变更通知(只包含参数变更报告)
|
||||
parts: List[str] = []
|
||||
parts.append("# API参数变更通知")
|
||||
parts.append(f"- **修改人:** {push_user if push_user.startswith('@') else '@' + push_user}")
|
||||
parts.append(f"- **修改时间:** {push_time}")
|
||||
parts.append("")
|
||||
for report in changed_reports:
|
||||
parts.append(_format_endpoint_block(report))
|
||||
parts.append("")
|
||||
if llm_review:
|
||||
parts.append("---")
|
||||
parts.append("### <font color=\"comment\">兼容性提示</font>")
|
||||
parts.append(llm_review.strip())
|
||||
|
||||
md = "\n".join(parts).strip()
|
||||
if _post_wecom_markdown(webhook_url, md):
|
||||
sent += 1
|
||||
print(f"第 {sent} 条通知已发送到企业微信(参数变更)")
|
||||
|
||||
if sent > 0:
|
||||
print(f"总共发送 {sent} 条通知到企业微信")
|
||||
|
||||
@@ -69,8 +69,8 @@ public class CultureClockInController {
|
||||
* @param lastCombo 上次组合
|
||||
* @param response HttpServletResponse
|
||||
*/
|
||||
@PostMapping(value = "/random-preview/base64")
|
||||
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo", required = false) String lastCombo, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
@GetMapping(value = "/random-preview/base641")
|
||||
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo1", required = false) String lastCombo, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
MutablePair<String, BufferedImage> pair = cultureClockInService.getRandomPicPreview(lastCombo, requestUrl);
|
||||
if (pair == null || pair.getRight() == null) {
|
||||
|
||||
Reference in New Issue
Block a user