Skip to content

[자신의 프로필 사진 수정] 사용자는 자신의 프로필 사진을 수정할 수 있다. (#90) #91

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

Merged
merged 9 commits into from
May 29, 2024
Merged
21 changes: 4 additions & 17 deletions be/src/main/java/yeonba/be/exception/BlockException.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package yeonba.be.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum BlockException implements BaseException {

ALREADY_BLOCKED_USER(
Expand All @@ -14,21 +18,4 @@ public enum BlockException implements BaseException {

private final HttpStatus httpStatus;
private final String reason;

BlockException(HttpStatus httpStatus, String reason) {
this.httpStatus = httpStatus;
this.reason = reason;
}

@Override
public HttpStatus getHttpStatus() {

return httpStatus;
}

@Override
public String getReason() {

return reason;
}
}
21 changes: 4 additions & 17 deletions be/src/main/java/yeonba/be/exception/ChatException.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package yeonba.be.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum ChatException implements BaseException {

NOT_YOUR_CHAT_ROOM(
Expand All @@ -18,21 +22,4 @@ public enum ChatException implements BaseException {

private final HttpStatus httpStatus;
private final String reason;

ChatException(HttpStatus httpStatus, String reason) {
this.httpStatus = httpStatus;
this.reason = reason;
}

@Override
public HttpStatus getHttpStatus() {

return httpStatus;
}

@Override
public String getReason() {

return reason;
}
}
35 changes: 12 additions & 23 deletions be/src/main/java/yeonba/be/exception/CommonException.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
package yeonba.be.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum CommonException implements BaseException {

BAD_REQUEST(
HttpStatus.BAD_REQUEST,
"잘못된 요청입니다."),
BAD_REQUEST(
HttpStatus.BAD_REQUEST,
"잘못된 요청입니다."),

INTERNAL_SERVER_ERROR(
HttpStatus.INTERNAL_SERVER_ERROR,
"서버 에러 관리자에게 문의 바랍니다.");
INTERNAL_SERVER_ERROR(
HttpStatus.INTERNAL_SERVER_ERROR,
"서버 에러 관리자에게 문의 바랍니다.");

private final HttpStatus httpStatus;
private final String reason;

CommonException(HttpStatus httpStatus, String reason) {
this.httpStatus = httpStatus;
this.reason = reason;
}

@Override
public HttpStatus getHttpStatus() {
return httpStatus;
}

@Override
public String getReason() {
return reason;
}
private final HttpStatus httpStatus;
private final String reason;
}
37 changes: 12 additions & 25 deletions be/src/main/java/yeonba/be/exception/FavoriteException.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
package yeonba.be.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum FavoriteException implements BaseException {

ALREADY_FAVORITE_USER(
HttpStatus.BAD_REQUEST,
"이미 즐겨찾기한 사용자입니다."),
ALREADY_FAVORITE_USER(
HttpStatus.BAD_REQUEST,
"이미 즐겨찾기한 사용자입니다."),

FAVORITE_NOT_FOUND(
HttpStatus.BAD_REQUEST,
"해당 즐겨찾기 내역이 존재하지 않습니다.");
FAVORITE_NOT_FOUND(
HttpStatus.BAD_REQUEST,
"해당 즐겨찾기 내역이 존재하지 않습니다.");

private final HttpStatus httpStatus;
private final String reason;

FavoriteException(HttpStatus httpStatus, String reason) {
this.httpStatus = httpStatus;
this.reason = reason;
}

@Override
public HttpStatus getHttpStatus() {

return httpStatus;
}

@Override
public String getReason() {

return reason;
}
private final HttpStatus httpStatus;
private final String reason;
}
41 changes: 15 additions & 26 deletions be/src/main/java/yeonba/be/exception/ReportException.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
package yeonba.be.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum ReportException implements BaseException {

REPORT_REASON_NOT_EXIST(
HttpStatus.BAD_REQUEST,
"신고 분류가 기타일 때는 사유가 존재해야 합니다."),
REPORT_REASON_NOT_EXIST(
HttpStatus.BAD_REQUEST,
"신고 분류가 기타일 때는 사유가 존재해야 합니다."),

REPORT_REASON_LENGTH_NOT_VALID(
HttpStatus.BAD_REQUEST,
"신고 사유는 1024자를 넘을 수 없습니다."),
REPORT_REASON_LENGTH_NOT_VALID(
HttpStatus.BAD_REQUEST,
"신고 사유는 1024자를 넘을 수 없습니다."),

CAN_NOT_REPORT_SELF(
HttpStatus.BAD_REQUEST,
"자기 자신을 신고할 수 없습니다.");
CAN_NOT_REPORT_SELF(
HttpStatus.BAD_REQUEST,
"자기 자신을 신고할 수 없습니다.");

private final HttpStatus httpStatus;
private final String reason;

ReportException(HttpStatus httpStatus, String reason) {
this.httpStatus = httpStatus;
this.reason = reason;
}

@Override
public HttpStatus getHttpStatus() {
return httpStatus;
}

@Override
public String getReason() {
return reason;
}
private final HttpStatus httpStatus;
private final String reason;
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public class UserJoinRequest {
description = "사진 싱크로율",
example = "80")
@Min(
value = 80,
message = "사진 싱크로율이 80퍼 이상이어야 가입할 수 있습니다.")
value = 75,
message = "사진 싱크로율이 75퍼 이상이어야 가입할 수 있습니다.")
@NotNull(message = "사진 싱크로율은 반드시 입력되어야 합니다.")
private int photoSyncRate;

Expand Down
17 changes: 6 additions & 11 deletions be/src/main/java/yeonba/be/mypage/controller/MyPageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Size;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import yeonba.be.mypage.dto.request.NotificationPermissionsUpdateRequest;
import yeonba.be.mypage.dto.request.UserChangeInactiveStatusRequest;
import yeonba.be.mypage.dto.request.UserUpdateProfilePhotoRequest;
import yeonba.be.mypage.dto.request.UserUpdateProfileRequest;
import yeonba.be.mypage.dto.request.UserUpdateUnwantedAcquaintancesRequest;
import yeonba.be.mypage.dto.response.BlockedUsersResponse;
Expand Down Expand Up @@ -71,12 +69,9 @@ public ResponseEntity<CustomResponse<UserProfileDetailResponse>> getProfileDetai
@PutMapping(path = "/users/profile-photos", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<CustomResponse<Void>> updateProfilePhotos(
@RequestAttribute("userId") long userId,
@Parameter(description = "업로드 할 새로운 프로필 사진들, 반드시 한 번에 2개씩 업로드")
@RequestPart("profilePhotos") @Size(min = 2, max = 2) List<MultipartFile> profilePhotos,
@Parameter(description = "프로필 사진과 싱크로율을 검증할 직접 찍은 사진")
@RequestPart("realTimePhoto") @Size(min = 1, max = 1) MultipartFile realTimePhoto) {
@Valid @ModelAttribute UserUpdateProfilePhotoRequest request) {

myPageService.updateProfilePhotos(profilePhotos, realTimePhoto, userId);
myPageService.updateProfilePhotos(userId, request);

return ResponseEntity
.ok()
Expand All @@ -87,8 +82,8 @@ public ResponseEntity<CustomResponse<Void>> updateProfilePhotos(
@ApiResponse(responseCode = "200", description = "자신의 프로필 수정 요청 정상 처리")
@PatchMapping("/users/profiles")
public ResponseEntity<CustomResponse<Void>> updateProfile(
@Valid @RequestBody UserUpdateProfileRequest request,
@RequestAttribute("userId") long userId) {
@RequestAttribute("userId") long userId,
@Valid @RequestBody UserUpdateProfileRequest request) {

myPageService.updateProfile(request, userId);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package yeonba.be.mypage.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.web.multipart.MultipartFile;

@Getter
@AllArgsConstructor
public class UserUpdateProfilePhotoRequest {

@Schema(
type = "array",
description = "수정할 프로필 사진들")
@Size(min = 2, max = 2, message = "프로필 사진은 정확히 2장이어야 합니다.")
@NotNull(message = "프로필 사진은 반드시 입력되어야 합니다.")
List<MultipartFile> profilePhotos;

@Schema(
type = "number",
description = "사진 싱크로율",
example = "85")
@Min(value = 75, message = "사진 싱크로율이 75퍼이상이어야 합니다.")
@NotNull(message = "사진 싱크로율은 반드시 입력되어야 합니다.")
private int photoSyncRate;
}
Loading