Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MaxKey单点登录官方(MaxKeyTop)
MaxKey
提交
d4ca0408
MaxKey
项目概览
MaxKey单点登录官方(MaxKeyTop)
/
MaxKey
9 个月 前同步成功
通知
75
Star
3
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d4ca0408
编写于
1月 22, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
workweixin
上级
89ca99e1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
29 deletion
+22
-29
maxkey-identitys/maxkey-synchronizers-workweixin/src/main/java/org/maxkey/synchronizer/workweixin/WorkweixinOrganizationService.java
...ynchronizer/workweixin/WorkweixinOrganizationService.java
+5
-15
maxkey-identitys/maxkey-synchronizers-workweixin/src/main/java/org/maxkey/synchronizer/workweixin/WorkweixinUsersService.java
...axkey/synchronizer/workweixin/WorkweixinUsersService.java
+17
-14
未找到文件。
maxkey-identitys/maxkey-synchronizers-workweixin/src/main/java/org/maxkey/synchronizer/workweixin/WorkweixinOrganizationService.java
浏览文件 @
d4ca0408
...
...
@@ -35,8 +35,6 @@ import org.springframework.stereotype.Service;
public
class
WorkweixinOrganizationService
extends
AbstractSynchronizerService
implements
ISynchronizerService
{
final
static
Logger
_logger
=
LoggerFactory
.
getLogger
(
WorkweixinOrganizationService
.
class
);
WorkWeixinDeptsResponse
deptsResponse
;
String
access_token
;
static
String
DEPTS_URL
=
"https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=%s"
;
...
...
@@ -49,13 +47,13 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i
for
(
WorkWeixinDepts
dept
:
rsp
.
getDepartment
())
{
_logger
.
info
(
"dept : "
+
dept
.
getId
()+
" "
+
dept
.
getName
()+
" "
+
dept
.
getParentid
());
Organizations
org
=
buildOrganization
(
dept
);
Organizations
org
anization
=
buildOrganization
(
dept
);
if
(
organizationsService
.
findOne
(
"id = ? and instid = ?"
,
new
Object
[]
{
org
.
getId
().
toString
(),
org
.
getInstId
()
},
new
Object
[]
{
org
anization
.
getId
(),
organization
.
getInstId
()
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
})
==
null
)
{
organizationsService
.
insert
(
org
);
organizationsService
.
insert
(
org
anization
);
}
else
{
organizationsService
.
update
(
org
);
organizationsService
.
update
(
org
anization
);
}
}
...
...
@@ -68,7 +66,7 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i
public
WorkWeixinDeptsResponse
requestDepartmentList
(
String
access_token
)
{
HttpRequestAdapter
request
=
new
HttpRequestAdapter
();
String
responseBody
=
request
.
get
(
String
.
format
(
DEPTS_URL
,
access_token
));
deptsResponse
=
JsonUtils
.
gson2Object
(
responseBody
,
WorkWeixinDeptsResponse
.
class
);
WorkWeixinDeptsResponse
deptsResponse
=
JsonUtils
.
gson2Object
(
responseBody
,
WorkWeixinDeptsResponse
.
class
);
_logger
.
info
(
"response : "
+
responseBody
);
for
(
WorkWeixinDepts
dept
:
deptsResponse
.
getDepartment
())
{
...
...
@@ -97,12 +95,4 @@ public class WorkweixinOrganizationService extends AbstractSynchronizerService i
this
.
access_token
=
access_token
;
}
public
WorkWeixinDeptsResponse
getDeptsResponse
()
{
return
deptsResponse
;
}
public
void
setDeptsResponse
(
WorkWeixinDeptsResponse
deptsResponse
)
{
this
.
deptsResponse
=
deptsResponse
;
}
}
maxkey-identitys/maxkey-synchronizers-workweixin/src/main/java/org/maxkey/synchronizer/workweixin/WorkweixinUsersService.java
浏览文件 @
d4ca0408
...
...
@@ -17,26 +17,25 @@
package
org.maxkey.synchronizer.workweixin
;
import
java.sql.Types
;
import
java.util.List
;
import
org.maxkey.entity.Organizations
;
import
org.maxkey.entity.UserInfo
;
import
org.maxkey.synchronizer.AbstractSynchronizerService
;
import
org.maxkey.synchronizer.ISynchronizerService
;
import
org.maxkey.synchronizer.workweixin.entity.WorkWeixinDepts
;
import
org.maxkey.synchronizer.workweixin.entity.WorkWeixinUsers
;
import
org.maxkey.synchronizer.workweixin.entity.WorkWeixinUsersResponse
;
import
org.maxkey.util.JsonUtils
;
import
org.maxkey.web.HttpRequestAdapter
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
WorkweixinUsersService
extends
AbstractSynchronizerService
implements
ISynchronizerService
{
final
static
Logger
_logger
=
LoggerFactory
.
getLogger
(
WorkweixinUsersService
.
class
);
@Autowired
WorkweixinOrganizationService
workweixinOrganizationService
;
String
access_token
;
static
String
USERS_URL
=
"https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=%s&department_id=%s&fetch_child=0"
;
...
...
@@ -44,8 +43,11 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen
public
void
sync
()
{
_logger
.
info
(
"Sync Users..."
);
try
{
for
(
WorkWeixinDepts
dept
:
workweixinOrganizationService
.
getDeptsResponse
().
getDepartment
())
{
List
<
Organizations
>
organizations
=
organizationsService
.
find
(
"instid = ?"
,
new
Object
[]
{
this
.
synchronizer
.
getInstId
()
},
new
int
[]
{
Types
.
VARCHAR
});
for
(
Organizations
dept
:
organizations
)
{
HttpRequestAdapter
request
=
new
HttpRequestAdapter
();
String
responseBody
=
request
.
get
(
String
.
format
(
USERS_URL
,
access_token
,
dept
.
getId
()));
WorkWeixinUsersResponse
usersResponse
=
JsonUtils
.
gson2Object
(
responseBody
,
WorkWeixinUsersResponse
.
class
);
...
...
@@ -54,7 +56,14 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen
for
(
WorkWeixinUsers
user
:
usersResponse
.
getUserlist
())
{
UserInfo
userInfo
=
buildUserInfo
(
user
);
_logger
.
info
(
"userInfo : "
+
userInfo
);
this
.
userInfoService
.
merge
(
userInfo
);
if
(
userInfoService
.
findOne
(
"username = ? and instid = ?"
,
new
Object
[]
{
userInfo
.
getUsername
(),
this
.
getSynchronizer
().
getInstId
()
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
VARCHAR
})
==
null
)
{
userInfo
.
setPassword
(
userInfo
.
getUsername
()
+
"Maxkey@888"
);
this
.
userInfoService
.
insert
(
userInfo
);
}
else
{
userInfoService
.
update
(
userInfo
);
}
}
}
...
...
@@ -89,13 +98,7 @@ public class WorkweixinUsersService extends AbstractSynchronizerService implemen
return
userInfo
;
}
public
void
setAccess_token
(
String
access_token
)
{
this
.
access_token
=
access_token
;
}
public
void
setWorkweixinOrganizationService
(
WorkweixinOrganizationService
workweixinOrganizationService
)
{
this
.
workweixinOrganizationService
=
workweixinOrganizationService
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录