feat: 新增多个服务类及工具类,重构部分代码结构
重构服务类结构,将分散的服务统一整合到service包下 新增ProjectConstant常量类及多个实体服务类 添加SecurityUtils安全工具类和BeanCacher工具类 优化部分UI控件和转换器的实现
This commit is contained in:
@@ -5,8 +5,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.ecep.contract.Desktop;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.model.SysConf;
|
||||
import com.ecep.contract.service.SysConfService;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.Property;
|
||||
|
||||
22
client/src/main/java/com/ecep/contract/util/BeanCacher.java
Normal file
22
client/src/main/java/com/ecep/contract/util/BeanCacher.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.ecep.contract.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
|
||||
public class BeanCacher {
|
||||
|
||||
private HashMap<Class<?>, Object> cachedBeans = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getBean(Class<T> requiredType) throws BeansException {
|
||||
Object object = cachedBeans.get(requiredType);
|
||||
if (object == null) {
|
||||
object = SpringApp.getBean(requiredType);
|
||||
cachedBeans.put(requiredType, object);
|
||||
}
|
||||
return (T) object;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.ecep.contract.util;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.ecep.contract.service.SysConfService;
|
||||
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.scene.control.DatePicker;
|
||||
import javafx.util.StringConverter;
|
||||
@@ -34,4 +36,10 @@ public class LocalDateConfig extends AbstractConfigBounder<LocalDate> {
|
||||
getControl().valueProperty().bindBidirectional(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfService(SysConfService confService) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'setConfService'");
|
||||
}
|
||||
|
||||
}
|
||||
87
client/src/main/java/com/ecep/contract/util/ParamUtils.java
Normal file
87
client/src/main/java/com/ecep/contract/util/ParamUtils.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.ecep.contract.util;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ParamUtils {
|
||||
public static Map<String, Object> between(LocalDate begin, LocalDate end) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("begin", begin);
|
||||
params.put("end", end);
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Map<String, Object> equal(String key, boolean value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, value);
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Map<String, Object> equal(String key, String value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, value);
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Map<String, Object> like(String key, String value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, "%" + value + "%");
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Map<String, Object> like(String key, LocalDate value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, "%" + value + "%");
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Map<String, Object> isNotNull(String key) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, Map.of("isNotNull", true));
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Map<String, Object> lessThan(String key, LocalDate value) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put(key, Map.of("lessThan", value));
|
||||
return params;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Map<String, Object> params = new HashMap<>();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder isNotNull(String key) {
|
||||
params.put(key, Map.of("isNotNull", true));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lessThan(String key, LocalDate value) {
|
||||
params.put(key, Map.of("lessThan", value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder equals(String key, Object value) {
|
||||
params.put(key, Map.of("equals", value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder between(String key, LocalDate begin, LocalDate end) {
|
||||
params.put(key, Map.of("begin", begin, "end", end));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, Object> build() {
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user