diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java index 7d82c41c31e..6d1bc180550 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java @@ -8,9 +8,11 @@ import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.portal.PortalSettings; +import com.ctrip.framework.apollo.portal.entity.po.UserInfo; import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo; import com.ctrip.framework.apollo.portal.listener.AppCreationEvent; import com.ctrip.framework.apollo.portal.service.AppService; +import com.ctrip.framework.apollo.portal.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; @@ -40,6 +42,8 @@ public class AppController { @Autowired private ApplicationEventPublisher publisher; + @Autowired + private UserService userService; @RequestMapping("") public List findAllApp() { @@ -71,12 +75,17 @@ public MultiResponseEntity nav(@PathVariable String appId) { @RequestMapping(value = "", method = RequestMethod.POST) public ResponseEntity create(@RequestBody App app) { - checkArgument(app.getName(), app.getAppId(), app.getOwnerEmail(), app.getOwnerName(), + checkArgument(app.getName(), app.getAppId(), app.getOwnerName(), app.getOrgId(), app.getOrgName()); if (!InputValidator.isValidClusterNamespace(app.getAppId())) { throw new BadRequestException(String.format("AppId格式错误: %s", InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE)); } + UserInfo userInfo = userService.findByUserId(app.getOwnerName()); + if (userInfo == null){ + throw new BadRequestException("应用负责人不存在"); + } + app.setOwnerEmail(userInfo.getEmail()); appService.enrichUserInfo(app); App createdApp = appService.create(app); diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java index 0a0be8c8e07..f9d7e845613 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -89,8 +90,11 @@ public ResponseEntity assignNamespaceRoleToUser(@PathVariable String appId if (!RoleType.isValidRoleType(roleType)){ throw new BadRequestException("role type is illegal"); } - rolePermissionService.assignRoleToUsers(RoleUtils.buildNamespaceRoleName(appId, namespaceName, roleType), + Set assignedUser = rolePermissionService.assignRoleToUsers(RoleUtils.buildNamespaceRoleName(appId, namespaceName, roleType), Sets.newHashSet(user), userInfoHolder.getUser().getUserId()); + if (CollectionUtils.isEmpty(assignedUser)){ + throw new BadRequestException(user + "已授权"); + } return ResponseEntity.ok().build(); } @@ -130,8 +134,11 @@ public ResponseEntity assignAppRoleToUser(@PathVariable String appId, @Pat if (!RoleType.isValidRoleType(roleType)){ throw new BadRequestException("role type is illegal"); } - rolePermissionService.assignRoleToUsers(RoleUtils.buildAppRoleName(appId, roleType), + Set assignedUsers = rolePermissionService.assignRoleToUsers(RoleUtils.buildAppRoleName(appId, roleType), Sets.newHashSet(user), userInfoHolder.getUser().getUserId()); + if (CollectionUtils.isEmpty(assignedUsers)){ + throw new BadRequestException(user + "已授权"); + } return ResponseEntity.ok().build(); } diff --git a/apollo-portal/src/main/resources/static/app.html b/apollo-portal/src/main/resources/static/app.html index 79a2c551f35..72e6ed42727 100644 --- a/apollo-portal/src/main/resources/static/app.html +++ b/apollo-portal/src/main/resources/static/app.html @@ -48,10 +48,7 @@
-
- -
-
+ (负责人具有项目管理的最高权限,比如分配配置的修改权,发布权等)
diff --git a/apollo-portal/src/main/resources/static/namespace/role.html b/apollo-portal/src/main/resources/static/namespace/role.html index 390308039c2..142ff3db73d 100644 --- a/apollo-portal/src/main/resources/static/namespace/role.html +++ b/apollo-portal/src/main/resources/static/namespace/role.html @@ -73,8 +73,8 @@