我在一个控制器中有两个方法,具有与参数相同的obejct:
@PostMapping("/pg-import")
public String importProcessGroup(@RequestBody NiFiArguments niFiArguments) {
log.info("Called method importFlow");
@PostMapping("/pg-change-version")
public String changeVersionProcessGroup(@RequestBody NiFiArguments niFiArguments) {
log.info("Called method importFlow");
Pojo对象:
@Data
public class NiFiArguments {
private String bucketIdentifier;
private String flowIdentifier;
private String flowVersion;
private String baseUrl;
private String processGroupId;
}
我想从导入进程组方法中排除进程组 ID 属性。可能吗?
一种方法是将NiFiArguments子类化到一个单独的类中。
@Data
public class NiFiArguments {
private String bucketIdentifier;
private String flowIdentifier;
private String flowVersion;
private String baseUrl;
}
@Data
public class NiFiArgumentsWithProcessGroup extends NiFiArguments {
private String processGroupId;
}
然后在两种方法中使用不同的对象。