设置角色权限

image.png
image.png

效果

  1. public static void main(String[] args) {
  2. OkHttpClient client = new OkHttpClient().newBuilder()
  3. .build();
  4. MediaType mediaType = MediaType.parse("text/plain");
  5. MultipartBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  6. .addFormDataPart("form_data","{\"datasource\":{\"id\":2,\"type\":\"table\"},\"force\":false,\"queries\":[{\"time_range\":\"No+filter\",\"filters\":[{\"col\":\"sex\",\"op\":\"IS NOT NULL\"}],\"extras\":{\"time_range_endpoints\":[\"inclusive\",\"exclusive\"],\"having\":\"\",\"having_druid\":[],\"where\":\"\"},\"applied_time_extras\":{},\"columns\":[\"sexName\"],\"metrics\":[\"count\"],\"annotation_layers\":[],\"row_limit\":100,\"timeseries_limit\":0,\"order_desc\":true,\"url_params\":{},\"custom_params\":{},\"custom_form_data\":{}}],\"result_format\":\"json\",\"result_type\":\"results\"}")
  7. .build();
  8. Request request = new Request.Builder()
  9. .url("http://localhost:8088/api/v1/chart/data")
  10. .method("POST", body)
  11. .build();
  12. Response response = client.newCall(request).execute();
  13. Gson gson = new Gson();
  14. Map map = gson.fromJson(response.body().string(), Map.class);
  15. System.out.println(map.get("result"));
  16. }

image.png