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 @@ ...@@ -6,7 +6,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version> <version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from com.nisum.ascend.inventory.repository -->
</parent> </parent>
<groupId>com.nisum.ascend</groupId> <groupId>com.nisum.ascend</groupId>
<artifactId>inventory</artifactId> <artifactId>inventory</artifactId>
......
package controller; package com.nisum.ascend.inventory.controller;
import dto.ProductDto; //import dto.ProductDto;
import model.Product; //import model.Product;
import org.springframework.beans.factory.annotation.Autowired; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux; import com.nisum.ascend.inventory.service.ProductService;
import service.ProductService;
@RestController @RestController
@RequestMapping("/products") @RequestMapping("/products")
...@@ -18,9 +14,9 @@ public class ProductController { ...@@ -18,9 +14,9 @@ public class ProductController {
@Autowired @Autowired
ProductService productService; ProductService productService;
@GetMapping() // @GetMapping()
public Flux<Product> findAll() { // public Flux<Product> findAll() {
Flux<Product> prods = productService.findAll(); // Flux<Product> prods = productService.findAll();
return prods; // return prods;
} // }
} }
package dto; package com.nisum.ascend.inventory.dto;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import model.Product; import com.nisum.ascend.inventory.model.Product;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
...@@ -20,7 +20,7 @@ public class ProductDto { ...@@ -20,7 +20,7 @@ public class ProductDto {
public static ProductDto generateDtoFromProduct(Product product) { 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(); 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); 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.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
......
package model; package com.nisum.ascend.inventory.model;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
......
package service; package com.nisum.ascend.inventory.service;
import dto.ProductDto; import com.nisum.ascend.inventory.dto.ProductDto;
import model.Product;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import repository.ProductRepository; import com.nisum.ascend.inventory.repository.ProductRepository;
@Service @Service
public class ProductService { public class ProductService {
@Autowired @Autowired
ProductRepository productRepository; 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 server.port=8080
spring.data.mongodb.uri=mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb\ spring.data.mongodb.uri=mongodb+srv://admin:${db.password}@inventory-promotions.d4nfz.mongodb\
.net/${spring.data.mongodb.database}?retryWrites=true&w=majority .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