Skip to content

Commit

Permalink
add update admin interface
Browse files Browse the repository at this point in the history
  • Loading branch information
liberhe committed Dec 17, 2023
1 parent 21322d0 commit 44f2186
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum CodeEnums {
NOT_FOUND_JD("1008", "not found jd"),
NOT_FOUND_MEMBER("1009", "not found user"),
NOT_THE_ADMIN("1010", "user not the admin"),
NOT_THE_SUPER_ADMIN("1018", "user not the auper admin"),
TEAM_JOIN_APPLICATION_NOT_EXIST("1011", "team join application not exist"),
//Sharing
SHARING_NOT_FOUND("5001", "Sharing not found"),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/dl/officialsite/team/TeamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ BaseResponse create(@RequestBody Team team, @RequestParam String address) {
/**
* 更改管理员 todo
*/
@PostMapping()
@PostMapping("update")
@Auth("admin")
BaseResponse update(@RequestBody Team team, @RequestParam String address) {
// Team TeamNew = teamService.update(team);
teamService.update(team,address);
return BaseResponse.successWithData(null);
}

Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/dl/officialsite/team/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,33 @@ public void batchJoin(TeamMemberBatchJoinVO teamMembers) {
}


public void update(Team team, String address) {
if(team.getAdministrator()!= null ) {
if( !checkMemberIsSupperAdmin(address)) {
throw new BizException(CodeEnums.NOT_THE_SUPER_ADMIN.getCode(),
CodeEnums.NOT_THE_SUPER_ADMIN.getMsg());
}
Team teamdb = teamRepository.findById(team.getId()).get();
teamdb.setAdministrator(team.getAdministrator());
teamRepository.save(teamdb);
} else {
Team teamdb = teamRepository.findById(team.getId()).get();
if(team.getTeamName()!=null) {
teamdb.setTeamName(team.getTeamName());
}
if(team.getTeamProfile()!=null) {
teamdb.setTeamProfile(team.getTeamProfile());
}
teamRepository.save(teamdb);
}

}

public boolean checkMemberIsSupperAdmin(String address) {
Team adminTeam = teamRepository.findById(1L).get();
if(adminTeam.getAdministrator().equals(address)){
return true;
}
return false;
}
}

0 comments on commit 44f2186

Please sign in to comment.