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