redis를 이전하기 위해 설정했던 모든 커밋 Revert
This commit is contained in:
		| @@ -2,12 +2,17 @@ package kr.co.vividnext.sodalive.admin.calculate | ||||
|  | ||||
| import kr.co.vividnext.sodalive.creator.admin.calculate.GetCreatorCalculateCommunityPostResponse | ||||
| import kr.co.vividnext.sodalive.extensions.convertLocalDateTime | ||||
| import org.springframework.cache.annotation.Cacheable | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
|  | ||||
| @Service | ||||
| class AdminCalculateService(private val repository: AdminCalculateQueryRepository) { | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'calculateLive:' + " + "#startDateStr + ':' + #endDateStr" | ||||
|     ) | ||||
|     fun getCalculateLive(startDateStr: String, endDateStr: String): List<GetCalculateLiveResponse> { | ||||
|         val startDate = startDateStr.convertLocalDateTime() | ||||
|         val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59) | ||||
| @@ -18,6 +23,10 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'calculateContent:' + " + "#startDateStr + ':' + #endDateStr" | ||||
|     ) | ||||
|     fun getCalculateContentList(startDateStr: String, endDateStr: String): List<GetCalculateContentResponse> { | ||||
|         val startDate = startDateStr.convertLocalDateTime() | ||||
|         val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59) | ||||
| @@ -28,6 +37,10 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'cumulativeSalesByContent:' + " + "#offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getCumulativeSalesByContent(offset: Long, limit: Long): GetCumulativeSalesByContentResponse { | ||||
|         val totalCount = repository.getCumulativeSalesByContentTotalCount() | ||||
|         val items = repository | ||||
| @@ -38,6 +51,10 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'calculateContentDonationList2:' + " + "#startDateStr + ':' + #endDateStr" | ||||
|     ) | ||||
|     fun getCalculateContentDonationList( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String | ||||
| @@ -51,6 +68,10 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'calculateCommunityPost:' + " + "#startDateStr + ':' + #endDateStr + ':' + #offset" | ||||
|     ) | ||||
|     fun getCalculateCommunityPost( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String, | ||||
|   | ||||
| @@ -20,8 +20,8 @@ import kr.co.vividnext.sodalive.live.recommend.RecommendLiveCreatorBannerReposit | ||||
| import kr.co.vividnext.sodalive.live.reservation.LiveReservationRepository | ||||
| import kr.co.vividnext.sodalive.live.room.cancel.LiveRoomCancel | ||||
| import kr.co.vividnext.sodalive.live.room.cancel.LiveRoomCancelRepository | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.LiveRoomInfoRedisRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.context.ApplicationEventPublisher | ||||
| @@ -37,7 +37,7 @@ import java.time.format.DateTimeFormatter | ||||
| @Service | ||||
| class AdminLiveService( | ||||
|     private val recommendCreatorBannerRepository: RecommendLiveCreatorBannerRepository, | ||||
|     private val roomInfoRepository: LiveRoomInfoRedisRepositoryV2, | ||||
|     private val roomInfoRepository: LiveRoomInfoRedisRepository, | ||||
|     private val roomCancelRepository: LiveRoomCancelRepository, | ||||
|     private val repository: AdminLiveRoomQueryRepository, | ||||
|     private val memberRepository: MemberRepository, | ||||
|   | ||||
| @@ -1,18 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.configs | ||||
|  | ||||
| import org.springframework.context.annotation.ComponentScan | ||||
| import org.springframework.context.annotation.Configuration | ||||
| import org.springframework.context.annotation.FilterType | ||||
| import org.springframework.data.jpa.repository.config.EnableJpaRepositories | ||||
|  | ||||
| @Configuration | ||||
| @EnableJpaRepositories( | ||||
|     basePackages = ["kr.co.vividnext.sodalive"], | ||||
|     includeFilters = [ | ||||
|         ComponentScan.Filter( | ||||
|             type = FilterType.ASSIGNABLE_TYPE, | ||||
|             classes = [org.springframework.data.jpa.repository.JpaRepository::class] | ||||
|         ) | ||||
|     ] | ||||
| ) | ||||
| class JpaConfig | ||||
| @@ -1,36 +1,32 @@ | ||||
| package kr.co.vividnext.sodalive.configs | ||||
|  | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.cache.annotation.EnableCaching | ||||
| import org.springframework.context.annotation.Bean | ||||
| import org.springframework.context.annotation.ComponentScan | ||||
| import org.springframework.context.annotation.Configuration | ||||
| import org.springframework.context.annotation.FilterType | ||||
| import org.springframework.data.redis.cache.RedisCacheConfiguration | ||||
| import org.springframework.data.redis.cache.RedisCacheManager | ||||
| import org.springframework.data.redis.connection.RedisConnectionFactory | ||||
| import org.springframework.data.redis.connection.RedisStandaloneConfiguration | ||||
| import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration | ||||
| import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory | ||||
| import org.springframework.data.redis.core.RedisTemplate | ||||
| import org.springframework.data.redis.core.StringRedisTemplate | ||||
| import org.springframework.data.redis.repository.configuration.EnableRedisRepositories | ||||
| import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer | ||||
| import org.springframework.data.redis.serializer.RedisSerializationContext | ||||
| import org.springframework.data.redis.serializer.StringRedisSerializer | ||||
| import java.time.Duration | ||||
|  | ||||
| @Configuration | ||||
| @EnableRedisRepositories( | ||||
|     basePackages = ["kr.co.vividnext.sodalive.redis.v1"], | ||||
|     redisTemplateRef = "redisTemplate", | ||||
|     excludeFilters = [ | ||||
|         ComponentScan.Filter( | ||||
|             type = FilterType.ASSIGNABLE_TYPE, | ||||
|             classes = [org.springframework.data.jpa.repository.JpaRepository::class] | ||||
|         ) | ||||
|     ] | ||||
| ) | ||||
| @EnableCaching | ||||
| @EnableRedisRepositories | ||||
| class RedisConfig( | ||||
|     @Value("\${spring.redis.host}") | ||||
|     private val host: String, | ||||
|     @Value("\${spring.redis.port}") | ||||
|     private val port: Int | ||||
| ) { | ||||
|     @Bean(name = ["redisConnectionFactory"]) | ||||
|     @Bean | ||||
|     fun redisConnectionFactory(): RedisConnectionFactory { | ||||
|         val clientConfiguration = LettuceClientConfiguration.builder() | ||||
|             .useSsl() | ||||
| @@ -40,15 +36,53 @@ class RedisConfig( | ||||
|         return LettuceConnectionFactory(RedisStandaloneConfiguration(host, port), clientConfiguration) | ||||
|     } | ||||
|  | ||||
|     @Bean(name = ["redisTemplate"]) | ||||
|     @Bean | ||||
|     fun redisTemplate(): RedisTemplate<*, *> { | ||||
|         val redisTemplate: RedisTemplate<*, *> = RedisTemplate<Any, Any>() | ||||
|         redisTemplate.setConnectionFactory(redisConnectionFactory()) | ||||
|         return redisTemplate | ||||
|     } | ||||
|  | ||||
|     @Bean(name = ["redisStringRedisTemplate"]) | ||||
|     fun redisStringRedisTemplate(): StringRedisTemplate { | ||||
|         return StringRedisTemplate(redisConnectionFactory()) | ||||
|     @Bean | ||||
|     fun cacheManager(redisConnectionFactory: RedisConnectionFactory): RedisCacheManager { | ||||
|         val defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig() | ||||
|             .entryTtl(Duration.ofMinutes(30)) | ||||
|             .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) | ||||
|             .serializeValuesWith( | ||||
|                 RedisSerializationContext.SerializationPair.fromSerializer( | ||||
|                     GenericJackson2JsonRedisSerializer() | ||||
|                 ) | ||||
|             ) | ||||
|  | ||||
|         val cacheConfigMap = mutableMapOf<String, RedisCacheConfiguration>() | ||||
|         cacheConfigMap["default"] = RedisCacheConfiguration.defaultCacheConfig() | ||||
|             .entryTtl(Duration.ofMinutes(30)) | ||||
|             .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) | ||||
|             .serializeValuesWith( | ||||
|                 RedisSerializationContext.SerializationPair.fromSerializer( | ||||
|                     GenericJackson2JsonRedisSerializer() | ||||
|                 ) | ||||
|             ) | ||||
|         cacheConfigMap["cache_ttl_3_days"] = RedisCacheConfiguration.defaultCacheConfig() | ||||
|             .entryTtl(Duration.ofDays(3)) | ||||
|             .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) | ||||
|             .serializeValuesWith( | ||||
|                 RedisSerializationContext.SerializationPair.fromSerializer( | ||||
|                     GenericJackson2JsonRedisSerializer() | ||||
|                 ) | ||||
|             ) | ||||
|         cacheConfigMap["cache_ttl_3_hours"] = RedisCacheConfiguration.defaultCacheConfig() | ||||
|             .entryTtl(Duration.ofHours(3)) | ||||
|             .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(StringRedisSerializer())) | ||||
|             .serializeValuesWith( | ||||
|                 RedisSerializationContext.SerializationPair.fromSerializer( | ||||
|                     GenericJackson2JsonRedisSerializer() | ||||
|                 ) | ||||
|             ) | ||||
|  | ||||
|         return RedisCacheManager.builder(redisConnectionFactory) | ||||
|             .cacheDefaults(defaultCacheConfig) | ||||
|             .withInitialCacheConfigurations(cacheConfigMap) | ||||
|             .build() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,60 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.configs | ||||
|  | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.context.annotation.Bean | ||||
| import org.springframework.context.annotation.ComponentScan | ||||
| import org.springframework.context.annotation.Configuration | ||||
| import org.springframework.context.annotation.FilterType | ||||
| import org.springframework.data.redis.connection.RedisClusterConfiguration | ||||
| import org.springframework.data.redis.connection.RedisConnectionFactory | ||||
| import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration | ||||
| import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory | ||||
| import org.springframework.data.redis.core.RedisTemplate | ||||
| import org.springframework.data.redis.core.StringRedisTemplate | ||||
| import org.springframework.data.redis.repository.configuration.EnableRedisRepositories | ||||
| import java.time.Duration | ||||
|  | ||||
| @Configuration | ||||
| @EnableRedisRepositories( | ||||
|     basePackages = ["kr.co.vividnext.sodalive.redis.v2"], | ||||
|     redisTemplateRef = "valkeyTemplate", | ||||
|     excludeFilters = [ | ||||
|         ComponentScan.Filter( | ||||
|             type = FilterType.ASSIGNABLE_TYPE, | ||||
|             classes = [org.springframework.data.jpa.repository.JpaRepository::class] | ||||
|         ) | ||||
|     ] | ||||
| ) | ||||
| class ValkeyConfig( | ||||
|     @Value("\${spring.valkey.host}") | ||||
|     private val host: String, | ||||
|     @Value("\${spring.valkey.port}") | ||||
|     private val port: Int | ||||
| ) { | ||||
|     @Bean(name = ["valkeyConnectionFactory"]) | ||||
|     fun valkeyConnectionFactory(): RedisConnectionFactory { | ||||
|         val clusterConfig = RedisClusterConfiguration() | ||||
|         clusterConfig.clusterNode(host, port) | ||||
|  | ||||
|         val clientConfig = LettuceClientConfiguration.builder() | ||||
|             .commandTimeout(Duration.ofSeconds(5)) | ||||
|             .shutdownTimeout(Duration.ofSeconds(5)) | ||||
|             .useSsl() | ||||
|             .disablePeerVerification() | ||||
|             .build() | ||||
|  | ||||
|         return LettuceConnectionFactory(clusterConfig, clientConfig) | ||||
|     } | ||||
|  | ||||
|     @Bean(name = ["valkeyTemplate"]) | ||||
|     fun valkeyTemplate(): RedisTemplate<*, *> { | ||||
|         val redisTemplate: RedisTemplate<*, *> = RedisTemplate<Any, Any>() | ||||
|         redisTemplate.setConnectionFactory(valkeyConnectionFactory()) | ||||
|         return redisTemplate | ||||
|     } | ||||
|  | ||||
|     @Bean(name = ["valkeyStringRedisTemplate"]) | ||||
|     fun valkeyStringRedisTemplate(): StringRedisTemplate { | ||||
|         return StringRedisTemplate(valkeyConnectionFactory()) | ||||
|     } | ||||
| } | ||||
| @@ -28,6 +28,7 @@ import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.cache.annotation.Cacheable | ||||
| import org.springframework.context.ApplicationEventPublisher | ||||
| import org.springframework.data.repository.findByIdOrNull | ||||
| import org.springframework.stereotype.Service | ||||
| @@ -716,6 +717,11 @@ class AudioContentService( | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_days"], | ||||
|         key = "'contentRanking:' + ':' +" + | ||||
|             "#isAdult + ':' + #startDate + ':' + #endDate + ':' + #sortType + ':' + #offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getAudioContentRanking( | ||||
|         isAdult: Boolean, | ||||
|         startDate: LocalDateTime, | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.event.EventItem | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.cache.annotation.Cacheable | ||||
| import org.springframework.data.domain.Pageable | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
| @@ -26,6 +27,7 @@ class AudioContentMainService( | ||||
|     private val imageHost: String | ||||
| ) { | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable(cacheNames = ["default"], key = "'themeList:' + ':' + #isAdult") | ||||
|     fun getThemeList(isAdult: Boolean): List<String> { | ||||
|         return audioContentThemeRepository.getActiveThemeOfContent(isAdult = isAdult) | ||||
|     } | ||||
| @@ -79,6 +81,7 @@ class AudioContentMainService( | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable(cacheNames = ["default"], key = "'newContentUploadCreatorList:' + #memberId + ':' + #isAdult") | ||||
|     fun getNewContentUploadCreatorList(memberId: Long, isAdult: Boolean): List<GetNewContentUploadCreator> { | ||||
|         return repository.getNewContentUploadCreatorList( | ||||
|             cloudfrontHost = imageHost, | ||||
| @@ -90,6 +93,7 @@ class AudioContentMainService( | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable(cacheNames = ["default"], key = "'contentMainBannerList:' + #memberId + ':' + #isAdult") | ||||
|     fun getAudioContentMainBannerList(memberId: Long, isAdult: Boolean) = | ||||
|         repository.getAudioContentMainBannerList(isAdult = isAdult) | ||||
|             .asSequence() | ||||
| @@ -152,6 +156,11 @@ class AudioContentMainService( | ||||
|             .toList() | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["default"], | ||||
|         key = "'getAudioContentCurationListWithPaging:' + #memberId + ':' + #isAdult + ':' + #contentType" + | ||||
|             "+ ':' + #offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getAudioContentCurationListWithPaging( | ||||
|         memberId: Long, | ||||
|         isAdult: Boolean, | ||||
|   | ||||
| @@ -4,12 +4,17 @@ import kr.co.vividnext.sodalive.admin.calculate.GetCalculateLiveResponse | ||||
| import kr.co.vividnext.sodalive.admin.calculate.GetCumulativeSalesByContentResponse | ||||
| import kr.co.vividnext.sodalive.extensions.convertLocalDateTime | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.cache.annotation.Cacheable | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
|  | ||||
| @Service | ||||
| class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) { | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["default"], | ||||
|         key = "'creatorCalculateLive:v20240403_01:' + " + "#member + ':' + #startDateStr + ':' + #endDateStr" | ||||
|     ) | ||||
|     fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List<GetCalculateLiveResponse> { | ||||
|         val startDate = startDateStr.convertLocalDateTime() | ||||
|         val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59) | ||||
| @@ -20,6 +25,11 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'creatorCalculateContentList:v20240403_01:' + " + | ||||
|             "#startDateStr + ':' + #endDateStr + ':' + #memberId + ':' + #offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getCalculateContentList( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String, | ||||
| @@ -38,6 +48,10 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'creatorCumulativeSalesByContent:' + " + "#memberId + ':' + #offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getCumulativeSalesByContent(memberId: Long, offset: Long, limit: Long): GetCumulativeSalesByContentResponse { | ||||
|         val totalCount = repository.getCumulativeSalesByContentTotalCount(memberId) | ||||
|         val items = repository | ||||
| @@ -48,6 +62,11 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'creatorCalculateContentDonationList2:' + " + | ||||
|             "#startDateStr + ':' + #endDateStr + ':' + #memberId + ':' + #offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getCalculateContentDonationList( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String, | ||||
| @@ -67,6 +86,11 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate | ||||
|     } | ||||
|  | ||||
|     @Transactional(readOnly = true) | ||||
|     @Cacheable( | ||||
|         cacheNames = ["cache_ttl_3_hours"], | ||||
|         key = "'creatorCalculateCommunityPost:' + " + | ||||
|             "#startDateStr + ':' + #endDateStr + ':' + #memberId + ':' + #offset + ':' + #limit" | ||||
|     ) | ||||
|     fun getCalculateCommunityPost( | ||||
|         startDateStr: String, | ||||
|         endDateStr: String, | ||||
|   | ||||
| @@ -7,9 +7,7 @@ import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.member.MemberRole | ||||
| import kr.co.vividnext.sodalive.member.login.LoginRequest | ||||
| import kr.co.vividnext.sodalive.member.login.LoginResponse | ||||
| import kr.co.vividnext.sodalive.member.token.MemberToken | ||||
| import kr.co.vividnext.sodalive.redis.v1.MemberTokenRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.MemberTokenRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.member.token.MemberTokenRepository | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.data.repository.findByIdOrNull | ||||
| import org.springframework.security.authentication.UsernamePasswordAuthenticationToken | ||||
| @@ -24,7 +22,6 @@ import kotlin.concurrent.write | ||||
| class CreatorAdminMemberService( | ||||
|     private val repository: MemberRepository, | ||||
|     private val tokenRepository: MemberTokenRepository, | ||||
|     private val tokenRepositoryV2: MemberTokenRepositoryV2, | ||||
|     private val tokenProvider: TokenProvider, | ||||
|     private val authenticationManagerBuilder: AuthenticationManagerBuilder, | ||||
|  | ||||
| @@ -50,30 +47,14 @@ class CreatorAdminMemberService( | ||||
|  | ||||
|         val lock = getOrCreateLock(memberId = memberId) | ||||
|         lock.write { | ||||
|             val memberToken = saveAndGetTokenById(memberId) | ||||
|             val memberToken = tokenRepository.findByIdOrNull(memberId) | ||||
|                 ?: throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|             if (memberToken != null) { | ||||
|                 memberToken.tokenSet.remove(token) | ||||
|                 tokenRepositoryV2.save(memberToken) | ||||
|             } | ||||
|             memberToken.tokenSet.remove(token) | ||||
|             tokenRepository.save(memberToken) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun saveAndGetTokenById(id: Long): MemberToken? { | ||||
|         var memberToken = tokenRepositoryV2.findByIdOrNull(id = id) | ||||
|  | ||||
|         if (memberToken == null) { | ||||
|             memberToken = tokenRepository.findByIdOrNull(id = id) | ||||
|  | ||||
|             if (memberToken != null) { | ||||
|                 tokenRepositoryV2.save(memberToken) | ||||
|                 tokenRepository.delete(memberToken) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return memberToken | ||||
|     } | ||||
|  | ||||
|     private fun login(email: String, password: String): LoginResponse { | ||||
|         val member = repository.findByEmail(email = email) ?: throw SodaException("로그인 정보를 확인해주세요.") | ||||
|         if (!member.isActive) { | ||||
|   | ||||
| @@ -12,8 +12,7 @@ import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.member.MemberAdapter | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.member.token.MemberToken | ||||
| import kr.co.vividnext.sodalive.redis.v1.MemberTokenRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.MemberTokenRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.member.token.MemberTokenRepository | ||||
| import org.slf4j.LoggerFactory | ||||
| import org.springframework.beans.factory.InitializingBean | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| @@ -36,8 +35,7 @@ class TokenProvider( | ||||
|     @Value("\${jwt.token-validity-in-seconds}") | ||||
|     private val tokenValidityInSeconds: Long, | ||||
|     private val repository: MemberRepository, | ||||
|     private val tokenRepository: MemberTokenRepository, | ||||
|     private val tokenRepositoryV2: MemberTokenRepositoryV2 | ||||
|     private val tokenRepository: MemberTokenRepository | ||||
| ) : InitializingBean { | ||||
|  | ||||
|     private val logger = LoggerFactory.getLogger(TokenProvider::class.java) | ||||
| @@ -67,11 +65,11 @@ class TokenProvider( | ||||
|  | ||||
|         val lock = getOrCreateLock(memberId = memberId) | ||||
|         lock.write { | ||||
|             val memberToken = saveAndGetTokenById(memberId) | ||||
|             val memberToken = tokenRepository.findByIdOrNull(memberId) | ||||
|                 ?: MemberToken(id = memberId) | ||||
|  | ||||
|             memberToken.tokenSet.add(token) | ||||
|             tokenRepositoryV2.save(memberToken) | ||||
|             tokenRepository.save(memberToken) | ||||
|         } | ||||
|  | ||||
|         return token | ||||
| @@ -86,7 +84,7 @@ class TokenProvider( | ||||
|             .body | ||||
|  | ||||
|         val authorities = claims[AUTHORITIES_KEY].toString().split(",").map { SimpleGrantedAuthority(it) } | ||||
|         val memberToken = saveAndGetTokenById(id = claims.subject.toLong()) | ||||
|         val memberToken = tokenRepository.findByIdOrNull(id = claims.subject.toLong()) | ||||
|             ?: throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         if (!memberToken.tokenSet.contains(token)) throw SodaException("로그인 정보를 확인해주세요.") | ||||
| @@ -98,21 +96,6 @@ class TokenProvider( | ||||
|         return UsernamePasswordAuthenticationToken(principal, token, authorities) | ||||
|     } | ||||
|  | ||||
|     private fun saveAndGetTokenById(id: Long): MemberToken? { | ||||
|         var memberToken = tokenRepositoryV2.findByIdOrNull(id = id) | ||||
|  | ||||
|         if (memberToken == null) { | ||||
|             memberToken = tokenRepository.findByIdOrNull(id = id) | ||||
|  | ||||
|             if (memberToken != null) { | ||||
|                 tokenRepositoryV2.save(memberToken) | ||||
|                 tokenRepository.delete(memberToken) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return memberToken | ||||
|     } | ||||
|  | ||||
|     fun validateToken(token: String): Boolean { | ||||
|         try { | ||||
|             Jwts.parserBuilder() | ||||
|   | ||||
| @@ -35,6 +35,8 @@ import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationMessage | ||||
| import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationRequest | ||||
| import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationResponse | ||||
| import kr.co.vividnext.sodalive.live.room.info.GetRoomInfoResponse | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfo | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomMember | ||||
| import kr.co.vividnext.sodalive.live.room.kickout.LiveRoomKickOutService | ||||
| import kr.co.vividnext.sodalive.live.room.like.GetLiveRoomHeartListResponse | ||||
| @@ -44,7 +46,7 @@ import kr.co.vividnext.sodalive.live.room.menu.CreateLiveMenuRequest | ||||
| import kr.co.vividnext.sodalive.live.room.menu.LiveRoomMenuService | ||||
| import kr.co.vividnext.sodalive.live.room.menu.UpdateLiveMenuRequest | ||||
| import kr.co.vividnext.sodalive.live.room.visit.LiveRoomVisitService | ||||
| import kr.co.vividnext.sodalive.live.roulette.NewRouletteService | ||||
| import kr.co.vividnext.sodalive.live.roulette.NewRouletteRepository | ||||
| import kr.co.vividnext.sodalive.live.signature.SignatureCanRepository | ||||
| import kr.co.vividnext.sodalive.live.tag.LiveTagRepository | ||||
| import kr.co.vividnext.sodalive.member.Gender | ||||
| @@ -52,10 +54,7 @@ import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.member.MemberRole | ||||
| import kr.co.vividnext.sodalive.member.block.BlockMemberRepository | ||||
| import kr.co.vividnext.sodalive.redis.v1.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.LiveRoomInfoRedisRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomInfoV2 | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.context.ApplicationEventPublisher | ||||
| import org.springframework.data.domain.Pageable | ||||
| @@ -76,11 +75,10 @@ import kotlin.concurrent.write | ||||
| @Transactional(readOnly = true) | ||||
| class LiveRoomService( | ||||
|     private val menuService: LiveRoomMenuService, | ||||
|     private val rouletteService: NewRouletteService, | ||||
|  | ||||
|     private val repository: LiveRoomRepository, | ||||
|     private val rouletteRepository: NewRouletteRepository, | ||||
|     private val roomInfoRepository: LiveRoomInfoRedisRepository, | ||||
|     private val roomInfoRepositoryV2: LiveRoomInfoRedisRepositoryV2, | ||||
|     private val roomCancelRepository: LiveRoomCancelRepository, | ||||
|     private val kickOutService: LiveRoomKickOutService, | ||||
|     private val blockMemberRepository: BlockMemberRepository, | ||||
| @@ -115,22 +113,6 @@ class LiveRoomService( | ||||
| ) { | ||||
|     private val tokenLocks: MutableMap<Long, ReentrantReadWriteLock> = mutableMapOf() | ||||
|  | ||||
|     private fun getLiveRoomInfo(roomId: Long): LiveRoomInfoV2? { | ||||
|         var roomInfoV2 = roomInfoRepositoryV2.findByIdOrNull(roomId) | ||||
|  | ||||
|         if (roomInfoV2 == null) { | ||||
|             val roomInfoV1 = roomInfoRepository.findByIdOrNull(roomId) | ||||
|  | ||||
|             if (roomInfoV1 != null) { | ||||
|                 roomInfoV2 = roomInfoV1.convertRoomInfoV2() | ||||
|                 roomInfoRepositoryV2.save(roomInfoV2) | ||||
|                 roomInfoRepository.delete(roomInfoV1) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return roomInfoV2 | ||||
|     } | ||||
|  | ||||
|     fun getRoomList( | ||||
|         dateString: String?, | ||||
|         status: LiveRoomStatus, | ||||
| @@ -168,7 +150,7 @@ class LiveRoomService( | ||||
|         return roomList | ||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) } | ||||
|             .map { | ||||
|                 val roomInfo = getLiveRoomInfo(it.id!!) | ||||
|                 val roomInfo = roomInfoRepository.findByIdOrNull(it.id!!) | ||||
|  | ||||
|                 val reservations = it.reservations | ||||
|                     .filter { reservation -> reservation.member!!.id!! == member.id!! && reservation.isActive } | ||||
| @@ -460,7 +442,7 @@ class LiveRoomService( | ||||
|         response.manager = GetRoomDetailManager(room.member!!, cloudFrontHost = cloudFrontHost) | ||||
|  | ||||
|         if (!room.channelName.isNullOrBlank()) { | ||||
|             val roomInfo = getLiveRoomInfo(roomId) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(roomId) | ||||
|  | ||||
|             if (roomInfo != null) { | ||||
|                 response.isPaid = canRepository.isExistPaidLiveRoom( | ||||
| @@ -669,9 +651,9 @@ class LiveRoomService( | ||||
|  | ||||
|         val lock = getOrCreateLock(memberId = member.id!!) | ||||
|         lock.write { | ||||
|             var roomInfo = getLiveRoomInfo(request.roomId) | ||||
|             var roomInfo = roomInfoRepository.findByIdOrNull(request.roomId) | ||||
|             if (roomInfo == null) { | ||||
|                 roomInfo = roomInfoRepositoryV2.save(LiveRoomInfoV2(roomId = request.roomId)) | ||||
|                 roomInfo = roomInfoRepository.save(LiveRoomInfo(roomId = request.roomId)) | ||||
|             } | ||||
|  | ||||
|             if (roomInfo.speakerCount + roomInfo.listenerCount + roomInfo.managerCount >= room.numberOfPeople) { | ||||
| @@ -710,7 +692,7 @@ class LiveRoomService( | ||||
|                 roomInfo.addListener(member, cloudFrontHost) | ||||
|             } | ||||
|  | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|             roomVisitService.roomVisit(room, member) | ||||
|         } | ||||
|     } | ||||
| @@ -807,7 +789,7 @@ class LiveRoomService( | ||||
|     } | ||||
|  | ||||
|     fun getRoomInfo(roomId: Long, member: Member): GetRoomInfoResponse { | ||||
|         val roomInfo = getLiveRoomInfo(roomId) | ||||
|         val roomInfo = roomInfoRepository.findByIdOrNull(roomId) | ||||
|             ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|         val room = repository.findByIdOrNull(roomId) | ||||
| @@ -835,7 +817,15 @@ class LiveRoomService( | ||||
|             .getNotificationUserIds(room.member!!.id!!) | ||||
|             .contains(member.id) | ||||
|  | ||||
|         val isActiveRoulette = rouletteService.hasActiveRoulette(creatorId = room.member!!.id!!) | ||||
|         var isActiveRoulette = false | ||||
|         val rouletteList = rouletteRepository.findByCreatorId(creatorId = room.member!!.id!!) | ||||
|  | ||||
|         for (roulette in rouletteList) { | ||||
|             if (roulette.isActive) { | ||||
|                 isActiveRoulette = true | ||||
|                 break | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         val donationRankingTop3UserIds = if (room.member!!.isVisibleDonationRank) { | ||||
|             explorerQueryRepository | ||||
| @@ -899,7 +889,7 @@ class LiveRoomService( | ||||
|         val liveRoomCreatorId = repository.getLiveRoomCreatorId(roomId) | ||||
|             ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|         val roomInfo = getLiveRoomInfo(roomId) | ||||
|         val roomInfo = roomInfoRepository.findByIdOrNull(roomId) | ||||
|             ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|         return if (liveRoomCreatorId != member.id!!) { | ||||
| @@ -920,18 +910,18 @@ class LiveRoomService( | ||||
|                 throw SodaException("잘못된 요청입니다.") | ||||
|             } | ||||
|  | ||||
|             val roomInfo = getLiveRoomInfo(request.roomId) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(request.roomId) | ||||
|                 ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|             roomInfo.removeDonationMessage(request.messageUUID) | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun getUserProfile(roomId: Long, userId: Long, member: Member): GetLiveRoomUserProfileResponse { | ||||
|         val room = repository.getLiveRoom(roomId) | ||||
|             ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|         val roomInfo = getLiveRoomInfo(roomId) | ||||
|         val roomInfo = roomInfoRepository.findByIdOrNull(roomId) | ||||
|             ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|         val user = memberRepository.findByIdOrNull(userId) | ||||
| @@ -1000,7 +990,7 @@ class LiveRoomService( | ||||
|     fun setSpeaker(request: SetManagerOrSpeakerOrAudienceRequest) { | ||||
|         val lock = getOrCreateLock(memberId = request.memberId) | ||||
|         lock.write { | ||||
|             val roomInfo = getLiveRoomInfo(request.roomId) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(request.roomId) | ||||
|                 ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|             val member = memberRepository.findByIdOrNull(request.memberId) | ||||
| @@ -1014,14 +1004,14 @@ class LiveRoomService( | ||||
|             roomInfo.removeManager(member) | ||||
|             roomInfo.addSpeaker(member, cloudFrontHost) | ||||
|  | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun setListener(request: SetManagerOrSpeakerOrAudienceRequest) { | ||||
|         val lock = getOrCreateLock(memberId = request.memberId) | ||||
|         lock.write { | ||||
|             val roomInfo = getLiveRoomInfo(request.roomId) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(request.roomId) | ||||
|                 ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|             val member = memberRepository.findByIdOrNull(request.memberId) | ||||
| @@ -1031,7 +1021,7 @@ class LiveRoomService( | ||||
|             roomInfo.removeManager(member) | ||||
|             roomInfo.addListener(member, cloudFrontHost) | ||||
|  | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -1044,7 +1034,7 @@ class LiveRoomService( | ||||
|             } | ||||
|  | ||||
|             val user = memberRepository.findByIdOrNull(request.memberId) ?: throw SodaException("해당하는 유저가 없습니다.") | ||||
|             val roomInfo = getLiveRoomInfo(request.roomId) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(request.roomId) | ||||
|                 ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|             val roomAccountResponse = LiveRoomMember(member = user, cloudFrontHost) | ||||
| @@ -1063,7 +1053,7 @@ class LiveRoomService( | ||||
|             roomInfo.removeSpeaker(user) | ||||
|             roomInfo.addManager(user, cloudFrontHost) | ||||
|  | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -1090,7 +1080,7 @@ class LiveRoomService( | ||||
|         if (request.message.isNotBlank()) { | ||||
|             val lock = getOrCreateLock(memberId = member.id!!) | ||||
|             lock.write { | ||||
|                 val roomInfo = getLiveRoomInfo(room.id!!) | ||||
|                 val roomInfo = roomInfoRepository.findByIdOrNull(room.id!!) | ||||
|                     ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|                 roomInfo.addDonationMessage( | ||||
| @@ -1101,7 +1091,7 @@ class LiveRoomService( | ||||
|                     donationMessage = request.message | ||||
|                 ) | ||||
|  | ||||
|                 roomInfoRepositoryV2.save(roomInfo) | ||||
|                 roomInfoRepository.save(roomInfo) | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -1136,7 +1126,7 @@ class LiveRoomService( | ||||
|         if (request.message.isNotBlank()) { | ||||
|             val lock = getOrCreateLock(memberId = member.id!!) | ||||
|             lock.write { | ||||
|                 val roomInfo = getLiveRoomInfo(room.id!!) | ||||
|                 val roomInfo = roomInfoRepository.findByIdOrNull(room.id!!) | ||||
|                     ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|                 roomInfo.addDonationMessage( | ||||
| @@ -1147,7 +1137,7 @@ class LiveRoomService( | ||||
|                     donationMessage = request.message | ||||
|                 ) | ||||
|  | ||||
|                 roomInfoRepositoryV2.save(roomInfo) | ||||
|                 roomInfoRepository.save(roomInfo) | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -1226,20 +1216,27 @@ class LiveRoomService( | ||||
|         val room = repository.getLiveRoom(roomId) | ||||
|         val lock = getOrCreateLock(memberId = member.id!!) | ||||
|         lock.write { | ||||
|             val roomInfo = getLiveRoomInfo(roomId) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(roomId) | ||||
|             if (roomInfo != null) { | ||||
|                 if (room?.member != null && room.member!! == member) { | ||||
|                     room.isActive = false | ||||
|                     kickOutService.deleteKickOutData(roomId = room.id!!) | ||||
|                     roomInfoRepositoryV2.deleteById(roomInfo.roomId) | ||||
|                     roomInfoRepository.deleteById(roomInfo.roomId) | ||||
|  | ||||
|                     val rouletteList = rouletteRepository.findByCreatorId(creatorId = member.id!!) | ||||
|                     if (rouletteList.isNotEmpty()) { | ||||
|                         rouletteList.forEach { | ||||
|                             it.isActive = false | ||||
|                             rouletteRepository.save(it) | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
|                     menuService.deactivateAll(memberId = member.id!!) | ||||
|                     rouletteService.deactivateAll(creatorId = member.id!!) | ||||
|                 } else { | ||||
|                     roomInfo.removeSpeaker(member) | ||||
|                     roomInfo.removeListener(member) | ||||
|                     roomInfo.removeManager(member) | ||||
|                     roomInfoRepositoryV2.save(roomInfo) | ||||
|                     roomInfoRepository.save(roomInfo) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.live.room.info | ||||
|  | ||||
| import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationMessage | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomInfoV2 | ||||
| import org.springframework.data.annotation.Id | ||||
| import org.springframework.data.redis.core.RedisHash | ||||
|  | ||||
| @@ -119,14 +118,4 @@ data class LiveRoomInfo( | ||||
|     fun removeDonationMessage(uuid: String) { | ||||
|         (donationMessageList as MutableList).removeIf { it.uuid == uuid } | ||||
|     } | ||||
|  | ||||
|     fun convertRoomInfoV2(): LiveRoomInfoV2 { | ||||
|         return LiveRoomInfoV2( | ||||
|             roomId = roomId, | ||||
|             speakerList = speakerList, | ||||
|             listenerList = listenerList, | ||||
|             managerList = managerList, | ||||
|             donationMessageList = donationMessageList | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v1 | ||||
| package kr.co.vividnext.sodalive.live.room.info | ||||
| 
 | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfo | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| 
 | ||||
| interface LiveRoomInfoRedisRepository : CrudRepository<LiveRoomInfo, Long> | ||||
| @@ -1,6 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.live.room.kickout | ||||
|  | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomKickOutV2 | ||||
| import org.springframework.data.annotation.Id | ||||
| import org.springframework.data.redis.core.RedisHash | ||||
|  | ||||
| @@ -21,13 +20,6 @@ data class LiveRoomKickOut( | ||||
|         userList.removeIf { it.userId == userId } | ||||
|         userList.add(liveRoomKickOutUser) | ||||
|     } | ||||
|  | ||||
|     fun convertV2(): LiveRoomKickOutV2 { | ||||
|         return LiveRoomKickOutV2( | ||||
|             roomId = roomId, | ||||
|             userList = userList | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|  | ||||
| data class LiveRoomKickOutUser( | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v1 | ||||
| package kr.co.vividnext.sodalive.live.room.kickout | ||||
| 
 | ||||
| import kr.co.vividnext.sodalive.live.room.kickout.LiveRoomKickOut | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| 
 | ||||
| interface LiveRoomKickOutRedisRepository : CrudRepository<LiveRoomKickOut, Long> | ||||
| @@ -2,15 +2,10 @@ package kr.co.vividnext.sodalive.live.room.kickout | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.room.LiveRoomRepository | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomMember | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.redis.v1.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.redis.v1.LiveRoomKickOutRedisRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.LiveRoomInfoRedisRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.redis.v2.LiveRoomKickOutRedisRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomInfoV2 | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomKickOutV2 | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| import org.springframework.data.repository.findByIdOrNull | ||||
| import org.springframework.stereotype.Service | ||||
| @@ -18,52 +13,18 @@ import org.springframework.stereotype.Service | ||||
| @Service | ||||
| class LiveRoomKickOutService( | ||||
|     private val roomInfoRepository: LiveRoomInfoRedisRepository, | ||||
|     private val roomInfoRepositoryV2: LiveRoomInfoRedisRepositoryV2, | ||||
|     private val repository: LiveRoomKickOutRedisRepository, | ||||
|     private val repositoryV2: LiveRoomKickOutRedisRepositoryV2, | ||||
|     private val memberRepository: MemberRepository, | ||||
|     private val roomRepository: LiveRoomRepository, | ||||
|  | ||||
|     @Value("\${cloud.aws.cloud-front.host}") | ||||
|     private val cloudFrontHost: String | ||||
| ) { | ||||
|     private fun getLiveRoomInfo(roomId: Long): LiveRoomInfoV2? { | ||||
|         var roomInfoV2 = roomInfoRepositoryV2.findByIdOrNull(roomId) | ||||
|  | ||||
|         if (roomInfoV2 == null) { | ||||
|             val roomInfoV1 = roomInfoRepository.findByIdOrNull(roomId) | ||||
|  | ||||
|             if (roomInfoV1 != null) { | ||||
|                 roomInfoV2 = roomInfoV1.convertRoomInfoV2() | ||||
|                 roomInfoRepositoryV2.save(roomInfoV2) | ||||
|                 roomInfoRepository.delete(roomInfoV1) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return roomInfoV2 | ||||
|     } | ||||
|  | ||||
|     private fun getLiveRoomKickOut(roomId: Long): LiveRoomKickOutV2? { | ||||
|         var liveRoomKickOutV2 = repositoryV2.findByIdOrNull(roomId) | ||||
|  | ||||
|         if (liveRoomKickOutV2 == null) { | ||||
|             val liveRoomKickOutV1 = repository.findByIdOrNull(roomId) | ||||
|  | ||||
|             if (liveRoomKickOutV1 != null) { | ||||
|                 liveRoomKickOutV2 = liveRoomKickOutV1.convertV2() | ||||
|                 repositoryV2.save(liveRoomKickOutV2) | ||||
|                 repository.delete(liveRoomKickOutV1) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return liveRoomKickOutV2 | ||||
|     } | ||||
|  | ||||
|     fun kickOut(request: LiveRoomKickOutRequest, member: Member) { | ||||
|         val room = roomRepository.findByIdOrNull(request.roomId) | ||||
|             ?: throw SodaException("해당하는 라이브가 없습니다.") | ||||
|  | ||||
|         val roomInfo = getLiveRoomInfo(request.roomId) | ||||
|         val roomInfo = roomInfoRepository.findByIdOrNull(request.roomId) | ||||
|             ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|         if (room.member == null || room.member!!.id == null) { | ||||
| @@ -74,20 +35,20 @@ class LiveRoomKickOutService( | ||||
|             throw SodaException("권한이 없습니다.") | ||||
|         } | ||||
|  | ||||
|         var liveRoomKickOut = getLiveRoomKickOut(request.roomId) | ||||
|         var liveRoomKickOut = repository.findByIdOrNull(request.roomId) | ||||
|         if (liveRoomKickOut == null) { | ||||
|             liveRoomKickOut = repositoryV2.save(LiveRoomKickOutV2(roomId = request.roomId)) | ||||
|             liveRoomKickOut = repository.save(LiveRoomKickOut(roomId = request.roomId)) | ||||
|         } | ||||
|  | ||||
|         liveRoomKickOut.kickOut(request.userId) | ||||
|         repositoryV2.save(liveRoomKickOut) | ||||
|         repository.save(liveRoomKickOut) | ||||
|  | ||||
|         val kickOutUser = memberRepository.findByIdOrNull(request.userId) | ||||
|         if (kickOutUser != null) { | ||||
|             roomInfo.removeSpeaker(kickOutUser) | ||||
|             roomInfo.removeListener(kickOutUser) | ||||
|             roomInfo.removeManager(kickOutUser) | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v1 | ||||
| package kr.co.vividnext.sodalive.live.room.menu | ||||
| 
 | ||||
| import kr.co.vividnext.sodalive.live.room.menu.LiveRoomMenu | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| 
 | ||||
| interface LiveRoomMenuRepository : CrudRepository<LiveRoomMenu, Long> { | ||||
| @@ -2,49 +2,17 @@ package kr.co.vividnext.sodalive.live.room.menu | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.roulette.RedisIdGenerator | ||||
| import kr.co.vividnext.sodalive.redis.v1.LiveRoomMenuRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.LiveRoomMenuRepositoryV2 | ||||
| import org.springframework.stereotype.Service | ||||
|  | ||||
| @Service | ||||
| class LiveRoomMenuService( | ||||
|     private val idGenerator: RedisIdGenerator, | ||||
|     private val repository: LiveRoomMenuRepository, | ||||
|     private val repositoryV2: LiveRoomMenuRepositoryV2 | ||||
|     private val repository: LiveRoomMenuRepository | ||||
| ) { | ||||
|     private fun findByCreatorId(creatorId: Long): List<LiveRoomMenu> { | ||||
|         var liveRoomMenuList = repositoryV2.findByCreatorId(creatorId) | ||||
|  | ||||
|         if (liveRoomMenuList.isEmpty()) { | ||||
|             liveRoomMenuList = repository.findByCreatorId(creatorId) | ||||
|  | ||||
|             if (liveRoomMenuList.isNotEmpty()) { | ||||
|                 val newLiveRoomMenuList = liveRoomMenuList.map { liveRoomMenu -> | ||||
|                     val newLiveRoomMenu = LiveRoomMenu( | ||||
|                         id = idGenerator.generateId(SEQUENCE_NAME), | ||||
|                         creatorId = liveRoomMenu.creatorId, | ||||
|                         isActive = liveRoomMenu.isActive, | ||||
|                         menu = liveRoomMenu.menu | ||||
|                     ) | ||||
|                     repositoryV2.save(newLiveRoomMenu) | ||||
|                     repository.delete(liveRoomMenu) | ||||
|  | ||||
|                     newLiveRoomMenu | ||||
|                 } | ||||
|  | ||||
|                 return newLiveRoomMenuList | ||||
|             } else { | ||||
|                 return emptyList() | ||||
|             } | ||||
|         } else { | ||||
|             return liveRoomMenuList | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun getAllLiveMenu(creatorId: Long, memberId: Long): List<GetMenuPresetResponse> { | ||||
|         if (creatorId != memberId) throw SodaException("잘못된 요청입니다.") | ||||
|  | ||||
|         return findByCreatorId(creatorId) | ||||
|         return repository.findByCreatorId(creatorId) | ||||
|             .sortedBy { it.id } | ||||
|             .asSequence() | ||||
|             .map { GetMenuPresetResponse(id = it.id, menu = it.menu, isActive = it.isActive) } | ||||
| @@ -54,7 +22,7 @@ class LiveRoomMenuService( | ||||
|     fun createLiveMenu(memberId: Long, request: CreateLiveMenuRequest): Boolean { | ||||
|         liveMenuValidate(menu = request.menu) | ||||
|  | ||||
|         val menuList = findByCreatorId(creatorId = memberId) | ||||
|         val menuList = repository.findByCreatorId(creatorId = memberId) | ||||
|  | ||||
|         if (menuList.size >= 3) { | ||||
|             throw SodaException("메뉴판의 최대개수는 3개입니다.") | ||||
| @@ -63,7 +31,7 @@ class LiveRoomMenuService( | ||||
|         if (request.isActive) { | ||||
|             menuList.forEach { | ||||
|                 it.isActive = false | ||||
|                 repositoryV2.save(it) | ||||
|                 repository.save(it) | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -74,14 +42,14 @@ class LiveRoomMenuService( | ||||
|             menu = request.menu | ||||
|         ) | ||||
|  | ||||
|         repositoryV2.save(menu) | ||||
|         repository.save(menu) | ||||
|         return request.isActive | ||||
|     } | ||||
|  | ||||
|     fun updateLiveMenu(memberId: Long, request: UpdateLiveMenuRequest) { | ||||
|         liveMenuValidate(menu = request.menu) | ||||
|  | ||||
|         val menuList = findByCreatorId(creatorId = memberId) | ||||
|         val menuList = repository.findByCreatorId(creatorId = memberId) | ||||
|         if (menuList.isEmpty()) { | ||||
|             throw SodaException("잘못된 요청입니다.") | ||||
|         } | ||||
| @@ -90,16 +58,16 @@ class LiveRoomMenuService( | ||||
|             if (it.id == request.id) { | ||||
|                 it.menu = request.menu | ||||
|                 it.isActive = request.isActive | ||||
|                 repositoryV2.save(it) | ||||
|                 repository.save(it) | ||||
|             } else if (request.isActive) { | ||||
|                 it.isActive = false | ||||
|                 repositoryV2.save(it) | ||||
|                 repository.save(it) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun getLiveMenu(creatorId: Long): GetMenuPresetResponse? { | ||||
|         val menuList = findByCreatorId(creatorId = creatorId) | ||||
|         val menuList = repository.findByCreatorId(creatorId = creatorId) | ||||
|  | ||||
|         var activeMenu: LiveRoomMenu? = null | ||||
|         for (menu in menuList) { | ||||
| @@ -117,11 +85,11 @@ class LiveRoomMenuService( | ||||
|     } | ||||
|  | ||||
|     fun deactivateAll(memberId: Long) { | ||||
|         val menuList = findByCreatorId(creatorId = memberId) | ||||
|         val menuList = repository.findByCreatorId(creatorId = memberId) | ||||
|  | ||||
|         menuList.forEach { | ||||
|             it.isActive = false | ||||
|             repositoryV2.save(it) | ||||
|             repository.save(it) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v1 | ||||
| package kr.co.vividnext.sodalive.live.roulette | ||||
| 
 | ||||
| import kr.co.vividnext.sodalive.live.roulette.NewRoulette | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| 
 | ||||
| interface NewRouletteRepository : CrudRepository<NewRoulette, Long> { | ||||
| @@ -16,9 +16,6 @@ import kr.co.vividnext.sodalive.live.room.LiveRoomRepository | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.member.MemberRole | ||||
| import kr.co.vividnext.sodalive.redis.v1.NewRouletteRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.RouletteRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.v2.RouletteV2 | ||||
| import org.springframework.data.repository.findByIdOrNull | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
| @@ -30,43 +27,15 @@ class NewRouletteService( | ||||
|  | ||||
|     private val canRepository: CanRepository, | ||||
|     private val repository: NewRouletteRepository, | ||||
|     private val repositoryV2: RouletteRepositoryV2, | ||||
|     private val roomRepository: LiveRoomRepository, | ||||
|     private val memberRepository: MemberRepository, | ||||
|     private val chargeRepository: ChargeRepository, | ||||
|     private val useCanCalculateRepository: UseCanCalculateRepository | ||||
| ) { | ||||
|     private fun findByCreatorId(creatorId: Long): List<RouletteV2> { | ||||
|         var rouletteV2List = repositoryV2.findByCreatorId(creatorId) | ||||
|  | ||||
|         if (rouletteV2List.isEmpty()) { | ||||
|             val rouletteV1List = repository.findByCreatorId(creatorId) | ||||
|  | ||||
|             if (rouletteV1List.isNotEmpty()) { | ||||
|                 rouletteV1List.forEach { rouletteV1 -> | ||||
|                     val rouletteV2 = RouletteV2( | ||||
|                         id = idGenerator.generateId(SEQUENCE_NAME), | ||||
|                         creatorId = rouletteV1.creatorId, | ||||
|                         can = rouletteV1.can, | ||||
|                         isActive = rouletteV1.isActive, | ||||
|                         items = rouletteV1.items | ||||
|                     ) | ||||
|  | ||||
|                     repositoryV2.save(rouletteV2) | ||||
|                     repository.delete(rouletteV1) | ||||
|                 } | ||||
|  | ||||
|                 rouletteV2List = repositoryV2.findByCreatorId(creatorId) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return rouletteV2List | ||||
|     } | ||||
|  | ||||
|     fun getAllRoulette(creatorId: Long, memberId: Long): List<GetNewRouletteResponse> { | ||||
|         if (creatorId != memberId) throw SodaException("잘못된 요청입니다.") | ||||
|  | ||||
|         val rouletteList = findByCreatorId(creatorId) | ||||
|         val rouletteList = repository.findByCreatorId(creatorId) | ||||
|  | ||||
|         return rouletteList.sortedBy { it.id } | ||||
|             .map { | ||||
| @@ -83,14 +52,14 @@ class NewRouletteService( | ||||
|         rouletteValidate(can = request.can, items = request.items) | ||||
|  | ||||
|         if (request.isActive) { | ||||
|             val rouletteList = findByCreatorId(creatorId = memberId) | ||||
|             val rouletteList = repository.findByCreatorId(creatorId = memberId) | ||||
|             rouletteList.forEach { | ||||
|                 it.isActive = false | ||||
|                 repositoryV2.save(it) | ||||
|                 repository.save(it) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         val roulette = RouletteV2( | ||||
|         val roulette = NewRoulette( | ||||
|             id = idGenerator.generateId(SEQUENCE_NAME), | ||||
|             creatorId = memberId, | ||||
|             can = request.can, | ||||
| @@ -98,14 +67,14 @@ class NewRouletteService( | ||||
|             items = request.items | ||||
|         ) | ||||
|  | ||||
|         repositoryV2.save(roulette) | ||||
|         repository.save(roulette) | ||||
|         return request.isActive | ||||
|     } | ||||
|  | ||||
|     fun updateRoulette(memberId: Long, request: UpdateNewRouletteRequest): Boolean { | ||||
|         rouletteValidate(can = request.can, items = request.items) | ||||
|  | ||||
|         val rouletteList = findByCreatorId(creatorId = memberId) | ||||
|         val rouletteList = repository.findByCreatorId(creatorId = memberId) | ||||
|  | ||||
|         if (rouletteList.isEmpty()) { | ||||
|             throw SodaException("잘못된 요청입니다.") | ||||
| @@ -121,10 +90,10 @@ class NewRouletteService( | ||||
|                 it.can = request.can | ||||
|                 it.items = request.items | ||||
|                 it.isActive = request.isActive | ||||
|                 repositoryV2.save(it) | ||||
|                 repository.save(it) | ||||
|             } else if (request.isActive) { | ||||
|                 it.isActive = false | ||||
|                 repositoryV2.save(it) | ||||
|                 repository.save(it) | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -132,13 +101,13 @@ class NewRouletteService( | ||||
|     } | ||||
|  | ||||
|     fun getRoulette(creatorId: Long, memberId: Long): GetRouletteResponse { | ||||
|         val rouletteList = findByCreatorId(creatorId = creatorId) | ||||
|         val rouletteList = repository.findByCreatorId(creatorId = creatorId) | ||||
|  | ||||
|         if (rouletteList.isEmpty()) { | ||||
|             throw SodaException("룰렛을 사용할 수 없습니다.") | ||||
|         } | ||||
|  | ||||
|         var activeRoulette: RouletteV2? = null | ||||
|         var activeRoulette: NewRoulette? = null | ||||
|         for (roulette in rouletteList) { | ||||
|             if (roulette.isActive) { | ||||
|                 activeRoulette = roulette | ||||
| @@ -170,13 +139,13 @@ class NewRouletteService( | ||||
|         } | ||||
|  | ||||
|         // STEP 2 - 룰렛 데이터 가져오기 | ||||
|         val rouletteList = findByCreatorId(creatorId = host.id!!) | ||||
|         val rouletteList = repository.findByCreatorId(creatorId = host.id!!) | ||||
|  | ||||
|         if (rouletteList.isEmpty()) { | ||||
|             throw SodaException("룰렛을 사용할 수 없습니다.") | ||||
|         } | ||||
|  | ||||
|         var activeRoulette: RouletteV2? = null | ||||
|         var activeRoulette: NewRoulette? = null | ||||
|         for (roulette in rouletteList) { | ||||
|             if (roulette.isActive) { | ||||
|                 activeRoulette = roulette | ||||
| @@ -251,28 +220,7 @@ class NewRouletteService( | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun hasActiveRoulette(creatorId: Long): Boolean { | ||||
|         val rouletteList = findByCreatorId(creatorId) | ||||
|  | ||||
|         for (roulette in rouletteList) { | ||||
|             if (roulette.isActive) { | ||||
|                 return true | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return false | ||||
|     } | ||||
|  | ||||
|     fun deactivateAll(creatorId: Long) { | ||||
|         val rouletteList = findByCreatorId(creatorId) | ||||
|  | ||||
|         rouletteList.forEach { | ||||
|             it.isActive = false | ||||
|             repositoryV2.save(it) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     companion object { | ||||
|         const val SEQUENCE_NAME = "Roulette:sequence" | ||||
|         const val SEQUENCE_NAME = "newRoulette:sequence" | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,13 +1,10 @@ | ||||
| package kr.co.vividnext.sodalive.live.roulette | ||||
|  | ||||
| import org.springframework.beans.factory.annotation.Qualifier | ||||
| import org.springframework.data.redis.core.StringRedisTemplate | ||||
| import org.springframework.stereotype.Service | ||||
|  | ||||
| @Service | ||||
| class RedisIdGenerator( | ||||
|     @Qualifier("valkeyStringRedisTemplate") private val stringRedisTemplate: StringRedisTemplate | ||||
| ) { | ||||
| class RedisIdGenerator(private val stringRedisTemplate: StringRedisTemplate) { | ||||
|     fun generateId(key: String): Long { | ||||
|         return stringRedisTemplate.opsForValue().increment(key, 1) ?: 1L | ||||
|     } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v1 | ||||
| package kr.co.vividnext.sodalive.live.roulette.v2 | ||||
| 
 | ||||
| import kr.co.vividnext.sodalive.live.roulette.NewRoulette | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| @@ -13,16 +13,13 @@ import kr.co.vividnext.sodalive.can.use.UseCanCalculateRepository | ||||
| import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.live.room.LiveRoomRepository | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.live.roulette.NewRoulette | ||||
| import kr.co.vividnext.sodalive.live.roulette.RedisIdGenerator | ||||
| import kr.co.vividnext.sodalive.live.roulette.RouletteItem | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.member.MemberRepository | ||||
| import kr.co.vividnext.sodalive.member.MemberRole | ||||
| import kr.co.vividnext.sodalive.redis.v1.LiveRoomInfoRedisRepository | ||||
| import kr.co.vividnext.sodalive.redis.v1.RouletteRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.LiveRoomInfoRedisRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomInfoV2 | ||||
| import org.springframework.data.repository.findByIdOrNull | ||||
| import org.springframework.stereotype.Service | ||||
| import org.springframework.transaction.annotation.Transactional | ||||
| @@ -41,27 +38,10 @@ class RouletteService( | ||||
|     private val memberRepository: MemberRepository, | ||||
|     private val chargeRepository: ChargeRepository, | ||||
|     private val roomInfoRepository: LiveRoomInfoRedisRepository, | ||||
|     private val roomInfoRepositoryV2: LiveRoomInfoRedisRepositoryV2, | ||||
|     private val useCanCalculateRepository: UseCanCalculateRepository | ||||
| ) { | ||||
|     private val tokenLocks: MutableMap<Long, ReentrantReadWriteLock> = mutableMapOf() | ||||
|  | ||||
|     private fun getLiveRoomInfo(roomId: Long): LiveRoomInfoV2? { | ||||
|         var roomInfoV2 = roomInfoRepositoryV2.findByIdOrNull(roomId) | ||||
|  | ||||
|         if (roomInfoV2 == null) { | ||||
|             val roomInfoV1 = roomInfoRepository.findByIdOrNull(roomId) | ||||
|  | ||||
|             if (roomInfoV1 != null) { | ||||
|                 roomInfoV2 = roomInfoV1.convertRoomInfoV2() | ||||
|                 roomInfoRepositoryV2.save(roomInfoV2) | ||||
|                 roomInfoRepository.delete(roomInfoV1) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return roomInfoV2 | ||||
|     } | ||||
|  | ||||
|     fun getAllRoulette(creatorId: Long, memberId: Long): List<GetRouletteResponseV2> { | ||||
|         if (creatorId != memberId) throw SodaException("잘못된 요청입니다.") | ||||
|  | ||||
| @@ -178,7 +158,7 @@ class RouletteService( | ||||
|  | ||||
|         val lock = getOrCreateLock(memberId = member.id!!) | ||||
|         lock.write { | ||||
|             val roomInfo = getLiveRoomInfo(room.id!!) | ||||
|             val roomInfo = roomInfoRepository.findByIdOrNull(room.id!!) | ||||
|                 ?: throw SodaException("해당하는 라이브의 정보가 없습니다.") | ||||
|  | ||||
|             roomInfo.addRouletteMessage( | ||||
| @@ -187,7 +167,7 @@ class RouletteService( | ||||
|                 donationMessage = "[$result] 당첨!" | ||||
|             ) | ||||
|  | ||||
|             roomInfoRepositoryV2.save(roomInfo) | ||||
|             roomInfoRepository.save(roomInfo) | ||||
|         } | ||||
|  | ||||
|         return SpinRouletteResponse(can = roulette.can, result = result, items = itemList) | ||||
|   | ||||
| @@ -35,9 +35,7 @@ import kr.co.vividnext.sodalive.member.stipulation.StipulationIds | ||||
| import kr.co.vividnext.sodalive.member.stipulation.StipulationRepository | ||||
| import kr.co.vividnext.sodalive.member.tag.MemberCreatorTag | ||||
| import kr.co.vividnext.sodalive.member.tag.MemberTagRepository | ||||
| import kr.co.vividnext.sodalive.member.token.MemberToken | ||||
| import kr.co.vividnext.sodalive.redis.v1.MemberTokenRepository | ||||
| import kr.co.vividnext.sodalive.redis.v2.MemberTokenRepositoryV2 | ||||
| import kr.co.vividnext.sodalive.member.token.MemberTokenRepository | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import kr.co.vividnext.sodalive.utils.generatePassword | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| @@ -64,7 +62,6 @@ import kotlin.concurrent.write | ||||
| class MemberService( | ||||
|     private val repository: MemberRepository, | ||||
|     private val tokenRepository: MemberTokenRepository, | ||||
|     private val tokenRepositoryV2: MemberTokenRepositoryV2, | ||||
|     private val stipulationRepository: StipulationRepository, | ||||
|     private val stipulationAgreeRepository: StipulationAgreeRepository, | ||||
|     private val creatorFollowingRepository: CreatorFollowingRepository, | ||||
| @@ -438,12 +435,11 @@ class MemberService( | ||||
|  | ||||
|         val lock = getOrCreateLock(memberId = memberId) | ||||
|         lock.write { | ||||
|             val memberToken = saveAndGetTokenById(memberId) | ||||
|             val memberToken = tokenRepository.findByIdOrNull(memberId) | ||||
|                 ?: throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|             if (memberToken != null) { | ||||
|                 memberToken.tokenSet.remove(token) | ||||
|                 tokenRepositoryV2.save(memberToken) | ||||
|             } | ||||
|             memberToken.tokenSet.remove(token) | ||||
|             tokenRepository.save(memberToken) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -455,25 +451,7 @@ class MemberService( | ||||
|         member.pushToken = null | ||||
|  | ||||
|         val lock = getOrCreateLock(memberId = memberId) | ||||
|         lock.write { | ||||
|             tokenRepository.deleteById(memberId) | ||||
|             tokenRepositoryV2.deleteById(memberId) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun saveAndGetTokenById(id: Long): MemberToken? { | ||||
|         var memberToken = tokenRepositoryV2.findByIdOrNull(id = id) | ||||
|  | ||||
|         if (memberToken == null) { | ||||
|             memberToken = tokenRepository.findByIdOrNull(id = id) | ||||
|  | ||||
|             if (memberToken != null) { | ||||
|                 tokenRepositoryV2.save(memberToken) | ||||
|                 tokenRepository.delete(memberToken) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return memberToken | ||||
|         lock.write { tokenRepository.deleteById(memberId) } | ||||
|     } | ||||
|  | ||||
|     @Transactional | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v1 | ||||
| package kr.co.vividnext.sodalive.member.token | ||||
| 
 | ||||
| import kr.co.vividnext.sodalive.member.token.MemberToken | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| import org.springframework.stereotype.Repository | ||||
| 
 | ||||
| @@ -1,6 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomInfoV2 | ||||
| import org.springframework.data.repository.CrudRepository | ||||
|  | ||||
| interface LiveRoomInfoRedisRepositoryV2 : CrudRepository<LiveRoomInfoV2, Long> | ||||
| @@ -1,6 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.v2.LiveRoomKickOutV2 | ||||
| import org.springframework.data.repository.CrudRepository | ||||
|  | ||||
| interface LiveRoomKickOutRedisRepositoryV2 : CrudRepository<LiveRoomKickOutV2, Long> | ||||
| @@ -1,8 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.live.room.menu.LiveRoomMenu | ||||
| import org.springframework.data.repository.CrudRepository | ||||
|  | ||||
| interface LiveRoomMenuRepositoryV2 : CrudRepository<LiveRoomMenu, Long> { | ||||
|     fun findByCreatorId(creatorId: Long): List<LiveRoomMenu> | ||||
| } | ||||
| @@ -1,8 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.member.token.MemberToken | ||||
| import org.springframework.data.repository.CrudRepository | ||||
| import org.springframework.stereotype.Repository | ||||
|  | ||||
| @Repository | ||||
| interface MemberTokenRepositoryV2 : CrudRepository<MemberToken, Long> | ||||
| @@ -1,8 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.redis.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.v2.RouletteV2 | ||||
| import org.springframework.data.repository.CrudRepository | ||||
|  | ||||
| interface RouletteRepositoryV2 : CrudRepository<RouletteV2, Long> { | ||||
|     fun findByCreatorId(creatorId: Long): List<RouletteV2> | ||||
| } | ||||
| @@ -1,123 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationMessage | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomMember | ||||
| import kr.co.vividnext.sodalive.live.room.info.LiveRoomMemberRole | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.data.annotation.Id | ||||
| import org.springframework.data.redis.core.RedisHash | ||||
|  | ||||
| @RedisHash("LiveRoomInfo") | ||||
| data class LiveRoomInfoV2( | ||||
|     @Id | ||||
|     val roomId: Long, | ||||
|     var speakerList: List<LiveRoomMember> = mutableListOf(), | ||||
|     var listenerList: List<LiveRoomMember> = mutableListOf(), | ||||
|     var managerList: List<LiveRoomMember> = mutableListOf(), | ||||
|     var donationMessageList: List<LiveRoomDonationMessage> = mutableListOf() | ||||
| ) { | ||||
|     var speakerCount = 0 | ||||
|         private set | ||||
|  | ||||
|     var listenerCount = 0 | ||||
|         private set | ||||
|  | ||||
|     var managerCount = 0 | ||||
|         private set | ||||
|  | ||||
|     fun addSpeaker(member: Member, cloudFrontHost: String) { | ||||
|         val liveRoomMember = LiveRoomMember(member, cloudFrontHost) | ||||
|         liveRoomMember.role = LiveRoomMemberRole.SPEAKER | ||||
|  | ||||
|         val speakerSet = speakerList.toMutableSet() | ||||
|         speakerSet.add(liveRoomMember) | ||||
|         speakerList = speakerSet.toList() | ||||
|  | ||||
|         setSpeakerCount() | ||||
|     } | ||||
|  | ||||
|     fun removeSpeaker(member: Member) { | ||||
|         (speakerList as MutableList).removeIf { it.id == member.id!! } | ||||
|         setSpeakerCount() | ||||
|     } | ||||
|  | ||||
|     private fun setSpeakerCount() { | ||||
|         speakerCount = speakerList.size | ||||
|     } | ||||
|  | ||||
|     fun addListener(member: Member, cloudFrontHost: String) { | ||||
|         val liveRoomMember = LiveRoomMember(member, cloudFrontHost) | ||||
|         liveRoomMember.role = LiveRoomMemberRole.LISTENER | ||||
|  | ||||
|         val listenerSet = listenerList.toMutableSet() | ||||
|         listenerSet.add(liveRoomMember) | ||||
|         listenerList = listenerSet.toList() | ||||
|  | ||||
|         setListenerCount() | ||||
|     } | ||||
|  | ||||
|     fun removeListener(member: Member) { | ||||
|         (listenerList as MutableList).removeIf { it.id == member.id!! } | ||||
|         setListenerCount() | ||||
|     } | ||||
|  | ||||
|     private fun setListenerCount() { | ||||
|         listenerCount = listenerList.size | ||||
|     } | ||||
|  | ||||
|     fun addManager(member: Member, cloudFrontHost: String) { | ||||
|         val liveRoomMember = LiveRoomMember(member, cloudFrontHost) | ||||
|         liveRoomMember.role = LiveRoomMemberRole.MANAGER | ||||
|  | ||||
|         val managerSet = managerList.toMutableSet() | ||||
|         managerSet.add(liveRoomMember) | ||||
|         managerList = managerSet.toList() | ||||
|  | ||||
|         setManagerCount() | ||||
|     } | ||||
|  | ||||
|     fun removeManager(member: Member) { | ||||
|         (managerList as MutableList).removeIf { it.id == member.id!! } | ||||
|         setManagerCount() | ||||
|     } | ||||
|  | ||||
|     private fun setManagerCount() { | ||||
|         managerCount = managerList.size | ||||
|     } | ||||
|  | ||||
|     fun addDonationMessage(memberId: Long, nickname: String, isSecret: Boolean, can: Int, donationMessage: String) { | ||||
|         val donationMessageSet = donationMessageList.toMutableSet() | ||||
|         donationMessageSet.add( | ||||
|             LiveRoomDonationMessage( | ||||
|                 memberId = memberId, | ||||
|                 nickname = nickname, | ||||
|                 isSecret = isSecret, | ||||
|                 canMessage = if (isSecret) { | ||||
|                     "${can}캔으로 비밀미션을 보냈습니다." | ||||
|                 } else { | ||||
|                     "${can}캔을 후원하셨습니다." | ||||
|                 }, | ||||
|                 donationMessage = donationMessage | ||||
|             ) | ||||
|         ) | ||||
|         donationMessageList = donationMessageSet.toList() | ||||
|     } | ||||
|  | ||||
|     fun addRouletteMessage(memberId: Long, nickname: String, donationMessage: String) { | ||||
|         val donationMessageSet = donationMessageList.toMutableSet() | ||||
|         donationMessageSet.add( | ||||
|             LiveRoomDonationMessage( | ||||
|                 memberId = memberId, | ||||
|                 nickname = nickname, | ||||
|                 isSecret = false, | ||||
|                 canMessage = "", | ||||
|                 donationMessage = donationMessage | ||||
|             ) | ||||
|         ) | ||||
|         donationMessageList = donationMessageSet.toList() | ||||
|     } | ||||
|  | ||||
|     fun removeDonationMessage(uuid: String) { | ||||
|         (donationMessageList as MutableList).removeIf { it.uuid == uuid } | ||||
|     } | ||||
| } | ||||
| @@ -1,24 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.live.room.kickout.LiveRoomKickOutUser | ||||
| import org.springframework.data.annotation.Id | ||||
| import org.springframework.data.redis.core.RedisHash | ||||
|  | ||||
| @RedisHash("LiveRoomKickOut") | ||||
| data class LiveRoomKickOutV2( | ||||
|     @Id | ||||
|     val roomId: Long, | ||||
|     var userList: MutableList<LiveRoomKickOutUser> = mutableListOf() | ||||
| ) { | ||||
|     fun kickOut(userId: Long) { | ||||
|         var liveRoomKickOutUser = userList.find { it.userId == userId } | ||||
|         if (liveRoomKickOutUser == null) { | ||||
|             liveRoomKickOutUser = LiveRoomKickOutUser(userId) | ||||
|         } else { | ||||
|             liveRoomKickOutUser.plusCount() | ||||
|         } | ||||
|  | ||||
|         userList.removeIf { it.userId == userId } | ||||
|         userList.add(liveRoomKickOutUser) | ||||
|     } | ||||
| } | ||||
| @@ -1,17 +0,0 @@ | ||||
| package kr.co.vividnext.sodalive.v2 | ||||
|  | ||||
| import kr.co.vividnext.sodalive.live.roulette.RouletteItem | ||||
| import org.springframework.data.redis.core.RedisHash | ||||
| import org.springframework.data.redis.core.index.Indexed | ||||
| import javax.persistence.Id | ||||
|  | ||||
| @RedisHash("Roulette") | ||||
| data class RouletteV2( | ||||
|     @Id | ||||
|     val id: Long, | ||||
|     @Indexed | ||||
|     val creatorId: Long, | ||||
|     var can: Int, | ||||
|     var isActive: Boolean, | ||||
|     var items: List<RouletteItem> = mutableListOf() | ||||
| ) | ||||
| @@ -52,14 +52,6 @@ jwt: | ||||
|     secret: ${JWT_SECRET} | ||||
|  | ||||
| spring: | ||||
|     data: | ||||
|       redis: | ||||
|           repositories: | ||||
|               enabled: false | ||||
|     valkey: | ||||
|         host: ${VALKEY_HOST} | ||||
|         port: ${VALKEY_PORT} | ||||
|  | ||||
|     redis: | ||||
|         host: ${REDIS_HOST} | ||||
|         port: ${REDIS_PORT} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user