|
@@ -5,7 +5,9 @@ import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.ops.api.binder.FileFormatBinder;
|
|
|
import com.qmth.ops.api.constants.OpsApiConstants;
|
|
|
import com.qmth.ops.api.security.AdminSession;
|
|
|
+import com.qmth.ops.api.security.Permission;
|
|
|
import com.qmth.ops.api.vo.CodeNameVO;
|
|
|
+import com.qmth.ops.api.vo.SuccessVO;
|
|
|
import com.qmth.ops.biz.domain.*;
|
|
|
import com.qmth.ops.biz.service.*;
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
@@ -15,9 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(OpsApiConstants.ADMIN_URI_PREFIX + "/property")
|
|
@@ -38,6 +38,9 @@ public class PropertyController {
|
|
|
@Resource
|
|
|
private EnvService envService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserPermissionService userPermissionService;
|
|
|
+
|
|
|
@InitBinder
|
|
|
public void initBinder(WebDataBinder dataBinder) {
|
|
|
dataBinder.addCustomFormatter(new FileFormatBinder());
|
|
@@ -66,13 +69,17 @@ public class PropertyController {
|
|
|
public Object updateBaseline(@RequestAttribute AdminSession adminSession, @RequestParam Long versionId,
|
|
|
@RequestParam Long moduleId, @RequestParam MultipartFile file, @RequestParam FileFormat extension,
|
|
|
@RequestParam(required = false) Long inheritVersionId) throws IOException {
|
|
|
- return propertyService.updateBaseline(versionService.getById(versionId), moduleService.getById(moduleId),
|
|
|
- file.getInputStream(), extension,
|
|
|
- inheritVersionId != null ? versionService.getById(inheritVersionId) : null);
|
|
|
+ Version version = versionService.getById(versionId);
|
|
|
+ adminSession.permissionCheck(Permission.PROPERTY_BASELINE_EDIT, version.getAppId());
|
|
|
+ return propertyService
|
|
|
+ .updateBaseline(version, moduleService.getById(moduleId), file.getInputStream(), extension,
|
|
|
+ inheritVersionId != null ? versionService.getById(inheritVersionId) : null);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/baseline/item/update")
|
|
|
public PropertyItem updateBaselineItem(@RequestAttribute AdminSession adminSession, PropertyItem item) {
|
|
|
+ Version version = versionService.getById(item.getVersionId());
|
|
|
+ adminSession.permissionCheck(Permission.PROPERTY_BASELINE_EDIT, version.getAppId());
|
|
|
return propertyService.updateBaselineItem(item);
|
|
|
}
|
|
|
|
|
@@ -81,8 +88,8 @@ public class PropertyController {
|
|
|
@RequestParam Long versionId, @RequestParam Long moduleId, @RequestParam Long envId) {
|
|
|
Env env = envService.getById(envId);
|
|
|
List<PropertyItem> list = propertyService.listPropertyItem(versionId, moduleId, env.getId());
|
|
|
- //非管理员/运维角色,且非环境维护用户,需要隐藏机密信息
|
|
|
- if (!adminSession.getUser().hasRole(Role.ADMIN, Role.OPS)) {
|
|
|
+ //且非环境可编辑用户,需要隐藏机密信息
|
|
|
+ if (!userPermissionService.hasPermission(adminSession.getUser(), Permission.PROPERTY_EDIT, env.getId())) {
|
|
|
for (PropertyItem item : list) {
|
|
|
//包含密钥/密码类信息
|
|
|
if (item.getKey().contains("secret") || item.getKey().contains("password")) {
|
|
@@ -112,15 +119,17 @@ public class PropertyController {
|
|
|
|
|
|
@PostMapping("/item/update")
|
|
|
public PropertyItem updatePropertyItem(@RequestAttribute AdminSession adminSession, PropertyItem item) {
|
|
|
+ Env env = envService.getById(item.getEnvId());
|
|
|
+ adminSession.permissionCheck(Permission.PROPERTY_EDIT, env.getId());
|
|
|
return propertyService.updatePropertyItem(item);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/item/delete")
|
|
|
public Object deletePropertyItem(@RequestAttribute AdminSession adminSession, PropertyItem item) {
|
|
|
+ Env env = envService.getById(item.getEnvId());
|
|
|
+ adminSession.permissionCheck(Permission.PROPERTY_EDIT, env.getId());
|
|
|
propertyService.deletePropertyItem(item);
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("success", true);
|
|
|
- return map;
|
|
|
+ return new SuccessVO(true);
|
|
|
}
|
|
|
|
|
|
}
|