Removed classes

This commit is contained in:
Sambo Chea 2020-06-10 17:58:31 +07:00
parent a94620a5ed
commit f9caf17a18
3 changed files with 0 additions and 62 deletions

View File

@ -1,20 +0,0 @@
package com.cubetiqs.demo.domain;
import lombok.*;
import javax.persistence.*;
import java.math.BigDecimal;
@Entity
@Table(name = "products")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private BigDecimal price;
private Boolean deleted;
}

View File

@ -1,8 +0,0 @@
package com.cubetiqs.demo.repository;
import com.cubetiqs.demo.domain.Product;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProductRepository extends JpaRepository<Product, Long> {
}

View File

@ -1,34 +0,0 @@
package com.cubetiqs.demo.rest;
import com.cubetiqs.demo.domain.Product;
import com.cubetiqs.demo.repository.ProductRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(path = "/products")
public class ProductController {
private final ProductRepository productRepository;
@Autowired
public ProductController(ProductRepository productRepository) {
this.productRepository = productRepository;
}
@RequestMapping(method = {RequestMethod.GET})
public List<Product> getAllProducts() {
return productRepository.findAll();
}
@GetMapping("/{id}")
public Product getOneProduct(@PathVariable Long id) {
return productRepository.findById(id).orElse(null);
}
@PostMapping
public Product createProduct(@RequestBody Product item) {
return productRepository.save(item);
}
}