mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
✨ Introducing new features. 钉钉互联
This commit is contained in:
1 parent
abb43f8a4e
commit
aa17bb3924
5 files changed
+150
No files matched your search
@@ -128,6 +128,11 @@
|
||||
<artifactId>cas-client-core</artifactId>
|
||||
<version>${cas.sdk.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dingtalk</artifactId>
|
||||
<version>${dingtalk.version}</version>
|
||||
</dependency>
|
||||
<!--web 模块-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.pig4cloud.pigx.admin.controller;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 钉钉、微信 互联
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2022/4/22
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/connect")
|
||||
@Api(value = "connect", tags = "开放互联")
|
||||
public class ConnectController {
|
||||
|
||||
/**
|
||||
* 同步钉钉用户
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sync/ding/user")
|
||||
public R syncUser() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步钉钉角色
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sync/ding/role")
|
||||
public R syncRole() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步钉钉部门
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sync/ding/dept")
|
||||
public R syncDept() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步企微用户
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sync/cp/user")
|
||||
public R syncCpUser() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步企微角色
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sync/cp/role")
|
||||
public R syncCpRole() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步企微部门
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/sync/cp/dept")
|
||||
public R syncCpDept() {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.pig4cloud.pigx.admin.service;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2022/4/22
|
||||
*
|
||||
* 互联平台
|
||||
*/
|
||||
public interface ConnectService {
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.pig4cloud.pigx.admin.service.impl;
|
||||
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenRequest;
|
||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponse;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysSocialDetailsMapper;
|
||||
import com.pig4cloud.pigx.admin.service.ConnectService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 互联平台实现
|
||||
*
|
||||
* 钉钉: https://open-dev.dingtalk.com/apiExplorer
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2022/4/22
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ConnectServiceImpl implements ConnectService {
|
||||
|
||||
private final SysSocialDetailsMapper sysSocialDetailsMapper;
|
||||
|
||||
private String getDingAccessToken() {
|
||||
SysSocialDetails dingTalk = sysSocialDetailsMapper
|
||||
.selectOne(Wrappers.<SysSocialDetails>lambdaQuery().eq(SysSocialDetails::getType, "ding"));
|
||||
GetAccessTokenRequest getAccessTokenRequest = new GetAccessTokenRequest().setAppKey(dingTalk.getAppId())
|
||||
.setAppSecret(dingTalk.getAppSecret());
|
||||
GetAccessTokenResponse tokenResponse = null;
|
||||
try {
|
||||
tokenResponse = createDingClient().getAccessToken(getAccessTokenRequest);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("调用钉钉异常", e);
|
||||
}
|
||||
return tokenResponse.getBody().getAccessToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建钉钉客户端
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
private com.aliyun.dingtalkoauth2_1_0.Client createDingClient() {
|
||||
Config config = new Config();
|
||||
config.protocol = "https";
|
||||
config.regionId = "central";
|
||||
return new com.aliyun.dingtalkoauth2_1_0.Client(config);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,6 +45,7 @@
|
||||
<spring-boot-admin.version>2.6.6</spring-boot-admin.version>
|
||||
<captcha.version>1.2.7</captcha.version>
|
||||
<cas.sdk.version>3.6.4</cas.sdk.version>
|
||||
<dingtalk.version>1.3.40</dingtalk.version>
|
||||
<swagger.fox.version>3.0.0</swagger.fox.version>
|
||||
<knife4j.version>2.0.9</knife4j.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
|
||||
Reference in new issue
Block a user