diff --git a/be/src/main/java/yeonba/be/arrow/controller/ArrowController.java b/be/src/main/java/yeonba/be/arrow/controller/ArrowController.java index 15200374..7e00ce88 100644 --- a/be/src/main/java/yeonba/be/arrow/controller/ArrowController.java +++ b/be/src/main/java/yeonba/be/arrow/controller/ArrowController.java @@ -4,16 +4,15 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; +import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; -import yeonba.be.arrow.dto.UserArrowsResponse; -import yeonba.be.arrow.dto.request.ArrowSendRequest; +import yeonba.be.arrow.dto.response.UserArrowsResponse; import yeonba.be.arrow.service.ArrowService; import yeonba.be.util.CustomResponse; @@ -38,47 +37,51 @@ public ResponseEntity> arrows( } @Operation(summary = "출석 체크", description = "출석 체크를 통해 사용자가 10개의 화살을 획득할 수 있습니다.") - @ApiResponse(responseCode = "202", description = "출석 체크 정상 처리") + @ApiResponse(responseCode = "200", description = "출석 체크 정상 처리") @PostMapping("/daily-check") public ResponseEntity> dailyCheck( @RequestAttribute("userId") long userId) { - arrowService.dailyCheck(userId); - - return ResponseEntity - .accepted() + ResponseEntity> response = ResponseEntity + .ok() .body(new CustomResponse<>()); + + LocalDate dailyCheckDay = LocalDate.now(); + if (!arrowService.dailyCheck(userId, dailyCheckDay)) { + response = ResponseEntity + .badRequest() + .body(new CustomResponse<>("이미 출석 체크한 사용자입니다.")); + } + + return response; } - @Operation(summary = "화살 보내기", description = "다른 사용자에게 화살을 보낼 수 있습니다.") - @ApiResponse(responseCode = "202", description = "화살 전송 정상 처리") + @Operation(summary = "화살 보내기", description = "다른 사용자에게 화살을 1개 보낼 수 있습니다.") + @ApiResponse(responseCode = "200", description = "화살 전송 정상 처리") @PostMapping("/users/{userId}/arrow") public ResponseEntity> sendArrow( @RequestAttribute("userId") long senderId, @Parameter(description = "화살 받는 사용자 ID", example = "1") - @PathVariable("userId") long receiverId, - @RequestBody ArrowSendRequest request) { + @PathVariable("userId") long receiverId) { - arrowService.sendArrow( - senderId, - receiverId, - request); + arrowService.sendArrow(senderId, receiverId); return ResponseEntity - .accepted() + .ok() .body(new CustomResponse<>()); } @Operation(summary = "화살 충전", description = "광고 시청시 화살 5개를 충전할 수 있습니다.") - @ApiResponse(responseCode = "202", description = "화살 충전 정상 처리") + @ApiResponse(responseCode = "200", description = "화살 충전 정상 처리") @PostMapping("/users/arrows") public ResponseEntity> chargeArrows( @RequestAttribute("userId") long userId) { - arrowService.chargeArrows(userId); + LocalDate chargeDay = LocalDate.now(); + arrowService.chargeArrows(userId, chargeDay); return ResponseEntity - .accepted() + .ok() .body(new CustomResponse<>()); } } diff --git a/be/src/main/java/yeonba/be/arrow/dto/request/ArrowSendRequest.java b/be/src/main/java/yeonba/be/arrow/dto/request/ArrowSendRequest.java deleted file mode 100644 index 8e3616e9..00000000 --- a/be/src/main/java/yeonba/be/arrow/dto/request/ArrowSendRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package yeonba.be.arrow.dto.request; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Positive; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -public class ArrowSendRequest { - - @Schema( - type = "number", - description = "보낼 화살 수", - example = "10") - @Positive(message = "화살은 1개 이상부터 보낼 수 있습니다.") - private int arrows; -} diff --git a/be/src/main/java/yeonba/be/arrow/dto/UserArrowsResponse.java b/be/src/main/java/yeonba/be/arrow/dto/response/UserArrowsResponse.java similarity index 50% rename from be/src/main/java/yeonba/be/arrow/dto/UserArrowsResponse.java rename to be/src/main/java/yeonba/be/arrow/dto/response/UserArrowsResponse.java index 229737e1..cf162620 100644 --- a/be/src/main/java/yeonba/be/arrow/dto/UserArrowsResponse.java +++ b/be/src/main/java/yeonba/be/arrow/dto/response/UserArrowsResponse.java @@ -1,4 +1,4 @@ -package yeonba.be.arrow.dto; +package yeonba.be.arrow.dto.response; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; @@ -8,9 +8,9 @@ @AllArgsConstructor public class UserArrowsResponse { - @Schema( - type = "number", - description = "사용자 화살 개수", - example = "10") - private int arrows; + @Schema( + type = "number", + description = "사용자 화살 개수", + example = "10") + private int arrows; } diff --git a/be/src/main/java/yeonba/be/arrow/entity/ArrowTransaction.java b/be/src/main/java/yeonba/be/arrow/entity/ArrowTransaction.java index b2159278..ee3bb487 100644 --- a/be/src/main/java/yeonba/be/arrow/entity/ArrowTransaction.java +++ b/be/src/main/java/yeonba/be/arrow/entity/ArrowTransaction.java @@ -3,6 +3,8 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EntityListeners; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @@ -14,6 +16,7 @@ import lombok.NoArgsConstructor; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import yeonba.be.arrow.enums.ArrowTransactionType; import yeonba.be.user.entity.User; @Table(name = "arrows_transactions") @@ -38,23 +41,30 @@ public class ArrowTransaction { @Column(nullable = false) private int arrows; + @Enumerated(EnumType.STRING) + private ArrowTransactionType type; + @CreatedDate @Column(nullable = false) private LocalDateTime createdAt; public ArrowTransaction( + ArrowTransactionType type, User receiver, int arrows) { + this.type = type; this.receiver = receiver; this.arrows = arrows; } public ArrowTransaction( + ArrowTransactionType type, User sender, User receiver, int arrows) { + this.type = type; this.sender = sender; this.receiver = receiver; this.arrows = arrows; diff --git a/be/src/main/java/yeonba/be/arrow/enums/ArrowTransactionType.java b/be/src/main/java/yeonba/be/arrow/enums/ArrowTransactionType.java new file mode 100644 index 00000000..030b56cc --- /dev/null +++ b/be/src/main/java/yeonba/be/arrow/enums/ArrowTransactionType.java @@ -0,0 +1,17 @@ +package yeonba.be.arrow.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ArrowTransactionType { + + DAILY_CHECK("출석 체크"), + + REWARDS_FOR_WATCHING_ADVERTISEMENTS("광고 시청 통한 화살 획득"), + + USER_TO_USER("사용자간 송수신"); + + private final String description; +} diff --git a/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepository.java b/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepository.java index bec97ff5..fec891b7 100644 --- a/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepository.java +++ b/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepository.java @@ -9,5 +9,5 @@ public interface ArrowTransactionRepository extends JpaRepository, ArrowTransactionRepositoryCustom { - boolean existsBySenderAndReceiver(User sentUser, User receivedUser); + boolean existsBySenderAndReceiver(User sender, User receiver); } diff --git a/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepositoryImpl.java b/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepositoryImpl.java index 13ab8176..5d9d8b70 100644 --- a/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepositoryImpl.java +++ b/be/src/main/java/yeonba/be/arrow/repository/ArrowTransactionRepositoryImpl.java @@ -1,6 +1,7 @@ package yeonba.be.arrow.repository; import static yeonba.be.arrow.entity.QArrowTransaction.arrowTransaction; +import static yeonba.be.arrow.enums.ArrowTransactionType.REWARDS_FOR_WATCHING_ADVERTISEMENTS; import static yeonba.be.user.entity.QUser.user; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -20,8 +21,9 @@ public boolean canChargeByAdvertisement(long userId, LocalDateTime today) { queryFactory .select(arrowTransaction.count()) .from(arrowTransaction) - .innerJoin(arrowTransaction.sender, user) + .innerJoin(arrowTransaction.receiver, user) .where( + arrowTransaction.type.eq(REWARDS_FOR_WATCHING_ADVERTISEMENTS), arrowTransaction.sender.isNull(), arrowTransaction.receiver.id.eq(userId), arrowTransaction.createdAt.after(today) diff --git a/be/src/main/java/yeonba/be/arrow/service/ArrowService.java b/be/src/main/java/yeonba/be/arrow/service/ArrowService.java index fe75c41c..ae5b3e26 100644 --- a/be/src/main/java/yeonba/be/arrow/service/ArrowService.java +++ b/be/src/main/java/yeonba/be/arrow/service/ArrowService.java @@ -1,17 +1,21 @@ package yeonba.be.arrow.service; +import static yeonba.be.arrow.enums.ArrowTransactionType.DAILY_CHECK; +import static yeonba.be.arrow.enums.ArrowTransactionType.REWARDS_FOR_WATCHING_ADVERTISEMENTS; +import static yeonba.be.arrow.enums.ArrowTransactionType.USER_TO_USER; + import java.time.LocalDate; import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import yeonba.be.arrow.dto.UserArrowsResponse; -import yeonba.be.arrow.dto.request.ArrowSendRequest; +import yeonba.be.arrow.dto.response.UserArrowsResponse; import yeonba.be.arrow.entity.ArrowTransaction; import yeonba.be.arrow.repository.ArrowCommand; import yeonba.be.arrow.repository.ArrowQuery; import yeonba.be.exception.ArrowException; import yeonba.be.exception.GeneralException; +import yeonba.be.exception.UserException; import yeonba.be.user.entity.User; import yeonba.be.user.repository.user.UserQuery; @@ -19,34 +23,38 @@ @RequiredArgsConstructor public class ArrowService { - private final int DAILY_CHECK_ARROW_COUNT = 10; - private final int ADVERTISEMENT_ARROW_COUNT = 5; private final UserQuery userQuery; private final ArrowCommand arrowCommand; private final ArrowQuery arrowQuery; - /* - 출석 체크는 다음 과정을 거쳐 이뤄진다. - 1. 사용자 최종 접속 일시를 통해 이미 출석 체크하였는지 확인 - 2. 화살 송수신 내역 저장 - 3. 사용자 최종 접속 일시 갱신 - 4. 사용자 화살 개수 증가 - */ @Transactional - public void dailyCheck(long userId) { + public boolean dailyCheck(long userId, LocalDate dailyCheckDay) { User dailyCheckUser = userQuery.findById(userId); - LocalDateTime dailyCheckedAt = LocalDateTime.now(); - dailyCheckUser.validateDailyCheck(dailyCheckedAt.toLocalDate()); + // 휴면 상태 사용자는 출석 체크 불가 + if (dailyCheckUser.isInactive()) { + throw new GeneralException(UserException.INACTIVE_USER); + } - ArrowTransaction arrowTransaction = new ArrowTransaction( - dailyCheckUser, - DAILY_CHECK_ARROW_COUNT); - arrowCommand.save(arrowTransaction); + boolean canDailyCheck = dailyCheckUser.canDailyCheckAt(dailyCheckDay); + + // 출석 체크 화살 내역 저장, 사용자 화살 증가 + if (canDailyCheck) { + int dailyCheckArrows = 10; + ArrowTransaction arrowTransaction = new ArrowTransaction( + DAILY_CHECK, + dailyCheckUser, + dailyCheckArrows); + arrowCommand.save(arrowTransaction); + + dailyCheckUser.plusArrow(dailyCheckArrows); + } + + // 사용자 최종 접속 일시 갱신 + dailyCheckUser.updateLastAccessedAt(LocalDateTime.now()); - dailyCheckUser.updateLastAccessedAt(dailyCheckedAt); - dailyCheckUser.plusArrow(DAILY_CHECK_ARROW_COUNT); + return canDailyCheck; } @Transactional(readOnly = true) @@ -57,54 +65,58 @@ public UserArrowsResponse getUserArrows(long userId) { return new UserArrowsResponse(user.getArrow()); } - /* - 화살 보내기 비즈니스 로직은 다음 과정을 거친다. - 1. 자기 자신에게 화살을 보내는 상황 검증 - 2. 화살을 보낸 사용자에게 또 보내는 상황 검증 - 3. 화살 내역 저장 - 4. 보내는 사용자 화살 감소, 화살이 부족할 경우 예외 발생 - 5. 받는 사용자 화살 증가 - */ @Transactional - public void sendArrow( - long senderId, - long receiverId, - ArrowSendRequest request) { + public void sendArrow(long senderId, long receiverId) { User sender = userQuery.findById(senderId); User receiver = userQuery.findById(receiverId); + // 휴면 상태에선 화살을 보낼 수 없음 + if (sender.isInactive()) { + throw new GeneralException(UserException.INACTIVE_USER); + } + + // 휴면 상태인 사용자에게 화살을 보낼 수 없음 + if (receiver.isInactive()) { + throw new GeneralException(ArrowException.CAN_NOT_SEND_ARROW_TO_INACTIVE_USER); + } + + // 자기 자신에게 화살을 보낼 수 없음 sender.validateNotSameUser(receiver); + // 같은 성별 사용자에게 화살을 보낼 수 없음 + sender.validateSameGender(receiver); + + // 이미 화살을 보낸 사용자에게 화살을 보낼 수 없음 if (arrowQuery.isArrowTransactionExist(sender, receiver)) { throw new GeneralException(ArrowException.ALREADY_SENT_ARROW_USER); } - int arrows = request.getArrows(); - ArrowTransaction arrowTransaction = new ArrowTransaction( - sender, - receiver, - arrows); + // 화살은 1개만 보낼 수 있음 + int sendArrow = 1; + ArrowTransaction arrowTransaction = + new ArrowTransaction(USER_TO_USER, sender, receiver, sendArrow); arrowCommand.save(arrowTransaction); - sender.minusArrow(arrows); - receiver.plusArrow(arrows); + sender.minusArrow(sendArrow); + receiver.plusArrow(sendArrow); } @Transactional - public void chargeArrows(long userId) { + public void chargeArrows(long userId, LocalDate chargeDay) { - User user = userQuery.findById(userId); + User arrowChargeUser = userQuery.findById(userId); - LocalDateTime today = LocalDate.now().atStartOfDay(); - arrowQuery.validateAdvertisementArrowCount(userId, today); + LocalDateTime chargeDayStartTime = chargeDay.atStartOfDay(); + arrowQuery.validateAdvertisementArrowCount(userId, chargeDayStartTime); + int chargeArrows = 5; ArrowTransaction arrowTransaction = new ArrowTransaction( - user, - ADVERTISEMENT_ARROW_COUNT); + REWARDS_FOR_WATCHING_ADVERTISEMENTS, + arrowChargeUser, + chargeArrows); arrowCommand.save(arrowTransaction); - user.plusArrow(ADVERTISEMENT_ARROW_COUNT); + arrowChargeUser.plusArrow(chargeArrows); } - } diff --git a/be/src/main/java/yeonba/be/exception/ArrowException.java b/be/src/main/java/yeonba/be/exception/ArrowException.java index e5c070ec..5c4563dc 100644 --- a/be/src/main/java/yeonba/be/exception/ArrowException.java +++ b/be/src/main/java/yeonba/be/exception/ArrowException.java @@ -1,7 +1,11 @@ package yeonba.be.exception; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.springframework.http.HttpStatus; +@Getter +@AllArgsConstructor public enum ArrowException implements BaseException { @@ -9,35 +13,18 @@ public enum ArrowException implements BaseException { HttpStatus.BAD_REQUEST, "1일 광고 시청은 최대 3회입니다."), - ALREADY_CHECKED_USER( - HttpStatus.BAD_REQUEST, - "이미 출석 체크한 사용자입니다."), - ALREADY_SENT_ARROW_USER( HttpStatus.BAD_REQUEST, "이미 화살을 보낸 사용자입니다."), NOT_ENOUGH_ARROW_TO_SEND( HttpStatus.BAD_REQUEST, - "화살이 부족하여 화살을 보낼 수 없습니다."); + "화살이 부족하여 화살을 보낼 수 없습니다."), + + CAN_NOT_SEND_ARROW_TO_INACTIVE_USER( + HttpStatus.BAD_REQUEST, + "휴면 상태인 사용자에겐 화살을 보낼 수 없습니다."); private final HttpStatus httpStatus; private final String reason; - - ArrowException(HttpStatus httpStatus, String reason) { - this.httpStatus = httpStatus; - this.reason = reason; - } - - @Override - public HttpStatus getHttpStatus() { - - return httpStatus; - } - - @Override - public String getReason() { - - return reason; - } } diff --git a/be/src/main/java/yeonba/be/exception/LoginException.java b/be/src/main/java/yeonba/be/exception/LoginException.java deleted file mode 100644 index deb5f8fd..00000000 --- a/be/src/main/java/yeonba/be/exception/LoginException.java +++ /dev/null @@ -1,31 +0,0 @@ -package yeonba.be.exception; - -import org.springframework.http.HttpStatus; - -public enum LoginException implements BaseException { - - VERIFICATION_CODE_NOT_FOUND( - HttpStatus.BAD_REQUEST, - "해당 인증 코드 내역이 존재하지 않습니다."); - - private final HttpStatus httpStatus; - private final String reason; - - LoginException(HttpStatus httpStatus, String reason) { - - this.httpStatus = httpStatus; - this.reason = reason; - } - - @Override - public HttpStatus getHttpStatus() { - - return httpStatus; - } - - @Override - public String getReason() { - - return reason; - } -} diff --git a/be/src/main/java/yeonba/be/exception/UserException.java b/be/src/main/java/yeonba/be/exception/UserException.java index 4799a498..69552e49 100644 --- a/be/src/main/java/yeonba/be/exception/UserException.java +++ b/be/src/main/java/yeonba/be/exception/UserException.java @@ -32,6 +32,18 @@ public enum UserException implements BaseException { HttpStatus.BAD_REQUEST, "해당 사용자가 존재하지 않습니다."), + SAME_USER( + HttpStatus.BAD_REQUEST, + "같은 사용자(자기 자신) 입니다."), + + SAME_GENDER_USER( + HttpStatus.BAD_REQUEST, + "같은 성별 사용자 입니다."), + + INACTIVE_USER( + HttpStatus.BAD_REQUEST, + "휴면 상태 사용자입니다. 휴면 해제가 필요합니다."), + USER_PREFERENCE_NOT_FOUND( HttpStatus.BAD_REQUEST, "해당 사용자의 선호내역이 존재하지 않습니다."), diff --git a/be/src/main/java/yeonba/be/mypage/dto/response/UserProfileDetailResponse.java b/be/src/main/java/yeonba/be/mypage/dto/response/UserProfileDetailResponse.java index 9b283d90..c562f5ee 100644 --- a/be/src/main/java/yeonba/be/mypage/dto/response/UserProfileDetailResponse.java +++ b/be/src/main/java/yeonba/be/mypage/dto/response/UserProfileDetailResponse.java @@ -75,7 +75,7 @@ public class UserProfileDetailResponse { public UserProfileDetailResponse(User user) { this.profilePhotoUrls = user.getProfilePhotoUrls(); - this.gender = user.getGender(); + this.gender = user.getGenderString(); this.birth = user.getBirth(); this.height = user.getHeight(); this.phoneNumber = user.getPhoneNumber(); diff --git a/be/src/main/java/yeonba/be/user/entity/User.java b/be/src/main/java/yeonba/be/user/entity/User.java index 99eb4fc9..f8bcdc60 100644 --- a/be/src/main/java/yeonba/be/user/entity/User.java +++ b/be/src/main/java/yeonba/be/user/entity/User.java @@ -16,6 +16,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.Optional; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,6 +27,7 @@ import yeonba.be.exception.ArrowException; import yeonba.be.exception.GeneralException; import yeonba.be.exception.UserException; +import yeonba.be.user.enums.Gender; import yeonba.be.user.enums.LoginType; @Table(name = "users") @@ -141,7 +143,7 @@ public User( public void validateNotSameUser(User user) { if (this.equals(user)) { - throw new IllegalArgumentException("동일한 사용자입니다."); + throw new GeneralException(UserException.SAME_USER); } } @@ -154,11 +156,14 @@ public void delete() { this.phoneNumber = "deleted"; } - public void validateDailyCheck(LocalDate dailyCheckDay) { + public boolean canDailyCheckAt(LocalDate dailyCheckDay) { - if (this.lastAccessedAt.isAfter(dailyCheckDay.atStartOfDay())) { - throw new GeneralException(ArrowException.ALREADY_CHECKED_USER); + if (Optional.ofNullable(this.lastAccessedAt).isEmpty()) { + + return true; } + + return this.lastAccessedAt.isBefore(dailyCheckDay.atStartOfDay()); } public String getRepresentativeProfilePhoto() { @@ -166,9 +171,9 @@ public String getRepresentativeProfilePhoto() { return this.profilePhotos.get(0).getPhotoUrl(); } - public void updateLastAccessedAt(LocalDateTime accessedAt) { + public void updateLastAccessedAt(LocalDateTime accessAt) { - this.lastAccessedAt = accessedAt; + this.lastAccessedAt = accessAt; } public void plusArrow(int arrow) { @@ -185,14 +190,14 @@ public void minusArrow(int arrow) { this.arrow -= arrow; } - public String getGender() { + public String getGenderString() { - if (this.gender) { + return Gender.genderBooleanToString(this.gender); + } - return "남"; - } + public boolean getGenderBoolean() { - return "여"; + return this.gender; } public List getProfilePhotoUrls() { @@ -224,6 +229,14 @@ public void updateRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } + public void validateSameGender(User user) { + + if (this.gender == user.getGenderBoolean()) { + throw new GeneralException(UserException.SAME_GENDER_USER); + } + + } + public void updateProfile( String nickname, int height, diff --git a/be/src/main/java/yeonba/be/user/enums/Gender.java b/be/src/main/java/yeonba/be/user/enums/Gender.java index 0668205c..ce7df7c6 100644 --- a/be/src/main/java/yeonba/be/user/enums/Gender.java +++ b/be/src/main/java/yeonba/be/user/enums/Gender.java @@ -1,7 +1,11 @@ package yeonba.be.user.enums; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.apache.commons.lang3.StringUtils; +@Getter +@AllArgsConstructor public enum Gender { MALE("남", true), @@ -10,11 +14,6 @@ public enum Gender { public final String genderString; public final boolean genderBoolean; - Gender(String genderString, boolean genderBoolean) { - this.genderString = genderString; - this.genderBoolean = genderBoolean; - } - public static Gender from(String genderString) { if (StringUtils.equals(genderString, MALE.genderString)) { @@ -24,4 +23,14 @@ public static Gender from(String genderString) { return FEMALE; } + + public static String genderBooleanToString(boolean genderBoolean) { + + if (genderBoolean == MALE.genderBoolean) { + + return MALE.genderString; + } + + return FEMALE.genderString; + } } diff --git a/be/src/main/java/yeonba/be/user/service/UserService.java b/be/src/main/java/yeonba/be/user/service/UserService.java index 23e48ac4..e65e6d2c 100644 --- a/be/src/main/java/yeonba/be/user/service/UserService.java +++ b/be/src/main/java/yeonba/be/user/service/UserService.java @@ -58,7 +58,7 @@ public UserProfileResponse getTargetUserProfile(long userId, long targetUserId) return new UserProfileResponse( targetUser.getProfilePhotoUrls(), - targetUser.getGender(), + targetUser.getGenderString(), targetUser.getNickname(), targetUser.getArrow(), targetUser.getAge(), diff --git a/be/src/main/java/yeonba/be/util/CustomResponse.java b/be/src/main/java/yeonba/be/util/CustomResponse.java index c863b4c5..3c5367fa 100644 --- a/be/src/main/java/yeonba/be/util/CustomResponse.java +++ b/be/src/main/java/yeonba/be/util/CustomResponse.java @@ -5,38 +5,38 @@ @Getter public class CustomResponse { - private final String status; + private final String status; - private final String message; + private final String message; - private final T data; + private final T data; - public CustomResponse(String message) { - this.status = "fail"; - this.message = message; - this.data = null; - } + public CustomResponse(String message) { + this.status = "fail"; + this.message = message; + this.data = null; + } - public CustomResponse(T data) { - this.status = "success"; - this.message = null; - this.data = data; - } + public CustomResponse(T data) { + this.status = "success"; + this.message = null; + this.data = data; + } - public CustomResponse() { - this.status = "success"; - this.message = null; - this.data = null; - } + public CustomResponse() { + this.status = "success"; + this.message = null; + this.data = null; + } - private CustomResponse(String message, T data) { - this.status = "fail"; - this.message = message; - this.data = data; - } + private CustomResponse(String message, T data) { + this.status = "fail"; + this.message = message; + this.data = data; + } - public static CustomResponse onFailure(String message, T data) { + public static CustomResponse onFailure(String message, T data) { - return new CustomResponse<>(message, data); - } + return new CustomResponse<>(message, data); + } }