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 73d82a40
authored
Oct 15, 2022
by
liushuangwu
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
f3da8ef1
ef437550
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 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 @
73d82a4
...
@@ -18,4 +18,7 @@ public class FeiShuDataDTO<T> {
...
@@ -18,4 +18,7 @@ public class FeiShuDataDTO<T> {
private
Boolean
hasMore
;
private
Boolean
hasMore
;
@JsonProperty
(
"department"
)
@JsonProperty
(
"department"
)
private
FeiShuDepartmentDTO
department
;
private
FeiShuDepartmentDTO
department
;
@JsonProperty
(
"chat_id"
)
private
String
chatId
;
}
}
src/main/java/com/pipihelper/project/feishu/dto/chat/FeiShuChatDTO.java
View file @
73d82a4
...
@@ -23,4 +23,11 @@ public class FeiShuChatDTO {
...
@@ -23,4 +23,11 @@ public class FeiShuChatDTO {
private
Boolean
external
;
private
Boolean
external
;
@JsonProperty
(
"tenant_key"
)
@JsonProperty
(
"tenant_key"
)
private
String
tenantKey
;
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 @
73d82a4
...
@@ -17,7 +17,6 @@ import com.pipihelper.project.feishu.dto.doc.FieldsDTO;
...
@@ -17,7 +17,6 @@ import com.pipihelper.project.feishu.dto.doc.FieldsDTO;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuBatchMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuBatchMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
//import org.springframework.http.MediaType;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.MediaType
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
...
@@ -375,21 +374,21 @@ public class FeiShuApiService {
...
@@ -375,21 +374,21 @@ public class FeiShuApiService {
*
*
* @return
* @return
*/
*/
public
List
<
FeiShuChatDTO
>
getChatList
(
)
{
public
String
createChatList
(
FeiShuChatDTO
feiShuChatDTO
)
{
String
api
=
"/im/v1/chats"
;
String
api
=
"/im/v1/chats"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"Bearer "
+
getTenantToken
());
headers
.
set
(
"Authorization"
,
"Bearer "
+
getTenantToken
());
headers
.
set
(
"Content-Type"
,
"application/json; charset=utf-8"
);
headers
.
set
(
"Content-Type"
,
"application/json; charset=utf-8"
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
headers
);
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
try
{
try
{
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
GET
,
requestEntity
,
String
.
class
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
objectMapper
.
writeValueAsString
(
feiShuChatDTO
),
headers
);
Type
type
=
new
TypeReference
<
FeiShuResultDTO
<
FeiShuChatDTO
>>()
{
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
}.
getType
();
System
.
out
.
println
(
responseEntity
.
getBody
());
System
.
out
.
println
(
responseEntity
.
getBody
());
Type
type
=
new
TypeReference
<
FeiShuResultDTO
>()
{
}.
getType
();
FeiShuResultDTO
feiShuResultDTO
=
JSONObject
.
parseObject
(
responseEntity
.
getBody
(),
type
);
FeiShuResultDTO
feiShuResultDTO
=
JSONObject
.
parseObject
(
responseEntity
.
getBody
(),
type
);
return
feiShuResultDTO
.
getData
().
get
Items
();
return
feiShuResultDTO
.
getData
().
get
ChatId
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
...
...
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