Newer
Older
sample-kotlin-spring+mybatis / src / main / kotlin / com / example / sample / service / SampleService.kt
yhornisse on 12 Mar 2020 528 bytes Add Sample.
package com.example.sample.service

import com.example.sample.entity.BookDto
import com.example.sample.entity.BookEntity
import com.example.sample.mapper.SampleMapper
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class SampleService(
    private val sampleMapper: SampleMapper
) {
    @Transactional()
    fun execute() : BookDto {
        val book: BookEntity = sampleMapper.findBy(0)
        return BookDto(book.name ?: "", book.author ?: "")
    }
}