add change log api
package io.jpom.controller.system;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.lang.Tuple;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpStatus;
import cn.jiangzeyin.common.JsonMessage;
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
@@ -17,11 +21,11 @@ import io.jpom.permission.SystemPermission;
import io.jpom.system.ServerConfigBean;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
import java.util.Objects;
/**
@@ -30,7 +34,7 @@ import java.util.Objects;
* @author bwcx_jzy
* @date 2019/7/22
*/
-@Controller
+@RestController
@RequestMapping(value = "system")
public class SystemUpdateController extends BaseServerController {
@@ -45,6 +49,18 @@ public class SystemUpdateController extends BaseServerController {
return JsonMessage.getString(200, "", JpomManifest.getInstance());
}
+ @PostMapping(value = "change_log", produces = MediaType.APPLICATION_JSON_VALUE)
+ public String changeLog() {
+ //
+ URL resource = ResourceUtil.getResource("CHANGELOG.md");
+ String log = StrUtil.EMPTY;
+ if (resource != null) {
+ InputStream stream = URLUtil.getStream(resource);
+ log = IoUtil.readUtf8(stream);
+ }
+ return JsonMessage.getString(200, "", log);
+ }
+
@RequestMapping(value = "uploadJar.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@OptLog(UserOperateLogV1.OptType.UpdateSys)
