This commit is contained in:
2026-06-03 13:19:18 +08:00
parent 1a96f59e42
commit 5824149138
3 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# 示例 Spring Controller用于本地测试 AST 解析
# 将此目录结构复制到你的 Java 项目中进行验证

View File

@@ -0,0 +1,27 @@
package com.example.controller;
import org.springframework.web.bind.annotation.*;
/**
* 示例 UserController用于测试 API 变更检测。
*/
@RestController
@RequestMapping("/api/users")
public class UserController {
/**
* 查询用户详情 — 含多种参数类型,便于测试增删改检测。
*/
@GetMapping("/{id}")
public String getUser(
@PathVariable("id") Long id,
@RequestParam(value = "includeDisabled", required = false, defaultValue = "false") Boolean includeDisabled
) {
return "ok";
}
@PostMapping
public String createUser(@RequestBody UserCreateRequest request) {
return "created";
}
}

View File

@@ -0,0 +1,26 @@
package com.example.controller;
/**
* 示例请求体 DTO测试 @RequestBody 字段展开。
*/
public class UserCreateRequest {
private String userName;
private Boolean userType;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Boolean getUserType() {
return userType;
}
public void setUserType(Boolean userType) {
this.userType = userType;
}
}