Browse Source

REPORT-8349 返回数据字段名兼容

master
kerry 7 years ago
parent
commit
3c902805c1
  1. 44
      designer-base/src/com/fr/design/extra/PluginUtils.java
  2. 3
      designer-base/src/com/fr/design/extra/PluginWebBridge.java
  3. 2
      designer-base/src/com/fr/design/extra/exe/GetInstalledPluginsExecutor.java
  4. 2
      designer-base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java

44
designer-base/src/com/fr/design/extra/PluginUtils.java

@ -1,5 +1,6 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.base.TemplateUtils; import com.fr.base.TemplateUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
@ -201,7 +202,7 @@ public class PluginUtils {
resultJSONArray.put(jo); resultJSONArray.put(jo);
} }
} }
return resultJSONArray; return PluginUtils.transferLocalPluginToJson(resultJSONArray);
} }
private static boolean isCompatibleCurrentEnv(String envVersion){ private static boolean isCompatibleCurrentEnv(String envVersion){
@ -209,7 +210,7 @@ public class PluginUtils {
} }
public static JSONArray transferPluginToJson(PluginContext [] pluginContexts){ public static JSONArray transferStorePluginToJson(PluginContext [] pluginContexts){
JSONArray ja = JSONArray.create(); JSONArray ja = JSONArray.create();
try { try {
for(PluginContext pluginContext : pluginContexts){ for(PluginContext pluginContext : pluginContexts){
@ -223,19 +224,44 @@ public class PluginUtils {
jo.put("vendor", pluginContext.getVendor()); jo.put("vendor", pluginContext.getVendor());
jo.put("price", pluginContext.getPrice()); jo.put("price", pluginContext.getPrice());
jo.put("jarTime", pluginContext.getRequiredJarTime()); jo.put("jarTime", pluginContext.getRequiredJarTime());
jo.put("isActive", pluginContext.isActive()); jo.put("active", pluginContext.isActive());
jo.put("isHidden", pluginContext.isHidden()); jo.put("hidden", pluginContext.isHidden());
jo.put("isFree", pluginContext.isFree()); jo.put("free", pluginContext.isFree());
jo.put("isLicDamage", pluginContext.isLicDamaged()); jo.put("licDamage", pluginContext.isLicDamaged());
jo.put("isAvailable", pluginContext.isAvailable()); jo.put("available", pluginContext.isAvailable());
jo.put("leftTime", String.valueOf(pluginContext.getLeftDays())); jo.put("leftTime", String.valueOf(pluginContext.getLeftDays()));
jo.put("isTrial", pluginContext.isOnTrial()); jo.put("trial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext)); jo.put("deadline", getDeadline(pluginContext));
jo.put("isRegisterFailed", pluginContext.isRegisterFailed()); jo.put("registerFailed", pluginContext.isRegisterFailed());
ja.put(jo); ja.put(jo);
} }
}catch (Exception e){ }catch (Exception e){
FRContext.getLogger().error(e.getMessage(), e);
}
return ja;
}
public static JSONArray transferLocalPluginToJson(JSONArray resultArr) throws Exception{
JSONArray ja = JSONArray.create();
for(int i = 0; i < resultArr.length(); i++){
JSONObject jo = JSONObject.create();
JSONObject pluginJsonObject = resultArr.getJSONObject(i);
jo.put("categoryId", pluginJsonObject.getString("cid"));
jo.put("description", pluginJsonObject.optString("description"));
jo.put("downloadTimes", Integer.parseInt(pluginJsonObject.getString("downloadTimes")));
jo.put("envVersion", pluginJsonObject.getString("envversion"));
jo.put("id", Integer.parseInt(pluginJsonObject.getString("id")));
jo.put("jarTime", pluginJsonObject.getString("jartime"));
jo.put("link", pluginJsonObject.getString("link"));
jo.put("name", pluginJsonObject.getString("name"));
jo.put("pic", pluginJsonObject.getString("pic"));
jo.put("pluginId", pluginJsonObject.getString("pluginid"));
jo.put("price", Integer.parseInt(pluginJsonObject.getString("price")));
jo.put("sellerId", Integer.parseInt(pluginJsonObject.getString("sellerId")));
jo.put("uploadTime", pluginJsonObject.getString("uploadTime"));
jo.put("vendor", pluginJsonObject.getString("vendor"));
jo.put("version", pluginJsonObject.getString("version"));
ja.put(jo);
} }
return ja; return ja;
} }

3
designer-base/src/com/fr/design/extra/PluginWebBridge.java

@ -56,6 +56,7 @@ public class PluginWebBridge {
private static final String PLUGIN_INFO = "pluginInfo"; private static final String PLUGIN_INFO = "pluginInfo";
private static final int COREPOOLSIZE = 3; private static final int COREPOOLSIZE = 3;
private static final int MAXPOOLSIZE = 5; private static final int MAXPOOLSIZE = 5;
private static final String I18N_PREFIX = "FR-";
private static PluginWebBridge helper; private static PluginWebBridge helper;
@ -572,7 +573,7 @@ public class PluginWebBridge {
* 国际化 * 国际化
*/ */
public String parseI18(final String key) { public String parseI18(final String key) {
return Inter.getLocText(key); return Inter.getLocText(I18N_PREFIX + key);
} }
/** /**

2
designer-base/src/com/fr/design/extra/exe/GetInstalledPluginsExecutor.java

@ -31,7 +31,7 @@ public class GetInstalledPluginsExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
List<PluginContext> plugins = PluginManager.getContexts(); List<PluginContext> plugins = PluginManager.getContexts();
JSONArray ja = PluginUtils.transferPluginToJson(plugins.toArray(new PluginContext[plugins.size()])); JSONArray ja = PluginUtils.transferStorePluginToJson(plugins.toArray(new PluginContext[plugins.size()]));
result = ja.toString(); result = ja.toString();
} }
} }

2
designer-base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java

@ -37,7 +37,7 @@ public class ReadUpdateOnlineExecutor implements Executor {
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
for (PluginView plugin : plugins) { for (PluginView plugin : plugins) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("pluginid", plugin.getID()); jsonObject.put("pluginId", plugin.getID());
jsonArray.put(jsonObject); jsonArray.put(jsonObject);
} }
result = jsonArray.toString(); result = jsonArray.toString();

Loading…
Cancel
Save