Skip to content

Commit

Permalink
chore: 오름차순으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyoil2 committed Mar 14, 2024
1 parent e344f23 commit 99fb773
Showing 1 changed file with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
package team.aliens.dms.persistence.point

import com.querydsl.jpa.impl.JPAQueryFactory
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.aliens.dms.domain.point.model.PointOption
import team.aliens.dms.domain.point.spi.PointOptionPort
import team.aliens.dms.persistence.point.mapper.PointOptionMapper
import team.aliens.dms.persistence.point.repository.PointOptionJpaRepository
import java.util.UUID

@Component
class PointOptionPersistenceAdapter(
private val queryFactory: JPAQueryFactory,
private val pointOptionMapper: PointOptionMapper,
private val pointOptionRepository: PointOptionJpaRepository
) : PointOptionPort {
override fun existByNameAndSchoolId(name: String, schoolId: UUID) =
pointOptionRepository.existsByNameAndSchoolId(name, schoolId)

override fun savePointOption(pointOption: PointOption): PointOption {
return pointOptionMapper.toDomain(
pointOptionRepository.save(pointOptionMapper.toEntity(pointOption))
)!!
}

override fun deletePointOption(pointOption: PointOption) {
pointOptionRepository.delete(
pointOptionMapper.toEntity(pointOption)
)
}

override fun queryPointOptionById(pointOptionId: UUID) = pointOptionMapper.toDomain(
pointOptionRepository.findByIdOrNull(pointOptionId)
)

override fun queryPointOptionsBySchoolIdAndKeyword(schoolId: UUID, keyword: String?): List<PointOption> {
return pointOptionRepository.findBySchoolIdAndNameContains(schoolId, keyword ?: "")
.map {
pointOptionMapper.toDomain(it)!!
}
.sortedByDescending { it.createdAt }
}
}
package team.aliens.dms.persistence.point

import com.querydsl.jpa.impl.JPAQueryFactory
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import team.aliens.dms.domain.point.model.PointOption
import team.aliens.dms.domain.point.spi.PointOptionPort
import team.aliens.dms.persistence.point.mapper.PointOptionMapper
import team.aliens.dms.persistence.point.repository.PointOptionJpaRepository
import java.util.UUID

@Component
class PointOptionPersistenceAdapter(
private val queryFactory: JPAQueryFactory,
private val pointOptionMapper: PointOptionMapper,
private val pointOptionRepository: PointOptionJpaRepository
) : PointOptionPort {
override fun existByNameAndSchoolId(name: String, schoolId: UUID) =
pointOptionRepository.existsByNameAndSchoolId(name, schoolId)

override fun savePointOption(pointOption: PointOption): PointOption {
return pointOptionMapper.toDomain(
pointOptionRepository.save(pointOptionMapper.toEntity(pointOption))
)!!
}

override fun deletePointOption(pointOption: PointOption) {
pointOptionRepository.delete(
pointOptionMapper.toEntity(pointOption)
)
}

override fun queryPointOptionById(pointOptionId: UUID) = pointOptionMapper.toDomain(
pointOptionRepository.findByIdOrNull(pointOptionId)
)

override fun queryPointOptionsBySchoolIdAndKeyword(schoolId: UUID, keyword: String?): List<PointOption> {
return pointOptionRepository.findBySchoolIdAndNameContains(schoolId, keyword ?: "")
.map {
pointOptionMapper.toDomain(it)!!
}
.sortedBy { it.createdAt }
}
}

0 comments on commit 99fb773

Please sign in to comment.