From cae784ab0232e3e3f8abfb0077fd9cf1e49ccb07 Mon Sep 17 00:00:00 2001 From: 许鹏程 <1821349743@qq.com> Date: 星期五, 19 五月 2023 18:42:38 +0800 Subject: [PATCH] 表单设计器 --- src/main/java/com/product/face/service/FaceDesignService.java | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/product/face/service/FaceDesignService.java b/src/main/java/com/product/face/service/FaceDesignService.java index 0e3f15f..ba68ba1 100644 --- a/src/main/java/com/product/face/service/FaceDesignService.java +++ b/src/main/java/com/product/face/service/FaceDesignService.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.drew.metadata.Face; +import com.product.admin.service.PublicService; import com.product.common.lang.StringUtils; import com.product.core.config.CoreConst; import com.product.core.entity.DataTableEntity; @@ -23,6 +24,7 @@ import org.apache.logging.log4j.core.Core; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.io.File; import java.util.*; import java.util.stream.Collectors; @@ -36,6 +38,9 @@ public class FaceDesignService extends AbstractBaseService implements IFaceDesignService { + @Resource + public PublicService publicService; + /** * 鑾峰彇琛ㄥ崟閰嶇疆璇︽儏 * @@ -48,10 +53,18 @@ FieldSetEntity fse = getBaseDao().getFieldSetEntity(FaceConst.TABLE_FACE_CONFIG, uuid, true); DataTableEntity fieldPropertyDt = fse.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY); if (DataTableEntity.isEmpty(fieldPropertyDt)) { - return null; + throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL); } + List<JSONObject> result = getFaceControlList(fieldPropertyDt); + Map<String, Object> other = new HashMap<>(); + other.put("drawingList", result); + fse.getSubData().clear(); + return BaseUtil.success(fse, other); + } + + public List<JSONObject> getFaceControlList(DataTableEntity faceControlDt) { List<JSONObject> result = new ArrayList<>(); - List<FieldSetEntity> data = fieldPropertyDt.getData(); + List<FieldSetEntity> data = faceControlDt.getData(); Map<String, List<FieldSetEntity>> collect = data.stream() .filter(item -> StringUtils.isEmpty(item.getString(FaceConst.FIELD_PARENT_UUID))) //杩囨护 鍙栫埗绾� // .sorted(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))) //鎺掑簭 @@ -64,11 +77,7 @@ result.add(getPropertyJson(propertyList, groupContainer)); } result.sort(Comparator.comparing(item -> item.getInteger(FaceConst.CONTROL_SEQUENCE))); - System.out.println(result); - Map<String, Object> other = new HashMap<>(); - other.put("drawingList", result); - fse.getSubData().clear(); - return BaseUtil.success(fse, other); + return result; } private JSONObject getPropertyJson(List<FieldSetEntity> propertyList, Map<String, List<FieldSetEntity>> groupContainer) { @@ -81,6 +90,15 @@ String propertyType = fs.getString(FaceConst.FIELD_PROPERTY_TYPE); String propertyName = fs.getString(FaceConst.FIELD_PROPERTY_NAME); propertyValue = fs.getString(FaceConst.FIELD_PROPERTY_VALUE); + if (StringUtils.equalsAny(propertyName, "renderKey", "formId")) { + propertyValue = fs.getString("id"); + } + if ("componentType".equals(propertyName) && "design".equals(propertyValue)) { + continue; + } + if ("layout".equals(propertyName)) { + property.put("defaultValue", null); + } switch (propertyType) { case "1"://瀛楃涓� property.put(propertyName, propertyValue); @@ -168,7 +186,7 @@ BaseUtil.createCreatorAndCreationTime(fse); fields.setData(fieldSetEntityList); fse.addSubDataTable(fields); - fse.setValue(FaceConst.FIELD_FACE_TYPE, 2); +// fse.setValue(FaceConst.FIELD_FACE_TYPE, 2); if (!StringUtils.isEmpty(fse.getUUID())) { getBaseDao().delete(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY, "master_uuid=?", new Object[]{fse.getUUID()}); } @@ -281,4 +299,18 @@ return fse; } + + /** + * 鍒犻櫎琛ㄥ崟璁捐 + * + * @param fse + * @throws BaseException + */ + @Override + @Transactional + public void deleteFace(FieldSetEntity fse) throws BaseException { + publicService.delete(fse); + } + + } -- Gitblit v1.9.2