package com.engine.organization.entity; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.api.browser.bean.SearchConditionOption; import java.util.ArrayList; import java.util.List; /** * @author:dxfeng * @createTime: 2022/06/13 * @version: 1.0 */ public class SelectOptionParam { /** * 下拉框Json转换 * * @param customValue * @return */ public static List convertJsonToListOption(String customValue) { List selectOptions = new ArrayList<>(); JSONArray objects = JSONObject.parseArray(customValue); if (objects.size() < 3) { return selectOptions; } JSONObject o = (JSONObject) objects.get(2); JSONArray datas = o.getJSONArray("datas"); if (!datas.isEmpty()) { int size = datas.size(); for (int i = 0; i < size; i++) { JSONObject jsonObject = (JSONObject) datas.get(i); SearchConditionOption option = new SearchConditionOption(jsonObject.getString("key"), jsonObject.getString("option")); selectOptions.add(option); } } return selectOptions; } /** * 获取自定义浏览按钮标识 * * @param customValue * @return */ public static String getCustomBrowserId(String customValue) { try { JSONArray objects = JSONObject.parseArray(customValue); if (null != objects && objects.size() > 2) { JSONObject object = (JSONObject) objects.get(2); return object.getString("value"); } } catch (Exception e) { } return customValue; } /** * 获取自定义浏览按钮标识 * * @param customValue * @return */ public static String getCustomBrowserValueSpan(String customValue) { JSONArray objects = JSONObject.parseArray(customValue); if (null != objects && objects.size() > 2) { JSONObject object = (JSONObject) objects.get(2); return object.getString("valueSpan"); } return customValue; } /** * 获取文本长度 * * @param customValue * @return */ public static String getTextLength(String customValue) { JSONArray objects = JSONObject.parseArray(customValue); if (null != objects && objects.size() > 2) { return objects.get(2).toString(); } return customValue; } }