Browse Source

Merge pull request #75 in DESIGN/design from ~KERRY/design_10.0:feature/10.0 to feature/10.0

* commit 'c6f0bd7dc1cef40a52dc8fc0f4df51b7e26d8856':
  REPORT-8349 返回数据字段名兼容
master
superman 7 years ago
parent
commit
4d9e93dcaa
  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;
import com.fr.base.FRContext;
import com.fr.base.TemplateUtils;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
@ -201,7 +202,7 @@ public class PluginUtils {
resultJSONArray.put(jo);
}
}
return resultJSONArray;
return PluginUtils.transferLocalPluginToJson(resultJSONArray);
}
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();
try {
for(PluginContext pluginContext : pluginContexts){
@ -223,19 +224,44 @@ public class PluginUtils {
jo.put("vendor", pluginContext.getVendor());
jo.put("price", pluginContext.getPrice());
jo.put("jarTime", pluginContext.getRequiredJarTime());
jo.put("isActive", pluginContext.isActive());
jo.put("isHidden", pluginContext.isHidden());
jo.put("isFree", pluginContext.isFree());
jo.put("isLicDamage", pluginContext.isLicDamaged());
jo.put("isAvailable", pluginContext.isAvailable());
jo.put("active", pluginContext.isActive());
jo.put("hidden", pluginContext.isHidden());
jo.put("free", pluginContext.isFree());
jo.put("licDamage", pluginContext.isLicDamaged());
jo.put("available", pluginContext.isAvailable());
jo.put("leftTime", String.valueOf(pluginContext.getLeftDays()));
jo.put("isTrial", pluginContext.isOnTrial());
jo.put("trial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext));
jo.put("isRegisterFailed", pluginContext.isRegisterFailed());
jo.put("registerFailed", pluginContext.isRegisterFailed());
ja.put(jo);
}
}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;
}

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 int COREPOOLSIZE = 3;
private static final int MAXPOOLSIZE = 5;
private static final String I18N_PREFIX = "FR-";
private static PluginWebBridge helper;
@ -572,7 +573,7 @@ public class PluginWebBridge {
* 国际化
*/
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
public void run(Process<String> process) {
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();
}
}

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

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

Loading…
Cancel
Save