15 lines
634 B
Kotlin
15 lines
634 B
Kotlin
package net.halfbinary.scavengerhuntapi.service
|
|
|
|
import net.halfbinary.scavengerhuntapi.error.exception.NotFoundException
|
|
import net.halfbinary.scavengerhuntapi.model.converter.toDomain
|
|
import net.halfbinary.scavengerhuntapi.model.domain.Hunter
|
|
import net.halfbinary.scavengerhuntapi.repository.HunterRepository
|
|
import org.springframework.stereotype.Service
|
|
|
|
@Service
|
|
class HunterService(private val hunterRepository: HunterRepository) {
|
|
fun getHunterByEmail(email: String): Hunter {
|
|
return hunterRepository.findByEmail(email)?.toDomain()
|
|
?: throw NotFoundException("No hunter with email $email found")
|
|
}
|
|
} |