Skip to content

Commit

Permalink
merge: (#90) Redis Repository 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut authored Oct 14, 2022
2 parents eb989d1 + 3d5a2e3 commit 337be12
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.comit.simtong.global.security.principle

import org.springframework.data.repository.findByIdOrNull
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.stereotype.Component
Expand All @@ -22,7 +23,7 @@ class AuthDetailsService(

override fun loadUserByUsername(userId: String): UserDetails {
val id = UUID.fromString(userId)
val user = userRepository.queryUserJpaEntityById(id) ?: throw InvalidTokenException.EXCEPTION
val user = userRepository.findByIdOrNull(id) ?: throw InvalidTokenException.EXCEPTION

return AuthDetails(id, user.authority)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.comit.simtong.persistence.auth

import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.comit.simtong.domain.auth.model.AuthCodeLimit
import team.comit.simtong.domain.auth.spi.AuthCodeLimitPort
Expand All @@ -22,7 +23,7 @@ class AuthCodeLimitPersistenceAdapter(
) : AuthCodeLimitPort {

override fun queryAuthCodeLimitByEmail(email: String) = authCodeLimitMapper.toDomain(
authCodeLimitRepository.queryAuthCodeLimitEntityByKey(email)
authCodeLimitRepository.findByIdOrNull(email)
)

override fun save(authCodeLimit: AuthCodeLimit) = authCodeLimitMapper.toDomain(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.comit.simtong.persistence.auth

import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.comit.simtong.domain.auth.model.AuthCode
import team.comit.simtong.domain.auth.spi.AuthCodePort
Expand All @@ -21,7 +22,7 @@ class AuthCodePersistenceAdapter(
): AuthCodePort {

override fun queryAuthCodeByEmail(email: String) = authCodeMapper.toDomain(
authCodeRepository.queryAuthCodeEntityByKey(email)
authCodeRepository.findByIdOrNull(email)
)

override fun save(authCode: AuthCode) = authCodeMapper.toDomain(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.comit.simtong.persistence.auth

import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.comit.simtong.domain.auth.spi.RefreshTokenPort
import team.comit.simtong.persistence.auth.mapper.RefreshTokenMapper
Expand All @@ -21,7 +22,7 @@ class RefreshTokenPersistenceAdapter(
) : RefreshTokenPort {

override fun queryRefreshTokenByToken(token: String) = refreshTokenMapper.toDomain(
refreshTokenRepository.queryRefreshTokenEntityByToken(token)
refreshTokenRepository.findByIdOrNull(token)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import javax.validation.constraints.NotNull
* @version 1.0.0
**/
@RedisHash("tbl_authcode")
class AuthCodeEntity(
data class AuthCodeEntity(
@Id
val key: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import javax.validation.constraints.NotNull
* @version 1.0.0
**/
@RedisHash("tbl_authcode_limit")
class AuthCodeLimitEntity(
data class AuthCodeLimitEntity(
@Id
val key: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import javax.validation.constraints.NotNull
* @version 1.0.0
**/
@RedisHash("tbl_refresh_token")
class RefreshTokenEntity(
data class RefreshTokenEntity(
@Id
val token: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ import team.comit.simtong.persistence.auth.entity.AuthCodeLimitEntity
**/
@Repository
interface AuthCodeLimitRepository : CrudRepository<AuthCodeLimitEntity, String> {

fun queryAuthCodeLimitEntityByKey(email: String): AuthCodeLimitEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ import team.comit.simtong.persistence.auth.entity.AuthCodeEntity
**/
@Repository
interface AuthCodeRepository : CrudRepository<AuthCodeEntity, String> {

fun queryAuthCodeEntityByKey(key: String): AuthCodeEntity?

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ import team.comit.simtong.persistence.auth.entity.RefreshTokenEntity
**/
@Repository
interface RefreshTokenRepository : CrudRepository<RefreshTokenEntity, String> {

fun queryRefreshTokenEntityByToken(token: String): RefreshTokenEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class MenuMapper : GenericMapper<MenuJpaEntity, Menu> {
@Autowired
protected lateinit var spotJpaRepository: SpotJpaRepository

@Mapping(target = "spot", expression = "java(spotJpaRepository.querySpotJpaEntityById(model.getSpotId()))")
@Mapping(target = "spot", expression = "java(spotJpaRepository.findById(model.getSpotId()).orElse(null))")
abstract override fun toEntity(model: Menu): MenuJpaEntity

@Mapping(target = "spotId", expression = "java(entity.getSpot().getId())")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import java.util.*
@Repository
interface SpotJpaRepository : CrudRepository<SpotJpaEntity, UUID> {

fun querySpotJpaEntityById(id: UUID): SpotJpaEntity?

fun querySpotJpaEntityByName(name: String): SpotJpaEntity?

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package team.comit.simtong.persistence.spot

import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.comit.simtong.domain.spot.spi.SpotPort
import team.comit.simtong.persistence.spot.mapper.SpotMapper
import java.util.UUID
import java.util.*

/**
*
Expand All @@ -24,7 +25,7 @@ class SpotPersistenceAdapter(
)

override fun querySpotById(id: UUID) = spotMapper.toDomain(
spotJpaRepository.querySpotJpaEntityById(id)
spotJpaRepository.findByIdOrNull(id)
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import java.util.*
@Repository
interface TeamJpaRepository : CrudRepository<TeamJpaEntity, UUID> {

fun queryTeamJpaEntityById(id: UUID): TeamJpaEntity?

fun queryTeamJpaEntityByName(name: String): TeamJpaEntity?

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class TeamMapper : GenericMapper<TeamJpaEntity, Team> {
@Autowired
protected lateinit var spotJpaRepository: SpotJpaRepository

@Mapping(target = "spot", expression = "java(spotJpaRepository.querySpotJpaEntityById(model.getSpotId()))")
@Mapping(target = "spot", expression = "java(spotJpaRepository.findById(model.getSpotId()).orElse(null))")
abstract override fun toEntity(model: Team): TeamJpaEntity

@Mapping(target = "spotId", expression = "java(entity.getSpot().getId())")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package team.comit.simtong.persistence.user

import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.comit.simtong.domain.user.model.User
import team.comit.simtong.domain.user.spi.UserPort
import team.comit.simtong.persistence.user.mapper.UserMapper
import team.comit.simtong.persistence.user.repository.UserJpaRepository
import java.util.UUID
import java.util.*

/**
*
Expand All @@ -23,7 +24,7 @@ class UserPersistenceAdapter(
) : UserPort {

override fun queryUserById(id: UUID) = userMapper.toDomain(
userJpaRepository.queryUserJpaEntityById(id)
userJpaRepository.findByIdOrNull(id)
)

override fun queryUserByEmployeeNumber(employeeNumber: Int) = userMapper.toDomain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ abstract class UserMapper : GenericMapper<UserJpaEntity, User> {
protected lateinit var teamJpaRepository: TeamJpaRepository

@Mappings(
Mapping(target = "spot", expression = "java(spotJpaRepository.querySpotJpaEntityById(model.getSpotId()))"),
Mapping(target = "team", expression = "java(teamJpaRepository.queryTeamJpaEntityById(model.getTeamId()))")
Mapping(target = "spot", expression = "java(spotJpaRepository.findById(model.getSpotId()).orElse(null))"),
Mapping(target = "team", expression = "java(teamJpaRepository.findById(model.getTeamId()).orElse(null))")
)
abstract override fun toEntity(model: User): UserJpaEntity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package team.comit.simtong.persistence.user.repository
import org.springframework.data.repository.CrudRepository
import org.springframework.stereotype.Repository
import team.comit.simtong.persistence.user.entity.UserJpaEntity
import java.util.UUID
import java.util.*

/**
*
Expand All @@ -17,8 +17,6 @@ import java.util.UUID
@Repository
interface UserJpaRepository : CrudRepository<UserJpaEntity, UUID> {

fun queryUserJpaEntityById(id: UUID): UserJpaEntity?

fun queryUserJpaEntityByEmployeeNumber(employeeNumber: Int): UserJpaEntity?

fun queryUserJpaEntityByEmail(email: String): UserJpaEntity?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import team.comit.simtong.thirdparty.email.template.MailTemplate

/**
*
* AWS SES를 이용해 메일 전송을 처리하는 SesAdapter
* AWS SES를 이용해 메일 전송을 처리하는 AwsSESAdapter
*
* @author Chokyunghyeon
* @date 2022/09/08
Expand Down

0 comments on commit 337be12

Please sign in to comment.