DataJPA/src/main/kotlin/com/chantha/jdbc/controller/ProductController.kt
2020-05-16 17:20:48 +07:00

19 lines
678 B
Kotlin

package com.chantha.jdbc.controller
import com.chantha.jdbc.jpa.model.Product
import com.chantha.jdbc.jpa.model.view.ProductWithOrderDetail
import com.chantha.jdbc.jpa.repo.ProductRepo
import com.chantha.jdbc.jpa.service.product.ProductService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@RestController
public class ProductController @Autowired constructor(private val productService: ProductService) {
@GetMapping("/product")
fun product():List<ProductWithOrderDetail>{
return productService.fetchAllProducts()
}
}