• 大小: 996KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-22
  • 语言: Java
  • 标签: 钉钉  源码  Java  微应用  

资源简介

钉钉企业微应用官方Demo,用Java语言开发,封装好了各种库,方便二次开发

资源截图

代码片段和文件信息

package com.alibaba.dingtalk.openapi.demo;

import com.alibaba.dingtalk.openapi.demo.auth.AuthHelper;
import com.alibaba.dingtalk.openapi.demo.department.DepartmentHelper;
import com.alibaba.dingtalk.openapi.demo.media.MediaHelper;
import com.alibaba.dingtalk.openapi.demo.message.LightAppMessageDelivery;
import com.alibaba.dingtalk.openapi.demo.message.MessageHelper;
import com.alibaba.dingtalk.openapi.demo.user.UserHelper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONobject;
import com.dingtalk.open.client.api.model.corp.*;
import com.dingtalk.open.client.api.model.corp.MessageBody.OABody.Body;
import com.dingtalk.open.client.api.model.corp.MessageBody.OABody.Body.Form;
import com.dingtalk.open.client.api.model.corp.MessageBody.OABody.Body.Rich;
import com.dingtalk.open.client.api.model.corp.MessageBody.OABody.Head;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * 本地测试方法钉钉API
 */
public class Demo {

    public static String TO_USER = ““;
    public static String TO_PARTY = ““;
    public static String AGENT_ID = ““;

    public static void main(String[] args) throws Exception {

        try {

            List departments = new ArrayList();
            departments = DepartmentHelper.listDepartments(AuthHelper.getAccessToken() “1“);
            JSONobject usersJSON = new JSONobject();

            System.out.println(“depart num:“ + departments.size());
            for (int i = 0; i < departments.size(); i++) {
                JSONobject userDepJSON = new JSONobject();
                System.out.println(“dep:“ + departments.get(i).toString());

                long offset = 0;
                int size = 5;
                CorpUserList corpUserList = new CorpUserList();
                while (true) {
                    corpUserList = UserHelper.getDepartmentUser(AuthHelper.getAccessToken() Long.valueOf(departments.get(i).getId())
                             offset size null);
                    System.out.println(JSON.toJSONString(corpUserList));
                    if (Boolean.TRUE.equals(corpUserList.isHasMore())) {
                        offset += size;
                    } else {
                        break;
                    }
                }
                if (corpUserList.getUserlist().size() == 0) {
                    continue;
                }
                for (int j = 0; j < corpUserList.getUserlist().size(); j++) {
                    String user = JSON.toJSONString(corpUserList.getUserlist().get(j));
                    userDepJSON.put(j + ““ JSONobject.parseobject(user CorpUserDetail.class));

                }


                usersJSON.put(departments.get(i).getName() userDepJSON);
                System.out.println(“user:“ + usersJSON.toString());
            }

            System.out.println(“depart:“ + usersJSON.toJSONString());


            // 获取access token
            String accessToken = AuthHelper.getAccessToken();
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-05-22 12:36  openapi-demo-java-master\
     文件         364  2018-05-22 12:36  openapi-demo-java-master\.gitignore
     文件        2563  2018-05-22 12:36  openapi-demo-java-master\README.md
     目录           0  2018-05-22 12:36  openapi-demo-java-master\lib\
     文件       50573  2018-05-22 12:36  openapi-demo-java-master\lib\client-sdk.api-1.0.2.jar
     文件        7797  2018-05-22 12:36  openapi-demo-java-master\lib\client-sdk.common-1.0.0-SNAPSHOT.jar
     文件       42170  2018-05-22 12:36  openapi-demo-java-master\lib\client-sdk.core-1.0.0-SNAPSHOT.jar
     文件       17604  2018-05-22 12:36  openapi-demo-java-master\lib\client-sdk.example-1.0.0-SNAPSHOT.jar
     文件        3009  2018-05-22 12:36  openapi-demo-java-master\lib\client-sdk.spring-1.0.0-SNAPSHOT.jar
     文件       12350  2018-05-22 12:36  openapi-demo-java-master\lib\lippi-oapi-encrpt.jar
     文件      732573  2018-05-22 12:36  openapi-demo-java-master\lib\taobao-sdk-java-auto_1479188381469-20170724.jar
     文件        9570  2018-05-22 12:36  openapi-demo-java-master\pom.xml
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\
     文件       12350  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\Demo.java
     文件         760  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\Env.java
     文件         414  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\OApiException.java
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\auth\
     文件        6632  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\auth\AuthHelper.java
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\department\
     文件        2806  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\department\DepartmentHelper.java
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\eventchange\
     文件        2889  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\eventchange\eventChangeHelper.java
     目录           0  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\media\
     文件        1790  2018-05-22 12:36  openapi-demo-java-master\src\main\java\com\alibaba\dingtalk\openapi\demo\media\MediaHelper.java
............此处省略99个文件信息

评论

共有 条评论