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


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java:
##########
@@ -74,9 +95,23 @@ 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);
+        // TODO The AssertUtils.checkApiAlert can simplify the exception.
+        if (team == null) {
+            throw new ApiAlertException(String.format("The team[Id=%s] doesn't 
exists.", teamId));
+        }
+        if (applicationService.countByTeamId(teamId) > 0) {
+            throw new ApiAlertException(String.format("Please delete the 
applications under the team[name=%s] first!", team.getTeamName()));
+        }
+        if (projectService.countByTeamId(teamId) > 0) {
+            throw new ApiAlertException(String.format("Please delete the 
projects under the team[name=%s] first!", team.getTeamName()));
+        }
+
+        memberService.deleteByTeamId(teamId);
+        variableService.deleteByTeamId(teamId);

Review Comment:
   > This team doesn't have any project and application, so these variables 
must not be used. Why can't delete them directly?
   > 
   > If StreamPark can't delete variables directly, why the member mapping can 
be deleted directly?
   
   Variables have a separate management module. Variables essentially belong to 
"resources". Resources include project, application, etc., as well as the 
management of jar and udf that we will do later. I think the deletion of all 
resources must be confirmed by the user at least, and member Just made a 
relationship mapping, I think it is reasonable to delete member directly



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to