1996fanrui commented on code in PR #1881:
URL:
https://github.com/apache/incubator-streampark/pull/1881#discussion_r1002634602
##########
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?
--
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]