Skip to content

Commit

Permalink
fix: apply pr's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun98 committed Nov 18, 2023
1 parent 6ee662b commit 1a13745
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChannelProfile> = mutableListOf()
val channelProfiles: MutableList<ChannelProfile> = 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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.springframework.stereotype.Controller
class ChatMessageController(
private val chatPublisher: ChatPublisher
) {

/**
* /pub/chat/message 로 들어오는 메시징을 처리한다.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
)
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -44,8 +45,8 @@ class Profile(
this.followingNumber++
}

fun addChannel(channelProfile: ChannelProfile) {
channelProfiles.add(channelProfile)
fun addChannel(channel: Channel) {
channelProfiles.add(ChannelProfile(channel, this))
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ProfileService(
@Transactional(readOnly = true)
fun findAllByIdIn(ids: List<Long>): List<ProfileInfoResponse> {
return profileRepository.findAllByIdIn(ids)
.map { p -> ProfileInfoResponse(p) }
.map { profile -> ProfileInfoResponse(profile) }
}

@Transactional
Expand Down

0 comments on commit 1a13745

Please sign in to comment.