publish 1.0.20
This commit is contained in:
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -57,55 +57,55 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||
import com.tiesheng.platform.config.ding.PlatformDingConfig;
|
||||
import com.tiesheng.platform.config.ding.bean.DingJsapiSignature;
|
||||
import com.tiesheng.platform.config.ding.bean.DingUserInfo;
|
||||
import com.tiesheng.platform.config.ding.bean.DingUserSimple;
|
||||
import com.tiesheng.platform.config.wxmini.PlatformWxminiConfig;
|
||||
import com.tiesheng.platform.config.wxmp.PlatformWxmpConfig;
|
||||
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
||||
@@ -131,8 +132,8 @@ public class LoginController {
|
||||
@RequestMapping("/ding/oauth2/{service}")
|
||||
@OperationIgnore
|
||||
public void dingOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
|
||||
String ddUserId = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
||||
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, ddUserId);
|
||||
DingUserSimple userSimple = platformDingConfig.getUserIdByCode(service, dto.getCode());
|
||||
DingUserInfo dingUserInfo = platformDingConfig.topapiV2UserGet(service, userSimple.getUserid());
|
||||
TokenBean tokenBean = tieshengLoginConfigurer.doLogin(new DoLoginInfo(dingUserInfo.getAppId(),
|
||||
dingUserInfo.getUserid(), "ding", JSON.toJSONString(dingUserInfo)));
|
||||
tieshengLoginConfigurer.onLoginRedirect(tokenBean, dto.getTo(), dto.getExtra(), response);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PlatformDingConfig {
|
||||
* @param service
|
||||
* @return
|
||||
*/
|
||||
public String doRequest(String service, String url, JSONObject body) {
|
||||
public <T> DingResponse<T> doRequest(String service, String url, JSONObject body, TypeReference<DingResponse<T>> typeReference) {
|
||||
if (StrUtil.contains(url, "?")) {
|
||||
url = url + "&access_token=" + getAccessToken(service);
|
||||
} else {
|
||||
@@ -70,12 +70,15 @@ public class PlatformDingConfig {
|
||||
execute = HttpUtil.createPost(url).body(body.toString()).execute();
|
||||
}
|
||||
|
||||
String resp = execute.body();
|
||||
if (execute.isOk()) {
|
||||
return resp;
|
||||
DingResponse<T> bean = JSONUtil.toBean(execute.body(), typeReference, true);
|
||||
if (!bean.isOk()) {
|
||||
LogFactory.get().info(bean.getErrmsg());
|
||||
}
|
||||
LogFactory.get().info("{}: {}", url, resp);
|
||||
return "";
|
||||
return bean;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,13 +122,15 @@ public class PlatformDingConfig {
|
||||
DingConfigBean dingConfigBean = getConfigBean(service);
|
||||
String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false);
|
||||
if (StrUtil.isEmpty(jsapiTicket)) {
|
||||
String response = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null);
|
||||
JSONObject respJson = JSONUtil.parseObj(response);
|
||||
if (!Objects.equals(respJson.getStr("errcode"), "0")) {
|
||||
throw new ApiException(respJson.getStr("errmsg"));
|
||||
DingResponse<String> respJson = doRequest(service, "https://oapi.dingtalk.com/get_jsapi_ticket", null,
|
||||
new TypeReference<DingResponse<String>>() {
|
||||
});
|
||||
if (!respJson.isOk()) {
|
||||
throw new ApiException(respJson.getErrmsg());
|
||||
}
|
||||
jsapiTicket = respJson.getStr("ticket");
|
||||
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), jsapiTicket, respJson.getLong("expires_in"));
|
||||
jsapiTicket = respJson.getTicket();
|
||||
TimedCacheHelper.getTimedCache().put(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(),
|
||||
jsapiTicket, respJson.getExpiresIn());
|
||||
}
|
||||
return jsapiTicket;
|
||||
}
|
||||
@@ -154,10 +159,11 @@ public class PlatformDingConfig {
|
||||
* @return
|
||||
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
|
||||
*/
|
||||
public String getUserIdByCode(String service, String code) {
|
||||
String resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
|
||||
JSONUtil.createObj().putOpt("code", code));
|
||||
return JSONUtil.parseObj(resp).getJSONObject("result").getStr("userid");
|
||||
public DingUserSimple getUserIdByCode(String service, String code) {
|
||||
DingResponse<DingUserSimple> resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/getuserinfo",
|
||||
JSONUtil.createObj().putOpt("code", code), new TypeReference<DingResponse<DingUserSimple>>() {
|
||||
});
|
||||
return resp.getResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -172,12 +178,11 @@ public class PlatformDingConfig {
|
||||
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
|
||||
DingConfigBean dingConfigBean = getConfigBean(service);
|
||||
|
||||
String response = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/get",
|
||||
JSONUtil.createObj().putOpt("userid", ddUserId));
|
||||
JSONObject resultJson = JSONUtil.parseObj(response).getJSONObject("result");
|
||||
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
|
||||
DingUserInfo userInfo = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/get",
|
||||
JSONUtil.createObj().putOpt("userid", ddUserId), new TypeReference<DingResponse<DingUserInfo>>() {
|
||||
}).getResult();
|
||||
// 设置一下job_number
|
||||
userInfo.setJobNumber(resultJson.getStr("job_number"));
|
||||
userInfo.setJobNumber(userInfo.getJobNumber());
|
||||
userInfo.setAppId(dingConfigBean.getAppKey());
|
||||
return userInfo;
|
||||
}
|
||||
@@ -195,16 +200,9 @@ public class PlatformDingConfig {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
|
||||
JSONUtil.createObj().putOpt("dept_id", deptId));
|
||||
|
||||
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(resp, new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
||||
}.getType(), true);
|
||||
|
||||
if (!result.isOk()) {
|
||||
result.setResult(new ArrayList<>());
|
||||
}
|
||||
return result.getResult();
|
||||
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/department/listsub",
|
||||
JSONUtil.createObj().putOpt("dept_id", deptId), new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
||||
}).getResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -220,15 +218,10 @@ public class PlatformDingConfig {
|
||||
return DingUserListVo.fail();
|
||||
}
|
||||
|
||||
String resp = doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
|
||||
JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100));
|
||||
|
||||
DingResponse<DingUserListVo> result = JSONUtil.toBean(resp, new TypeReference<DingResponse<DingUserListVo>>() {
|
||||
}.getType(), true);
|
||||
if (!result.isOk()) {
|
||||
result.setResult(DingUserListVo.fail());
|
||||
}
|
||||
return result.getResult();
|
||||
return doRequest(service, "https://oapi.dingtalk.com/topapi/v2/user/list",
|
||||
JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100),
|
||||
new TypeReference<DingResponse<DingUserListVo>>() {
|
||||
}).getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +287,9 @@ public class PlatformDingConfig {
|
||||
body.putOpt("agent_id", configBean.getAgentId());
|
||||
body.putOpt("userid_list", CollUtil.join(userIds, ","));
|
||||
body.putOpt("msg", msg);
|
||||
doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body);
|
||||
doRequest(service, "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", body,
|
||||
new TypeReference<DingResponse<String>>() {
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -6,6 +6,8 @@ public class DingResponse<T> {
|
||||
|
||||
private String errcode;
|
||||
private String errmsg;
|
||||
private String ticket;
|
||||
private Long expiresIn;
|
||||
private T result;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -43,4 +45,20 @@ public class DingResponse<T> {
|
||||
public void setResult(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getTicket() {
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public void setTicket(String ticket) {
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public Long getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public void setExpiresIn(Long expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@ import java.util.List;
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
public class DingUserInfo {
|
||||
public class DingUserInfo extends DingUserSimple {
|
||||
|
||||
private String name;
|
||||
private String userid;
|
||||
private String avatar;
|
||||
private String mobile;
|
||||
private String email;
|
||||
@@ -17,7 +15,6 @@ public class DingUserInfo {
|
||||
private String nickname;
|
||||
private String title;
|
||||
private String remark;
|
||||
private String unionid;
|
||||
private String appId;
|
||||
private List<String> deptIdList;
|
||||
private boolean leader;
|
||||
@@ -34,30 +31,6 @@ public class DingUserInfo {
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUnionid() {
|
||||
return unionid;
|
||||
}
|
||||
|
||||
public void setUnionid(String unionid) {
|
||||
this.unionid = unionid;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.tiesheng.platform.config.ding.bean;
|
||||
|
||||
public class DingUserSimple {
|
||||
|
||||
private String unionid;
|
||||
private String name;
|
||||
private String userid;
|
||||
|
||||
public String getUnionid() {
|
||||
return unionid;
|
||||
}
|
||||
|
||||
public void setUnionid(String unionid) {
|
||||
this.unionid = unionid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.19</version>
|
||||
<version>1.0.20</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user