This commit is contained in:
@@ -239,32 +239,67 @@ def send_parameter_change_notification(
|
|||||||
mentioned_users: Optional[List[str]] = None,
|
mentioned_users: Optional[List[str]] = None,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""
|
"""
|
||||||
发送 Markdown 格式的接口参数变更通知。
|
发送 Markdown 格式的接口变更通知。
|
||||||
|
|
||||||
:param webhook_url: 企微 Webhook
|
按变更类型拆分,分别下发企微通知:
|
||||||
:param reports: 变更报告
|
- 方法变更 → 【API请求方式变更通知】
|
||||||
:param push_user: 推送人
|
- 路径变更(新增/修改/删除) → 【API路径变更通知】
|
||||||
:param push_time: 推送时间
|
- 参数变更 → API参数变更通知
|
||||||
:param llm_review: LLM 兼容性摘要
|
|
||||||
:param mentioned_users: @ 成员(Markdown 暂不支持,保留参数)
|
不同类型之间互不干扰,各自独立发送。
|
||||||
:return: 成功发送条数
|
|
||||||
"""
|
"""
|
||||||
if not reports and not llm_review:
|
if not reports and not llm_review:
|
||||||
print("无接口参数变更,不发送到企业微信")
|
print("无接口参数变更,不发送到企业微信")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
full_md = build_markdown_notification(reports, push_user, push_time, llm_review)
|
# 按类型分组
|
||||||
segments = _split_markdown(full_md, MAX_MD_LENGTH)
|
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]
|
||||||
|
removed_reports = [r for r in reports if r.is_removed_endpoint]
|
||||||
|
changed_reports = [
|
||||||
|
r for r in reports
|
||||||
|
if not r.is_new_endpoint
|
||||||
|
and not r.is_removed_endpoint
|
||||||
|
and not r.is_renamed_endpoint
|
||||||
|
and not r.is_method_changed
|
||||||
|
]
|
||||||
|
|
||||||
sent = 0
|
sent = 0
|
||||||
for i, segment in enumerate(segments):
|
|
||||||
if i > 0:
|
# 1. 方法变更通知
|
||||||
segment = (
|
if method_changed_reports:
|
||||||
f"<font color=\"comment\">(续 {i + 1}/{len(segments)})</font>\n\n" + segment
|
md = build_markdown_notification(method_changed_reports, push_user, push_time)
|
||||||
)
|
segments = _split_markdown(md, MAX_MD_LENGTH)
|
||||||
if _post_wecom_markdown(webhook_url, segment):
|
for i, segment in enumerate(segments):
|
||||||
sent += 1
|
if i > 0:
|
||||||
print(f"第 {sent} 条通知已发送到企业微信")
|
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. 路径变更通知(新增/修改/删除)
|
||||||
|
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} 条通知已发送到企业微信(路径变更)")
|
||||||
|
|
||||||
|
# 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} 条通知已发送到企业微信(参数变更)")
|
||||||
|
|
||||||
if sent > 0:
|
if sent > 0:
|
||||||
print(f"总共发送 {sent} 条通知到企业微信")
|
print(f"总共发送 {sent} 条通知到企业微信")
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class CultureClockInController {
|
|||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/random-preview/base641")
|
@GetMapping(value = "/random-preview/base641")
|
||||||
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo", required = true) String lastCombo, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo1", required = true) 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) {
|
||||||
@@ -91,7 +91,7 @@ public class CultureClockInController {
|
|||||||
* @param lastCombo 上次组合
|
* @param lastCombo 上次组合
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/random-preview/delete")
|
@PostMapping(value = "/random-preview/delete")
|
||||||
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo", required = false) String lastCombo, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public ActionResult<Base64ImageVo> getRandomPicPreviewBase64(@RequestParam(value = "lastCombo", 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user