浙政钉调用强制组件

浙政钉调用强制组件

第一步

获取通讯录权限范围文档地址: 获取通讯录权限范围

第二步

根据组织Code查询详情文档地址: 根据组织Code查询详情

package datadockingjiande.web.controllers;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.xxpt.gateway.shared.client.http.ExecutableClient;
import com.alibaba.xxpt.gateway.shared.client.http.PostClient;
import datadockingjiande.utils.ZZDUtil;
import lombok.extern.slf4j.Slf4j;
import org.pitaya.comm.MD5Utils;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author wcy
 * @Date 2024/3/12 11:09 上午
 * @Description: 浙政钉强制组件调用
 */
@Slf4j
@RestController
@RequestMapping("api/zzd/")
@Component
public class ZZDController {

	private static final String DOMAINNAME = "openplatform-pro.ding.zj.gov.cn";
	private static final String OWNERAPPKEY = "***";
	private static final String OWNERSECREKEY = "***";

	/**
	 * 第一步获取通讯录权限范围
	 * @return
	 */
	@RequestMapping("getScopes")
	private JSONObject getScopes() {
		ExecutableClient executableClient = ZZDUtil.getInstance(OWNERAPPKEY, OWNERSECREKEY, DOMAINNAME);
		String api = "/auth/scopesV2";
		PostClient postClient = executableClient.newPostClient(api);
		postClient.addParameter("tenantId", "196729");
		String apiResult = postClient.post();
		log.info("第一步查询强制组件<获取通讯录权限范围>详情:{}", apiResult);
		return JSONObject.parseObject(apiResult);
	}

	/**
	 * 第二步获取通讯录部门信息
	 * @param code 第一步返回的deptVisibleScopes
	 * @return
	 */
	@RequestMapping("getOrganizationByCode")
	private JSONObject getOrganizationByCode(@RequestParam String code) {
		ExecutableClient executableClient = ZZDUtil.getInstance(OWNERAPPKEY, OWNERSECREKEY, DOMAINNAME);
		String api = "/mozi/organization/getOrganizationByCode";
		PostClient postClient = executableClient.newPostClient(api);
		postClient.addParameter("pageNo", "1");
		postClient.addParameter("pageSize", "100");
		postClient.addParameter("organizationCode", code);
		postClient.addParameter("tenantId", "196729");
		String apiResult = postClient.post();
		log.info("第二步查询强制组件<获取通讯录部门信息>详情:{}", apiResult);
		return JSONObject.parseObject(apiResult);
	}

}
public class ZZDUtil {

	private static ExecutableClient executableClient = null;

	public static ExecutableClient getInstance(String appkey, String secrekey, String domainame) {
		if (executableClient != null) {
			return executableClient;
		}
		executableClient = ExecutableClient.getInstance();
		executableClient.setAccessKey(appkey);
		executableClient.setSecretKey(secrekey);
		executableClient.setDomainName(domainame);
		executableClient.setProtocal("https");
		executableClient.init();
		return executableClient;
	}

}

  • 15
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值