DataJPA/src/main/kotlin/com/chantha/jdbc/controller/ProductController.kt

25 lines
916 B
Kotlin
Raw Normal View History

2020-05-16 17:20:48 +07:00
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
2020-05-18 14:51:58 +07:00
import org.springframework.web.bind.annotation.CrossOrigin
2020-05-16 17:20:48 +07:00
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@RestController
2020-05-17 13:35:32 +07:00
public class ProductController @Autowired constructor(private val productService: ProductService,private val productRepo: ProductRepo) {
2020-05-16 17:20:48 +07:00
2020-05-17 13:35:32 +07:00
@GetMapping("/api/product/order")
2020-05-16 17:20:48 +07:00
fun product():List<ProductWithOrderDetail>{
return productService.fetchAllProducts()
}
2020-05-18 14:51:58 +07:00
2020-05-17 13:35:32 +07:00
@GetMapping("/api/product/getproduct")
fun getAllProduct():List<Product>{
return productRepo.readAllRecord()
}
2020-05-16 17:20:48 +07:00
}