作者 钟来

添加飞书参数条件查询

package com.ruoyi.common.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.ruoyi.common.utils.html.HttpUtils;
... ... @@ -86,14 +87,23 @@ public class FeishuUtil {
}
}
public static String getFeishuTable( String tenant_access_token,String app_token, String table_id)
public static String getFeishuTable( String tenant_access_token,String app_token, String table_id,Map<String,Object> body)
{
String url = "https://open.feishu.cn/open-apis/bitable/v1/apps/"+app_token+"/tables/"+table_id+"/records/search";
try {
Response response = HttpUtils.postJsonBody(url, builder -> {
builder.addHeader("Content-Type", "application/json");
builder.addHeader("Authorization", "Bearer "+tenant_access_token);
}, null);
builder.addHeader("Authorization", "Bearer " + tenant_access_token);
}, jsonObject -> {
if(null != body && body.size() > 0)
{
for(String key : body.keySet())
{
jsonObject.put(key,body.get(key));
}
}
});
String str = response.body().string();
return str;
} catch (IOException e) {
... ...
package com.zhonglai.luhui.api.controller.test;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.ruoyi.common.core.domain.AjaxResult;
... ... @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "测试")
... ... @@ -76,8 +78,8 @@ public class TestController {
@ApiOperation("获取飞书多维表格数据")
@RequestMapping(value = "getFeishuTable/{app_token}/{table_id}")
public String getFeishuTable(@PathVariable String app_token, @PathVariable String table_id) throws IOException {
String str = FeishuUtil.getFeishuTable(FeishuUtil.gettenant_access_token("cli_a88a14d3b279d01c","Z3hpYKHeR1yR2aiv6Rp0mcnwKvehkzmT"),app_token,table_id);
public String getFeishuTable(@PathVariable String app_token, @PathVariable String table_id,@RequestBody HashMap<String,Object> map) throws IOException {
String str = FeishuUtil.getFeishuTable(FeishuUtil.gettenant_access_token("cli_a88a14d3b279d01c","Z3hpYKHeR1yR2aiv6Rp0mcnwKvehkzmT"),app_token,table_id,map);
if(null != str)
{
return str;
... ... @@ -89,10 +91,15 @@ public class TestController {
}
public static void main(String[] args) {
String jsr= "{\"store_id\":0,\"create_time\":\"1746668144\",\"gender\":\"未知\",\"action_type\":3,\"telephone\":\"18061271693\",\"promotion_id\":0,\"clue_source\":5,\"store_pack_id\":0,\"refer_dy_id\":\"2046931013\",\"app_name\":\"暂未获取到\",\"ad_id\":\"0\",\"module_id\":\"1805421364269097\",\"flow_type\":1,\"name\":\"未命名\",\"site_id\":\"0\",\"remark_dict\":{},\"adv_id\":\"0\",\"clue_type\":2,\"location\":\"山东+泰安\",\"id\":\"7501883876034215974\",\"module_name\":\"官方电话\",\"clue_convert_status\":\"外部流量\",\"refer_dy_name\":\"鱼儿乐>智慧渔业系统\"}";
ClueData clueData = GsonConstructor.get().fromJson(jsr, ClueData.class);
System.out.println(clueData);
subData(clueData);
JSONArray sort = new JSONArray();
JSONObject field_name = new JSONObject();
field_name.put("field_name","记录时间");
sort.add(field_name);
Map<String,Object> body = new HashMap<>();
body.put("sort",sort);
String str = FeishuUtil.getFeishuTable(FeishuUtil.gettenant_access_token("cli_a88a14d3b279d01c","Z3hpYKHeR1yR2aiv6Rp0mcnwKvehkzmT"),"OcUYbxkuCakxYlsbrEUcXyqKnbf","tblo4dUsFjWXAt8U",body);
System.out.println(str);
}
private static void subData(ClueData clueData)
... ...