-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathProductController.java
More file actions
39 lines (30 loc) · 1.12 KB
/
ProductController.java
File metadata and controls
39 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package hello.hellospring.controller;
import hello.hellospring.domain.Product;
import hello.hellospring.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class ProductController {
private final ProductService productService;
@Autowired
public ProductController(ProductService productService) {
this.productService = productService;
}
@GetMapping("products")
public List<Product> list() {
List<Product> products = productService.findProducts();
return products;
}
@GetMapping("heartclick")
void heartclick(@RequestParam("pid") Long pid) {
productService.HeartClick(pid);
}
@GetMapping("heartunclick")
void heartunclick(@RequestParam("pid") Long pid) {
productService.HeartUnClick(pid);
}
}