From 2ff4695afbe8e5f399d880f5686b75dbcdcf9bb3 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Sat, 23 Nov 2024 20:02:55 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E5=9C=A8=E6=B2=A1?= =?UTF-8?q?=E6=9C=89itsm=E6=A8=A1=E5=9D=97=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=BB=84=E5=90=88=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=97=B6=E6=8A=A5=E9=94=99=E6=9F=90=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1295486827331584]在没有itsm模块的情况下,添加组合工具时报错某接口不存在 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1295486827331584 --- .../api/notify/GetDefaultNotifyPolicyApi.java | 17 ++- .../tenant/api/notify/NotifyPolicyGetApi.java | 13 ++- .../api/notify/NotifyPolicySearchApi.java | 8 ++ .../notify/NotifyPolicySystemParamList.java | 104 ++++++++++++++++++ 4 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySystemParamList.java diff --git a/src/main/java/neatlogic/module/tenant/api/notify/GetDefaultNotifyPolicyApi.java b/src/main/java/neatlogic/module/tenant/api/notify/GetDefaultNotifyPolicyApi.java index 605990df..4177b033 100644 --- a/src/main/java/neatlogic/module/tenant/api/notify/GetDefaultNotifyPolicyApi.java +++ b/src/main/java/neatlogic/module/tenant/api/notify/GetDefaultNotifyPolicyApi.java @@ -17,8 +17,11 @@ package neatlogic.module.tenant.api.notify; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.notify.core.INotifyPolicyHandler; +import neatlogic.framework.notify.core.NotifyPolicyHandlerFactory; import neatlogic.framework.notify.dao.mapper.NotifyMapper; import neatlogic.framework.notify.dto.NotifyPolicyVo; +import neatlogic.framework.notify.exception.NotifyPolicyHandlerNotFoundException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; @@ -35,20 +38,24 @@ public class GetDefaultNotifyPolicyApi extends PrivateApiComponentBase { @Override public String getName() { - return "获取默认通知策略"; + return "nmtan.getdefaultnotifypolicyapi.getname"; } @Input({ - @Param(name = "handler", type = ApiParamType.STRING, isRequired = true, desc = "策略类型"), + @Param(name = "handler", type = ApiParamType.STRING, isRequired = true, desc = "common.handler"), }) @Output({ - @Param(explode = NotifyPolicyVo.class, desc = "通知策略信息") + @Param(explode = NotifyPolicyVo.class, desc = "common.tbodylist") }) - @Description(desc = "获取默认通知策略") + @Description(desc = "nmtan.getdefaultnotifypolicyapi.getname") @Override public Object myDoService(JSONObject paramObj) throws Exception { String handler = paramObj.getString("handler"); - NotifyPolicyVo notifyPolicyVo = notifyMapper.getDefaultNotifyPolicyByHandler(handler); + INotifyPolicyHandler notifyPolicyHandler = NotifyPolicyHandlerFactory.getHandler(handler); + if (notifyPolicyHandler == null) { + throw new NotifyPolicyHandlerNotFoundException(handler); + } + NotifyPolicyVo notifyPolicyVo = notifyMapper.getDefaultNotifyPolicyByHandler(notifyPolicyHandler.getClassName()); return notifyPolicyVo; } diff --git a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyGetApi.java b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyGetApi.java index 991d0e0d..de255ae8 100644 --- a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyGetApi.java +++ b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicyGetApi.java @@ -61,7 +61,7 @@ public class NotifyPolicyGetApi extends PrivateApiComponentBase { @Override public String getName() { - return "通知策略信息获取接口"; + return "nmtan.notifypolicygetapi.getname"; } @Override @@ -69,9 +69,14 @@ public class NotifyPolicyGetApi extends PrivateApiComponentBase { return null; } - @Input({@Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "策略id")}) - @Output({@Param(explode = NotifyPolicyVo.class, desc = "策略信息")}) - @Description(desc = "通知策略信息获取接口") + @Override + public boolean disableReturnCircularReferenceDetect() { + return true; + } + + @Input({@Param(name = "id", type = ApiParamType.LONG, isRequired = true, desc = "common.id")}) + @Output({@Param(explode = NotifyPolicyVo.class, desc = "common.tbodylist")}) + @Description(desc = "nmtan.notifypolicygetapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { Long id = jsonObj.getLong("id"); diff --git a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySearchApi.java b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySearchApi.java index f4026392..a15dc5e9 100644 --- a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySearchApi.java +++ b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySearchApi.java @@ -22,8 +22,11 @@ import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.common.util.PageUtil; import neatlogic.framework.dependency.constvalue.FrameworkFromType; import neatlogic.framework.dependency.core.DependencyManager; +import neatlogic.framework.notify.core.INotifyPolicyHandler; +import neatlogic.framework.notify.core.NotifyPolicyHandlerFactory; import neatlogic.framework.notify.dao.mapper.NotifyMapper; import neatlogic.framework.notify.dto.NotifyPolicyVo; +import neatlogic.framework.notify.exception.NotifyPolicyHandlerNotFoundException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; @@ -71,6 +74,11 @@ public class NotifyPolicySearchApi extends PrivateApiComponentBase { public Object myDoService(JSONObject jsonObj) throws Exception { JSONObject resultObj = new JSONObject(); NotifyPolicyVo notifyPolicyVo = JSON.toJavaObject(jsonObj, NotifyPolicyVo.class); + INotifyPolicyHandler notifyPolicyHandler = NotifyPolicyHandlerFactory.getHandler(notifyPolicyVo.getHandler()); + if (notifyPolicyHandler == null) { + throw new NotifyPolicyHandlerNotFoundException(notifyPolicyVo.getHandler()); + } + notifyPolicyVo.setHandler(notifyPolicyHandler.getClassName()); List tbodyList = notifyMapper.getNotifyPolicyList(notifyPolicyVo); for (NotifyPolicyVo notifyPolicy : tbodyList) { diff --git a/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySystemParamList.java b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySystemParamList.java new file mode 100644 index 00000000..f5c799bd --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/notify/NotifyPolicySystemParamList.java @@ -0,0 +1,104 @@ +package neatlogic.module.tenant.api.notify; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.crossover.CrossoverServiceFactory; +import neatlogic.framework.dto.ConditionParamVo; +import neatlogic.framework.form.attribute.core.FormAttributeHandlerFactory; +import neatlogic.framework.form.attribute.core.IFormAttributeHandler; +import neatlogic.framework.form.dao.mapper.FormMapper; +import neatlogic.framework.form.dto.FormAttributeVo; +import neatlogic.framework.form.dto.FormVo; +import neatlogic.framework.form.exception.FormNotFoundException; +import neatlogic.framework.form.service.IFormCrossoverService; +import neatlogic.framework.notify.core.INotifyPolicyHandler; +import neatlogic.framework.notify.core.NotifyPolicyHandlerFactory; +import neatlogic.framework.notify.exception.NotifyPolicyHandlerNotFoundException; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Service +@OperationType(type = OperationTypeEnum.SEARCH) +public class NotifyPolicySystemParamList extends PrivateApiComponentBase { + + @Resource + private FormMapper formMapper; + + @Override + public String getToken() { + return "notify/policy/systemparam/list"; + } + + @Override + public String getName() { + return "nmtan.notifypolicysystemparamlist.getname"; + } + + @Override + public String getConfig() { + return null; + } + + @Input({ + @Param(name = "notifyPolicyHandler", type = ApiParamType.STRING, isRequired = true, desc = "common.handler"), + @Param(name = "formUuid", type = ApiParamType.STRING, desc = "term.framework.formuuid"), + @Param(name = "tag", type = ApiParamType.STRING, desc = "common.tag"), + @Param(name = "isAll", type = ApiParamType.INTEGER, rule = "0,1", desc = "term.process.isreturnallattr") + }) + @Output({ + @Param(name = "tbodyList", explode = ConditionParamVo[].class, desc = "common.tbodylist") + }) + @Description(desc = "nmtan.notifypolicysystemparamlist.getname") + @Override + public Object myDoService(JSONObject jsonObj) throws Exception { + String notifyPolicyHandler = jsonObj.getString("notifyPolicyHandler"); + INotifyPolicyHandler handler = NotifyPolicyHandlerFactory.getHandler(notifyPolicyHandler); + if (handler == null) { + throw new NotifyPolicyHandlerNotFoundException(notifyPolicyHandler); + } + List systemParamList = handler.getSystemParamList(); + systemParamList.sort((e1, e2) -> e1.getName().compareToIgnoreCase(e2.getName())); + List paramList = new ArrayList<>(systemParamList); + // 表单条件 + String formUuid = jsonObj.getString("formUuid"); + if (StringUtils.isNotBlank(formUuid)) { + FormVo form = formMapper.getFormByUuid(formUuid); + if (form == null) { + throw new FormNotFoundException(formUuid); + } + Integer isAll = jsonObj.getInteger("isAll"); + String tag = jsonObj.getString("tag"); + IFormCrossoverService formCrossoverService = CrossoverServiceFactory.getApi(IFormCrossoverService.class); + List formAttrList = formCrossoverService.getFormAttributeListNew(formUuid, form.getName(), tag); + for (FormAttributeVo formAttributeVo : formAttrList) { + IFormAttributeHandler formHandler = FormAttributeHandlerFactory.getHandler(formAttributeVo.getHandler()); + if(formHandler == null){ + continue; + } + if ((isAll != null && isAll.equals(1)) || formHandler.isConditionable()) { + ConditionParamVo conditionParamVo = new ConditionParamVo(); + conditionParamVo.setName(formAttributeVo.getUuid()); + conditionParamVo.setLabel(formAttributeVo.getLabel()); + if (formHandler.getParamType() != null) { + conditionParamVo.setParamType(formHandler.getParamType().getName()); + conditionParamVo.setParamTypeName(formHandler.getParamType().getText()); + } + conditionParamVo.setIsEditable(0); + conditionParamVo.setType("form"); + paramList.add(conditionParamVo); + } + } + } + JSONObject resultObj = new JSONObject(); + resultObj.put("tbodyList", paramList); + return resultObj; + } + +} -- Gitee