|
@@ -6,7 +6,7 @@ import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.core.exception.ParameterException;
|
|
|
import com.qmth.boot.core.exception.UnauthorizedException;
|
|
|
import com.qmth.ops.api.constants.OpsApiConstants;
|
|
|
-import com.qmth.ops.api.controller.binder.ConfigFormatBinder;
|
|
|
+import com.qmth.ops.api.controller.binder.FileFormatBinder;
|
|
|
import com.qmth.ops.biz.domain.*;
|
|
|
import com.qmth.ops.biz.service.*;
|
|
|
import com.qmth.ops.biz.utils.PropertyFileUtil;
|
|
@@ -45,25 +45,25 @@ public class ConfigExportController {
|
|
|
|
|
|
@InitBinder
|
|
|
public void initBinder(WebDataBinder dataBinder) {
|
|
|
- dataBinder.addCustomFormatter(new ConfigFormatBinder());
|
|
|
+ dataBinder.addCustomFormatter(new FileFormatBinder());
|
|
|
}
|
|
|
|
|
|
@GetMapping("/{appCode}/{moduleCode}/{envCode}/{version}.{format}")
|
|
|
public void exportVersionConfigFile(@PathVariable String appCode, @PathVariable String moduleCode,
|
|
|
- @PathVariable String envCode, @PathVariable String version, @PathVariable ConfigFormat format,
|
|
|
+ @PathVariable String envCode, @PathVariable String version, @PathVariable FileFormat format,
|
|
|
@RequestParam String secret, HttpServletResponse response) throws IOException {
|
|
|
exportConfigFile(appCode, moduleCode, envCode, version, secret, format, response);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/{appCode}/{moduleCode}/{envCode}.{format}")
|
|
|
public void exportMasterVersionConfigFile(@PathVariable String appCode, @PathVariable String moduleCode,
|
|
|
- @PathVariable String envCode, @PathVariable ConfigFormat format, @RequestParam String secret,
|
|
|
+ @PathVariable String envCode, @PathVariable FileFormat format, @RequestParam String secret,
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
exportConfigFile(appCode, moduleCode, envCode, null, secret, format, response);
|
|
|
}
|
|
|
|
|
|
private void exportConfigFile(String appCode, String moduleCode, String envCode, String versionNumber,
|
|
|
- String exportSecret, ConfigFormat format, HttpServletResponse response) throws IOException {
|
|
|
+ String exportSecret, FileFormat format, HttpServletResponse response) throws IOException {
|
|
|
User user = userService.findByExportSecret(exportSecret);
|
|
|
if (user == null || user.getRole() != Role.OPS) {
|
|
|
throw new UnauthorizedException("鉴权失败");
|
|
@@ -89,12 +89,12 @@ public class ConfigExportController {
|
|
|
}
|
|
|
List<ConfigItem> list = configService
|
|
|
.mergeConfigList(app.getId(), version.getId(), module.getId(), env.getId());
|
|
|
- if (format == ConfigFormat.PROPERTY) {
|
|
|
+ if (format == FileFormat.PROPERTY) {
|
|
|
response.reset();
|
|
|
response.setContentType("application/octet-stream; charset=unicode");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=application." + format.getExtension());
|
|
|
PropertyFileUtil.write(list, response.getOutputStream());
|
|
|
- } else if (format == ConfigFormat.JSON) {
|
|
|
+ } else if (format == FileFormat.JSON) {
|
|
|
response.reset();
|
|
|
response.setContentType("application/octet-stream; charset=utf-8");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=application." + format.getExtension());
|