refactor(vo): 重构VO对象结构,统一字段命名和接口实现

重构所有VO对象,统一字段命名规范,移除冗余字段,优化接口实现
新增Voable接口用于VO对象转换
调整BaseViewModel和ProjectBasedViewModel接口定义
更新相关服务和控制器以适应VO对象变更
This commit is contained in:
2025-09-21 17:47:52 +08:00
parent 07c3f39a95
commit 039d753bab
408 changed files with 6602 additions and 4800 deletions

View File

@@ -8,6 +8,7 @@ import com.ecep.contract.model.BaseEnumEntity;
import com.ecep.contract.model.BasedEntity;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.model.NamedEntity;
import com.ecep.contract.service.IEntityService;
import javafx.beans.property.Property;
import javafx.collections.FXCollections;
@@ -68,9 +69,7 @@ public class ComboBoxUtils {
return null;
}
private static
class ComboBoxStringConverter<T> extends javafx.util.StringConverter<T> {
private static class ComboBoxStringConverter<T> extends javafx.util.StringConverter<T> {
private final List<T> dataset;
public ComboBoxStringConverter(ObservableList<T> list) {
@@ -118,8 +117,41 @@ public class ComboBoxUtils {
}
public static <T extends IdentityEntity & NamedEntity> void initialComboBox(
ComboBox<T> comboBox, Property<T> property, List<T> dataSet, boolean hasNull
) {
ComboBox<T> comboBox, Property<Integer> property, IEntityService<T> queryService, boolean hasNull) {
ObservableList<T> list = FXCollections.observableArrayList();
if (hasNull) {
list.add(null);
}
list.addAll(queryService.findAll());
comboBox.setItems(list);
// 从ComboBox选择到property的单向绑定
comboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
property.setValue(newValue != null ? newValue.getId() : null);
});
// 从property到ComboBox的单向绑定
property.addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
comboBox.getSelectionModel().clearSelection();
return;
}
list.stream()
.filter(item -> item != null && newValue.equals(item.getId()))
.findFirst()
.ifPresent(comboBox.getSelectionModel()::select);
});
EntityStringConverter<T> converter = new EntityStringConverter<>(list);
comboBox.setConverter(converter);
// 初始化ComboBox的值
if (property.getValue() != null) {
list.stream()
.filter(item -> item != null && property.getValue().equals(item.getId()))
.findFirst()
.ifPresent(comboBox.getSelectionModel()::select);
}
}
public static <T extends IdentityEntity & NamedEntity> void initialComboBox(
ComboBox<T> comboBox, Property<T> property, List<T> dataSet, boolean hasNull) {
ObservableList<T> list = FXCollections.observableArrayList();
if (hasNull) {
list.add(null);
@@ -138,7 +170,7 @@ public class ComboBoxUtils {
public static <K> void bindComboBox(ComboBox<K> comboBox, Property<K> property) {
property.addListener((observable, oldValue, newValue) -> {
comboBox.setValue(newValue);
// comboBox.getItems().stream().filter(k->k.equals(newValue)).findFirst().ifPresent(comboBox::setValue);
// comboBox.getItems().stream().filter(k->k.equals(newValue)).findFirst().ifPresent(comboBox::setValue);
});
comboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
@@ -150,7 +182,8 @@ public class ComboBoxUtils {
});
}
public static <K extends Enum<?>, T extends BaseEnumEntity<K>> void bindComboBox(ComboBox<T> comboBox, Property<K> property, List<T> dataSet) {
public static <K extends Enum<?>, T extends BaseEnumEntity<K>> void bindComboBox(ComboBox<T> comboBox,
Property<K> property, List<T> dataSet) {
property.addListener((observable, oldValue, newValue) -> {
dataSet.stream().filter(l -> l.getType() == newValue).findFirst().ifPresent(comboBox::setValue);
});
@@ -163,13 +196,13 @@ public class ComboBoxUtils {
property.setValue(newValue.getType());
});
// comboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
// if (newValue == null) {
// property.setValue(null);
// return;
// }
// property.setValue(newValue.getType());
// });
// comboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
// if (newValue == null) {
// property.setValue(null);
// return;
// }
// property.setValue(newValue.getType());
// });
comboBox.setCellFactory(param -> new ListCell<>() {
@Override