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 a60855ce
authored
Oct 15, 2022
by
zhaolianjie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
卡片流程 - 查询用户
1 parent
14f3567f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 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/feishu/controller/FeiShuEventController.java
View file @
a60855c
...
...
@@ -107,14 +107,21 @@ public class FeiShuEventController {
return
getInteractiveCardStr
(
fileName1
,
"遗憾放弃"
);
}
else
if
(
"wait"
.
equals
(
actionTypeSecond
))
{
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String
waitUserId
=
feiShuMsgCardEventDTO
.
getOpen_id
();
JSONObject
waitObj
=
feiShuApiService
.
getUserInfo
(
waitUserId
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String
oldUserId
=
feiShuMsgCardEventDTO
.
getAction
().
getValue
().
getKey
().
split
(
"\\."
)[
2
];
String
robUserId
=
feiShuMsgCardEventDTO
.
getOpen_id
();
JSONObject
oldObj
=
feiShuApiService
.
getUserInfo
(
oldUserId
);
JSONObject
robObj
=
feiShuApiService
.
getUserInfo
(
robUserId
);
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json.json.json"
);
return
getInteractiveCardStr
(
fileName1
,
""
);
return
getInteractiveCardStr
(
fileName1
,
"
已经被抢啦啦啦~
"
);
}
default
:
}
...
...
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
a60855c
...
...
@@ -282,6 +282,23 @@ public class FeiShuApiService {
}
}
public
JSONObject
getUserInfo
(
String
openId
)
{
String
api
=
"/contact/v3/users/:{userId}?department_id_type=open_department_id&user_id_type=open_id"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"Bearer "
+
getTenantToken
());
headers
.
set
(
"Content-Type"
,
"application/json; charset=utf-8"
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
headers
);
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
try
{
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
JSONObject
.
class
,
openId
);
JSONObject
user
=
responseEntity
.
getBody
().
getJSONObject
(
"user"
);
return
user
;
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
//下载文件
public
byte
[]
downloadFile
(
String
filePath
)
{
String
api
=
"/im/v1/files/{filePath}"
;
...
...
@@ -322,7 +339,7 @@ public class FeiShuApiService {
//上传图片
public
String
uploadImage
(
String
image_type
,
byte
[]
file
)
{
public
String
uploadImage
(
String
image_type
,
byte
[]
file
)
{
String
api
=
"/im/v1/images"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
@@ -417,6 +434,7 @@ public class FeiShuApiService {
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
public
String
joinChatList
(
FeiShuChatDTO
feiShuChatDTO
)
{
String
api
=
"/im/v1/chats/{chat_id}/members"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
...
...
@@ -426,7 +444,7 @@ public class FeiShuApiService {
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
try
{
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
objectMapper
.
writeValueAsString
(
feiShuChatDTO
),
headers
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
,
feiShuChatDTO
.
getChatId
());
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
,
feiShuChatDTO
.
getChatId
());
System
.
out
.
println
(
responseEntity
.
getBody
());
Type
type
=
new
TypeReference
<
FeiShuResultDTO
>()
{
}.
getType
();
...
...
@@ -436,6 +454,7 @@ public class FeiShuApiService {
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
/**
* 群发消息
* https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM
...
...
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