-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 워크스페이스 설정 로직 #193
base: develop
Are you sure you want to change the base?
[FEAT] 워크스페이스 설정 로직 #193
Changes from all commits
ae9c7fc
870d872
541d9f6
4dcc56c
54e69b2
82d9d9e
fa1f535
b8e1071
ac7398c
f087ba4
0b2a5b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
import com.tiki.server.note.adapter.NoteFinder; | ||
import com.tiki.server.note.entity.Note; | ||
import com.tiki.server.team.exception.TeamException; | ||
import com.tiki.server.memberteammanager.service.dto.response.MemberTeamPositionGetResponse; | ||
import com.tiki.server.memberteammanager.service.dto.response.MemberTeamInformGetResponse; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
@@ -44,9 +44,9 @@ public void leaveTeam(final long memberId, final long teamId) { | |
memberTeamManagerDeleter.delete(memberTeamManager); | ||
} | ||
|
||
public MemberTeamPositionGetResponse getPosition(final long memberId, final long teamId) { | ||
public MemberTeamInformGetResponse getMemberTeamInform(final long memberId, final long teamId) { | ||
MemberTeamManager memberTeamManager = memberTeamManagerFinder.findByMemberIdAndTeamId(memberId, teamId); | ||
return MemberTeamPositionGetResponse.from(memberTeamManager.getPosition()); | ||
return MemberTeamInformGetResponse.from(memberTeamManager.getPosition(), memberTeamManager.getName()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파라미터가 두 개이므로, of로 하면 좋을 거 같아요. |
||
} | ||
|
||
@Transactional | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.tiki.server.memberteammanager.service.dto.response; | ||
|
||
import com.tiki.server.common.entity.Position; | ||
|
||
public record MemberTeamInformGetResponse( | ||
Position position, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nonnull, Notnull 같은 널 방지 들어가면 좋을 거 같아요. |
||
String name | ||
) { | ||
public static MemberTeamInformGetResponse from(final Position position, final String name) { | ||
return new MemberTeamInformGetResponse(position, name); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,12 @@ | |
import java.security.Principal; | ||
|
||
import com.tiki.server.common.dto.BaseResponse; | ||
import com.tiki.server.team.controller.dto.request.UpdateTeamIconRequest; | ||
import com.tiki.server.team.controller.dto.request.UpdateTeamNameRequest; | ||
import com.tiki.server.team.controller.dto.request.UpdateTeamMemberAndTeamInformRequest; | ||
import com.tiki.server.team.dto.request.UpdateTeamMemberAndTeamInformServiceRequest; | ||
import com.tiki.server.team.dto.response.CategoriesGetResponse; | ||
import com.tiki.server.team.dto.response.TeamsGetResponse; | ||
|
||
import com.tiki.server.team.service.dto.response.TeamInformGetResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
@@ -68,26 +69,23 @@ public ResponseEntity<BaseResponse> deleteTeam( | |
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PatchMapping("/{teamId}/name") | ||
public ResponseEntity<BaseResponse> updateTeamName( | ||
final Principal principal, | ||
@PathVariable final long teamId, | ||
@RequestBody final UpdateTeamNameRequest request | ||
@GetMapping("/{teamId}/inform") | ||
public ResponseEntity<SuccessResponse<TeamInformGetResponse>> getTeamName( | ||
@PathVariable final long teamId | ||
) { | ||
long memberId = Long.parseLong(principal.getName()); | ||
teamService.updateTeamName(memberId, teamId, request.newTeamName()); | ||
return ResponseEntity.ok(success(SUCCESS_UPDATE_TEAM_NAME.getMessage())); | ||
TeamInformGetResponse response = teamService.getTeamInform(teamId); | ||
return ResponseEntity.ok().body(success(SUCCESS_GET_CATEGORIES.getMessage(), response)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 팀 이름을 가져오는 api와 맞는 성공메세지명을 사용하면 좋을 거 같아요. |
||
} | ||
|
||
@PatchMapping("/{teamId}/icon") | ||
public ResponseEntity<BaseResponse> updateIconImage( | ||
@PatchMapping("/{teamId}/inform") | ||
public ResponseEntity<BaseResponse> updateTeamAndTeamMemberInform( | ||
final Principal principal, | ||
@PathVariable final long teamId, | ||
@RequestBody final UpdateTeamIconRequest request | ||
@RequestBody final UpdateTeamMemberAndTeamInformRequest request | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 행위가 뒤에 오는 dto명이면 더 좋을 거 같아요. |
||
) { | ||
long memberId = Long.parseLong(principal.getName()); | ||
teamService.updateIconImage(memberId, teamId, request.iconImageUrl()); | ||
return ResponseEntity.ok(success(SUCCESS_UPDATE_TEAM_ICON.getMessage())); | ||
teamService.updateTeamAndTeamMemberInform(memberId, teamId, UpdateTeamMemberAndTeamInformServiceRequest.from(request)); | ||
return ResponseEntity.ok(success(SUCCESS_UPDATE_TEAM_NAME.getMessage())); | ||
} | ||
|
||
@PatchMapping("/{teamId}/member/{targetId}/admin") | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tiki.server.team.controller.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record UpdateTeamMemberAndTeamInformRequest( | ||
@NotNull String teamMemberName, | ||
@NotNull String teamName, | ||
@NotNull String teamUrl | ||
) { | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.tiki.server.team.dto.request; | ||
|
||
import com.tiki.server.team.controller.dto.request.UpdateTeamMemberAndTeamInformRequest; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record UpdateTeamMemberAndTeamInformServiceRequest( | ||
@NotNull String teamMemberName, | ||
@NotNull String teamName, | ||
@NotNull String teamIconUrl | ||
) { | ||
public static UpdateTeamMemberAndTeamInformServiceRequest from(UpdateTeamMemberAndTeamInformRequest request) { | ||
return new UpdateTeamMemberAndTeamInformServiceRequest( | ||
request.teamMemberName(), | ||
request.teamName(), | ||
request.teamUrl() | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,11 @@ | |
import com.tiki.server.memberteammanager.adapter.MemberTeamManagerFinder; | ||
import com.tiki.server.team.adapter.TeamDeleter; | ||
import com.tiki.server.team.adapter.TeamFinder; | ||
import com.tiki.server.team.dto.request.UpdateTeamMemberAndTeamInformServiceRequest; | ||
import com.tiki.server.team.dto.response.CategoriesGetResponse; | ||
import com.tiki.server.team.dto.response.TeamsGetResponse; | ||
|
||
import com.tiki.server.team.service.dto.response.TeamInformGetResponse; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
@@ -29,7 +31,6 @@ | |
import com.tiki.server.team.dto.response.TeamCreateResponse; | ||
import com.tiki.server.team.entity.Category; | ||
import com.tiki.server.team.entity.Team; | ||
import com.tiki.server.team.exception.TeamException; | ||
import com.tiki.server.team.vo.TeamVO; | ||
import com.tiki.server.timeblock.adapter.TimeBlockDeleter; | ||
|
||
|
@@ -83,23 +84,26 @@ public void deleteTeam(final long memberId, final long teamId) { | |
teamDeleter.deleteById(teamId); | ||
} | ||
|
||
private Team createTeam(final TeamCreateRequest request, final University univ) { | ||
return Team.of(request, univ); | ||
public TeamInformGetResponse getTeamInform(final long teamId) { | ||
Team team = teamFinder.findById(teamId); | ||
return TeamInformGetResponse.from(team.getName(), team.getUniv(), team.getIconImageUrl()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파라미터가 적으면 적을 수록 좋은 코드라는 리뷰를 다른 프로젝트에서 받아서 Team 자체를 파라미터로 넘겨도 좋을 거 같아요! 물론 지금도 좋습니다. |
||
} | ||
|
||
@Transactional | ||
public void updateTeamName(final long memberId, final long teamId, final String newTeamName) { | ||
checkIsAdmin(memberId, teamId); | ||
Team team = teamFinder.findById(teamId); | ||
team.updateName(newTeamName); | ||
private Team createTeam(final TeamCreateRequest request, final University univ) { | ||
return Team.of(request, univ); | ||
} | ||
|
||
@Transactional | ||
public void updateIconImage(final long memberId, final long teamId, final String iconImageUrl) { | ||
checkIsAdmin(memberId, teamId); | ||
public void updateTeamAndTeamMemberInform( | ||
final long memberId, | ||
final long teamId, | ||
final UpdateTeamMemberAndTeamInformServiceRequest request | ||
) { | ||
MemberTeamManager memberTeamManager = checkIsAdmin(memberId, teamId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checkIsAdmin을 통해 ADMIN도 검사하고 멤버팀매니저도 받아오는데 개인적으로 메소드가 두 일을 한다고 생각합니다! |
||
memberTeamManager.updateName(request.teamMemberName()); | ||
Team team = teamFinder.findById(teamId); | ||
deleteIconUrl(team); | ||
team.setIconImageUrl(iconImageUrl); | ||
team.updateInform(request.teamName(), request.teamIconUrl()); | ||
updateIconUrlS3(team, request.teamIconUrl()); | ||
} | ||
|
||
@Transactional | ||
|
@@ -114,8 +118,8 @@ private MemberTeamManager createMemberTeamManager(final Member member, final Tea | |
return MemberTeamManager.of(member, team, position); | ||
} | ||
|
||
private void deleteIconUrl(final Team team) { | ||
if (!team.isDefaultImage()) { | ||
private void updateIconUrlS3(final Team team, final String iconUrl) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s3라는 이름이 안 들어가도 괜찮을거 같아요. 만약 추후에 s3를 이용하지 않게된다면 메소드 네이밍을 바꿔야 한다고 생각하기 때문입니다! 만약 들어가는게 좋은거 같다면 updateIconS3Url이 더 나을 거 같아요. |
||
if (!team.isDefaultImage() && !team.getImageUrl().equals(iconUrl)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iconUrl 동등성 검사 로직을 team으로 위임해도 좋을 거 같아요. |
||
s3Handler.deleteFile(team.getIconImageUrl()); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.tiki.server.team.service.dto.response; | ||
|
||
import com.tiki.server.common.entity.University; | ||
|
||
public record TeamInformGetResponse( | ||
String teamName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 널 방지 로직 들어가면 좋을 거 같아요. |
||
University university, | ||
String teamIconUrl | ||
) { | ||
|
||
public static TeamInformGetResponse from(final String teamName, final University university, final String teamIconUrl) { | ||
return new TeamInformGetResponse(teamName, university, teamIconUrl); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
성공메세지랑 api 메소드명이랑 매치가 안되는 거 같아요!