Commit 4ca01743 authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

[AFP-55] Fix merge conflict [@kliew]

parents 67b24376 448064c7
......@@ -6,7 +6,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath/> <!-- lookup parent from com.nisum.ascend.inventory.repository -->
</parent>
<groupId>com.nisum.ascend</groupId>
<artifactId>inventory</artifactId>
......
package controller;
package com.nisum.ascend.inventory.controller;
import dto.ProductDto;
import model.Product;
//import dto.ProductDto;
//import model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import service.ProductService;
import com.nisum.ascend.inventory.service.ProductService;
@RestController
@RequestMapping("/products")
......@@ -18,9 +14,9 @@ public class ProductController {
@Autowired
ProductService productService;
@GetMapping()
public Flux<Product> findAll() {
Flux<Product> prods = productService.findAll();
return prods;
}
// @GetMapping()
// public Flux<Product> findAll() {
// Flux<Product> prods = productService.findAll();
// return prods;
// }
}
package dto;
package com.nisum.ascend.inventory.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import model.Product;
import com.nisum.ascend.inventory.model.Product;
@Getter
@AllArgsConstructor
......@@ -20,7 +20,7 @@ public class ProductDto {
public static ProductDto generateDtoFromProduct(Product product) {
// TODO: Fetch the product's promotion from the Promotions service
// TODO: Fetch the product's promotion from the Promotions com.nisum.ascend.inventory.service
PromotionDto promotion = new PromotionDto();
return new ProductDto(product.getSku(), product.getUpc(), product.getProdName(), product.getProdDesc(), product.getPrice(), product.getProdImgUrl(), product.getBrand(), product.getCategory(), product.getAvailableStock(), promotion);
......
package dto;
package com.nisum.ascend.inventory.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
......
package model;
package com.nisum.ascend.inventory.model;
import lombok.Getter;
import lombok.Setter;
......
package repository;
package com.nisum.ascend.inventory.repository;
import model.Product;
import com.nisum.ascend.inventory.model.Product;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
......
package service;
package com.nisum.ascend.inventory.service;
import dto.ProductDto;
import model.Product;
import com.nisum.ascend.inventory.dto.ProductDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import repository.ProductRepository;
import com.nisum.ascend.inventory.repository.ProductRepository;
@Service
public class ProductService {
@Autowired
ProductRepository productRepository;
public Flux<ProductDto> testDto() {
return productRepository.findAll()
.map(ProductDto::generateDtoFromProduct)
.flatMap(Flux::just);
}
public Flux<Product> findAll(){
return productRepository.findAll();
}
}
spring.config.import=classpath:secret.properties
server.port=8080
spring.data.mongodb.uri=mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb\
.net/${spring.data.mongodb.database}?retryWrites=true&w=majority
spring.data.mongodb.database=products-promotions-db
spring.data.mongodb.database=products-promotions-DB
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