Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
626ceb22
提交
626ceb22
编写于
8月 20, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
钉钉免密
上级
a6bae625
变更
3
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
164 行增加
和
74 行删除
+164
-74
pom.xml
ibzuaa-core/pom.xml
+8
-1
UserDingtalkRegisterService.java
...e/uaa/extensions/service/UserDingtalkRegisterService.java
+127
-62
UserDingtalkRegisterResource.java
...lab/api/rest/extensions/UserDingtalkRegisterResource.java
+29
-11
未找到文件。
ibzuaa-core/pom.xml
浏览文件 @
626ceb22
...
...
@@ -103,7 +103,14 @@
<artifactId>
spring-ldap-core
</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
alibaba-dingtalk-service-sdk
</artifactId>
<version>
1.0.1
</version>
</dependency>
</dependencies>
<properties>
<maven.build.timestamp.format>
yyyyMMddHHmmss
</maven.build.timestamp.format>
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UserDingtalkRegisterService.java
浏览文件 @
626ceb22
此差异已折叠。
点击以展开。
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UserDingtalkRegisterResource.java
浏览文件 @
626ceb22
...
...
@@ -9,6 +9,7 @@ import cn.ibizlab.util.domain.IBZUSER;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.security.AuthTokenUtil
;
import
cn.ibizlab.util.security.AuthenticationInfo
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
cn.ibizlab.util.service.IBZUSERService
;
...
...
@@ -18,10 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.UUID
;
...
...
@@ -46,15 +44,16 @@ public class UserDingtalkRegisterResource {
/**
* 获取钉钉开放平台创建的网站应用appid
*/
@GetMapping
(
value
=
"/uaa/getDingtalkAppId"
)
public
ResponseEntity
<
JSONObject
>
getDingtalkAppId
()
{
@GetMapping
(
value
=
{
"/uaa/getDingtalkAppId"
,
"/uaa/open/dingtalk/access_token"
,
"/uaa/open/dingtalk/appid"
}
)
public
ResponseEntity
<
JSONObject
>
getDingtalkAppId
(
@RequestParam
(
value
=
"id"
,
required
=
false
)
String
id
)
{
JSONObject
obj
=
new
JSONObject
();
SysOpenAccess
openAccess
=
openAccessService
.
getById
(
"dingtalk"
);
SysOpenAccess
openAccess
=
userDingtalkRegisterService
.
getOpenAccess
(
id
);
if
(
openAccess
==
null
||
(
openAccess
.
getDisabled
()!=
null
&&
openAccess
.
getDisabled
()==
1
))
return
ResponseEntity
.
ok
(
obj
);
String
appId
=
openAccess
.
getAccessKey
();
// qq互联appid
String
appId
=
openAccess
.
getAccessKey
();
if
(!
StringUtils
.
isEmpty
(
appId
))
{
obj
.
put
(
"appid"
,
appId
);
obj
.
put
(
"access_token"
,
openAccess
.
getAccessToken
());
}
return
ResponseEntity
.
ok
(
obj
);
...
...
@@ -68,15 +67,17 @@ public class UserDingtalkRegisterResource {
* @return
*/
@PostMapping
(
value
=
"/uaa/queryDingtalkUserByCode"
)
public
ResponseEntity
<
JSONObject
>
queryDingtalkUserByCode
(
@RequestBody
JSONObject
param
)
{
public
ResponseEntity
<
JSONObject
>
queryDingtalkUserByCode
(
@Request
Param
(
value
=
"id"
,
required
=
false
)
String
id
,
@RequestParam
(
value
=
"code"
,
required
=
false
)
String
tmpcode
,
@Request
Body
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
// 空校验
String
code
=
param
.
getString
(
"code"
);
if
(
StringUtils
.
isEmpty
(
code
))
code
=
tmpcode
;
if
(
StringUtils
.
isEmpty
(
code
))
throw
new
BadRequestAlertException
(
"code为空"
,
"UserDingtalkRegisterResource"
,
""
);
// 从数据库中获取钉钉授权应用信息
SysOpenAccess
openAccess
=
openAccessService
.
getById
(
"dingtalk"
);
SysOpenAccess
openAccess
=
userDingtalkRegisterService
.
getOpenAccess
(
id
);
if
(
openAccess
==
null
||
(
openAccess
.
getDisabled
()!=
null
&&
openAccess
.
getDisabled
()==
1
))
throw
new
BadRequestAlertException
(
"未找到配置"
,
"UserDingtalkRegisterResource"
,
""
);
String
appId
=
openAccess
.
getAccessKey
();
// 个人应用开发过程中的唯一性标识AppId
...
...
@@ -95,7 +96,7 @@ public class UserDingtalkRegisterResource {
}
// 根据openid查用户授权信息
SysUserAuth
userAuth
=
sysUserAuthService
.
getOne
(
Wrappers
.<
SysUserAuth
>
query
().
eq
(
"identifier"
,
openid
));
SysUserAuth
userAuth
=
sysUserAuthService
.
getOne
(
Wrappers
.<
SysUserAuth
>
lambdaQuery
().
eq
(
SysUserAuth:
:
getIdentityType
,
"dingtalk"
).
eq
(
SysUserAuth:
:
getIdentifier
,
openid
));
// 该钉钉用户注册过账号,登录系统
if
(!
StringUtils
.
isEmpty
(
userAuth
))
{
IBZUSER
ibzuser
=
ibzuserService
.
getById
(
userAuth
.
getUserid
());
...
...
@@ -182,4 +183,21 @@ public class UserDingtalkRegisterResource {
}
@GetMapping
(
value
=
{
"/uaa/open/dingtalk/auth/{code}"
})
public
ResponseEntity
<
AuthenticationInfo
>
getUserByToken
(
@PathVariable
(
value
=
"code"
)
String
code
,
@RequestParam
(
value
=
"id"
,
required
=
false
)
String
id
)
{
AuthenticationUser
user
=
userDingtalkRegisterService
.
getUserByToken
(
id
,
code
);
final
String
token
=
jwtTokenUtil
.
generateToken
(
user
);
AuthenticationUser
user2
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
user2
);
user2
.
setAuthorities
(
null
);
user2
.
setPermissionList
(
null
);
// 返回 token
return
ResponseEntity
.
ok
().
body
(
new
AuthenticationInfo
(
token
,
user2
));
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录