-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
44 deletions.
There are no files selected for viewing
88 changes: 44 additions & 44 deletions
88
...stence/src/main/kotlin/team/aliens/dms/persistence/point/PointOptionPersistenceAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
} | ||
} |