This commit is contained in:
@@ -51,7 +51,7 @@ WeComNotifier ────────► ApiChangeNotifier(新
|
||||
**方法指纹建议**(用于跨 commit 匹配同一接口):
|
||||
|
||||
```
|
||||
controller源文件 + 方法名 + 参数槽位(如 0:query,1:body;不含类型与绑定名)
|
||||
controller源文件 + 方法名(不含参数信息;增删参/改类型等由 ParameterDiffEngine 检测)
|
||||
```
|
||||
|
||||
仅 URI 匹配在「改路径」场景会失效,需指纹辅助。
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
1. 解析旧/新 commit 下同一 Controller 源码 AST
|
||||
2. 提取每个方法的 `httpMethod` + `uri`(已有 `EndpointParser` 逻辑)
|
||||
3. 用**方法指纹**(类文件 + 方法名 + 参数槽位,如 `0:query,1:query`;不含类型与绑定名)匹配新旧接口
|
||||
3. 用**方法指纹**(类文件 + 方法名,如 `ApplyClockInController.java#getApply`)匹配新旧接口;参数增删改由 ParameterDiffEngine 检测
|
||||
4. 指纹相同且 URI 不同 → **修改路径**
|
||||
5. 仅旧有新无 → **删除**;仅新有旧无 → **新增**
|
||||
|
||||
|
||||
@@ -29,16 +29,9 @@ public class EndpointSnapshot {
|
||||
this.parameters = parameters == null ? List.of() : new ArrayList<>(parameters);
|
||||
}
|
||||
|
||||
public static String buildFingerprint(String sourceFile, String methodName,
|
||||
List<MethodParameterSnapshot> parameters) {
|
||||
StringBuilder sig = new StringBuilder();
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
if (i > 0) {
|
||||
sig.append(',');
|
||||
}
|
||||
sig.append(parameters.get(i).fingerprintSlotKey(i));
|
||||
}
|
||||
return sourceFile + "#" + methodName + "#" + sig;
|
||||
/** 跨 commit 配对同一 Java 方法;不含参数信息,参数 diff 由 ParameterDiffEngine 负责 */
|
||||
public static String buildFingerprint(String sourceFile, String methodName) {
|
||||
return sourceFile + "#" + methodName;
|
||||
}
|
||||
|
||||
public String getFingerprint() {
|
||||
|
||||
@@ -53,11 +53,6 @@ public class MethodParameterSnapshot {
|
||||
return dtoClassName;
|
||||
}
|
||||
|
||||
/** 接口指纹槽位:序号 + 参数来源,不含类型与绑定名,避免类型/绑定变更导致误配对 */
|
||||
public String fingerprintSlotKey(int index) {
|
||||
return index + ":" + source;
|
||||
}
|
||||
|
||||
/** path/query 按绑定名匹配,避免仅 Java 形参重命名误报 */
|
||||
public String identityKey() {
|
||||
if ("path".equals(source) || "query".equals(source)) {
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ApiChangeNotifier {
|
||||
sb.append("# 【API参数变更通知】").append("\n\n");
|
||||
sb.append(MarkdownStyles.quoteKvBold("修改人", MarkdownStyles.colorComment(modifier))).append("\n");
|
||||
sb.append(MarkdownStyles.quoteKvBold("时间", MarkdownStyles.colorComment(modifyTime))).append("\n");
|
||||
sb.append(MarkdownStyles.quoteKvBold("变更类型", MarkdownStyles.colorWarning("修改参数"))).append("\n");
|
||||
//sb.append(MarkdownStyles.quoteKvBold("变更类型", MarkdownStyles.colorWarning("修改参数"))).append("\n");
|
||||
sb.append(MarkdownStyles.quoteKvBold("URI",
|
||||
MarkdownStyles.colorInfo(report.getHttpMethod()) + " "
|
||||
+ MarkdownStyles.inlineCode(report.getUri()))).append("\n");
|
||||
|
||||
@@ -93,7 +93,7 @@ public class EndpointSnapshotParser {
|
||||
List<String> httpMethods = extractHttpMethods(annotation, annName);
|
||||
List<MethodParameterSnapshot> params = extractParameters(method);
|
||||
String methodDescription = MethodDescriptionExtractor.extract(method);
|
||||
String fingerprint = EndpointSnapshot.buildFingerprint(sourceFile, method.getNameAsString(), params);
|
||||
String fingerprint = EndpointSnapshot.buildFingerprint(sourceFile, method.getNameAsString());
|
||||
for (String httpMethod : httpMethods) {
|
||||
for (String subPath : subPaths) {
|
||||
String uri = joinPaths(basePath, subPath);
|
||||
|
||||
Reference in New Issue
Block a user