Skip to content

Commit

Permalink
Merge pull request #281 from Hous-Release/fix/#280
Browse files Browse the repository at this point in the history
사용자 탈퇴 요청 시 피드백 받는 부분 수정
  • Loading branch information
hyejungg authored Dec 22, 2022
2 parents a83e7f2 + 9494df5 commit 2c585d4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
10 changes: 7 additions & 3 deletions src/main/java/hous/server/controller/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import hous.server.service.slack.SlackService;
import hous.server.service.user.UserRetrieveService;
import hous.server.service.user.UserService;
import hous.server.service.user.UserServiceUtils;
import hous.server.service.user.dto.request.DeleteUserRequestDto;
import hous.server.service.user.dto.request.UpdatePushSettingRequestDto;
import hous.server.service.user.dto.request.UpdateTestScoreRequestDto;
Expand Down Expand Up @@ -151,13 +152,14 @@ public ResponseEntity<SuccessResponse<String>> updateRepresentBadge(@ApiIgnore @
@ApiOperation(
value = "[인증] 마이 페이지(설정) - 회원 정보를 삭제합니다.",
notes = "회원 정보 탈퇴 요청 시 해당 유저의 모든 정보를 삭제합니다.\n"
+ "feedbackType을 NO를 보낸 경우, 사유가 없는 것으로 판단합니다."
+ "feedbackType을 NO를 보낸 경우, 사유가 없는 것으로 판단합니다. comment가 없는 경우 빈스트링(\"\")으로 보내주세요."
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "성공입니다."),
@ApiResponse(code = 400,
message = "1. 사유를 선택 안한 경우, NO를 보내주세요. (feedbackType)\n"
+ "2. 의견은 200 글자 이내로 입력해주세요. (comment)",
+ "2. 의견은 200 글자 이내로 입력해주세요. (comment)\n"
+ "3. 의견이 없는 경우, 빈 스트링(\"\")을 보내주세요. (comment)",
response = ErrorResponse.class),
@ApiResponse(code = 401, message = "토큰이 만료되었습니다. 다시 로그인 해주세요.", response = ErrorResponse.class),
@ApiResponse(code = 404, message = "탈퇴했거나 존재하지 않는 유저입니다.", response = ErrorResponse.class),
Expand All @@ -172,7 +174,9 @@ public ResponseEntity<SuccessResponse<String>> updateRepresentBadge(@ApiIgnore @
public ResponseEntity<SuccessResponse<String>> deleteUser(@ApiIgnore @UserId Long userId,
@Valid @RequestBody DeleteUserRequestDto request) {
userService.deleteUser(request, userId);
slackService.sendSlackMessageDeleteUser(userRetrieveService.getFeedback(request.getComment()));
if (UserServiceUtils.isNewFeedback(request.getFeedbackType(), request.getComment())) {
slackService.sendSlackMessageDeleteUser(userRetrieveService.getFeedback(request.getComment()));
}
return SuccessResponse.OK;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static List<LayoutBlock> createUserDeleteMessage(UserDeleteResponse userD
layoutBlockList.add(section(section ->
section.text(markdownText(PROD_USER_DELETE_MESSAGE + stringBuilder.toString()))));

if (userDeleteResponse.getComment() != null) {
if (!userDeleteResponse.getComment().isBlank()) {
layoutBlockList.add(section(section ->
section.text(markdownText(PROD_NOW_USER_DELETE_COMMENT + userDeleteResponse.getComment()))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ public class UserDeleteResponse {
private String comment;

public static UserDeleteResponse of(long totalDeleteUserCount, List<UserDelete> users, String comment) {
if (comment == null) {
return UserDeleteResponse.builder()
.totalDeleteUserCount(totalDeleteUserCount)
.totalDeleteUserList(users.stream()
.map(user -> UserDelete.of(user.getCount(), user.getFeedbackType()))
.sorted(Comparator.comparing(userDelete -> userDelete.getFeedbackType().length()))
.collect(Collectors.toList())
)
.build();
}
return UserDeleteResponse.builder()
.totalDeleteUserCount(totalDeleteUserCount)
.totalDeleteUserList(users.stream()
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/hous/server/service/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import hous.server.domain.badge.repository.RepresentRepository;
import hous.server.domain.common.RedisKey;
import hous.server.domain.feedback.Feedback;
import hous.server.domain.feedback.FeedbackType;
import hous.server.domain.feedback.repository.FeedbackRepository;
import hous.server.domain.personality.Personality;
import hous.server.domain.personality.PersonalityColor;
Expand Down Expand Up @@ -167,7 +166,7 @@ public void deleteUser(DeleteUserRequestDto request, Long userId) {
RoomServiceUtils.deleteParticipateUser(participateRepository, roomRepository, me, room, participate);
}

if (!(request.getFeedbackType().equals(FeedbackType.NO) && request.getComment() == null)) {
if (UserServiceUtils.isNewFeedback(request.getFeedbackType(), request.getComment())) {
feedbackRepository.save(Feedback.newInstance(request.getFeedbackType(), request.getComment()));
}
userRepository.delete(user);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/hous/server/service/user/UserServiceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import hous.server.common.exception.ConflictException;
import hous.server.common.exception.NotFoundException;
import hous.server.common.exception.ValidationException;
import hous.server.domain.feedback.FeedbackType;
import hous.server.domain.personality.Personality;
import hous.server.domain.personality.PersonalityColor;
import hous.server.domain.personality.repository.PersonalityRepository;
Expand Down Expand Up @@ -132,4 +133,8 @@ public static List<Onboarding> toMeFirstList(List<Onboarding> onboardings, Onboa
result.addAll(exceptMeList);
return result;
}

public static boolean isNewFeedback(FeedbackType feedbackType, String comment) {
return !(feedbackType.equals(FeedbackType.NO) && comment.isBlank());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public class DeleteUserRequestDto {

@ApiModelProperty(value = "의견", example = "흠냐링 제법 괜찮았으나 안쓰게 되네요.")
@Size(max = Constraint.FEEDBACK_COMMENT_MAX, message = "{user.comment.max}")
@NotNull(message = "{user.comment.notNull}")
private String comment;
}
1 change: 1 addition & 0 deletions src/main/resources/messages/validation.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ rule.list.notNull=\uADDC\uCE59 \uB9AC\uC2A4\uD2B8\uB97C \uC785\uB825\uD574\uC8FC
rule.list.min=\uADDC\uCE59 \uB9AC\uC2A4\uD2B8\uB294 \uBE48 \uBC30\uC5F4\uC744 \uBCF4\uB0BC \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
user.feedbackType.notNull=\uC0AC\uC720\uB97C \uC120\uD0DD \uC548\uD55C \uACBD\uC6B0, NO\uB97C \uBCF4\uB0B4\uC8FC\uC138\uC694.
user.comment.max=\uC758\uACAC\uC740 200 \uAE00\uC790 \uC774\uB0B4\uB85C \uC785\uB825\uD574\uC8FC\uC138\uC694.
user.comment.notNull=\uC758\uACAC\uC774 \uC5C6\uB294 \uACBD\uC6B0, \uBE48 \uC2A4\uD2B8\uB9C1(\"\")\uC744 \uBCF4\uB0B4\uC8FC\uC138\uC694.

0 comments on commit 2c585d4

Please sign in to comment.