diff --git a/src/main/java/neatlogic/module/tenant/api/mailserver/MailServerTestApi.java b/src/main/java/neatlogic/module/tenant/api/mailserver/MailServerTestApi.java index 5e24087ddbbfb5f078235c5693b1833c12326b44..967a78264ada213f0ff33aa9f088b01fbe5e1131 100644 --- a/src/main/java/neatlogic/module/tenant/api/mailserver/MailServerTestApi.java +++ b/src/main/java/neatlogic/module/tenant/api/mailserver/MailServerTestApi.java @@ -16,10 +16,12 @@ import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.label.NOTIFY_CONFIG_MODIFY; import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.dto.MailServerVo; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.framework.util.EmailUtil; +import neatlogic.framework.util.RegexUtils; import org.springframework.stereotype.Service; import java.util.Collections; @@ -51,18 +53,33 @@ public class MailServerTestApi extends PrivateApiComponentBase { } @Input({ + @Param(name = "id", type = ApiParamType.STRING, desc = "common.id"), + @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, isRequired = true, maxLength = 50, desc = "common.name"), + @Param(name = "host", type = ApiParamType.STRING, isRequired = true, maxLength = 50, desc = "term.framework.smpthost"), + @Param(name = "port", type = ApiParamType.INTEGER, isRequired = true, desc = "term.framework.smptport"), + @Param(name = "userName", type = ApiParamType.STRING, maxLength = 50, desc = "common.username"), + @Param(name = "password", type = ApiParamType.STRING, maxLength = 50, desc = "common.password"), + @Param(name = "homeUrl", type = ApiParamType.STRING, desc = "common.homeurl"), + @Param(name = "fromAddress", type = ApiParamType.STRING, isRequired = true, maxLength = 50, desc = "common.mailaddress"), + @Param(name = "sslEnable", type = ApiParamType.ENUM, rule = "true,false", isRequired = true, maxLength = 50, desc = "term.framework.smptsslenable"), @Param(name = "emailAddress", type = ApiParamType.EMAIL, isRequired = true, desc = "common.mailaddress") }) @Output({}) @Description(desc = "nmtam.mailservertestapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { - EmailUtil.sendHtmlEmail( +// EmailUtil.sendHtmlEmail( +// "Test mail", +// "Your configured mail server information is available!", +// Collections.singletonList(jsonObj.getString("emailAddress")), +// null +// ); + MailServerVo mailServerVo = jsonObj.toJavaObject(MailServerVo.class); + EmailUtil.sendEmailWithFile( "Test mail", "Your configured mail server information is available!", Collections.singletonList(jsonObj.getString("emailAddress")), - null - ); + null, null, mailServerVo); return null; } diff --git a/src/main/java/neatlogic/module/tenant/api/wechat/TestWechatApi.java b/src/main/java/neatlogic/module/tenant/api/wechat/TestWechatApi.java index 13b19cd53e4df0ac5eda16d3f8dd368a88a4109d..2d45c29b1402289cd09a5291e913c0cca4955957 100644 --- a/src/main/java/neatlogic/module/tenant/api/wechat/TestWechatApi.java +++ b/src/main/java/neatlogic/module/tenant/api/wechat/TestWechatApi.java @@ -16,26 +16,20 @@ import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.auth.label.NOTIFY_CONFIG_MODIFY; import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.dao.mapper.NotifyConfigMapper; import neatlogic.framework.dto.WechatVo; -import neatlogic.framework.exception.wechat.WechatAuthenticationInformationNotFoundException; -import neatlogic.framework.notify.core.NotifyHandlerType; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.framework.util.WechatUtil; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; -import javax.annotation.Resource; - @Component @AuthAction(action = NOTIFY_CONFIG_MODIFY.class) @OperationType(type = OperationTypeEnum.SEARCH) public class TestWechatApi extends PrivateApiComponentBase { - @Resource - private NotifyConfigMapper notifyConfigMapper; +// @Resource +// private NotifyConfigMapper notifyConfigMapper; @Override public String getName() { @@ -43,17 +37,21 @@ public class TestWechatApi extends PrivateApiComponentBase { } @Input({ + @Param(name = "corpId", type = ApiParamType.STRING, isRequired = true, desc = "term.framework.corpid"), + @Param(name = "corpSecret", type = ApiParamType.STRING, isRequired = true, desc = "term.framework.corpsecret"), + @Param(name = "agentId", type = ApiParamType.STRING, isRequired = true, desc = "term.framework.agentid"), @Param(name = "toUser", type = ApiParamType.STRING, isRequired = true, desc = "nmtaw.testwechatapi.input.param.desc.touser") }) @Output({}) @Description(desc = "nmtaw.testwechatapi.getname") @Override public Object myDoService(JSONObject paramObj) throws Exception { - String config = notifyConfigMapper.getConfigByType(NotifyHandlerType.WECHAT.getValue()); - if (StringUtils.isBlank(config)) { - throw new WechatAuthenticationInformationNotFoundException(); - } - WechatVo wechatVo = JSONObject.parseObject(config, WechatVo.class); +// String config = notifyConfigMapper.getConfigByType(NotifyHandlerType.WECHAT.getValue()); +// if (StringUtils.isBlank(config)) { +// throw new WechatAuthenticationInformationNotFoundException(); +// } +// WechatVo wechatVo = JSONObject.parseObject(config, WechatVo.class); + WechatVo wechatVo = paramObj.toJavaObject(WechatVo.class); WechatUtil.AccessToken accessToken = WechatUtil.getAccessToken(wechatVo.getCorpId(), wechatVo.getCorpSecret()); String toUser = paramObj.getString("toUser"); JSONObject data = WechatUtil.getTextCardMsg(