Commit 892ead98 authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

Merge branch 'dev' of https://gitlab.mynisum.com/ascend/inventory-backend into dev

Need to update model
parents 5632daf3 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import service.ProductService; import com.nisum.ascend.inventory.service.ProductService;
@RestController @RestController
public class ProductController { public class ProductController {
......
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.getProductName(), product.getProductDescription(), product.getPrice(), product.getProductImageUrl(), product.getBrand(), product.getCategory(), product.getAvailableStock(), promotion); return new ProductDto(product.getSku(), product.getUpc(), product.getProductName(), product.getProductDescription(), product.getPrice(), product.getProductImageUrl(), 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 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);
}
} }
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