You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by GitBox <gi...@apache.org> on 2022/10/21 15:51:27 UTC

[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #1881: [Feature] Check apps and projects before delete team

wolfboys commented on code in PR #1881:
URL: https://github.com/apache/incubator-streampark/pull/1881#discussion_r1001947269


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java:
##########
@@ -74,9 +94,21 @@ public void createTeam(Team team) {
     }
 
     @Override
-    public void deleteTeam(Team team) {
-        // TODO 查询 app 和 project,如果还有 app 或 project 没有删除,则 team 不能被删除。
-        this.removeById(team);
+    public void deleteTeam(Long teamId) {
+        log.info("{} Proceed delete team[Id={}]", commonService.getCurrentUser().getUsername(), teamId);
+        Team team = this.getById(teamId);
+        if (team == null) {
+            log.info("The team[Id={}] doesn't exists.", teamId);
+            return;
+        }
+        AssertUtils.state(applicationService.countByTeamId(teamId) == 0,
+            String.format("Please delete the applications under the team[name=%s] first!", team.getTeamName()));

Review Comment:
   I recommend use `ApiAlertException`



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java:
##########
@@ -74,9 +94,21 @@ public void createTeam(Team team) {
     }
 
     @Override
-    public void deleteTeam(Team team) {
-        // TODO 查询 app 和 project,如果还有 app 或 project 没有删除,则 team 不能被删除。
-        this.removeById(team);
+    public void deleteTeam(Long teamId) {
+        log.info("{} Proceed delete team[Id={}]", commonService.getCurrentUser().getUsername(), teamId);
+        Team team = this.getById(teamId);
+        if (team == null) {
+            log.info("The team[Id={}] doesn't exists.", teamId);

Review Comment:
   I recommend use `ApiAlertException`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org