|
@@ -0,0 +1,461 @@
|
|
|
+package org.jeecg.modules.system.util;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
+import com.dingtalk.api.DingTalkClient;
|
|
|
+import com.dingtalk.api.request.*;
|
|
|
+import com.dingtalk.api.response.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.client.ClientProtocolException;
|
|
|
+import org.apache.http.client.config.RequestConfig;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.client.utils.URLEncodedUtils;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.system.entity.SysUser;
|
|
|
+import org.jeecg.modules.system.service.ISysUserService;
|
|
|
+import org.jeecg.modules.system.service.impl.SysUserServiceImpl;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.security.MessageDigest;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+import java.util.Formatter;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class HttpHelper {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
+ public static Long agentId;
|
|
|
+
|
|
|
+ private static String appKey;
|
|
|
+
|
|
|
+ private static String appSecret;
|
|
|
+
|
|
|
+ private static String frontpageUrl;
|
|
|
+
|
|
|
+// private static String corpId;
|
|
|
+//
|
|
|
+// private static String appId;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private Environment env;
|
|
|
+
|
|
|
+ private static HttpHelper httpHelper;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void readConfig() {
|
|
|
+// agentId = Long.valueOf(env.getProperty("dingtalk.agentId")).longValue();
|
|
|
+ appKey = env.getProperty("dingtalk.appKey");
|
|
|
+ appSecret = env.getProperty("dingtalk.appSecret");
|
|
|
+ frontpageUrl = env.getProperty("frontpage.url");
|
|
|
+// corpId = env.getProperty("dingtalk.corpId");
|
|
|
+// appId = env.getProperty("dingtalk.appId");
|
|
|
+ httpHelper = this;
|
|
|
+ httpHelper.sysUserService = this.sysUserService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * params:
|
|
|
+ * url:需要Get请求的网址
|
|
|
+ *
|
|
|
+ * return:
|
|
|
+ * 返回请求时网页相应的数据,用json存储
|
|
|
+ */
|
|
|
+ public static JSONObject httpGet(String url) {
|
|
|
+ //创建httpClient
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+ HttpGet httpGet = new HttpGet(url); //生成一个请求
|
|
|
+ RequestConfig requestConfig = RequestConfig.custom(). //配置请求的一些属性
|
|
|
+ setSocketTimeout(5000).setConnectTimeout(5000).setConnectionRequestTimeout(1000).build();
|
|
|
+ httpGet.setConfig(requestConfig); //为请求设置属性
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
+ try {
|
|
|
+ response = httpClient.execute(httpGet);
|
|
|
+ //如果返回结果的code不等于200,说明出错了
|
|
|
+ if (response.getStatusLine().getStatusCode() != 200) {
|
|
|
+ System.out.println("request url failed, http code=" + response.getStatusLine().getStatusCode() + ", url=" + url);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ HttpEntity entity = response.getEntity(); //reponse返回的数据在entity中
|
|
|
+ if (entity != null) {
|
|
|
+ String resultStr = EntityUtils.toString(entity, "utf-8");//将数据转化为string格式
|
|
|
+ JSONObject result = JSONObject.parseObject(resultStr); //将结果转化为json格式
|
|
|
+ if (result.getInteger("errcode") == 0) { //如果返回值得errcode值为0,则成功
|
|
|
+ //移除一些没用的元素
|
|
|
+ result.remove("errcode");
|
|
|
+ result.remove("errmsg");
|
|
|
+ return result; //返回有用的信息
|
|
|
+ } else { //返回结果出错了,则打印出来
|
|
|
+ System.out.println("request url=" + url + ",return value=");
|
|
|
+ System.out.println(resultStr);
|
|
|
+ int errCode = result.getInteger("errcode");
|
|
|
+ String errMsg = result.getString("errmsg");
|
|
|
+ throw new Exception("ErrorCode:" + errCode + "ErrorMsg" + errMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ClientProtocolException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ System.out.println("request url=" + url + ", exception, msg=" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ System.out.println("request url=" + url + ", exception, msg=" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (response != null) try {
|
|
|
+ response.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**然后是调用httpGet方法获得access_token的代码实现:*/
|
|
|
+ public static String getAccessToken(String corpid,String corpsecret){
|
|
|
+ String url="https://oapi.dingtalk.com/gettoken?"+"corpid="+corpid+"&corpsecret="+corpsecret;
|
|
|
+ JSONObject res=HttpHelper.httpGet(url); //将httpGet方法封装在HttpHelper类中
|
|
|
+ String access_token="";
|
|
|
+ if(res!=null){
|
|
|
+ access_token=res.getString("access_token");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //throw new Exception("Cannot resolve field access_token from oapi resonpse");
|
|
|
+ }
|
|
|
+ return access_token;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 使用钉钉客户端函数,获取access_token
|
|
|
+ * @param appKey
|
|
|
+ * @param appSecret
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getAccessTokenByDD(String appKey,String appSecret){
|
|
|
+ DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
|
|
+ OapiGettokenRequest request = new OapiGettokenRequest();
|
|
|
+ request.setAppkey(appKey);
|
|
|
+ request.setAppsecret(appSecret);
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ String access_token = "";
|
|
|
+ try {
|
|
|
+ OapiGettokenResponse response = client.execute(request);
|
|
|
+ access_token = response.getAccessToken();
|
|
|
+ }catch (Exception ex){
|
|
|
+ log.error("---------------------------- get token exception:"+ex.getMessage());
|
|
|
+ }
|
|
|
+ return access_token;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前用户钉钉信息
|
|
|
+ * @param code
|
|
|
+ * @param access_token
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static JSONObject getUserInfoByDD(String code , String access_token){
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/getuserinfo");
|
|
|
+ OapiUserGetuserinfoRequest request = new OapiUserGetuserinfoRequest();
|
|
|
+ request.setCode(code);
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ JSONObject userInfo = new JSONObject();
|
|
|
+ try {
|
|
|
+ // 获取当前用户,userid
|
|
|
+ OapiUserGetuserinfoResponse response = client.execute(request, access_token);
|
|
|
+ JSONObject responseJson = JSON.parseObject(JSONObject.toJSONString(response));
|
|
|
+ if (responseJson.getInteger("errcode") == 0){
|
|
|
+ userInfo = responseJson.getJSONObject("body");
|
|
|
+ /*
|
|
|
+ JSONObject absInfo = responseJson.getJSONObject("body");
|
|
|
+ // 获取用户详细信息
|
|
|
+ DingTalkClient clientDetail = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/get");
|
|
|
+ OapiUserGetRequest reqDetail = new OapiUserGetRequest();
|
|
|
+ reqDetail.setUserid(absInfo.getString("userid"));
|
|
|
+ reqDetail.setHttpMethod("GET");
|
|
|
+ OapiUserGetResponse respDetail = clientDetail.execute(reqDetail, access_token);
|
|
|
+
|
|
|
+ responseJson = JSON.parseObject(JSONObject.toJSONString(respDetail));
|
|
|
+ if (responseJson.getInteger("errcode") == 0)
|
|
|
+ userInfo = responseJson.getJSONObject("body");
|
|
|
+ else
|
|
|
+ log.error("---------------------------- get userinfo detail error:"+responseJson.getString("errmsg"));
|
|
|
+ */
|
|
|
+ }else{
|
|
|
+ log.error("---------------------------- get userinfo error:"+responseJson.getString("errmsg"));
|
|
|
+ }
|
|
|
+ }catch (Exception ex){
|
|
|
+ log.error("---------------------------- get userinfo exception:"+ex.getMessage());
|
|
|
+ }
|
|
|
+ return userInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户信息详情
|
|
|
+ * @param access_token
|
|
|
+ * @param userid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static JSONObject getUserCompleteInfoByDD(String access_token,String userid){
|
|
|
+ DingTalkClient clientDetail = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/get");
|
|
|
+ OapiUserGetRequest reqDetail = new OapiUserGetRequest();
|
|
|
+ reqDetail.setUserid(userid);
|
|
|
+ reqDetail.setHttpMethod("GET");
|
|
|
+ JSONObject userInfo = new JSONObject();
|
|
|
+ try {
|
|
|
+ OapiUserGetResponse respDetail = clientDetail.execute(reqDetail, access_token);
|
|
|
+
|
|
|
+ JSONObject responseJson = JSON.parseObject(JSONObject.toJSONString(respDetail));
|
|
|
+ if (responseJson.getInteger("errcode") == 0)
|
|
|
+ userInfo = responseJson.getJSONObject("body");
|
|
|
+ else
|
|
|
+ log.error("---------------------------- get userinfo detail error:" + responseJson.getString("errmsg"));
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("---------------------------- get userinfo detail exception:" + ex.getMessage());
|
|
|
+ }
|
|
|
+ return userInfo;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 向网页请求ticket值,用Get方式请求网页
|
|
|
+ * param:
|
|
|
+ * access_token:上面得到的access_token值
|
|
|
+ *
|
|
|
+ * return:
|
|
|
+ * 返回值是ticket
|
|
|
+ */
|
|
|
+ public static String getTicket(String access_token){
|
|
|
+ String url="https://oapi.dingtalk.com/get_jsapi_ticket?"+ "access_token="+access_token;
|
|
|
+
|
|
|
+ JSONObject res=HttpHelper.httpGet(url);//步骤3中有httpGet的定义,只是封装在HttpHelper类中
|
|
|
+ String ticket="";
|
|
|
+ if(res!=null){
|
|
|
+ ticket=res.getString("ticket");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // new Exception("Cannot resolve field ticket from oapi resonpse");
|
|
|
+ }
|
|
|
+ return ticket;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject getUserInfo(String code , String access_token){
|
|
|
+ String url="https://oapi.dingtalk.com/user/getuserinfo?"+ "code="+code + "&access_token="+access_token;
|
|
|
+ JSONObject res=HttpHelper.httpGet(url);//步骤3中有httpGet的定义,只是封装在HttpHelper类中
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ public static JSONObject getUserCompleteInfo(String access_token,String userid) {
|
|
|
+ String url="https://oapi.dingtalk.com/user/get?" + "access_token="+access_token + "&userid="+userid;
|
|
|
+ JSONObject res=HttpHelper.httpGet(url);//步骤3中有httpGet的定义,只是封装在HttpHelper类中
|
|
|
+ System.out.println(res);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 生成签名的函数
|
|
|
+ * params:
|
|
|
+ * ticket:签名数据
|
|
|
+ * nonceStr:签名用的随机字符串,从properties文件中读取
|
|
|
+ * timeStamp:生成签名用的时间戳
|
|
|
+ * url:当前请求的URL地址
|
|
|
+ */
|
|
|
+ public static String getSign(String ticket, String nonceStr, long timeStamp, String url) throws Exception {
|
|
|
+ String plain = "jsapi_ticket=" + ticket + "&noncestr=" + nonceStr + "×tamp=" + String.valueOf(timeStamp)
|
|
|
+ + "&url=" + url;
|
|
|
+ try {
|
|
|
+ MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); //安全hash算法
|
|
|
+ sha1.reset();
|
|
|
+ sha1.update(plain.getBytes("UTF-8")); //根据参数产生hash值
|
|
|
+ return bytesToHex(sha1.digest());
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
+ throw new Exception(e.getMessage());
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new Exception(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //将bytes类型的数据转化为16进制类型
|
|
|
+ private static String bytesToHex(byte[] hash) {//将字符串转化为16进制的数据
|
|
|
+ Formatter formatter = new Formatter();
|
|
|
+ for (byte b : hash) {
|
|
|
+ formatter.format("%02x", b);
|
|
|
+ }
|
|
|
+ String result = formatter.toString();
|
|
|
+ formatter.close();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取调用钉钉接口的凭证
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static OapiGettokenResponse getAccessToken() throws Exception{
|
|
|
+ DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
|
|
+ OapiGettokenRequest request = new OapiGettokenRequest();
|
|
|
+ request.setAppkey(appKey);
|
|
|
+ request.setAppsecret(appSecret);
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ OapiGettokenResponse response = client.execute(request);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取钉钉所有用户的信息
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static List<OapiUserListbypageResponse.Userlist> getUserInfoList() throws Exception{
|
|
|
+ OapiGettokenResponse accessTokenObj = getAccessToken();
|
|
|
+ String accessToken = accessTokenObj.getAccessToken();
|
|
|
+ List<OapiUserListbypageResponse.Userlist> ret = new LinkedList<>();
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/listbypage");
|
|
|
+ OapiUserListbypageRequest request = new OapiUserListbypageRequest();
|
|
|
+ long size = 100L;
|
|
|
+ List<OapiDepartmentListResponse.Department> depList = getDepartmentList(accessToken);
|
|
|
+ for (OapiDepartmentListResponse.Department dep : depList) {
|
|
|
+ request.setDepartmentId(dep.getId());//代表跟部门
|
|
|
+ request.setSize(size);
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ long index = 0;
|
|
|
+ while (true){
|
|
|
+ request.setOffset(index*size);//分页起始位
|
|
|
+ OapiUserListbypageResponse execute = client.execute(request,accessToken);
|
|
|
+ List<OapiUserListbypageResponse.Userlist> curResult = execute.getUserlist();
|
|
|
+
|
|
|
+ if(curResult.size() > 0) {
|
|
|
+ ret.addAll(curResult);
|
|
|
+ }
|
|
|
+ if (!execute.getHasMore() || curResult.size() == 0 )
|
|
|
+ break;
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据工号获取用户id
|
|
|
+ * @param accessToken
|
|
|
+ * @param jobNumber 工号
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private static OapiUserListbypageResponse.Userlist getUserByJobnumber(String accessToken,String jobNumber) throws Exception{
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/user/listbypage");
|
|
|
+ OapiUserListbypageRequest request = new OapiUserListbypageRequest();
|
|
|
+ long size = 100;
|
|
|
+ List<OapiDepartmentListResponse.Department> depList = getDepartmentList(accessToken);
|
|
|
+ OapiUserListbypageResponse.Userlist ret = null;
|
|
|
+ for (OapiDepartmentListResponse.Department dep : depList) {
|
|
|
+ request.setDepartmentId(dep.getId());//代表跟部门
|
|
|
+ request.setSize(size);
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ long index = 0;
|
|
|
+ while (true){
|
|
|
+ request.setOffset(index*size);//分页起始位
|
|
|
+ OapiUserListbypageResponse execute = client.execute(request,accessToken);
|
|
|
+ List<OapiUserListbypageResponse.Userlist> curResult = execute.getUserlist();
|
|
|
+ List<OapiUserListbypageResponse.Userlist> users = curResult.stream().filter(item -> jobNumber.equals(item.getJobnumber())).collect(Collectors.toList());
|
|
|
+ if (users.size()>0)
|
|
|
+ ret = users.get(0);
|
|
|
+
|
|
|
+ if (!execute.getHasMore() || curResult.size() == 0 || ret != null)
|
|
|
+ break;
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ if (ret != null)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取部门列表
|
|
|
+ * @param accessToken
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static List<OapiDepartmentListResponse.Department> getDepartmentList(String accessToken) throws Exception{
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/list");
|
|
|
+ OapiDepartmentListRequest request = new OapiDepartmentListRequest();
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ OapiDepartmentListResponse response = client.execute(request, accessToken);
|
|
|
+ List<OapiDepartmentListResponse.Department> ret = new LinkedList<>();
|
|
|
+ if (response.isSuccess()){
|
|
|
+ ret = response.getDepartment();
|
|
|
+ }else {
|
|
|
+ log.error("---------------------------- get department list error:" + response.getErrmsg());
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送钉钉消息
|
|
|
+ * @param username 人员的name,根据name去钉钉中匹配,找到对应的钉钉userid
|
|
|
+ * @param title 消息标题
|
|
|
+ * @param content 消息内容
|
|
|
+ * @param url 变长参数,可不填,为消息跳转地址
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+// public static OapiMessageCorpconversationAsyncsendV2Response sendDingTalkMsg(String username,String title,String content,String url) throws Exception{
|
|
|
+//
|
|
|
+// OapiGettokenResponse accessToken = getAccessToken();
|
|
|
+// /*
|
|
|
+// List<OapiUserListbypageResponse.Userlist> userlist = getUserInfoList(accessToken.getAccessToken(), 100L);
|
|
|
+// List<OapiUserListbypageResponse.Userlist> users = userlist.stream().filter(item -> username.equals(item.getJobnumber())).collect(Collectors.toList());
|
|
|
+// if(users==null || users.isEmpty()){
|
|
|
+// throw new RuntimeException("钉钉消息发送失败");
|
|
|
+// }*/
|
|
|
+//
|
|
|
+// //实时查询所有的钉钉用户
|
|
|
+// //OapiUserListbypageResponse.Userlist user = getUserByJobnumber(accessToken.getAccessToken(), username);
|
|
|
+// //根据本地同步的用户查询userid
|
|
|
+// SysUser user = httpHelper.sysUserService.getUserByName(username);
|
|
|
+// if (user == null){
|
|
|
+// throw new RuntimeException("钉钉消息发送失败:获取钉钉用户信息失败");
|
|
|
+// }
|
|
|
+// //实时查询所有的钉钉用户
|
|
|
+// //String dingdingUid = user.getUserid();
|
|
|
+// String dingdingUid = user.getDingdingUid();
|
|
|
+// if(oConvertUtils.isEmpty(dingdingUid)){
|
|
|
+// throw new RuntimeException("钉钉消息发送失败:"+username+"没有同步钉钉上的用户id");
|
|
|
+// }
|
|
|
+// DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2");
|
|
|
+// OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request();
|
|
|
+// request.setUseridList(dingdingUid);
|
|
|
+// request.setAgentId(agentId);
|
|
|
+// request.setToAllUser(false);
|
|
|
+// OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
|
|
|
+// //发送action_card消息
|
|
|
+// msg.setActionCard(new OapiMessageCorpconversationAsyncsendV2Request.ActionCard());
|
|
|
+// msg.getActionCard().setTitle(title);
|
|
|
+// msg.getActionCard().setMarkdown(content);
|
|
|
+// msg.getActionCard().setSingleTitle("查看详情");
|
|
|
+// //dingtalk://dingtalkclient/action/openapp?corpid=免登企业corpId&container_type=work_platform&app_id=应用id&redirect_type=jump&redirect_url=跳转url
|
|
|
+// String jumpUrl = frontpageUrl + "/#/"+url;
|
|
|
+//// String url = "dingtalk://dingtalkclient/action/openapp?corpid="+corpId+"&container_type=work_platform&app_id="+appId+"&redirect_type=jump&redirect_url="+ URLEncoder.encode(jumpUrl,"utf-8");
|
|
|
+// msg.getActionCard().setSingleUrl(jumpUrl);
|
|
|
+// msg.setMsgtype("action_card");
|
|
|
+// request.setMsg(msg);
|
|
|
+// OapiMessageCorpconversationAsyncsendV2Response response = client.execute(request,accessToken.getAccessToken());
|
|
|
+// return response;
|
|
|
+// }
|
|
|
+}
|