mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 08:48:30 +08:00
add:exportApis()
This commit is contained in:
parent
1b1cbef791
commit
29b895b087
@ -13,6 +13,7 @@ import org.springframework.util.StringUtils;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -72,6 +73,32 @@ public class KoTimeController {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/exportApis")
|
||||||
|
@ResponseBody
|
||||||
|
@Auth
|
||||||
|
public void exportApis(String question, String orderBy, String sort, HttpServletResponse response) {
|
||||||
|
List<MethodInfo> apis = getApis(question, orderBy, sort);
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
response.addHeader("Content-Disposition", "attachment; filename=interfaces.csv");
|
||||||
|
|
||||||
|
try( OutputStream out = response.getOutputStream();
|
||||||
|
BufferedOutputStream bufferedOut = new BufferedOutputStream(out)){
|
||||||
|
String line = "序号,类名,方法名,路由,平均响应(ms),调用次数\n";
|
||||||
|
if ("english".equals(Context.getConfig().getLanguage())) {
|
||||||
|
line = "No,ClassName,Method,Route,Avg(ms),CallNum\n";
|
||||||
|
}
|
||||||
|
bufferedOut.write(line.getBytes("utf-8"));
|
||||||
|
for (int i = 0; i < apis.size(); i++) {
|
||||||
|
MethodInfo methodInfo = apis.get(i);
|
||||||
|
line = (i+1)+","+methodInfo.getClassName()+","+methodInfo.getMethodName()+"(),"+methodInfo.getRouteName()+","+methodInfo.getAvgRunTime()+","+methodInfo.getCallNum()+"\n";
|
||||||
|
bufferedOut.write(line.getBytes("utf-8"));
|
||||||
|
}
|
||||||
|
bufferedOut.flush();
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/getParamGraph")
|
@GetMapping("/getParamGraph")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Auth
|
@Auth
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
ko-time.version=2.4.6
|
ko-time.version=2.4.8
|
||||||
@ -42,6 +42,8 @@ tab.summary.sysusage-metric.physical-memory.current-used=此程序占用
|
|||||||
|
|
||||||
tab.interface.search-tip=搜索方法名或者类名...
|
tab.interface.search-tip=搜索方法名或者类名...
|
||||||
tab.interface.interface-list.avg-tip=平均响应
|
tab.interface.interface-list.avg-tip=平均响应
|
||||||
|
tab.interface.interface-list.sort-desc-tip=降序
|
||||||
|
tab.interface.interface-list.sort-asc-tip=升序
|
||||||
tab.interface.interface-list.call-num-tip=调用次数
|
tab.interface.interface-list.call-num-tip=调用次数
|
||||||
tab.interface.interface-list.show-metric.type=类型
|
tab.interface.interface-list.show-metric.type=类型
|
||||||
tab.interface.interface-list.show-metric.avg=平均耗时
|
tab.interface.interface-list.show-metric.avg=平均耗时
|
||||||
|
|||||||
@ -42,6 +42,8 @@ tab.summary.sysusage-metric.physical-memory.current-used=ThisUsed
|
|||||||
|
|
||||||
tab.interface.search-tip=search method name or class name...
|
tab.interface.search-tip=search method name or class name...
|
||||||
tab.interface.interface-list.avg-tip=avg
|
tab.interface.interface-list.avg-tip=avg
|
||||||
|
tab.interface.interface-list.sort-desc-tip=desc
|
||||||
|
tab.interface.interface-list.sort-asc-tip=asc
|
||||||
tab.interface.interface-list.call-num-tip=callNum
|
tab.interface.interface-list.call-num-tip=callNum
|
||||||
tab.interface.interface-list.show-metric.type=type
|
tab.interface.interface-list.show-metric.type=type
|
||||||
tab.interface.interface-list.show-metric.avg=avg time
|
tab.interface.interface-list.show-metric.avg=avg time
|
||||||
|
|||||||
@ -92,11 +92,11 @@
|
|||||||
className = data[i]['name'].split('.')[0];
|
className = data[i]['name'].split('.')[0];
|
||||||
}
|
}
|
||||||
if (methodType == 'Controller' && routeName != null && routeName != '') {
|
if (methodType == 'Controller' && routeName != null && routeName != '') {
|
||||||
html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span> (<span class='common-li-special'>" + routeName + "</span>)   <span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
|
html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span><span style='color: #9c40ad;font-size: 14px;font-weight: bold'>()</span> <<span class='common-li-special'>" + routeName + "</span>> <span style='font-size: 10px;text-transform: lowercase' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
|
||||||
"   <span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
|
"   <span style='font-size: 10px;text-transform: unset;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
|
||||||
} else {
|
} else {
|
||||||
html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span>   <span style='font-size: 10px;text-transform: unset' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
|
html += "<li onclick=\"showMethods('" + apiId + "')\" class='common-li' id=\"" + apiId + "-list\">" + className + "#<span class='common-li-bolder'>" + methodName + "</span><span style='color: #9c40ad;font-size: 14px;font-weight: bold'>()</span> <span style='font-size: 10px;text-transform: unset' class=\"uk-label uk-label-" + color + "\">{{tab.interface.interface-list.avg-tip}} " + avgRunTime + " ms</span>" +
|
||||||
"   <span style='font-size: 10px;text-transform: lowercase;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
|
" <span style='font-size: 10px;text-transform: lowercase;background-color:#6d6d85' class=\"uk-label\">{{tab.interface.interface-list.call-num-tip}} " + callNum + "</span></li>";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
element.innerHTML = html;
|
element.innerHTML = html;
|
||||||
@ -633,6 +633,19 @@
|
|||||||
loadApis();
|
loadApis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exportApis() {
|
||||||
|
let searchDom = getDom("searchText");
|
||||||
|
let searchText = searchDom.value;
|
||||||
|
let apiSortName = getDom('apiSortName')
|
||||||
|
let apiSortType = getDom('apiSortType')
|
||||||
|
let url = concatToken(`contextPath/koTime/exportApis?question=${searchText}&orderBy=${apiSortName.value}&sort=${apiSortType.value}`);
|
||||||
|
let a = document.createElement("a");
|
||||||
|
a.style.display='none';
|
||||||
|
a.href = url;
|
||||||
|
a.click();
|
||||||
|
setTimeout(()=>{a.remove();},3000);
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
refreshData();
|
refreshData();
|
||||||
});
|
});
|
||||||
@ -805,18 +818,19 @@
|
|||||||
<div class="uk-width-1-5@s">
|
<div class="uk-width-1-5@s">
|
||||||
<div style="display: flex;">
|
<div style="display: flex;">
|
||||||
<input style="width: 60px;border-top: none;border-right: none;border-left: none;background-color: inherit" class="uk-input" type="text" placeholder="根据" value="根据" disabled>
|
<input style="width: 60px;border-top: none;border-right: none;border-left: none;background-color: inherit" class="uk-input" type="text" placeholder="根据" value="根据" disabled>
|
||||||
<select id="apiSortName" onchange="changeApiSort()" style="width: 100px;border-top: none;border-right: none;border-left: none;border-bottom: 1px solid lightgreen;color:#213121;background-color: inherit" class="uk-select">
|
<select id="apiSortName" onchange="changeApiSort()" style="cursor: pointer;width: 100px;border-top: none;border-right: none;border-left: none;border-bottom: 1px solid lightgreen;color:#213121;background-color: inherit" class="uk-select">
|
||||||
<option value="avgRunTime" selected>平均响应</option>
|
<option value="avgRunTime" selected>{{tab.interface.interface-list.avg-tip}}</option>
|
||||||
<option value="callNum">调用次数</option>
|
<option value="callNum">{{tab.interface.interface-list.call-num-tip}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-5@s">
|
<div class="uk-width-1-5@s">
|
||||||
<div style="width: 70px">
|
<div style="display: flex;width: 100px">
|
||||||
<select id="apiSortType" onchange="changeApiSort()" style="border-top: none;border-right: none;border-left: none;border-bottom: 1px solid lightgreen;color:#213121;background-color: inherit" class="uk-select">
|
<select id="apiSortType" onchange="changeApiSort()" style="cursor: pointer;width: 70px;border-top: none;border-right: none;border-left: none;border-bottom: 1px solid lightgreen;color:#213121;background-color: inherit" class="uk-select">
|
||||||
<option value="desc" selected>降序</option>
|
<option value="desc" selected>{{tab.interface.interface-list.sort-desc-tip}}</option>
|
||||||
<option value="asc">升序</option>
|
<option value="asc">{{tab.interface.interface-list.sort-asc-tip}}</option>
|
||||||
</select>
|
</select>
|
||||||
|
<button onclick="exportApis()" style="width: 100px;border: none;color: #0000FF;font-weight: bolder" title="导出csv" class="uk-button uk-button-default">=></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user