Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
zhangshaowu
/
pipi-helper
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6ace790c
authored
Oct 15, 2022
by
liushuangwu
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
111
1 parent
610e1206
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
29 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/service/EmployeeService.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
6ace790
...
...
@@ -2,11 +2,11 @@ package com.pipihelper.project.feishu.controller;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.FeiShuEventDTO
;
import
com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO
;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.employee.SystemFieldsDTO
;
import
com.pipihelper.project.feishu.entity.Employee
;
import
com.pipihelper.project.feishu.service.EmployeeService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuEventService
;
...
...
@@ -18,10 +18,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* @Description: TODO
...
...
@@ -88,35 +86,40 @@ public class FeiShuEventController {
@PostMapping
(
"/employee-list"
)
public
Object
event
()
{
//employeeService.uprsetAllEmployee();
List
<
FeiShuEmployeeDTO
>
dtos
=
feiShuApiService
.
getEmployeeList
();
return
dtos
;
}
List
<
Employee
>
employeeList
=
employeeService
.
findAll
();
Map
<
String
,
Employee
>
employeeMap
=
employeeList
.
stream
().
collect
(
Collectors
.
toMap
(
Employee:
:
getOpenId
,
Function
.
identity
()));
@PostMapping
(
"/department"
)
public
Object
department
(
String
department
)
{
List
<
String
>
openIdList
=
dtos
.
stream
().
map
(
FeiShuEmployeeDTO:
:
getUserId
).
collect
(
Collectors
.
toList
());
employeeList
.
forEach
(
it
->
{
if
(!
openIdList
.
contains
(
it
.
getOpenId
()))
{
employeeService
.
deleteById
(
it
.
getId
());
return
feiShuApiService
.
getDepartment
(
department
);
}
});
dtos
.
forEach
(
it
->
{
Employee
currentEmployee
=
employeeMap
.
get
(
it
.
getUserId
());
if
(
currentEmployee
!=
null
)
{
return
;
@PostMapping
(
"/create-chart"
)
public
Object
createChatList
(
String
department
)
{
FeiShuChatDTO
feiShuChatDTO
=
new
FeiShuChatDTO
();
feiShuChatDTO
.
setName
(
"按摩群"
);
feiShuChatDTO
.
setOwnerId
(
"ou_5d72916b0a0b800b0fff6861eb52cf13"
);
ArrayList
<
String
>
strings
=
Lists
.
newArrayList
(
"ou_5d72916b0a0b800b0fff6861eb52cf13"
,
"ou_59498f75298812fbbed4de46fc5462e3"
,
"ou_aa066da071443aefb2351ee248190583"
,
"ou_5f30c2076fc2c5a5225bfdbb2da1ea6f"
,
"ou_c902848a93e19928043a7fa38bef295b"
);
String
[]
userIds
=
new
String
[
strings
.
size
()];
for
(
int
i
=
0
;
i
<
strings
.
size
();
i
++)
{
userIds
[
i
]
=
strings
.
get
(
i
);
}
Employee
employee
=
new
Employee
();
SystemFieldsDTO
systemFieldsDTO
=
it
.
getSystemFields
();
employee
.
setOpenId
(
it
.
getUserId
());
if
(
systemFieldsDTO
!=
null
)
{
employee
.
setGender
(
systemFieldsDTO
.
getGender
());
employee
.
setStatus
(
systemFieldsDTO
.
getStatus
());
employee
.
setDepartmentId
(
systemFieldsDTO
.
getDepartmentId
());
employee
.
setName
(
systemFieldsDTO
.
getName
());
employee
.
setMobile
(
systemFieldsDTO
.
getMobile
());
feiShuChatDTO
.
setUserIdList
(
userIds
);
return
feiShuApiService
.
createChatList
(
feiShuChatDTO
);
}
employeeService
.
create
(
employee
);
});
return
dtos
;
@PostMapping
(
"/join-chart"
)
public
Object
joinChatList
(
String
openId
)
{
FeiShuChatDTO
feiShuChatDTO
=
new
FeiShuChatDTO
();
feiShuChatDTO
.
setChatId
(
"oc_398c8c0b88421980d840db157c14ec20"
);
feiShuChatDTO
.
setIdList
(
new
String
[]{
openId
});
return
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
}
}
src/main/java/com/pipihelper/project/feishu/service/EmployeeService.java
View file @
6ace790
package
com
.
pipihelper
.
project
.
feishu
.
service
;
import
com.pipihelper.project.feishu.dao.EmployeeDao
;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.employee.SystemFieldsDTO
;
import
com.pipihelper.project.feishu.entity.Employee
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Service
public
class
EmployeeService
{
...
...
@@ -13,6 +18,9 @@ public class EmployeeService {
@Autowired
private
EmployeeDao
employeeDao
;
@Autowired
private
FeiShuApiService
feiShuApiService
;
public
Employee
findById
(
Integer
id
)
{
return
employeeDao
.
findById
(
id
);
}
...
...
@@ -36,4 +44,39 @@ public class EmployeeService {
public
List
<
Employee
>
findAll
()
{
return
employeeDao
.
findAll
();
}
/**
* 同步所有花名册
*/
public
void
uprsetAllEmployee
()
{
List
<
FeiShuEmployeeDTO
>
dtos
=
feiShuApiService
.
getEmployeeList
();
List
<
Employee
>
employeeList
=
this
.
findAll
();
Map
<
String
,
Employee
>
employeeMap
=
employeeList
.
stream
().
collect
(
Collectors
.
toMap
(
Employee:
:
getOpenId
,
Function
.
identity
()));
List
<
String
>
openIdList
=
dtos
.
stream
().
map
(
FeiShuEmployeeDTO:
:
getUserId
).
collect
(
Collectors
.
toList
());
employeeList
.
forEach
(
it
->
{
if
(!
openIdList
.
contains
(
it
.
getOpenId
()))
{
this
.
deleteById
(
it
.
getId
());
}
});
dtos
.
forEach
(
it
->
{
Employee
currentEmployee
=
employeeMap
.
get
(
it
.
getUserId
());
if
(
currentEmployee
!=
null
)
{
return
;
}
Employee
employee
=
new
Employee
();
SystemFieldsDTO
systemFieldsDTO
=
it
.
getSystemFields
();
employee
.
setOpenId
(
it
.
getUserId
());
if
(
systemFieldsDTO
!=
null
)
{
employee
.
setGender
(
systemFieldsDTO
.
getGender
());
employee
.
setStatus
(
systemFieldsDTO
.
getStatus
());
employee
.
setDepartmentId
(
systemFieldsDTO
.
getDepartmentId
());
employee
.
setName
(
systemFieldsDTO
.
getName
());
employee
.
setMobile
(
systemFieldsDTO
.
getMobile
());
}
this
.
create
(
employee
);
});
}
}
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
6ace790
...
...
@@ -375,7 +375,7 @@ public class FeiShuApiService {
* @return
*/
public
String
createChatList
(
FeiShuChatDTO
feiShuChatDTO
)
{
String
api
=
"/im/v1/chats"
;
String
api
=
"/im/v1/chats
?user_id_type=open_id
"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"Bearer "
+
getTenantToken
());
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment