Commit ef437550 by zhaolianjie

创建群组

1 parent 4a7e39e2
......@@ -18,4 +18,7 @@ public class FeiShuDataDTO<T> {
private Boolean hasMore;
@JsonProperty("department")
private FeiShuDepartmentDTO department;
@JsonProperty("chat_id")
private String chatId;
}
......@@ -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;
}
......@@ -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().getItems();
return feiShuResultDTO.getData().getChatId();
} 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) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!