Skip to content

Commit

Permalink
hotfix:be
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Oct 24, 2024
1 parent f64d397 commit b0d02d7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,10 @@ else if (entity.containsField(field)) {
inFormFields.contains(field) ? new Object[] { mixValue } : value);
}
}

} else {
// v3.9 其他类型,需要限制字段类型???
initialValReady.put(field, value);
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public String toHTML() {
continue;
}

System.out.println(last.prev + " <> " + current.prev);
if (last.content.equals(current.content) && Objects.equals(last.prev, current.prev)) {
last.rowspan++;
current.rowspan = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ private String buildSql(Dimension[] dims, Numerical[] nums) {
StringUtils.join(dimSqlItems, ", "),
StringUtils.join(numSqlItems, ", "),
getSourceEntity().getName(), getFilterSql(nums.length > 0 ? nums[0] : null));
System.out.println(sql);

return appendSqlSort(sql);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.Record;
import cn.devezhao.persist4j.dialect.FieldType;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONAware;
Expand All @@ -20,9 +21,12 @@
import com.rebuild.core.Application;
import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.metadata.MetadataSorter;
import com.rebuild.core.metadata.easymeta.DisplayType;
import com.rebuild.core.service.DataSpecificationException;
import com.rebuild.core.service.query.AdvFilterParser;
import com.rebuild.core.service.query.ParseHelper;
import com.rebuild.core.service.query.QueryHelper;
import com.rebuild.utils.JSONUtils;
import com.rebuild.web.BaseController;
import com.rebuild.web.IdParam;
Expand All @@ -34,14 +38,17 @@

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* 非业务实体操作(如系统实体)
*
* @author devezhao
* @since 2020/11/6
* @see com.rebuild.core.Application#getService(int)
* @see Application#getService(int)
* @see GeneralOperatingController
*/
@Slf4j
Expand Down Expand Up @@ -81,6 +88,35 @@ public RespBody get(@IdParam ID recordId, HttpServletRequest request) {
return RespBody.ok(record);
}

@RequestMapping("common-find")
public RespBody find(HttpServletRequest request) {
String k = getParameterNotNull(request, "k");
Object id = getParameterNotNull(request, "id");

String[] ef = k.split("\\.");
Entity findEntity = MetadataHelper.getEntity(ef[0]);
Field findField = findEntity.getField(ef[1]);
String sql = String.format("select %s from %s where %s = ?",
findEntity.getPrimaryField().getName(), findEntity.getName(), findField.getName());
// 引用字段查名称
if (findField.getType() == FieldType.REFERENCE) {
if (ID.isId(id)) {
id = ID.valueOf(id.toString());
} else {
Set<Field> queryFields = new HashSet<>();
queryFields.add(findField.getReferenceEntity().getNameField());
queryFields.addAll(Arrays.asList(MetadataSorter.sortFields(findField.getReferenceEntity(), DisplayType.SERIES)));
id = QueryHelper.queryIdValue(queryFields.toArray(new Field[0]), id.toString(), false);
}
}

Object[] found = id == null ? null
: Application.createQueryNoFilter(sql).setParameter(1, id).unique();

if (found != null) return RespBody.ok(JSONUtils.toJSONObject("id", found[0]));
return RespBody.ok(JSONUtils.toJSONObject("entity", findEntity.getName()));
}

@RequestMapping("common-list")
public RespBody list(HttpServletRequest request) {
JSONObject queryBody = (JSONObject) ServletUtils.getRequestJson(request);
Expand Down

0 comments on commit b0d02d7

Please sign in to comment.