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 605990df23b0b3e23cb9d7e19a65cd7a6cc21cdb..4177b0338d6b3cc7c90c29bb641b197f5c7ffd5a 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 991d0e0d9062f346875c28881a07b281c1db62b5..de255ae87e2e4bb0fd82b8fd18ffb45f1231dd3d 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 f402639296fe92182c49f87e5f942b8ba0559ffc..a15dc5e967a11024a2112f16b6c45292941f1357 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 0000000000000000000000000000000000000000..f5c799bd9a9507594f49783a91aa5bc3ff07d589 --- /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; + } + +}