-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : UserImage 엔티티, 도메인 * feat : 프로필 수정 API * feat : 프로필 수정 usecase 구현 * feat : 닉네임 중복 체크 쿼리(본인 제외한 중복) * feat : test 코드 의존 클래스 추가
- Loading branch information
1 parent
22772a0
commit 223496e
Showing
17 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
adapters/in-web/src/main/kotlin/com/pokit/user/dto/request/UpdateProfileRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.pokit.user.dto.request | ||
|
||
import jakarta.validation.constraints.NotBlank | ||
import jakarta.validation.constraints.Size | ||
|
||
data class UpdateProfileRequest( | ||
val profileImageId: Int, | ||
@field:NotBlank(message = "닉네임은 필수값입니다.") | ||
@field:Size(max = 10, message = "닉네임은 10자 이하만 가능합니다.") | ||
val nickname: String | ||
) | ||
|
||
internal fun UpdateProfileRequest.toDto() = UserCommand( | ||
profileImageId = this.profileImageId, | ||
nickname = this.nickname | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...s/out-persistence/src/main/kotlin/com/pokit/out/persistence/user/impl/UserImageAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.pokit.out.persistence.user.impl | ||
|
||
import com.pokit.out.persistence.user.persist.UserImageRepository | ||
import com.pokit.out.persistence.user.persist.toDomain | ||
import com.pokit.user.model.UserImage | ||
import com.pokit.user.port.out.UserImagePort | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.stereotype.Repository | ||
|
||
@Repository | ||
class UserImageAdapter( | ||
private val userImageRepository: UserImageRepository | ||
) : UserImagePort { | ||
override fun loadById(id: Int): UserImage? { | ||
return userImageRepository.findByIdOrNull(id) | ||
?.toDomain() | ||
} | ||
|
||
override fun loadAll(): List<UserImage> { | ||
return userImageRepository.findAll() | ||
.map { it.toDomain() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...out-persistence/src/main/kotlin/com/pokit/out/persistence/user/persist/UserImageEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.pokit.out.persistence.user.persist | ||
|
||
import com.pokit.user.model.UserImage | ||
import jakarta.persistence.* | ||
|
||
@Table(name = "USER_IMAGE") | ||
@Entity | ||
class UserImageEntity( | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id") | ||
val id: Int = 0, | ||
|
||
@Column(name = "url") | ||
val url: String | ||
) { | ||
companion object { | ||
fun of(userImage: UserImage) = | ||
UserImageEntity( | ||
id = userImage.id, | ||
url = userImage.url | ||
) | ||
} | ||
} | ||
|
||
fun UserImageEntity.toDomain() = UserImage(this.id, this.url) |
6 changes: 6 additions & 0 deletions
6
...persistence/src/main/kotlin/com/pokit/out/persistence/user/persist/UserImageRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.pokit.out.persistence.user.persist | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface UserImageRepository : JpaRepository<UserImageEntity, Int> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
application/src/main/kotlin/com/pokit/user/port/out/UserImagePort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.pokit.user.port.out | ||
|
||
import com.pokit.user.model.UserImage | ||
|
||
interface UserImagePort { | ||
fun loadById(id: Int): UserImage? | ||
|
||
fun loadAll(): List<UserImage> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
domain/src/main/kotlin/com/pokit/user/dto/request/UserCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.pokit.user.dto.request | ||
|
||
data class UserCommand( | ||
val profileImageId: Int, | ||
val nickname: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.pokit.user.model | ||
|
||
data class UserImage( | ||
val id: Int, | ||
val url: String | ||
) |