Skip to content

Commit

Permalink
update files
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodolphe_Lassalle committed Jul 8, 2024
1 parent 986880b commit cdc4d0b
Show file tree
Hide file tree
Showing 48 changed files with 1,352 additions and 220 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
"java.configuration.updateBuildConfiguration": "interactive",
"java.compile.nullAnalysis.mode": "automatic"
}
52 changes: 13 additions & 39 deletions backend/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- build
- test
- deploy
image: maven:3.8.5-openjdk-17

# Inclure le template Auto-DevOps pour des configurations automatiques
include:
- template: Auto-DevOps.gitlab-ci.yml
stages:
- build
- test
- quality

# Configuration des jobs
build:
stage: build
image: maven:3.8.5-jdk-17 # Utilisez l'image Docker Maven avec Java 17
script:
- mvn clean package # Commande Maven pour compiler et empaqueter l'application
artifacts:
paths:
- target/*.jar # Spécifie les artefacts à archiver (fichier JAR de l'application)
script:
- ./mvnw package

test:
stage: test
image: maven:3.8.5-jdk-17
script:
- mvn test # Exécute les tests Maven
artifacts:
reports:
junit: target/surefire-reports/*.xml # Spécifie les rapports de tests à archiver

deploy:
stage: deploy
image: openjdk:17-jdk # Utilisez l'image Docker OpenJDK 17 pour le déploiement
script:
- java -jar target/*.jar # Commande pour démarrer l'application Spring Boot
environment:
name: production # Nom de l'environnement de déploiement
only:
- main # Déployer uniquement à partir de la branche main
script:
- ./mvnw test

include:
- template: Auto-DevOps.gitlab-ci.yml
quality:
stage: quality
script:
- ./mvnw site
34 changes: 31 additions & 3 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.epsyl</groupId>
Expand All @@ -18,6 +18,12 @@
<java.version>17</java.version>
</properties>
<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Spring Boot Starter Data MongoDB -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -44,11 +50,28 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring Boot Starter mail -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- Spring Boot Starter test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.12.4</version>
<scope>test</scope>
</dependency>
<!-- Spring Boot Devtools -->
<dependency>
Expand All @@ -68,6 +91,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>de.undercouch</groupId>
<artifactId>bson4jackson</artifactId>
<version>2.15.1</version>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
Expand All @@ -86,8 +114,8 @@
</dependency>
<!-- BCrypt -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</dependency>
</dependencies>

Expand Down
27 changes: 27 additions & 0 deletions backend/src/main/java/com/epsyl/eps/config/JacksonConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.epsyl.eps.config;

import org.bson.types.ObjectId;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

import com.epsyl.eps.serialization.ObjectIdDeserrializer;
import com.epsyl.eps.serialization.ObjectIdSerializer;
import com.fasterxml.jackson.databind.module.SimpleModule;

@Configuration
public class JacksonConfig {

@Bean
public Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
SimpleModule module = new SimpleModule();

module.addSerializer(ObjectId.class, new ObjectIdSerializer());
module.addDeserializer(ObjectId.class, new ObjectIdDeserrializer());

builder.modules(module);

return builder;
}
}
24 changes: 24 additions & 0 deletions backend/src/main/java/com/epsyl/eps/config/ObjectMapperConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.epsyl.eps.config;

import org.bson.types.ObjectId;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.epsyl.eps.serialization.ObjectIdDeserrializer;
import com.epsyl.eps.serialization.ObjectIdSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;

@Configuration
public class ObjectMapperConfig {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();

module.addSerializer(ObjectId.class, new ObjectIdSerializer());
module.addDeserializer(ObjectId.class, new ObjectIdDeserrializer());
mapper.registerModule(module);
return mapper;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.epsyl.eps.configuration_global;
package com.epsyl.eps.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.epsyl.eps.controllers;

import org.springframework.web.bind.annotation.RestController;

import com.epsyl.eps.entities.ArchiveProspect;
import com.epsyl.eps.services.ArchiveProspectService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

@RestController
@RequestMapping("/api/v1/archive")
public class ArchiveProspectController {

@Autowired
private ArchiveProspectService archiveProspectService;

// GET api/v1/archive/all
@GetMapping("/all")
public Iterable<ArchiveProspect> getAllArchive() {
return archiveProspectService.listAll();
}

// GET api/v1/archive/id
@GetMapping("/{id}")
public ArchiveProspect getArchive(@PathVariable String id) {
return archiveProspectService.getArchiveProspectByID(id).get();
}

// POST api/v1/archive/save
@RequestMapping("/save")
public ArchiveProspect saveArchive(@RequestBody ArchiveProspect archive) {
return archiveProspectService.save(archive);
}

// PUT api/v1/archive/id
// @PutMapping("/{id}")
// public ArchiveProspect updateArchive(@RequestBody ArchiveProspect archive, @PathVariable String id) {
// archive.set_id(id);
// archiveProspectService.save(archive);
// return archive;
// }

// DELETE api/v1/archive/delete/id
@RequestMapping("/delete/{id}")
public ResponseEntity<Void> deleteArchive(@PathVariable String _id) {
archiveProspectService.deleteArchive(_id);
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.bson.types.ObjectId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -51,7 +52,7 @@ public ResponseEntity<Map<String, String>> uploadFile(@RequestParam("file") Mult
}

@GetMapping("/download/{id}")
public ResponseEntity<byte[]> downloadFile(@PathVariable String _id) {
public ResponseEntity<byte[]> downloadFile(@PathVariable ObjectId _id) {
FileStorage fileStorage = fileStorageService.getFile(_id);
if(fileStorage != null) {
HttpHeaders headers = new HttpHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Optional;

import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -69,7 +70,7 @@ public List<ProspectDTO> getAllProspects() {

// GET /api/v1/prospect/id
@RequestMapping("/{id}")
public ResponseEntity<Prospect> getProspectById(@PathVariable String _id) {
public ResponseEntity<Prospect> getProspectById(@PathVariable ObjectId _id) {
Optional<Prospect> prospect = prospectService.getProspectByID(_id);
if (prospect.isPresent()) {
return ResponseEntity.ok(prospect.get());
Expand All @@ -87,20 +88,20 @@ public boolean checkTrigram(@RequestParam String trigramme) {
// POST /api/v1/prospect/save
@PostMapping("/save")
public Prospect saveProspect(@RequestBody Prospect prospect) {
return prospectService.save(prospect);
return prospectService.createProspect(prospect);
}

// PUT /api/v1/prospect/id
@PutMapping("/{id}")
public Prospect updateProspect(@PathVariable String _id, @RequestBody Prospect prospect) {
return prospectService.updateProspect(_id, prospect);
public ResponseEntity<Prospect> updateProspect(@PathVariable ObjectId id, @RequestBody Prospect prospect) {
Prospect updatedProspect = prospectService.updateProspect(id, prospect);
return ResponseEntity.ok(updatedProspect);
}

// DELETE /api/v1/prospect/delete/id
@DeleteMapping("/delete/{id}")
public ResponseEntity<Void> deleteProspect(@PathVariable String _id) {
prospectService.deleteProspectById(_id);
public ResponseEntity<Void> deleteProspect(@PathVariable ObjectId id) {
prospectService.deleteProspectById(id);
return ResponseEntity.noContent().build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.epsyl.eps.controllers;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.epsyl.eps.entities.Role;
import com.epsyl.eps.services.RoleService;

import lombok.RequiredArgsConstructor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;


@RestController
@RequestMapping("/api/v1/roles")
@RequiredArgsConstructor
public class RolesController {

@Autowired
private RoleService roleService;

@GetMapping("/all")
public Iterable<Role> getRoles() {
return roleService.getAllRoles();
}

}
Loading

0 comments on commit cdc4d0b

Please sign in to comment.