|
@@ -3,6 +3,7 @@ package com.qmth.ops.api.controller.admin;
|
|
|
import com.qmth.ops.api.constants.OpsApiConstants;
|
|
|
import com.qmth.ops.api.security.AdminSession;
|
|
|
import com.qmth.ops.biz.domain.NginxConfig;
|
|
|
+import com.qmth.ops.biz.domain.Role;
|
|
|
import com.qmth.ops.biz.service.AppService;
|
|
|
import com.qmth.ops.biz.service.EnvService;
|
|
|
import com.qmth.ops.biz.service.ModuleService;
|
|
@@ -29,18 +30,23 @@ public class NginxConfigController {
|
|
|
|
|
|
@PostMapping("/find")
|
|
|
public NginxConfig find(@RequestAttribute AdminSession adminSession, @RequestParam Long appId,
|
|
|
- @RequestParam Long envId, @RequestParam(required = false) Long moduleId) {
|
|
|
+ @RequestParam(required = false) Long envId, @RequestParam(required = false) Long moduleId) {
|
|
|
adminSession.validateApp(appService.getById(appId));
|
|
|
- return nginxConfigService.find(appService.getById(appId), envService.getById(envId),
|
|
|
+ return nginxConfigService.find(appService.getById(appId), envId != null ? envService.getById(envId) : null,
|
|
|
moduleId != null ? moduleService.getById(moduleId) : null);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
public Object update(@RequestAttribute AdminSession adminSession, @RequestParam Long appId,
|
|
|
- @RequestParam Long envId, @RequestParam(required = false) Long moduleId, @RequestParam String content) {
|
|
|
+ @RequestParam(required = false) Long envId, @RequestParam(required = false) Long moduleId,
|
|
|
+ @RequestParam String content) {
|
|
|
adminSession.validateApp(appService.getById(appId));
|
|
|
- adminSession.validateEnv(envService.getById(envId));
|
|
|
- return nginxConfigService.update(appService.getById(appId), envService.getById(envId),
|
|
|
+ if (envId != null) {
|
|
|
+ adminSession.validateEnv(envService.getById(envId));
|
|
|
+ } else {
|
|
|
+ adminSession.validateRole(Role.DEV, Role.ADMIN);
|
|
|
+ }
|
|
|
+ return nginxConfigService.update(appService.getById(appId), envId != null ? envService.getById(envId) : null,
|
|
|
moduleId != null ? moduleService.getById(moduleId) : null, content);
|
|
|
}
|
|
|
|