Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正 取得路由时,返回数据格式为JSON类型时,输出格式不正确的问题 #2250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import javax.servlet.ServletException;

import com.alibaba.fastjson.JSON;
import org.unidal.lookup.annotation.Inject;
import org.unidal.web.mvc.PageHandler;
import org.unidal.web.mvc.annotation.InboundActionMeta;
Expand Down Expand Up @@ -141,9 +142,9 @@ public void handleOutbound(Context ctx) throws ServletException, IOException {
model.setContent(routerInfo);
break;
case JSON:
Map<String, String> kvs = buildKvs(report, domain, ip);
Map<String, Map<String, String>> kvs = buildKvs(report, domain, ip);

model.setContent(kvs.toString());
model.setContent(JSON.toJSONString(kvs));
break;
case BUILD:
Date period = TimeHelper.getCurrentDay(-1);
Expand All @@ -160,15 +161,17 @@ public void handleOutbound(Context ctx) throws ServletException, IOException {
ctx.getHttpServletResponse().getWriter().write(model.getContent());
}

private Map<String, String> buildKvs(RouterConfig report, String domain, String ip) {
Map<String, String> kvs = new HashMap<String, String>();
private Map<String, Map<String, String>> buildKvs(RouterConfig report, String domain, String ip) {
Map<String, String> map = new HashMap<>();

kvs.put("block", String.valueOf(m_configManager.shouldBlock(ip)));
kvs.put("routers", buildRouterInfo(ip, domain, report));
kvs.put("sample", String.valueOf(buildSampleInfo(domain)));
kvs.put("startTransactionTypes", m_filterManager.getAtomicStartTypes());
kvs.put("matchTransactionTypes", m_filterManager.getAtomicMatchTypes());
map.put("block", String.valueOf(m_configManager.shouldBlock(ip)));
map.put("routers", buildRouterInfo(ip, domain, report));
map.put("sample", String.valueOf(buildSampleInfo(domain)));
map.put("startTransactionTypes", m_filterManager.getAtomicStartTypes());
map.put("matchTransactionTypes", m_filterManager.getAtomicMatchTypes());

return kvs;
Map<String, Map<String, String>> kvConfig = new HashMap<>();
kvConfig.put("kvs",map);
return kvConfig;
}
}