表单组件添加适用对象

This commit is contained in:
weizhiqiang 2023-02-19 00:14:27 +08:00
parent c2ccdce29a
commit e44b506562
5 changed files with 31 additions and 3 deletions

View file

@ -22,10 +22,10 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public enum ComponentApplyRange implements SkyeyeEnumClass {
GLOBALLY_APPLICABLE("1", "全局适用", true, true),
LOCAL_APPLICATION("2", "局部适用", true, false);
GLOBALLY_APPLICABLE(1, "全局适用", true, true),
LOCAL_APPLICATION(2, "局部适用", true, false);
private String key;
private Integer key;
private String value;

View file

@ -93,6 +93,9 @@ public class DsFormComponentController {
* @param outputObject 出参以及提示信息的返回值对象
*/
@ApiOperation(id = "queryAllDsFormComponentList", value = "获取所有的动态表单组件", method = "GET", allUse = "2")
@ApiImplicitParams(value = {
@ApiImplicitParam(id = "serviceClassName", name = "serviceClassName", value = "业务对象的服务层className", required = "required"),
@ApiImplicitParam(id = "dsFormPageType", name = "dsFormPageType", value = "表单布局类型", required = "required")})
@RequestMapping("/post/DsFormComponentController/queryAllDsFormComponentList")
public void queryAllDsFormComponentList(InputObject inputObject, OutputObject outputObject) {
dsFormComponentService.queryAllDsFormComponentList(inputObject, outputObject);

View file

@ -89,6 +89,10 @@ public class DsFormComponent extends IconOrImgInfo {
@ApiModelProperty(value = "组件关联的属性,可参考#ComponentAttr", required = "json")
private List<String> attrKeys;
@TableField(value = "apply_form_type", typeHandler = JacksonTypeHandler.class)
@ApiModelProperty(value = "适用表单布局类型,可参考#DsFormPageType", required = "json")
private List<String> applyFormType;
@TableField("apply_range")
@ApiModelProperty(value = "适用范围,参考#ComponentApplyRange", required = "required,num")
private Integer applyRange;

View file

@ -4,6 +4,7 @@
package com.skyeye.dsform.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.tree.Tree;
import com.google.common.base.Joiner;
import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl;
@ -12,6 +13,7 @@ import com.skyeye.common.constans.CommonNumConstants;
import com.skyeye.common.entity.search.CommonPageInfo;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.dsform.classenum.ComponentApplyRange;
import com.skyeye.dsform.dao.DsFormComponentDao;
import com.skyeye.dsform.entity.DsFormComponent;
import com.skyeye.dsform.service.DsFormComponentService;
@ -49,7 +51,25 @@ public class DsFormComponentServiceImpl extends SkyeyeBusinessServiceImpl<DsForm
*/
@Override
public void queryAllDsFormComponentList(InputObject inputObject, OutputObject outputObject) {
Map<String, Object> params = inputObject.getParams();
String serviceClassName = params.get("serviceClassName").toString();
String dsFormPageType = params.get("dsFormPageType").toString();
List<DsFormComponent> formComponentList = list();
// 过滤数据
formComponentList = formComponentList.stream()
.filter(component -> {
if (CollectionUtil.isNotEmpty(component.getApplyFormType()) && component.getApplyFormType().indexOf(dsFormPageType) >= 0) {
// 适用布局匹配
if (component.getApplyRange().equals(ComponentApplyRange.GLOBALLY_APPLICABLE.getKey())
|| (component.getApplyRange().equals(ComponentApplyRange.LOCAL_APPLICATION.getKey()) &&
CollectionUtil.isNotEmpty(component.getApplyObject()) && component.getApplyObject().indexOf(serviceClassName) >= 0)) {
// 适配全局对象适用并且局部范围内适用包含指定serviceClassName的
return true;
}
}
return false;
}).collect(Collectors.toList());
// 获取组件的详细信息
List<String> componentIds = formComponentList.stream()
.map(DsFormComponent::getId).collect(Collectors.toList());

View file

@ -14,6 +14,7 @@
a.icon_type iconType,
a.icon_pic iconPic,
a.type_id typeId,
a.apply_range applyRange,
a.create_id createId,
CONVERT(a.create_time, char) createTime,
a.last_update_id lastUpdateId,