This commit is contained in:
2025-11-26 16:10:17 +08:00
parent f0e85c5a18
commit c10bd369c0
83 changed files with 1755 additions and 541 deletions

View File

@@ -1,30 +1,37 @@
package com.ecep.contract.converter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.ecep.contract.service.DepartmentService;
import com.ecep.contract.vo.DepartmentVo;
import javafx.util.StringConverter;
import jakarta.annotation.PostConstruct;
@Lazy
@Component
public class DepartmentStringConverter extends EntityStringConverter<DepartmentVo> {
@Lazy
@Autowired
/**
* 部门字符串转换器
*/
public class DepartmentStringConverter extends StringConverter<DepartmentVo> {
private DepartmentService service;
public DepartmentStringConverter() {
}
@PostConstruct
private void init() {
setInitialized(department -> service.findById(department.getId()));
setSuggestion(service::search);
public DepartmentStringConverter(DepartmentService service) {
this.service = service;
}
@Override
public String toString(DepartmentVo department) {
if (department == null) {
return "-";
}
return department.getCode() + " " + department.getName();
}
@Override
public DepartmentVo fromString(String string) {
if (service == null || string == null || string.trim().isEmpty()) {
return null;
}
return service.findByCode(string.trim());
}
}

View File

@@ -1,30 +1,26 @@
package com.ecep.contract.converter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import javafx.util.StringConverter;
import com.ecep.contract.service.VendorGroupService;
import com.ecep.contract.vo.VendorGroupVo;
import jakarta.annotation.PostConstruct;
@Lazy
@Component
public class VendorGroupStringConverter extends EntityStringConverter<VendorGroupVo> {
@Lazy
@Autowired
public class VendorGroupStringConverter extends StringConverter<VendorGroupVo> {
private VendorGroupService service;
public VendorGroupStringConverter() {
public VendorGroupStringConverter(VendorGroupService service) {
this.service = service;
}
@PostConstruct
private void init() {
setInitialized(group -> service.findById(group.getId()));
setSuggestion(service::search);
@Override
public String toString(VendorGroupVo object) {
return object == null ? "" : object.getCode() + " " + object.getName();
}
@Override
public VendorGroupVo fromString(String string) {
return service.findByCode(string);
}
}