Commit ef437550 by zhaolianjie

创建群组

1 parent 4a7e39e2
...@@ -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;
} }
...@@ -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;
} }
...@@ -17,9 +17,12 @@ import com.pipihelper.project.feishu.dto.doc.FieldsDTO; ...@@ -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.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.*; import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
...@@ -84,7 +87,7 @@ public class FeiShuApiService { ...@@ -84,7 +87,7 @@ public class FeiShuApiService {
* @param sendMsg * @param sendMsg
* @return * @return
*/ */
public JSONObject sendMsg( String receive_id_type, JSONObject sendMsg) { public JSONObject sendMsg(String receive_id_type, JSONObject sendMsg) {
System.out.println(sendMsg.toString()); System.out.println(sendMsg.toString());
//发送消息 //发送消息
...@@ -109,7 +112,6 @@ public class FeiShuApiService { ...@@ -109,7 +112,6 @@ public class FeiShuApiService {
} }
@Async @Async
public JSONObject replyMsg(String message_id, JSONObject replyMsg) { public JSONObject replyMsg(String message_id, JSONObject replyMsg) {
System.out.println(replyMsg.toString()); System.out.println(replyMsg.toString());
...@@ -375,21 +377,21 @@ public class FeiShuApiService { ...@@ -375,21 +377,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().getItems(); return feiShuResultDTO.getData().getChatId();
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e); throw new ServiceException("飞书:" + api + "接口调用失败" + "\n" + e);
} }
...@@ -471,7 +473,6 @@ public class FeiShuApiService { ...@@ -471,7 +473,6 @@ public class FeiShuApiService {
* *
* @param appToken * @param appToken
* @param tableId * @param tableId
* @return * @return
*/ */
public List getTableRecords(String appToken, String tableId) { 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!