publish 1.0.18
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.17</version>
|
||||
<version>1.0.18</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.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</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.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
@@ -49,6 +48,37 @@ public class PlatformDingConfig {
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送get请求
|
||||
* 会自动增加accessToken在url上面
|
||||
*
|
||||
* @param service
|
||||
* @return
|
||||
*/
|
||||
public String doRequest(String service, String url, JSONObject body) {
|
||||
if (StrUtil.contains(url, "?")) {
|
||||
url = url + "&access_token=" + getAccessToken(service);
|
||||
} else {
|
||||
url = url + "?access_token=" + getAccessToken(service);
|
||||
}
|
||||
|
||||
HttpResponse execute;
|
||||
if (body == null) {
|
||||
execute = HttpUtil.createGet(url).execute();
|
||||
} else {
|
||||
execute = HttpUtil.createPost(url).body(body.toString()).execute();
|
||||
}
|
||||
|
||||
String resp = execute.body();
|
||||
if (execute.isOk()) {
|
||||
return resp;
|
||||
}
|
||||
LogFactory.get().info("{}: {}", url, resp);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 逻辑方法
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -89,8 +119,7 @@ public class PlatformDingConfig {
|
||||
DingConfigBean dingConfigBean = getConfigBean(service);
|
||||
String jsapiTicket = TimedCacheHelper.getTimedCache().get(CACHE_JSAPI_TICKET + dingConfigBean.getAppKey(), false);
|
||||
if (StrUtil.isEmpty(jsapiTicket)) {
|
||||
String response = HttpUtil.get("https://oapi.dingtalk.com/get_jsapi_ticket?access_token=" + getAccessToken(service));
|
||||
LogFactory.get().info("getJsapiTicket: " + response);
|
||||
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"));
|
||||
@@ -126,11 +155,9 @@ public class PlatformDingConfig {
|
||||
* @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) {
|
||||
HttpRequest request = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service))
|
||||
.body(JSONUtil.createObj().putOpt("code", code).toString());
|
||||
try (HttpResponse response = request.execute()) {
|
||||
return JSONUtil.parseObj(response.body()).getJSONObject("result").getStr("userid");
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@@ -144,16 +171,15 @@ public class PlatformDingConfig {
|
||||
*/
|
||||
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
|
||||
DingConfigBean dingConfigBean = getConfigBean(service);
|
||||
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token="
|
||||
+ getAccessToken(service))
|
||||
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute()) {
|
||||
JSONObject resultJson = JSONUtil.parseObj(response.body()).getJSONObject("result");
|
||||
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
|
||||
// 设置一下job_number
|
||||
userInfo.setJobNumber(resultJson.getStr("job_number"));
|
||||
userInfo.setAppId(dingConfigBean.getAppKey());
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
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);
|
||||
// 设置一下job_number
|
||||
userInfo.setJobNumber(resultJson.getStr("job_number"));
|
||||
userInfo.setAppId(dingConfigBean.getAppKey());
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,16 +194,17 @@ public class PlatformDingConfig {
|
||||
if (StrUtil.isEmpty(token)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
|
||||
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute()) {
|
||||
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response.body(), new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
||||
}.getType(), true);
|
||||
|
||||
if (!result.isOk()) {
|
||||
result.setResult(new ArrayList<>());
|
||||
}
|
||||
return result.getResult();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -192,16 +219,16 @@ public class PlatformDingConfig {
|
||||
if (StrUtil.isEmpty(token)) {
|
||||
return DingUserListVo.fail();
|
||||
}
|
||||
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token)
|
||||
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString())
|
||||
.execute()) {
|
||||
DingResponse<DingUserListVo> result = JSONUtil.toBean(response.body(), new TypeReference<DingResponse<DingUserListVo>>() {
|
||||
}.getType(), true);
|
||||
if (!result.isOk()) {
|
||||
result.setResult(DingUserListVo.fail());
|
||||
}
|
||||
return result.getResult();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,12 +290,11 @@ public class PlatformDingConfig {
|
||||
msg.set("msgtype", "action_card");
|
||||
msg.set("action_card", actionCard);
|
||||
|
||||
HashMap<String, Object> body = new HashMap<>(10);
|
||||
body.put("agent_id", configBean.getAgentId());
|
||||
body.put("userid_list", CollUtil.join(userIds, ","));
|
||||
body.put("msg", msg);
|
||||
String resp = HttpUtil.post("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + getAccessToken(service),
|
||||
JSONUtil.toJsonStr(body));
|
||||
JSONObject body = new JSONObject();
|
||||
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);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>1.0.17</version>
|
||||
<version>1.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user