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 496df8f8
authored
Oct 16, 2022
by
weiss
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
da42f986
110fa57d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
496df8f
...
...
@@ -177,11 +177,10 @@ public class FeiShuEventController {
public
synchronized
JSONObject
rob
(
FeiShuMsgCardEventDTO
feiShuMsgCardEventDTO
)
{
String
oldUserId
=
feiShuMsgCardEventDTO
.
getAction
().
getValue
().
getKey
().
split
(
"\\."
)[
2
];
String
robUserId
=
feiShuMsgCardEventDTO
.
getOpen_id
();
JSONObject
user
=
feiShuApiService
.
getUserInfo
(
robUserId
);
Employee
employee
=
employeeService
.
findByOpenId
(
robUserId
);
Pain
oldPain
=
painService
.
findByOpenId
(
oldUserId
);
oldPain
.
setOpenId
(
robUserId
);
oldPain
.
setName
(
user
.
getString
(
"name"
));
oldPain
.
setName
(
employee
.
getName
(
));
painService
.
update
(
oldPain
);
FeiShuChatDTO
feiShuChatDTO
=
new
FeiShuChatDTO
();
feiShuChatDTO
.
setChatId
((
String
)
CacheUtil
.
get
(
"chatId"
));
...
...
@@ -194,7 +193,7 @@ public class FeiShuEventController {
massageService
.
updateMassageMsgCardToPiPiChat
((
String
)
CacheUtil
.
get
(
"chatId"
));
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被"
+
user
.
getString
(
"name"
)
+
"抢啦,啦啦~"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被"
+
employee
.
getName
(
)
+
"抢啦,啦啦~"
);
}
/**
...
...
@@ -216,6 +215,13 @@ public class FeiShuEventController {
return
null
;
}
@PostMapping
(
"/delete-chat-list"
)
public
Object
deleteChat
()
{
String
chatId
=
(
String
)
CacheUtil
.
get
(
"chatId"
);
log
.
info
(
"删除群组id:{}"
,
chatId
);
feiShuApiService
.
deleteChatList
(
chatId
);
return
null
;
}
@PostMapping
(
"/employee-list"
)
public
Object
event
()
{
...
...
@@ -366,13 +372,13 @@ public class FeiShuEventController {
}
@PostMapping
(
"/send-msg"
)
public
Result
sendMsg
(
String
receiveId
,
String
msg
,
String
receiveIdType
){
public
Result
sendMsg
(
String
receiveId
,
String
msg
,
String
receiveIdType
)
{
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"text"
,
msg
);
feiShuMsgDTO
.
setMsgType
(
"text"
);
feiShuMsgDTO
.
setContent
(
content
.
toString
());
if
(
receiveId
.
equals
(
"-1"
))
{
if
(
receiveId
.
equals
(
"-1"
))
{
receiveId
=
(
String
)
CacheUtil
.
get
(
"chatId"
);
}
feiShuMsgDTO
.
setReceiveId
(
receiveId
);
...
...
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
496df8f
...
...
@@ -25,7 +25,6 @@ import okhttp3.Request;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
...
...
@@ -454,6 +453,26 @@ public class FeiShuApiService {
}
}
public
String
deleteChatList
(
String
chatId
)
{
String
api
=
"/im/v1/chats/:{chat_id}"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"Bearer "
+
getTenantToken
());
headers
.
set
(
"Content-Type"
,
"application/json; charset=utf-8"
);
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
try
{
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
headers
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
DELETE
,
requestEntity
,
String
.
class
,
chatId
);
System
.
out
.
println
(
responseEntity
.
getBody
());
Type
type
=
new
TypeReference
<
FeiShuResultDTO
>()
{
}.
getType
();
FeiShuResultDTO
feiShuResultDTO
=
JSONObject
.
parseObject
(
responseEntity
.
getBody
(),
type
);
return
feiShuResultDTO
.
getData
().
getChatId
();
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
/**
* 群发消息
* https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM
...
...
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
View file @
496df8f
...
...
@@ -156,7 +156,16 @@ public class MassageNoticeScheduleService {
}
}
}
/**
* 每周四18:00删除当天的群聊
*/
// @Async
// @Scheduled(cron = "0 0 18 * * ?")
public
void
deleteChatList
()
{
String
chatId
=
(
String
)
CacheUtil
.
get
(
"chatId"
);
feiShuApiService
.
deleteChatList
(
chatId
);
}
/**
* 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
...
...
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