增加了相关方法
This commit is contained in:
parent
422b9a4150
commit
1455a07772
@ -22,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.cm.common.dingding.controller.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.dingding.service.IDingDingAppDepartmentService;
|
||||
import com.cm.common.dingding.service.IDingDingMessageService;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.taobao.api.ApiException;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -27,10 +30,17 @@ public class DemoController {
|
||||
|
||||
@Autowired
|
||||
private IDingDingMessageService dingDingMessageService;
|
||||
@Autowired
|
||||
private IDingDingAppDepartmentService dingDingAppDepartmentService;
|
||||
|
||||
@GetMapping("sendmessage/{phone}")
|
||||
private SuccessResult sendMessage(@PathVariable("phone") String phone) {
|
||||
public SuccessResult sendMessage(@PathVariable("phone") String phone) {
|
||||
return dingDingMessageService.send(phone, "测试");
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public JSONObject list() throws ApiException {
|
||||
return dingDingAppDepartmentService.list();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.cm.common.dingding.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.taobao.api.ApiException;
|
||||
|
||||
/**
|
||||
* @ClassName: IDingDingAppDepartmentService
|
||||
* @Description: 钉钉部门
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/7/21 9:42 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IDingDingAppDepartmentService {
|
||||
|
||||
JSONObject list() throws ApiException;
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.cm.common.dingding.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.base.AbstractService;
|
||||
import com.cm.common.dingding.manager.app.DingDingAppManager;
|
||||
import com.cm.common.dingding.service.IDingDingAppDepartmentService;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
|
||||
import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName: DingDingAppDepartmentServiceImpl
|
||||
* @Description: 钉钉部门管理,需要开放钉钉应用:权限管理 -> 通讯录管理 -> 通讯录部门信息读权限
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/7/21 9:42 上午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class DingDingAppDepartmentServiceImpl extends AbstractService implements IDingDingAppDepartmentService {
|
||||
@Override
|
||||
public JSONObject list() throws ApiException {
|
||||
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
|
||||
OapiV2DepartmentListsubRequest oapiV2DepartmentListsubRequest = new OapiV2DepartmentListsubRequest();
|
||||
oapiV2DepartmentListsubRequest.setDeptId(1L);
|
||||
oapiV2DepartmentListsubRequest.setLanguage("zh_CN");
|
||||
OapiV2DepartmentListsubResponse rsp = client.execute(oapiV2DepartmentListsubRequest, DingDingAppManager.getInstance().getAccessToken());
|
||||
System.out.println(rsp.getBody());
|
||||
return JSON.parseObject(rsp.getBody());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user