feat:qiyeEmail模块
This commit is contained in:
parent
55056d6f7b
commit
27ee4fe15b
BIN
jeecg-module-abnormal-alarm/lib/open-common-1.0-SNAPSHOT.jar
Normal file
BIN
jeecg-module-abnormal-alarm/lib/open-common-1.0-SNAPSHOT.jar
Normal file
Binary file not shown.
BIN
jeecg-module-abnormal-alarm/lib/open-sdk-20211201132528.jar
Normal file
BIN
jeecg-module-abnormal-alarm/lib/open-sdk-20211201132528.jar
Normal file
Binary file not shown.
|
@ -31,6 +31,26 @@
|
|||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter-cloud</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.mrmike</groupId>
|
||||
<artifactId>ok2curl</artifactId>
|
||||
<version>0.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netease.qiye</groupId>
|
||||
<artifactId>open-common</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/open-common-1.0-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netease.qiye</groupId>
|
||||
<artifactId>open-sdk</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/open-sdk-20211201132528.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
package org.jeecg.modules.qiyeEmail.api;
|
||||
|
||||
/*
|
||||
* 账号相关的ApiURL
|
||||
* */
|
||||
public interface AccountAPI {
|
||||
String ACCOUNTINFO = "/api/gw/qiye/mailaccount/getMailAccountInfo";
|
||||
}
|
|
@ -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<AppLoginResp> appLoginRespR = qiyeOpenPlatSDK.appLogin(authCode);
|
||||
AppLoginResp appLoginResp = appLoginRespR.getDataBean(AppLoginResp.class);
|
||||
qiyeOpenPlatSDK.getQiyeOpenPlatSDKConfig().setupToken(appLoginResp);
|
||||
|
||||
return qiyeOpenPlatSDK;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.jeecg.modules.qiyeEmail.base;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RParam {
|
||||
|
||||
private String domain;
|
||||
|
||||
private String account_name;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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<String ,Object> con;
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -37,15 +37,15 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- <build>-->
|
||||
<!-- <plugins>-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
|
||||
<!-- </plugin>-->
|
||||
<!-- </plugins>-->
|
||||
<!-- </build>-->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!--<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -68,5 +68,5 @@
|
|||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</build>-->
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue
Block a user