diff --git a/src/main/java/im/zhaojun/zfile/controller/admin/DebugController.java b/src/main/java/im/zhaojun/zfile/controller/admin/DebugController.java new file mode 100644 index 0000000..9bf854a --- /dev/null +++ b/src/main/java/im/zhaojun/zfile/controller/admin/DebugController.java @@ -0,0 +1,31 @@ +package im.zhaojun.zfile.controller.admin; + + +import im.zhaojun.zfile.model.support.ResultBean; +import im.zhaojun.zfile.service.SystemConfigService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import javax.annotation.Resource; + +@Controller +public class DebugController { + + @Value("${zfile.debug}") + private Boolean debug; + + @Resource + private SystemConfigService systemConfigService; + + @GetMapping("/debug/resetPwd") + public ResultBean resetPwd() { + if (debug) { + systemConfigService.updateUsernameAndPwd("admin", "123456"); + return ResultBean.success(); + } else { + return ResultBean.error("未开启 DEBUG 模式,不允许进行此操作。"); + } + } + +} \ No newline at end of file diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 580f180..249732c 100644 --- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -86,6 +86,11 @@ "name": "zfile.tmp.path", "type": "java.lang.String", "description": "临时文件路径." + }, + { + "name": "zfile.debug", + "type": "java.lang.Boolean", + "description": "是否开启 debug 模式." } ] } \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a6f9c5d..57f5e9b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,34 @@ +zfile: + debug: false + log: + path: ${user.home}/.zfile/logs + db: + path: ${user.home}/.zfile/db/zfile + tmp: + path: ${user.home}/.zfile/tmp + cache: + auto-refresh: + interval: 1 + timeout: 1800 + constant: + readme: readme.md + password: password.txt + preview: + audio: + maxFileSizeMb: 5 + text: + maxFileSizeKb: 512 + onedrive: + clientId: 09939809-c617-43c8-a220-a93c1513c5d4 + clientSecret: _l:zI-_yrW75lV8M61K@z.I2K@B/On6Q + redirectUri: https://zfile.jun6.net/onedrive/callback + scope: offline_access User.Read Files.ReadWrite.All + onedrive-china: + clientId: 4a72d927-1907-488d-9eb2-1b465c53c1c5 + clientSecret: Y9CEA=82da5n-y_]KAWAgLH3?R9xf7Uw + redirectUri: https://zfile.jun6.net/onedrive/china-callback + scope: offline_access User.Read Files.ReadWrite.All + server: port: 8080 servlet: @@ -13,7 +44,7 @@ spring: settings: web-allow-others: true path: /h2-console - enabled: false + enabled: ${zfile.debug} datasource: # 初始化数据导入 data: classpath*:db/data.sql @@ -47,34 +78,4 @@ spring: chain: gzipped: true profiles: - active: prod - -zfile: - log: - path: ${user.home}/.zfile/logs - db: - path: ${user.home}/.zfile/db/zfile - tmp: - path: ${user.home}/.zfile/tmp - cache: - auto-refresh: - interval: 1 - timeout: 1800 - constant: - readme: readme.md - password: password.txt - preview: - audio: - maxFileSizeMb: 5 - text: - maxFileSizeKb: 512 - onedrive: - clientId: 09939809-c617-43c8-a220-a93c1513c5d4 - clientSecret: _l:zI-_yrW75lV8M61K@z.I2K@B/On6Q - redirectUri: https://zfile.jun6.net/onedrive/callback - scope: offline_access User.Read Files.ReadWrite.All - onedrive-china: - clientId: 4a72d927-1907-488d-9eb2-1b465c53c1c5 - clientSecret: Y9CEA=82da5n-y_]KAWAgLH3?R9xf7Uw - redirectUri: https://zfile.jun6.net/onedrive/china-callback - scope: offline_access User.Read Files.ReadWrite.All \ No newline at end of file + active: prod \ No newline at end of file