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 ef437550
authored
Oct 15, 2022
by
zhaolianjie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
创建群组
1 parent
4a7e39e2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
11 deletions
src/main/java/com/pipihelper/project/feishu/dto/FeiShuDataDTO.java
src/main/java/com/pipihelper/project/feishu/dto/chat/FeiShuChatDTO.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/feishu/dto/FeiShuDataDTO.java
View file @
ef43755
...
...
@@ -18,4 +18,7 @@ public class FeiShuDataDTO<T> {
private
Boolean
hasMore
;
@JsonProperty
(
"department"
)
private
FeiShuDepartmentDTO
department
;
@JsonProperty
(
"chat_id"
)
private
String
chatId
;
}
src/main/java/com/pipihelper/project/feishu/dto/chat/FeiShuChatDTO.java
View file @
ef43755
...
...
@@ -23,4 +23,11 @@ public class FeiShuChatDTO {
private
Boolean
external
;
@JsonProperty
(
"tenant_key"
)
private
String
tenantKey
;
@JsonProperty
(
"user_id_type"
)
private
String
userIdType
;
@JsonProperty
(
"user_id_list"
)
private
String
[]
userIdList
;
}
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
ef43755
...
...
@@ -17,9 +17,12 @@ import com.pipihelper.project.feishu.dto.doc.FieldsDTO;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuBatchMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
//import org.springframework.http.MediaType;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.*
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
...
...
@@ -84,7 +87,7 @@ public class FeiShuApiService {
* @param sendMsg
* @return
*/
public
JSONObject
sendMsg
(
String
receive_id_type
,
JSONObject
sendMsg
)
{
public
JSONObject
sendMsg
(
String
receive_id_type
,
JSONObject
sendMsg
)
{
System
.
out
.
println
(
sendMsg
.
toString
());
//发送消息
...
...
@@ -109,7 +112,6 @@ public class FeiShuApiService {
}
@Async
public
JSONObject
replyMsg
(
String
message_id
,
JSONObject
replyMsg
)
{
System
.
out
.
println
(
replyMsg
.
toString
());
...
...
@@ -375,21 +377,21 @@ public class FeiShuApiService {
*
* @return
*/
public
List
<
FeiShuChatDTO
>
getChatList
(
)
{
public
String
createChatList
(
FeiShuChatDTO
feiShuChatDTO
)
{
String
api
=
"/im/v1/chats"
;
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
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
Type
type
=
new
TypeReference
<
FeiShuResultDTO
<
FeiShuChatDTO
>>()
{
}.
getType
();
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
objectMapper
.
writeValueAsString
(
feiShuChatDTO
),
headers
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
System
.
out
.
println
(
responseEntity
.
getBody
());
Type
type
=
new
TypeReference
<
FeiShuResultDTO
>()
{
}.
getType
();
FeiShuResultDTO
feiShuResultDTO
=
JSONObject
.
parseObject
(
responseEntity
.
getBody
(),
type
);
return
feiShuResultDTO
.
getData
().
get
Items
();
return
feiShuResultDTO
.
getData
().
get
ChatId
();
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
...
...
@@ -471,7 +473,6 @@ public class FeiShuApiService {
*
* @param appToken
* @param tableId
* @return
*/
public
List
getTableRecords
(
String
appToken
,
String
tableId
)
{
...
...
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