update:some interfaces

This commit is contained in:
huoyo 2024-10-06 23:43:42 +08:00
parent 59dab8a26a
commit a9e0f8b6dc
4 changed files with 16 additions and 34 deletions

View File

@ -36,48 +36,34 @@ public class KoClassController {
@PutMapping("/{className}/replace") @PutMapping("/{className}/replace")
@ResponseBody @ResponseBody
@Auth @Auth
public Map updateClass(@RequestParam("classFile") MultipartFile classFile, @PathVariable("className") String className) { public KoResult updateClass(@RequestParam("classFile") MultipartFile classFile, @PathVariable("className") String className) {
Map map = new HashMap();
if (classFile == null || classFile.isEmpty()) { if (classFile == null || classFile.isEmpty()) {
map.put("state", 0); return KoResult.failed("文件不能为空");
map.put("message", "文件不能为空");
return map;
} }
if (!StringUtils.hasText(className)) { if (!StringUtils.hasText(className)) {
map.put("state", 0); return KoResult.failed("类名不能为空");
map.put("message", "类名不能为空");
return map;
} }
className = className.trim(); className = className.trim();
File file = null; File file = null;
try { try {
String originalFilename = classFile.getOriginalFilename(); String originalFilename = classFile.getOriginalFilename();
if (!originalFilename.endsWith(".class")) { if (!originalFilename.endsWith(".class")) {
map.put("state", 0); return KoResult.failed("仅支持.class文件");
map.put("message", "仅支持.class文件");
return map;
} }
String[] filename = originalFilename.split("\\."); String[] filename = originalFilename.split("\\.");
String substring = className.substring(className.lastIndexOf(".") + 1); String substring = className.substring(className.lastIndexOf(".") + 1);
if (!substring.equals(filename[0])) { if (!substring.equals(filename[0])) {
map.put("state", 0); return KoResult.failed("请确认类名是否正确");
map.put("message", "请确认类名是否正确");
return map;
} }
file = uploadFile(classFile.getBytes(), filename[0]); file = uploadFile(classFile.getBytes(), filename[0]);
} catch (IOException e) { } catch (IOException e) {
log.severe("Error class file!"); log.severe("Error class file!");
map.put("state", 0); return KoResult.failed("无法解析文件");
map.put("message", "无法解析文件");
return map;
} }
final ClassInfoService classService = SystemService.getInstance(ClassInfoService.class); final ClassInfoService classService = SystemService.getInstance(ClassInfoService.class);
classService.updateClass(className, file.getAbsolutePath()); classService.updateClass(className, file.getAbsolutePath());
file.deleteOnExit(); file.deleteOnExit();
return KoResult.success("更新成功");
map.put("state", 1);
map.put("message", "更新成功");
return map;
} }

View File

@ -24,9 +24,9 @@ public class KoDynamicPropertyController {
@PutMapping @PutMapping
@ResponseBody @ResponseBody
@Auth @Auth
public boolean updateDynamicProperties(@RequestBody TextParam textParam) { public KoResult updateDynamicProperties(@RequestBody TextParam textParam) {
if (!StringUtils.hasText(textParam.getText())) { if (!StringUtils.hasText(textParam.getText())) {
return false; return KoResult.failed("更新失败");
} }
String[] textSplit = textParam.getText().trim().split("\n"); String[] textSplit = textParam.getText().trim().split("\n");
Properties dynamicProperties = Context.getDynamicProperties(); Properties dynamicProperties = Context.getDynamicProperties();
@ -45,16 +45,13 @@ public class KoDynamicPropertyController {
dynamicProperties.setProperty(propertyStr,valueStr); dynamicProperties.setProperty(propertyStr,valueStr);
} }
return true; return KoResult.success();
} }
@GetMapping @GetMapping
@ResponseBody @ResponseBody
@Auth @Auth
public Map getDynamicProperties() { public KoResult getDynamicProperties() {
Map map = new HashMap();
map.put("state", 0);
map.put("message", "文件不能为空");
Properties dynamicProperties = Context.getDynamicProperties(); Properties dynamicProperties = Context.getDynamicProperties();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for (String key : dynamicProperties.stringPropertyNames()) { for (String key : dynamicProperties.stringPropertyNames()) {
@ -63,7 +60,6 @@ public class KoDynamicPropertyController {
stringBuilder.append(key+"="+value+"\n"); stringBuilder.append(key+"="+value+"\n");
} }
} }
map.put("data", stringBuilder.toString()); return KoResult.success(stringBuilder.toString());
return map;
} }
} }

View File

@ -35,10 +35,10 @@ public class KoExceptionController {
@GetMapping("/{exceptionId}/details") @GetMapping("/{exceptionId}/details")
@ResponseBody @ResponseBody
@Auth @Auth
public List<ExceptionInfo> getMethodsByExceptionId(@PathVariable("exceptionId") String exceptionId, String message) { public KoResult getMethodsByExceptionId(@PathVariable("exceptionId") String exceptionId, String message) {
GraphService graphService = GraphService.getInstance(); GraphService graphService = GraphService.getInstance();
List<ExceptionInfo> exceptionInfos = graphService.getExceptionInfos(exceptionId, message); List<ExceptionInfo> exceptionInfos = graphService.getExceptionInfos(exceptionId, message);
return exceptionInfos; return KoResult.success(exceptionInfos);
} }
} }

View File

@ -526,8 +526,8 @@
} }
function loadDynamicProperties() { function loadDynamicProperties() {
get(concatToken('contextPath/koTime/dynamicProperties'), function (data) { get(concatToken('contextPath/koTime/dynamicProperties'), function (res) {
let text = data['data']; let text = res['content'];
document.querySelector("#dynamicText").value = text; document.querySelector("#dynamicText").value = text;
}); });
} }