From 0c7388e30c6d6eea74758cfcd4895322afab0390 Mon Sep 17 00:00:00 2001 From: HeoSeokMun Date: Sun, 17 Dec 2023 15:46:40 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 동물 정보를 변경 할 수 없게 함 --- .../controller/UserController.kt | 30 ++----------------- .../dto/request/UpdateFemaleRequestDto.kt | 15 ---------- ...eMaleRequestDto.kt => UpdateRequestDto.kt} | 4 +-- .../com/yourssu/ssudateserver/entity/User.kt | 4 +-- .../ssudateserver/service/UserService.kt | 2 -- 5 files changed, 5 insertions(+), 50 deletions(-) delete mode 100644 src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateFemaleRequestDto.kt rename src/main/kotlin/com/yourssu/ssudateserver/dto/request/{UpdateMaleRequestDto.kt => UpdateRequestDto.kt} (78%) diff --git a/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt b/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt index e300d61..290af54 100644 --- a/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt +++ b/src/main/kotlin/com/yourssu/ssudateserver/controller/UserController.kt @@ -4,8 +4,7 @@ import com.yourssu.ssudateserver.dto.request.RefreshTokenRequestDto import com.yourssu.ssudateserver.dto.request.RegisterCodeRequestDto import com.yourssu.ssudateserver.dto.request.RegisterFemaleRequestDto import com.yourssu.ssudateserver.dto.request.RegisterMaleRequestDto -import com.yourssu.ssudateserver.dto.request.UpdateFemaleRequestDto -import com.yourssu.ssudateserver.dto.request.UpdateMaleRequestDto +import com.yourssu.ssudateserver.dto.request.UpdateRequestDto import com.yourssu.ssudateserver.dto.response.RefreshTokenResponseDto import com.yourssu.ssudateserver.dto.response.RegisterResponseDto import com.yourssu.ssudateserver.dto.response.UpdateResponseDto @@ -84,36 +83,13 @@ class UserController( return userService.getMyInfo(oauthName = userPrincipal.name) } - @PatchMapping("/users/my/male") + @PatchMapping("/users/my") fun updateMaleInfo( - @RequestBody updateRequestDto: UpdateMaleRequestDto, + @RequestBody updateRequestDto: UpdateRequestDto, @AuthenticationPrincipal userPrincipal: UserPrincipal, ): UpdateResponseDto { - if (updateRequestDto.animals == MaleAnimals.ALL) { - throw AllCanNotRegisterException("ALL은 등록불가능 합니다.") - } - - return userService.updateUserInfo( - Animals.valueOf(updateRequestDto.animals.toString()), - updateRequestDto.nickName, - updateRequestDto.mbti, - updateRequestDto.introduce, - updateRequestDto.contact, - userPrincipal.name - ) - } - - @PatchMapping("/users/my/female") - fun updateFemaleInfo( - @RequestBody updateRequestDto: UpdateFemaleRequestDto, - @AuthenticationPrincipal userPrincipal: UserPrincipal, - ): UpdateResponseDto { - if (updateRequestDto.animals == FemaleAnimals.ALL) { - throw AllCanNotRegisterException("ALL은 등록불가능 합니다.") - } return userService.updateUserInfo( - Animals.valueOf(updateRequestDto.animals.toString()), updateRequestDto.nickName, updateRequestDto.mbti, updateRequestDto.introduce, diff --git a/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateFemaleRequestDto.kt b/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateFemaleRequestDto.kt deleted file mode 100644 index 62beb6c..0000000 --- a/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateFemaleRequestDto.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.yourssu.ssudateserver.dto.request - -import com.yourssu.ssudateserver.enums.FemaleAnimals -import com.yourssu.ssudateserver.enums.MBTI -import javax.validation.constraints.Size - -data class UpdateFemaleRequestDto( - val animals: FemaleAnimals, - @field:Size(message = "닉네임은 최대 9글자 입니다.", min = 1, max = 9) - val nickName: String, - val mbti: MBTI, - @field:Size(message = "소개글은 최대 100글자 입니다.", min = 1, max = 100) - val introduce: String, - val contact: String, -) diff --git a/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateMaleRequestDto.kt b/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateRequestDto.kt similarity index 78% rename from src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateMaleRequestDto.kt rename to src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateRequestDto.kt index 3f1d1b4..c2080b6 100644 --- a/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateMaleRequestDto.kt +++ b/src/main/kotlin/com/yourssu/ssudateserver/dto/request/UpdateRequestDto.kt @@ -1,11 +1,9 @@ package com.yourssu.ssudateserver.dto.request import com.yourssu.ssudateserver.enums.MBTI -import com.yourssu.ssudateserver.enums.MaleAnimals import javax.validation.constraints.Size -data class UpdateMaleRequestDto( - val animals: MaleAnimals, +data class UpdateRequestDto( @field:Size(message = "닉네임은 최대 9글자 입니다.", min = 1, max = 9) val nickName: String, val mbti: MBTI, diff --git a/src/main/kotlin/com/yourssu/ssudateserver/entity/User.kt b/src/main/kotlin/com/yourssu/ssudateserver/entity/User.kt index 621719d..e1ab72d 100644 --- a/src/main/kotlin/com/yourssu/ssudateserver/entity/User.kt +++ b/src/main/kotlin/com/yourssu/ssudateserver/entity/User.kt @@ -25,7 +25,7 @@ class User( @field:Column(name = "animals") @field:Enumerated(EnumType.STRING) - var animals: Animals, + val animals: Animals, @field:Column(name = "mbti") @field:Enumerated(EnumType.STRING) @@ -64,13 +64,11 @@ class User( val createdAt: LocalDateTime, ) { fun updateInfo( - animals: Animals, nickName: String, mbti: MBTI, introduce: String, contact: String, ): User { - this.animals = animals this.nickName = nickName this.mbti = mbti this.introduce = introduce diff --git a/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt b/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt index 92b2b12..a151c10 100644 --- a/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt +++ b/src/main/kotlin/com/yourssu/ssudateserver/service/UserService.kt @@ -120,7 +120,6 @@ class UserService( @Transactional fun updateUserInfo( - animals: Animals, nickName: String, mbti: MBTI, introduce: String, @@ -135,7 +134,6 @@ class UserService( } val updatedUser = user.updateInfo( - animals = animals, nickName = nickName, mbti = mbti, introduce = introduce,