mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善自动补全
This commit is contained in:
@@ -11,7 +11,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
@@ -91,7 +90,11 @@ public class TreeDto {
|
||||
private static List<TreeDto> getChildren(Object x) {
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getChildren().stream().map(TreeDto::buildTree).toList();
|
||||
List<TreeDto> list = ((TreeDto) x).getChildren();
|
||||
if (list == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list.stream().map(TreeDto::buildTree).toList();
|
||||
}
|
||||
|
||||
Object c = ReflectUtils.getFieldValue(x, "children");
|
||||
|
||||
@@ -224,27 +224,34 @@ class DictionaryService extends BaseService<DictionaryEntity, DictionaryReposito
|
||||
if (StringUtils.isNotEmpty(request.getOrganizationId())){
|
||||
|
||||
nativeQuery = entityManager.createNativeQuery(
|
||||
"""
|
||||
|
||||
select distinct %s from %s where organization_id = %s and %s like '%%%s%%'
|
||||
|
||||
"""
|
||||
.formatted(
|
||||
request.getFieldName(),
|
||||
request.getTableName(),
|
||||
request.getOrganizationId(), ObjectUtils.defaultIfNull(request.getQuery(), "")));
|
||||
"select distinct " +
|
||||
request.getFieldName() +
|
||||
" from " +
|
||||
request.getTableName() +
|
||||
" where " +
|
||||
" organization_id = '" +
|
||||
request.getOrganizationId() +
|
||||
"'" +
|
||||
" and " +
|
||||
request.getFieldName() +
|
||||
" like '%" +
|
||||
ObjectUtils.defaultIfNull(request.getQuery(), "") +
|
||||
"%'");
|
||||
|
||||
}else {
|
||||
|
||||
nativeQuery = entityManager.createNativeQuery(
|
||||
"""
|
||||
|
||||
select distinct %s from %s where %s like '%%%s%%'
|
||||
"select distinct " +
|
||||
request.getFieldName() +
|
||||
" from " +
|
||||
request.getTableName() +
|
||||
" where " +
|
||||
request.getFieldName() +
|
||||
" like '%" +
|
||||
ObjectUtils.defaultIfNull(request.getQuery(), "") +
|
||||
"%'");
|
||||
|
||||
"""
|
||||
.formatted(
|
||||
request.getFieldName(),
|
||||
request.getTableName(), ObjectUtils.defaultIfNull(request.getQuery(), "")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import cn.lihongjie.coal.script.entity.ScriptEntity;
|
||||
import cn.lihongjie.coal.script.mapper.ScriptMapper;
|
||||
import cn.lihongjie.coal.script.repository.ScriptRepository;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
import groovy.lang.Script;
|
||||
|
||||
@@ -25,6 +27,7 @@ import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||
@@ -194,6 +197,9 @@ class ScriptService extends BaseService<ScriptEntity, ScriptRepository> {
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
ObjectMapper objectMapper;
|
||||
|
||||
@SneakyThrows
|
||||
public ScriptExecResultDto exec(ScriptExecResultDto json) throws ScriptException {
|
||||
|
||||
@@ -228,7 +234,7 @@ class ScriptService extends BaseService<ScriptEntity, ScriptRepository> {
|
||||
}
|
||||
});
|
||||
|
||||
script.setProperty("params", json.getParams());
|
||||
script.setProperty("params", ObjectUtils.defaultIfNull(json.getParams(), objectMapper.createObjectNode()));
|
||||
script.setProperty("ioc", applicationContext);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.common.Ctx
|
||||
import cn.lihongjie.coal.dictionary.dto.AutoCompleteRequest
|
||||
import cn.lihongjie.coal.dictionary.service.DictionaryService
|
||||
import org.springframework.context.ApplicationContext
|
||||
@@ -11,5 +12,5 @@ def service = ioc.getBean(DictionaryService.class)
|
||||
|
||||
|
||||
|
||||
return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis", fieldName: "name", query: params.get("query").asText()))
|
||||
return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis", fieldName: "name", organizationId: Ctx.currentUser().organizationId,query: params.get("query")?.asText()))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.common.Ctx
|
||||
import cn.lihongjie.coal.dictionary.dto.AutoCompleteRequest
|
||||
import cn.lihongjie.coal.dictionary.service.DictionaryService
|
||||
import org.springframework.context.ApplicationContext
|
||||
@@ -11,5 +12,5 @@ def service = ioc.getBean(DictionaryService.class)
|
||||
|
||||
|
||||
|
||||
return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis_kf_items", fieldName: "name", query: params.get("query").asText()))
|
||||
return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis_kf_items kf inner join t_coal_washing_daily_analysis a on kf.coal_washing_daily_analysis_id = a.id", fieldName: "kf.name",organizationId: Ctx.currentUser().organizationId, query: params.get("query")?.asText()))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user