diff --git a/jeecg-module-abnormal-alarm/lib/open-common-1.0-SNAPSHOT.jar b/jeecg-module-abnormal-alarm/lib/open-common-1.0-SNAPSHOT.jar new file mode 100644 index 00000000..e7157ba8 Binary files /dev/null and b/jeecg-module-abnormal-alarm/lib/open-common-1.0-SNAPSHOT.jar differ diff --git a/jeecg-module-abnormal-alarm/lib/open-sdk-20211201132528.jar b/jeecg-module-abnormal-alarm/lib/open-sdk-20211201132528.jar new file mode 100644 index 00000000..855691dc Binary files /dev/null and b/jeecg-module-abnormal-alarm/lib/open-sdk-20211201132528.jar differ diff --git a/jeecg-module-abnormal-alarm/pom.xml b/jeecg-module-abnormal-alarm/pom.xml index 738e3429..c093296d 100644 --- a/jeecg-module-abnormal-alarm/pom.xml +++ b/jeecg-module-abnormal-alarm/pom.xml @@ -31,6 +31,26 @@ org.jeecgframework.boot jeecg-boot-starter-cloud + + + com.github.mrmike + ok2curl + 0.7.0 + + + com.netease.qiye + open-common + 1.0 + system + ${project.basedir}/lib/open-common-1.0-SNAPSHOT.jar + + + com.netease.qiye + open-sdk + 1.0 + system + ${project.basedir}/lib/open-sdk-20211201132528.jar + \ No newline at end of file diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/api/AccountAPI.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/api/AccountAPI.java new file mode 100644 index 00000000..a6a26564 --- /dev/null +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/api/AccountAPI.java @@ -0,0 +1,8 @@ +package org.jeecg.modules.qiyeEmail.api; + +/* +* 账号相关的ApiURL +* */ +public interface AccountAPI { + String ACCOUNTINFO = "/api/gw/qiye/mailaccount/getMailAccountInfo"; +} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/InstanceSDK.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/InstanceSDK.java new file mode 100644 index 00000000..eaf32e22 --- /dev/null +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/InstanceSDK.java @@ -0,0 +1,43 @@ +package org.jeecg.modules.qiyeEmail.base; + +import com.netease.qiye.qiyeopenplatform.common.constant.ResultEnum; +import com.netease.qiye.qiyeopenplatform.common.dto.login.AppLoginResp; +import com.netease.qiye.qiyeopenplatform.sdk.QiyeOpenPlatSDK; +import com.netease.qiye.qiyeopenplatform.sdk.QiyeOpenPlatSDKConfig; +import com.netease.qiye.qiyeopenplatform.sdk.dto.Q; +import com.netease.qiye.qiyeopenplatform.sdk.dto.R; +import org.jeecg.common.util.SpringContextUtils; +import org.springframework.core.env.Environment; + +public class InstanceSDK { + + public static QiyeOpenPlatSDK getInstance() { + //init + //Environment env = SpringContextUtils.getBean(Environment.class); + /*String appId = env.getProperty("qiyeEmail.appId"); + String orgOpenId = env.getProperty("qiyeEmail.orgOpenId"); + String authCode = env.getProperty("qiyeEmail.authCode"); + String urlPrefix = env.getProperty("qiyeEmail.urlPrefix");*/ + String appId = "qy20231114144636B85B"; + String orgOpenId = "9c96b0ec1e6be89a"; + String authCode = "O1eSXJwU"; + String urlPrefix = "https://api.qiye.163.com"; + + QiyeOpenPlatSDKConfig qiyeOpenPlatSDKConfig = QiyeOpenPlatSDKConfig.builder() + //应用ID + .appId(appId) + //企业OpenID + .orgOpenId(orgOpenId) + //服务地址信息 + .urlPrefix(urlPrefix) + .build(); + // 创建SDK实例 + QiyeOpenPlatSDK qiyeOpenPlatSDK = new QiyeOpenPlatSDK("qiyeOpenPlatSDK", qiyeOpenPlatSDKConfig); + // 通过授权码登录 获取Token并设置Token + R appLoginRespR = qiyeOpenPlatSDK.appLogin(authCode); + AppLoginResp appLoginResp = appLoginRespR.getDataBean(AppLoginResp.class); + qiyeOpenPlatSDK.getQiyeOpenPlatSDKConfig().setupToken(appLoginResp); + + return qiyeOpenPlatSDK; + } +} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/RParam.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/RParam.java new file mode 100644 index 00000000..a0b6f74e --- /dev/null +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/RParam.java @@ -0,0 +1,11 @@ +package org.jeecg.modules.qiyeEmail.base; + +import lombok.Data; + +@Data +public class RParam { + + private String domain; + + private String account_name; +} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/dto/AccountInfo.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/dto/AccountInfo.java new file mode 100644 index 00000000..14e819b5 --- /dev/null +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/dto/AccountInfo.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.qiyeEmail.base.dto; + +import lombok.Data; +import java.io.Serializable; + +@Data +public class AccountInfo implements Serializable { + + private String domain; + + private String accountName; + + private Integer usedQuota; + + private Integer maxQuota; + + private Integer spamStatus; +} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/dto/ResponseText.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/dto/ResponseText.java new file mode 100644 index 00000000..5546928f --- /dev/null +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/base/dto/ResponseText.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.qiyeEmail.base.dto; + +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@Data +public class ResponseText implements Serializable { + + private boolean suc; + + private String node; + + private Long ver; + + private Map con; +} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/service/Account.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/service/Account.java new file mode 100644 index 00000000..37b84771 --- /dev/null +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/qiyeEmail/service/Account.java @@ -0,0 +1,41 @@ +package org.jeecg.modules.qiyeEmail.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.map.MapUtil; +import com.alibaba.fastjson.JSON; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.netease.qiye.qiyeopenplatform.sdk.QiyeOpenPlatSDK; +import com.netease.qiye.qiyeopenplatform.sdk.dto.Q; +import com.netease.qiye.qiyeopenplatform.sdk.dto.R; +import org.jeecg.modules.qiyeEmail.api.AccountAPI; +import org.jeecg.modules.qiyeEmail.base.InstanceSDK; +import org.jeecg.modules.qiyeEmail.base.RParam; +import org.jeecg.modules.qiyeEmail.base.dto.AccountInfo; +import org.jeecg.modules.qiyeEmail.base.dto.ResponseText; + +public class Account { + + public static AccountInfo getMailAccountInfo(RParam rParam){ + QiyeOpenPlatSDK platSDK = InstanceSDK.getInstance(); + Q reqParam = Q.init(rParam); + R result = platSDK.commonInvoke(reqParam, AccountAPI.ACCOUNTINFO); + String responseText = result.getResponseText(); + try { + ObjectMapper objectMapper = new ObjectMapper(); + ResponseText response = objectMapper.readValue(responseText, ResponseText.class); + return BeanUtil.mapToBean(response.getCon(),AccountInfo.class, CopyOptions.create()); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static void main(String[] args) { + RParam rParam = new RParam(); + rParam.setDomain("ndc.org.cn"); + rParam.setAccount_name("cnndc.rn.ng"); + System.out.println(getMailAccountInfo(rParam)); + } +} diff --git a/jeecg-server-cloud/armd-demo-cloud-start/pom.xml b/jeecg-server-cloud/armd-demo-cloud-start/pom.xml index 2e3435e2..2056cda6 100644 --- a/jeecg-server-cloud/armd-demo-cloud-start/pom.xml +++ b/jeecg-server-cloud/armd-demo-cloud-start/pom.xml @@ -37,15 +37,15 @@ - - - - - - - - + + + org.springframework.boot + spring-boot-maven-plugin + + + +