Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fix: shop module structure
Browse files Browse the repository at this point in the history
change the shop module structure and add a new module shop_database that contains all the entities and repositories of shop
add a line in the README about swagger

linked #15
  • Loading branch information
MeloLawson committed Jan 3, 2024
1 parent 5e48cf9 commit 234cad9
Show file tree
Hide file tree
Showing 30 changed files with 733 additions and 139 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ To manage the microservices of the application, you need to first launch the mod
Then launch the module api_gateway and the module mediator.
You can have access to the Dashboard of the eureka_server at http://localhost:8761. You will see all the microservices.

### For the endpoints documentation
You can access the documentation of each endpoints after launching at this address : http://<localhost:service port>/swagger-ui/index.html#. This page also allow you to try the different endpoints of the concerned service.


# terminal

Expand Down
79 changes: 10 additions & 69 deletions Server/shop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,79 +15,20 @@
<properties>
<java.version>17</java.version>
</properties>
<packaging>pom</packaging>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<modules>
<module>shop_database</module>
<module>product</module>
</modules>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<groupId>com.cashmanager.server</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<attach>false</attach>
</configuration>
</execution>
</executions>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
</image>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
17 changes: 5 additions & 12 deletions Server/shop/product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
<groupId>com.cashmanager.server</groupId>
<artifactId>shop</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.cashmanager.server</groupId>

<artifactId>product</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>product</name>
Expand Down Expand Up @@ -45,13 +44,7 @@
</dependency>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>shop</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>common</artifactId>
<artifactId>shop_database</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@SpringBootApplication
@EnableJpaRepositories(basePackages = "com.cashmanager.server")
@EntityScan("com.cashmanager.server.shop.entities")
@EntityScan("com.cashmanager.server.shop_database.entities")
public class ProductApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.cashmanager.server.product.controller;
package com.cashmanager.server.product.controllers;

import com.cashmanager.server.common.dto.ProductDto;
import com.cashmanager.server.product.exceptions.ProductException;
import com.cashmanager.server.product.service.interfaces.IProductService;
import com.cashmanager.server.product.services.interfaces.IProductService;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.cashmanager.server.product.exceptions;

/**
* Class that will be thrown when an error occur while communicated with the database
*/
public class ProductException extends Exception{
public ProductException() {
super();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.cashmanager.server.product.service;
package com.cashmanager.server.product.services;

import com.cashmanager.server.common.dto.ProductDto;
import com.cashmanager.server.product.exceptions.ProductException;
import com.cashmanager.server.product.service.interfaces.IProductService;
import com.cashmanager.server.product.service.mappers.ProductMapper;
import com.cashmanager.server.shop.entities.Product;
import com.cashmanager.server.shop.repositories.ProductRepository;
import com.cashmanager.server.product.services.interfaces.IProductService;
import com.cashmanager.server.product.services.mappers.ProductMapper;

import com.cashmanager.server.shop_database.entities.Product;
import com.cashmanager.server.shop_database.repositories.ProductRepository;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cashmanager.server.product.service.interfaces;
package com.cashmanager.server.product.services.interfaces;

import com.cashmanager.server.common.dto.ProductDto;
import com.cashmanager.server.product.exceptions.ProductException;
Expand All @@ -9,6 +9,11 @@

public interface IProductService {

/**
* Function that recuperate the products available in the database, via the ProductRepository
* @return List of ProductDto
* @throws ProductException if there is an error when communicating with the database
*/
List<ProductDto> getAllProducts() throws ProductException;
Optional<ProductDto> getProductById(UUID productId);
Optional<ProductDto> updateProduct(UUID productId, ProductDto product);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.cashmanager.server.product.services.mappers;

import com.cashmanager.server.common.dto.ProductDto;
import com.cashmanager.server.shop_database.entities.Product;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface ProductMapper {

ProductMapper INSTANCE = Mappers.getMapper(ProductMapper.class);

/**
* Function that convert the entity Product to the ProductDto
* @param product : the product that will be converted
* @return productDto that result from the conversion
*/
ProductDto productToProductDto(Product product);

/**
* Function that convert the dto ProductDto to the entity Product
* @param productDto : the dto that will be converted
* @return product that result from the conversion
*/
Product productDtoToProduct(ProductDto productDto);
}
33 changes: 33 additions & 0 deletions Server/shop/shop_database/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ services:
image: 'postgres:16.1-alpine'
volumes:
- 'db:/var/lib/postgres/data'
- '../init-shop-db.sh:/docker-entrypoint-initdb.d/init-shop-db.sh'
- '../../init-shop-db.sh:/docker-entrypoint-initdb.d/init-shop-db.sh'
env_file:
- ../.env.local
- ../../.env.local
ports:
- '5432:5432'
volumes:
Expand Down
Loading

0 comments on commit 234cad9

Please sign in to comment.