-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProductController.java
54 lines (38 loc) · 1.48 KB
/
ProductController.java
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.hudabanimustafa.pos.pos.controller;
import com.hudabanimustafa.pos.pos.dao.ProductDao;
import com.hudabanimustafa.pos.pos.entity.ProductEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RequestMapping(path = "/products")
@RestController
@CrossOrigin
public class ProductController {
@Autowired
private ProductDao productDao;
@PostMapping("/update-product")
public ProductEntity addProduct(@RequestBody ProductEntity product) {
return this.productDao.addProduct(product);
}
@PostMapping("/add-product")
public ProductEntity updateProduct(@RequestBody ProductEntity product) {
return this.productDao.updateProduct(product);
}
@GetMapping("/delete-product")
public String deleteProduct(@RequestParam Integer productId) {
this.productDao.deleteProduct(productId);
return "success";
}
@GetMapping("/get-by-barcode")
public ProductEntity getProductByBarcode(@RequestParam String barcode){
return this.productDao.getProductByBarcode(barcode);
}
@GetMapping("/get-by-Id")
public ProductEntity getProductById(@RequestParam int productId){
return this.productDao.getProductById(productId);
}
@GetMapping("/get-all-products")
public List<ProductEntity> getAllProducts(){
return this.productDao.getAllProducts();
}
}