refactor(vo): 重构VO类及相关模型,添加Voable接口实现
feat(constant): 添加WebSocket错误码常量 docs(model): 为模型类添加注释 fix(service): 修复ProductUsageService缓存键问题 refactor(converter): 重构字符串转换器,移除EntityStringConverter依赖 feat(tab): 添加ComboBoxUtils工具类,优化下拉框初始化 style: 移除无用导入和字段
This commit is contained in:
@@ -1,32 +1,24 @@
|
||||
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.BankService;
|
||||
import com.ecep.contract.vo.BankVo;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
public class BankStringConverter extends StringConverter<BankVo> {
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@Deprecated
|
||||
public class BankStringConverter extends EntityStringConverter<BankVo> {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
BankService service;
|
||||
|
||||
public BankStringConverter() {
|
||||
|
||||
public BankStringConverter(BankService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
// #2
|
||||
setInitialized(project -> service.findById(project.getId()));
|
||||
setSuggestion(service::search);
|
||||
setFromString(service::findByName);
|
||||
@Override
|
||||
public String toString(BankVo object) {
|
||||
return object == null ? "" : object.getCode() + " " + object.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankVo fromString(String string) {
|
||||
return service.findByName(string);
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,17 @@ package com.ecep.contract.converter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.service.ContractGroupService;
|
||||
import javafx.util.StringConverter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.vo.ContractGroupVo;
|
||||
|
||||
public class ContractGroupStringConverter extends EntityStringConverter<ContractGroupVo> {
|
||||
public class ContractGroupStringConverter extends StringConverter<ContractGroupVo> {
|
||||
private ContractGroupService service;
|
||||
|
||||
private List<ContractGroupVo> dataset;
|
||||
|
||||
public ContractGroupStringConverter() {
|
||||
}
|
||||
|
||||
public ContractGroupStringConverter(List<ContractGroupVo> dataset) {
|
||||
this.dataset = dataset;
|
||||
public ContractGroupStringConverter(ContractGroupService contractGroupService) {
|
||||
this.service = contractGroupService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,32 +20,14 @@ public class ContractGroupStringConverter extends EntityStringConverter<Contract
|
||||
if (group == null) {
|
||||
return "All";
|
||||
}
|
||||
return group.getName();
|
||||
return group.getCode() + " " + group.getName() + " " + group.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractGroupVo fromString(String string) {
|
||||
if (dataset == null) {
|
||||
return null;
|
||||
}
|
||||
if (!StringUtils.hasText(string)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ContractGroupVo group : dataset) {
|
||||
if (group == null) {
|
||||
continue;
|
||||
}
|
||||
if (toString(group).equals(string)) {
|
||||
return group;
|
||||
}
|
||||
if (group.getCode().equals(string)) {
|
||||
return group;
|
||||
}
|
||||
if (group.getName().contains(string)) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return service.findByCode(string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.converter;
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -9,21 +10,20 @@ import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
public class ContractStringConverter extends EntityStringConverter<ContractVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
public class ContractStringConverter extends StringConverter<ContractVo> {
|
||||
ContractService service;
|
||||
|
||||
public ContractStringConverter() {
|
||||
public ContractStringConverter(ContractService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
setInitialized(project -> service.findById(project.getId()));
|
||||
setSuggestion(service::search);
|
||||
// TODO 按名称找出,容易出问题
|
||||
setFromString(service::findByName);
|
||||
@Override
|
||||
public String toString(ContractVo cc) {
|
||||
return cc.getCode() + " " + cc.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractVo fromString(String string) {
|
||||
return service.findByCode(string);
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,30 @@ package com.ecep.contract.converter;
|
||||
|
||||
import com.ecep.contract.service.ContractTypeService;
|
||||
import com.ecep.contract.vo.ContractTypeVo;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
public class ContractTypeStringConverter extends EntityStringConverter<ContractTypeVo> {
|
||||
/**
|
||||
* 合同类型字符串转换器
|
||||
*
|
||||
* @author songqq
|
||||
*/
|
||||
public class ContractTypeStringConverter extends StringConverter<ContractTypeVo> {
|
||||
ContractTypeService contractTypeService;
|
||||
|
||||
public ContractTypeStringConverter(ContractTypeService contractTypeService) {
|
||||
this.contractTypeService = contractTypeService;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setInitialized(project -> contractTypeService.findById(project.getId()));
|
||||
setSuggestion(contractTypeService::search);
|
||||
setFromString(contractTypeService::findByName);
|
||||
@Override
|
||||
public String toString(ContractTypeVo object) {
|
||||
return object.getCode() + " " + object.getCatalog() + " " + object.getName() + " " + object.getTitle()
|
||||
+ "("
|
||||
+ object.getDirection() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractTypeVo fromString(String string) {
|
||||
return contractTypeService.findByCode(string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user