DataJPA/src/main/kotlin/com/chantha/jdbc/controller/ProductController.kt
2020-05-17 13:35:32 +07:00

23 lines
856 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,private val productRepo: ProductRepo) {
@GetMapping("/api/product/order")
fun product():List<ProductWithOrderDetail>{
return productService.fetchAllProducts()
}
@GetMapping("/api/product/getproduct")
fun getAllProduct():List<Product>{
return productRepo.readAllRecord()
}
}