From 1a1374591921adac895f064972feb29362f61594 Mon Sep 17 00:00:00 2001 From: hyun98 Date: Sat, 18 Nov 2023 20:19:19 +0900 Subject: [PATCH] fix: apply pr's comments --- .../kotlin/joryu/sns_service/channel/entity/Channel.kt | 9 +++++---- .../joryu/sns_service/channel/entity/ChannelProfile.kt | 5 +++-- .../sns_service/chat/controller/ChatMessageController.kt | 1 - .../kotlin/joryu/sns_service/chat/dto/ChatMessage.kt | 2 +- .../kotlin/joryu/sns_service/profile/entity/Profile.kt | 5 +++-- .../joryu/sns_service/profile/service/ProfileService.kt | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/Channel.kt b/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/Channel.kt index a92a539..d4f8daf 100755 --- a/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/Channel.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/Channel.kt @@ -15,20 +15,21 @@ class Channel( val channelType: ChannelType = ChannelType.PERSONAL ) : Serializable { @Id + @Column(name = "channel_id") val id: String = UUID.randomUUID().toString() @OneToMany(mappedBy = "channel") - val channelUsers: MutableList = mutableListOf() + val channelProfiles: MutableList = mutableListOf() @Column(name = "channel_name") var channelName: String = channelName private set - fun changeChannelName(newName: String) { + fun updateChannelName(newName: String) { channelName = newName } - fun addUserToChannel(user: ChannelProfile) { - channelUsers.add(user) + fun addProfileToChannel(profile: ChannelProfile) { + channelProfiles.add(profile) } } \ No newline at end of file diff --git a/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/ChannelProfile.kt b/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/ChannelProfile.kt index ec7a38f..2679b9c 100755 --- a/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/ChannelProfile.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/channel/entity/ChannelProfile.kt @@ -9,13 +9,14 @@ import java.io.Serializable class ChannelProfile( @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "channel_id") - var channel: Channel? = null, + val channel: Channel = Channel(), @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "profile_id") - var profile: Profile? = null + val profile: Profile = Profile() ): Serializable { @Id + @Column(name = "channel_profile_id") @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long = 0 } diff --git a/sns_service/src/main/kotlin/joryu/sns_service/chat/controller/ChatMessageController.kt b/sns_service/src/main/kotlin/joryu/sns_service/chat/controller/ChatMessageController.kt index 469f8bf..b21909d 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/chat/controller/ChatMessageController.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/chat/controller/ChatMessageController.kt @@ -9,7 +9,6 @@ import org.springframework.stereotype.Controller class ChatMessageController( private val chatPublisher: ChatPublisher ) { - /** * /pub/chat/message 로 들어오는 메시징을 처리한다. */ diff --git a/sns_service/src/main/kotlin/joryu/sns_service/chat/dto/ChatMessage.kt b/sns_service/src/main/kotlin/joryu/sns_service/chat/dto/ChatMessage.kt index ca0baea..176ba33 100644 --- a/sns_service/src/main/kotlin/joryu/sns_service/chat/dto/ChatMessage.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/chat/dto/ChatMessage.kt @@ -2,6 +2,6 @@ package joryu.sns_service.chat.dto data class ChatMessage( val channelId: String, - val sender: String, + val senderProfileId: String, val content: String = "", ) diff --git a/sns_service/src/main/kotlin/joryu/sns_service/profile/entity/Profile.kt b/sns_service/src/main/kotlin/joryu/sns_service/profile/entity/Profile.kt index 4c7fec2..bd8cbcc 100755 --- a/sns_service/src/main/kotlin/joryu/sns_service/profile/entity/Profile.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/profile/entity/Profile.kt @@ -1,6 +1,7 @@ package joryu.sns_service.profile.entity import jakarta.persistence.* +import joryu.sns_service.channel.entity.Channel import joryu.sns_service.channel.entity.ChannelProfile import joryu.sns_service.common.entity.BaseEntity import joryu.sns_service.follow.entity.Follow @@ -44,8 +45,8 @@ class Profile( this.followingNumber++ } - fun addChannel(channelProfile: ChannelProfile) { - channelProfiles.add(channelProfile) + fun addChannel(channel: Channel) { + channelProfiles.add(ChannelProfile(channel, this)) } } diff --git a/sns_service/src/main/kotlin/joryu/sns_service/profile/service/ProfileService.kt b/sns_service/src/main/kotlin/joryu/sns_service/profile/service/ProfileService.kt index 7b838d9..3409a2e 100755 --- a/sns_service/src/main/kotlin/joryu/sns_service/profile/service/ProfileService.kt +++ b/sns_service/src/main/kotlin/joryu/sns_service/profile/service/ProfileService.kt @@ -41,7 +41,7 @@ class ProfileService( @Transactional(readOnly = true) fun findAllByIdIn(ids: List): List { return profileRepository.findAllByIdIn(ids) - .map { p -> ProfileInfoResponse(p) } + .map { profile -> ProfileInfoResponse(profile) } } @Transactional