Commit 62a2de4f authored by snamdeo's avatar snamdeo

commiting the code after making the changes for backend

parents
Pipeline #2304 failed with stages
package com.altimetrik.poc.controller;
import com.altimetrik.poc.dto.ProductDetails;
import com.altimetrik.poc.services.ShoppingCartServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("api/v1")
public class ShoppingCartController {
@Autowired
ShoppingCartServices shoppingCartServices;
@GetMapping("/getProducts")
public ResponseEntity<List<ProductDetails>> getProducts(){
List<ProductDetails> products = shoppingCartServices.getProducts();
return ResponseEntity.ok(products);
}
@DeleteMapping("/removeProducts")
public void removeProducts(@RequestBody ProductDetails p){
shoppingCartServices.removeProducts(p);
}
@PostMapping ("/addProducts")
@CrossOrigin(origins="http://localhost:3000")
public void addProducts(@RequestBody ProductDetails p){
shoppingCartServices.addProducts(p);
}
@PutMapping("/updateProducts")
public void updateProducts(@RequestBody ProductDetails p){
shoppingCartServices.updateProduct(p);
}
}
package com.altimetrik.poc.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Customers {
private Integer id;
private String email;
private String password;
}
\ No newline at end of file
package com.altimetrik.poc.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProductDetails {
private Integer orderNumber;
private Integer taxPrice;
private Integer shippingPrice;
private Integer totalPrice;
private Integer itemsPrice;
private Integer[] productIds;
}
package com.altimetrik.poc.services;
import com.altimetrik.poc.dto.ProductDetails;
import java.util.List;
public interface ShoppingCartServices {
public List<ProductDetails> getProducts();
public void addProducts(ProductDetails p);
public void removeProducts(ProductDetails p);
public void updateProduct(ProductDetails p);
}
package com.altimetrik.poc.services;
import com.altimetrik.poc.dto.ProductDetails;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class ShoppingCartServicesImpl implements ShoppingCartServices{
List<ProductDetails> product = new ArrayList<>();
public List<ProductDetails> getProducts(){
return product;
}
public void addProducts(ProductDetails p){
product.add(p);
}
public void removeProducts(ProductDetails p){
product.remove(p);
}
public void updateProduct(ProductDetails p){
product.remove(p);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment