40 Commits

Author SHA1 Message Date
be487d6a03 Merge pull request 'gestion revu de code en utilisant uniquement les DTO' (#75) from features/crud_entites into develop
Reviewed-on: #75
2026-02-01 22:49:00 +00:00
3be64e7f44 Merge pull request 'gestion de profil, secteur, section et arbre decoupage' (#73) from features/crud_entites into develop
Reviewed-on: #73
2026-01-27 08:58:32 +00:00
03a661cdc0 Merge pull request 'gestion de profil, secteur, section et arbre decoupage' (#72) from features/crud_entites into develop
Reviewed-on: #72
2026-01-27 08:37:52 +00:00
a68ec444cc Merge pull request 'features/crud_entites' (#70) from features/crud_entites into develop
Reviewed-on: #70
2026-01-13 20:33:17 +00:00
58f517bf31 Merge pull request 'correction creation user par defaut' (#68) from features/crud_entites into develop
Reviewed-on: #68
2025-12-20 19:03:51 +00:00
7f18f22efb Merge pull request 'correction creation user par defaut' (#66) from features/crud_entites into develop
Reviewed-on: #66
2025-12-20 18:55:42 +00:00
af3218412f Merge pull request 'correction creation user par defaut' (#64) from features/crud_entites into develop
Reviewed-on: #64
2025-12-20 17:06:19 +00:00
f35670c72e Merge pull request 'correction creation user par defaut' (#62) from features/crud_entites into develop
Reviewed-on: #62
2025-12-20 15:03:45 +00:00
a77c0e854d Merge pull request 'correction creation user par defaut' (#60) from features/crud_entites into develop
Reviewed-on: #60
2025-12-20 14:48:47 +00:00
e75eff4e20 Merge pull request 'correction lecture de secret chargement' (#58) from features/crud_entites into develop
Reviewed-on: #58
2025-12-20 14:33:59 +00:00
40d078c653 Merge pull request 'correction lecture de secret chargement' (#56) from features/crud_entites into develop
Reviewed-on: #56
2025-12-20 14:14:02 +00:00
31dd11d017 Merge pull request 'correction lecture de secret chargement' (#54) from features/crud_entites into develop
Reviewed-on: #54
2025-12-20 13:10:40 +00:00
6dfd12fae8 Merge pull request 'correction lecture de secret chargement' (#52) from features/crud_entites into develop
Reviewed-on: #52
2025-12-20 12:57:46 +00:00
a4ad0a4556 Merge pull request 'correction lecture de secret chargement' (#50) from features/crud_entites into develop
Reviewed-on: #50
2025-12-20 12:41:09 +00:00
411a6c0c2d Merge pull request 'correction lecture de secret' (#48) from features/crud_entites into develop
Reviewed-on: #48
2025-12-20 12:21:25 +00:00
bed73b2b16 Merge pull request 'correction lecture de secret' (#46) from features/crud_entites into develop
Reviewed-on: #46
2025-12-20 12:10:00 +00:00
5a0814a0ba Merge pull request 'correction lecture de secret' (#44) from features/crud_entites into develop
Reviewed-on: #44
2025-12-20 12:00:12 +00:00
126254ea94 Merge pull request 'correction lecture de secret' (#42) from features/crud_entites into develop
Reviewed-on: #42
2025-12-20 11:43:55 +00:00
f9e4681af4 Merge pull request 'correction lecture de secret' (#40) from features/crud_entites into develop
Reviewed-on: #40
2025-12-20 11:39:40 +00:00
84089d3639 Merge pull request 'correction profil actif' (#38) from features/crud_entites into develop
Reviewed-on: #38
2025-12-20 10:48:01 +00:00
02b0a937b4 Merge pull request 'correction profil actif' (#36) from features/crud_entites into develop
Reviewed-on: #36
2025-12-20 10:02:19 +00:00
c0096457fb Merge pull request 'nouvelle verson ci-cd avec gitea runner natif intallé sur hote' (#34) from features/crud_entites into develop
Reviewed-on: #34
2025-12-19 19:14:24 +00:00
b6062ba4d1 Merge pull request 'nouvelle verson ci-cd avec gitea runner natif intallé sur hote' (#33) from features/crud_entites into develop
Reviewed-on: #33
2025-12-19 10:50:02 +00:00
8dc8c974d3 Merge pull request 'correction docker composer avec les secrets' (#32) from features/crud_entites into develop
Reviewed-on: #32
2025-12-19 10:39:57 +00:00
957416df9e Merge pull request 'correction docker composer avec les secrets' (#30) from features/crud_entites into develop
Reviewed-on: #30
2025-12-18 15:47:21 +00:00
8d8af75108 Merge pull request 'correction docker composer avec les secrets' (#28) from features/crud_entites into develop
Reviewed-on: #28
2025-12-18 15:46:02 +00:00
555f13508e Merge pull request 'correction docker composer avec les secrets' (#26) from features/crud_entites into develop
Reviewed-on: #26
2025-12-18 10:36:10 +00:00
d92a2b2503 Merge pull request 'correction docker composer avec les secrets' (#24) from features/crud_entites into develop
Reviewed-on: #24
2025-12-17 17:13:46 +00:00
5ccfdb6a3f Merge pull request 'correction docker composer avec les secrets' (#22) from features/crud_entites into develop
Reviewed-on: #22
2025-12-17 16:58:50 +00:00
87b3bfbe83 Merge pull request 'correction docker composer avec les secrets' (#20) from features/crud_entites into develop
Reviewed-on: #20
2025-12-17 16:49:15 +00:00
62f25ea726 Merge pull request 'correction docker composer avec les secrets' (#18) from features/crud_entites into develop
Reviewed-on: #18
2025-12-17 16:41:46 +00:00
6125fcbd0b Merge pull request 'correction docker composer' (#16) from features/crud_entites into develop
Reviewed-on: #16
2025-12-17 16:26:17 +00:00
211af6103a Merge pull request 'features/crud_entites' (#14) from features/crud_entites into develop
Reviewed-on: #14
2025-12-17 14:12:53 +00:00
d27b622db8 Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#12) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 35s
Reviewed-on: #12
2025-12-16 18:22:48 +00:00
c80b40082c Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#10) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 44s
Reviewed-on: #10
2025-12-16 18:06:52 +00:00
4a88af6487 Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#8) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 34s
Reviewed-on: #8
2025-12-05 19:24:00 +00:00
966b0af1c2 Merge pull request 'Changement en DB du nom de la colonne personne_id en proprietaire_id dans la table enquete' (#6) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 36s
Reviewed-on: #6
2025-12-05 19:20:57 +00:00
58aa088ac3 Merge pull request 'ajout de ci-cd' (#4) from features/crud_entites into develop
All checks were successful
CD - Deploy on main / deploy (pull_request) Successful in 39s
Reviewed-on: #4
2025-12-05 19:10:37 +00:00
033b430051 Merge pull request 'ajout de ci-cd' (#2) from features/crud_entites into develop
Some checks failed
CD - Deploy on main / deploy (pull_request) Failing after 39s
Reviewed-on: #2
2025-12-05 19:06:43 +00:00
b8dbc7f625 Merge pull request 'ajout de ci-cd' (#1) from features/crud_entites into develop
Reviewed-on: #1
2025-12-05 17:53:30 +00:00
482 changed files with 1916 additions and 13990 deletions

View File

@@ -52,10 +52,8 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV"
# 4) Checkout du dépôt
#- name: Checkout repository
# uses: https://gitea.com/actions/checkout@v4 #actions/checkout@v4
- name: Checkout repository
run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
uses: actions/checkout@v4
# 5) Informations de contexte (sans secrets)
- name: Show context information

View File

@@ -52,10 +52,8 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV"
# 4) Checkout du dépôt
#- name: Checkout repository
# uses: https://gitea.com/actions/checkout@v4 #actions/checkout@v4
- name: Checkout repository
run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
uses: actions/checkout@v4
# 5) Création des secrets runtime (CI uniquement)
- name: Create runtime secrets

3
.gitignore vendored
View File

@@ -4,5 +4,4 @@ fiscad.log*
target/*
ansible
secrets/
.env
/uploads/
.env

18
pom.xml
View File

@@ -73,7 +73,6 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
@@ -150,24 +149,7 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.wildbit.java</groupId>
<artifactId>postmark</artifactId>
<version>1.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>

View File

@@ -1,13 +1,9 @@
package io.gmss.fiscad.configuration;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.gmss.fiscad.security.CustomUserDetailsService;
import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
@@ -67,7 +63,4 @@ public class ApplicationConfig {
return authenticationManagerBuilder.build();
}
}

View File

@@ -1,50 +0,0 @@
package io.gmss.fiscad.configuration;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new Jdk8Module());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return mapper;
}
@Bean
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
return builder -> {
builder.modules(new JavaTimeModule(), new Jdk8Module());
builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
};
}
@Bean
public RestTemplate restTemplate(ObjectMapper mapper) {
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
MappingJackson2HttpMessageConverter converter =
new MappingJackson2HttpMessageConverter(mapper);
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().removeIf(
c -> c instanceof MappingJackson2HttpMessageConverter
);
restTemplate.getMessageConverters().add(converter);
return restTemplate;
}
}

View File

@@ -1,120 +0,0 @@
//package io.gmss.fiscad.configuration;
//
//import com.backend.api.security.CustomUserDetailsService;
//import com.backend.api.security.JwtAuthenticationEntryPoint;
//import com.backend.api.security.JwtAuthenticationFilter;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpMethod;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.BeanIds;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
//
//@Configuration
//@EnableWebSecurity // active la sécurité web sur le projet
//@EnableGlobalMethodSecurity( // est utilisé pour définir la sécurité sur les méthodes
// securedEnabled = true, // est activé pour protéger un controlleur ou un service
// jsr250Enabled = true, // active le role qui doit être utilisé
// prePostEnabled = true // active le controle avant et après l'execution de la requête
//)
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
//
// /**
// * Est utilisé pour authentifier un utlisateur ou pour définir un role
// */
// @Autowired
// CustomUserDetailsService customUserDetailsService;
//
// @Autowired
// private JwtAuthenticationEntryPoint unauthorizedHandler;
//
// @Bean
// public JwtAuthenticationFilter jwtAuthenticationFilter() {
// return new JwtAuthenticationFilter();
// }
//
//
//
// private static final String[] AUTH_WHITELIST = {
//
// // -- swagger ui
// "/swagger-resources/**",
// "/swagger-ui.html",
// "/v3/api-docs",
// "/swagger-ui/**",
// "/webjars/**",
// "/api/**",
//// "/api/synonym/**",
// "/api/auth/**"
// };
// @Override
// public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
// authenticationManagerBuilder
// .userDetailsService(customUserDetailsService)
// .passwordEncoder(passwordEncoder());
// }
//
// @Bean(BeanIds.AUTHENTICATION_MANAGER)
// @Override
// public AuthenticationManager authenticationManagerBean() throws Exception {
// return super.authenticationManagerBean();
// }
//
// @Bean
// public PasswordEncoder passwordEncoder() {
// return new BCryptPasswordEncoder();
// }
//
// /**
// *
// * @param http
// * @throws Exception
// */
// @Override
// protected void configure(HttpSecurity http) throws Exception {
// http
// .cors()
// .and()
// .csrf()
// .disable()
// .exceptionHandling()
// .authenticationEntryPoint(unauthorizedHandler)
// .and()
// .sessionManagement()
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
// .and()
// .authorizeRequests()
// .antMatchers("/",
// "/favicon.ico",
// "/**/*.png",
// "/**/*.gif",
// "/**/*.svg",
// "/**/*.jpg",
// "/**/*.html",
// "/**/*.css",
// "/**/*.js")
// .permitAll()
// .antMatchers(AUTH_WHITELIST).permitAll()
// .antMatchers("/api/auth/**")
// .permitAll()
// .antMatchers("/api/user/checkUsernameAvailability", "/api/user/checkEmailAvailability")
// .permitAll()
// .antMatchers(HttpMethod.GET, "/api/polls/**", "/api/users/**")
// .permitAll()
// .anyRequest()
// .authenticated();
//
// // Add our custom JWT security filter
// http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
//
// }
//}

View File

@@ -1,113 +1,11 @@
package io.gmss.fiscad.configuration;
import io.gmss.fiscad.security.JwtAuthenticationEntryPoint;
import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import java.util.List;
@EnableWebSecurity
@Configuration
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true)
@RequiredArgsConstructor
public class SpringSecurityConfig {
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final AuthenticationProvider authenticationProvider;
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private static final String[] PUBLIC_ENDPOINTS = {
"/api/auth/login",
"/api/open/**",
"/api/synchronisation/references",
"/v3/api-docs/**",
"/swagger-ui/**",
"/swagger-ui.html",
"/error",
"/api/**" // A ENLEVER AVANT LA MISE EN PRODUCTION
};
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
// Désactivation CSRF car JWT stateless
.csrf(AbstractHttpConfigurer::disable)
// CORS configuration propre
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
// Gestion des exceptions dauthentification
.exceptionHandling(exception ->
exception.authenticationEntryPoint(jwtAuthenticationEntryPoint)
)
// Stateless session
.sessionManagement(session ->
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
// Configuration des autorisations
.authorizeHttpRequests(auth -> auth
// Autoriser les requêtes OPTIONS (CORS preflight)
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
// Endpoints publics
.requestMatchers(PUBLIC_ENDPOINTS).permitAll()
// Tout le reste nécessite authentification
.anyRequest().authenticated()
)
// Provider dauthentification
.authenticationProvider(authenticationProvider)
// Ajout du filtre JWT avant UsernamePasswordAuthenticationFilter
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
return http.build();
}
/**
* Configuration CORS centralisée.
* ⚠️ En production, remplacer "*" par ton domaine frontend.
*/
@Bean
public CorsConfigurationSource corsConfigurationSource() {
return request -> {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(List.of("*")); // ⚠️ restreindre en prod
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
configuration.setAllowedHeaders(List.of("*"));
configuration.setAllowCredentials(false);
return configuration;
};
}
}
/*
import io.gmss.fiscad.security.JwtAuthenticationEntryPoint;
import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -129,15 +27,16 @@ public class SpringSecurityConfig {
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final AuthenticationProvider authenticationProvider;
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private static final String[] AUTH_WHITELIST = {
// "/api/**",
"/api/**",
"/api/auth/login",
"/api/open/**",
"/api/synchronisation/references",
"/v3/api-docs/**",
"/swagger-ui/**",
"/swagger-ui.html",
"/error"
"/swagger-ui.html"
};
@@ -159,7 +58,7 @@ public class SpringSecurityConfig {
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
.authorizeHttpRequests(req ->
req
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
//.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers(AUTH_WHITELIST).permitAll()
.anyRequest()
.authenticated()
@@ -167,8 +66,11 @@ public class SpringSecurityConfig {
.authenticationProvider(authenticationProvider)
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
;
return http.build();
}
}*/
}

View File

@@ -27,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Arrondissement")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class ArrondissementController {
private final ArrondissementService arrondissementService;
@@ -175,7 +175,7 @@ public class ArrondissementController {
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementById(id).orElse(null), "Arrondissement trouvé avec succès."),
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -199,31 +199,7 @@ public class ArrondissementController {
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementListByCommuneId(communeId), "Liste des arrondissements par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/commune/{communeId}")
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementListByCommuneId(communeId,pageable), "Liste des arrondissements par commune chargée avec succès."),
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Commune")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class CommuneController {
private final CommuneService communeService;
@@ -185,31 +185,7 @@ public class CommuneController {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, communeService.getCommunesByDepartementId(departementId), "Liste des communes par département chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-departement-id/{departementId}")
public ResponseEntity<?> getCommuneByDepartementIdPaged(@PathVariable Long departementId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, communeService.getCommunesByDepartementId(departementId,pageable), "Liste des communes par département chargée avec succès."),
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Département")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class DepartementController {
private final DepartementService departementService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Nationalité")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class NationaliteController {
private final NationaliteService nationaliteService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Quartier")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class QuartierController {
private final QuartierService quartierService;
@@ -158,7 +158,7 @@ public class QuartierController {
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierById(id).orElse(null), "Quartier trouvé avec succès."),
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -182,31 +182,7 @@ public class QuartierController {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierListByArrondissementId(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/arrondissement/{arrondissementId}")
public ResponseEntity<?> getQuartierByArrondissementPaged(@PathVariable Long arrondissementId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierListByArrondissementId(arrondissementId,pageable), "Liste des quartiers par commune chargée avec succès."),
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -7,7 +7,6 @@ import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
@@ -25,7 +24,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
//@SecurityRequirement(name = "bearer")
@Tag(name = "Secteur")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class SecteurController {
@@ -315,31 +314,5 @@ public class SecteurController {
}
@Operation(
summary = "recuperer tous les secteurs d'un departement",
description = "Permet de récuperer l'ensemble des secteurs du departement dont l'ID est fourni en path"
)
@GetMapping("/by-departement-id/{departementId}")
public ResponseEntity<?> getSecteurByDepartementId(@PathVariable Long departementId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getListSecteurByDepartementId(departementId), "Secteur trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -5,7 +5,6 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -36,11 +35,11 @@ public class SecteurDecoupageController {
@PostMapping("/create")
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
try {
secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -60,10 +59,10 @@ public class SecteurDecoupageController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupagePaylaodWeb), "SecteurDecoupage mis à jour avec succès."),
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -153,58 +152,11 @@ public class SecteurDecoupageController {
}
}
@GetMapping("/by-secteur-id/{secteurId}")
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurId(@PathVariable Long secteurId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId), "Liste des secteurDecoupages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-secteur-decoupage-id/{secteurId}")
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurIdPaged(@PathVariable Long secteurId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId,pageable), "Liste des secteurDecoupages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -5,7 +5,6 @@ import io.gmss.fiscad.interfaces.decoupage.SectionService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SectionPaylaodWeb;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
@@ -22,7 +21,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/section", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
//@SecurityRequirement(name = "bearer")
@Tag(name = "Section")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class SectionController {

View File

@@ -2,7 +2,6 @@ package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.paylaods.ApiResponse;
@@ -11,8 +10,6 @@ import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -51,9 +48,9 @@ public class EnqueteController {
@PostMapping("/create")
public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) {
try {
enquetePayLoadWeb = enqueteService.createEnquete(enquetePayLoadWeb);
Enquete enquete = enqueteService.createEnquete(enquetePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, enquetePayLoadWeb, "Enquete batiment créé avec succès."),
new ApiResponse<>(true, enquete, "Enquete batiment créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -215,8 +212,8 @@ public class EnqueteController {
summary = "Récupérer les enquetes d'une parcelle",
description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles"
)
@GetMapping("/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllByParcelle(@PathVariable Long parcelleId) {
@GetMapping("/all/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin(@PathVariable Long parcelleId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "Liste des enquetes chargée avec succès."),
@@ -239,36 +236,6 @@ public class EnqueteController {
}
@Operation(
summary = "Récupérer les enquetes d'une parcelle",
description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles"
)
@GetMapping("/page/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllByParcellePaged(@PathVariable Long parcelleId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByParcellePageable(parcelleId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/dgi/decoupage-admin-for-enquete")
@@ -483,8 +450,5 @@ public class EnqueteController {
}

View File

@@ -6,13 +6,10 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.FiltreParcelle;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -31,7 +28,7 @@ import java.util.List;
@RestController
@RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE)
//@SecurityRequirement(name = "bearer")
@SecurityRequirement(name = "bearer")
@Tag(name = "Parcelle")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@@ -51,9 +48,9 @@ public class ParcelleController {
@PostMapping("/create")
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
try {
parcellePayLoadWeb = parcelleService.createParcelle(parcellePayLoadWeb);
Parcelle parcelle = parcelleService.createParcelle(parcellePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, parcellePayLoadWeb, "parcelle créée avec succès."),
new ApiResponse<>(true, parcelle, "parcelle créée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -91,7 +88,6 @@ public class ParcelleController {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
@@ -122,67 +118,12 @@ public class ParcelleController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
// @GetMapping("/all/by-decoupage")
// public ResponseEntity<?> getAllByDecoupage() {
// try {
// return new ResponseEntity<>(
// new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
@GetMapping("/id/{id}")
public ResponseEntity<?> getParcelleById(@CurrentUser UserPrincipal currentUser, @PathVariable Long id) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleByIdToDto(userId,id), "enquete trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllParcelle(@CurrentUser UserPrincipal currentUser) {
public ResponseEntity<?> getAllParcelle() {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListToDto(userId), "Liste des enquetes chargée avec succès."),
new ApiResponse<>(true, parcelleService.getParcelleList(), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -201,19 +142,37 @@ public class ParcelleController {
}
}
@GetMapping("/all/by-decoupage")
public ResponseEntity<?> getAllByDecoupage() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllParcellePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) {
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListPageableToDto(userId,pageable), "Liste des enquetes chargée avec succès."),
new ApiResponse<>(true, parcelleService.getParcelleList(pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -233,49 +192,38 @@ public class ParcelleController {
}
@PostMapping("/all-paged/multi-criteres")
public ResponseEntity<?> getAllParcelleFiltrePaged(@CurrentUser UserPrincipal currentUser, @RequestParam int pageNo, @RequestParam int pageSize, @RequestBody FiltreParcelle filtreParcelle) {
@GetMapping("/id/{id}")
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleById(id), "enquete trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/user-id/{userId}")
public ResponseEntity<?> getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleByMultiFiltre(userId,filtreParcelle,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllParcelleByQuartier(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByQuartierToDto(userId,quartierId), "Liste des enquetes chargée avec succès."),
new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -294,154 +242,6 @@ public class ParcelleController {
}
}
@GetMapping("/all-paged/by-quartier-id/{quartierId}")
public ResponseEntity<?> getAllParcelleByQuartierPaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByQuartierPageableToDto(userId,quartierId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-rue-id/{rueId}")
public ResponseEntity<?> getAllParcelleByRue(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId) {
try {
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByRueToDto(userId,rueId), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-rue-id/{rueId}")
public ResponseEntity<?> getAllParcelleByRuePaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
HttpStatus.OK
);
Long userId = currentUser.getUser().getId();
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleListByRuePageableToDto(userId,rueId,pageable), "Liste des enquetes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/syncrhonise-etat-batie-parcelle")
public ResponseEntity<?> putSynchroniseEtatBatieParcelle() {
try {
Integer nombreParcelleSync= parcelleService.majParcelleBatieNonbatie();
return new ResponseEntity<>(
new ApiResponse<>(true,nombreParcelleSync , "Parcelle mise à jour avec succes."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
// @GetMapping("/user-id/{userId}")
// public ResponseEntity<?> getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
// try {
// Pageable pageable = PageRequest.of(pageNo, pageSize);
// return new ResponseEntity<>(
// new ApiResponse<>(true, parcelleService.getParcelleDataTableListByUserId(userId,pageable), "enquete trouvé avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
}

View File

@@ -20,7 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
@SecurityRequirement(name = "bearer")
@Tag(name = "ParcelleGeometrie")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ParcelleGeomController {
private final ParcelleGeomService parcelleGeomService;
@@ -63,24 +63,6 @@ public class ParcelleGeomController {
);
}
@GetMapping("/by-quartier-id/{quartierId}")
public ResponseEntity<?> getParcellesGeomsByQuartierId(@PathVariable Long quartierId) {
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListByQuatierId(quartierId), "Liste des parcelle chargée avec succès."),
HttpStatus.OK
);
}
@GetMapping("/page/by-quartier-id/{quartierId}")
public ResponseEntity<?> getParcellesGeomsByQuartierIdPaged(@PathVariable Long quartierId,@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListByQuatierIdPaged(quartierId,pageable), "Liste des parcelle chargée avec succès."),
HttpStatus.OK
);
}
@GetMapping("/by-arrondissement/{codeArrondissement}")
public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) {
return new ResponseEntity<>(

View File

@@ -7,17 +7,12 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.dto.PersonneCompletDTO;
import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -41,9 +36,9 @@ public class PersonneController {
@PostMapping("/create")
public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) {
try {
personnePayLoadWeb = personneService.createPersonne(personnePayLoadWeb);
Personne personne = personneService.createPersonne(personnePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, personnePayLoadWeb, "Contribuable créé avec succès."),
new ApiResponse<>(true, personne, "Contribuable créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -104,7 +99,7 @@ public class PersonneController {
@GetMapping("/id/{id}")
public ResponseEntity<?> getPersonneById(@PathVariable Long id) {
try{
Optional<PersonnePayLoadWeb> optionalPersonne= personneService.getPersonneById(id);
Optional<Personne> optionalPersonne= personneService.getPersonneById(id);
return new ResponseEntity<>(
new ApiResponse<>(true, optionalPersonne.orElse(null), "Personne retrouvée avec succès."),
HttpStatus.OK
@@ -116,70 +111,4 @@ public class PersonneController {
);
}
}
@PostMapping("/recherche")
public ResponseEntity<?> rechercherPersonne(@RequestBody RecherchePersonneResquestBody recherchePersonneResquestBody ) {
try{
// personneService.recherchePersonne(recherchePersonneResquestBody);
return new ResponseEntity<>(
new ApiResponse<>(true, personneService.recherchePersonne(recherchePersonneResquestBody), "Personne retrouvée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK
);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllPersonne() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, personneService.getPersonneList(), "Liste des personnes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllPersonnePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, personneService.getPersonneList(pageable), "Liste des personnes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -1,272 +0,0 @@
package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/piece", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Piece")
@CrossOrigin(origins = "*")
public class PieceController {
private final PieceService pieceService;
private static final Logger logger = LoggerFactory.getLogger(PieceController.class);
@PostMapping("/create")
public ResponseEntity<?> createPiece(@RequestBody @Valid @Validated PiecePayLoadWeb piecePayLoadWeb) {
try {
piecePayLoadWeb = pieceService.createPiece(piecePayLoadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, piecePayLoadWeb, "Piece créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updatePiece(@PathVariable Long id, @RequestBody PiecePayLoadWeb piecePayLoadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.updatePiece(id,piecePayLoadWeb), "Piece mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deletePiece(@PathVariable Long id) {
try {
pieceService.deletePiece(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Piece supprimée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllPieceList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getPieceListToDto(), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllPiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getPieceListToDtoPageable(pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllPieceByEnqueteList(@PathVariable Long enqueteId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteToDto(enqueteId), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllPieceByParcellePaged(@PathVariable Long enqueteId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteToDtoPageable(enqueteId,pageable), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-batiment-id/{enqueteBatimentId}")
public ResponseEntity<?> getAllPieceByEnqueteBatiment(@PathVariable Long enqueteBatimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteBatimentToDto(enqueteBatimentId), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-unite-logement-id/{enqueteUniteLogementId}")
public ResponseEntity<?> getAllPieceByEnqueteUniteLogement(@PathVariable Long enqueteUniteLogementId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getAllPieceByEnqueteUniteLogementToDto(enqueteUniteLogementId), "Liste des pieces chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getPieceById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, pieceService.getPieceByToDto(id), "Piece trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -1,7 +1,6 @@
package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.interfaces.infocad.metier.UploadService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.JobModels;
import io.gmss.fiscad.proprietes.ZipStorageProperties;
@@ -9,9 +8,6 @@ import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
import io.gmss.fiscad.service.FileStorageService;
import io.gmss.fiscad.service.StringManager;
import io.gmss.fiscad.service.ZipAsyncService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
@@ -49,13 +45,12 @@ import java.util.UUID;
@SecurityRequirement(name = "bearer")
@Tag(name = "Upload")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class UploadController {
boolean headIsValid = false;
private final ZipAsyncService service;
private final ZipStorageProperties props;
private final UploadService uploadService;
private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
@Autowired
@@ -99,7 +94,7 @@ public class UploadController {
try {
if (uploadRepository.findById(id).isPresent()) {
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findById(id), "File with id {" + id + "} is found."), HttpStatus.OK);
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK);
} else {
return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK);
}
@@ -144,39 +139,30 @@ public class UploadController {
.body(resource);
}
@PostMapping(
value = "/save",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
)
public ResponseEntity<?> saveFilePieceId(
@Parameter(
description = "Fichier à uploader",
required = true,
content = @Content(
mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE,
schema = @Schema(type = "string", format = "binary")
)
)
@RequestPart("file") MultipartFile file,
@PostMapping("/save")
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file, @RequestParam String reference, @RequestParam String description /*, @RequestParam Long idTypeUpload*/) {
@Parameter(description = "ID de la pièce", required = true)
@RequestParam("pieceId") Long pieceId
) {
try {
return ResponseEntity.ok(
new ApiResponse(true,
uploadService.createUpload(file, pieceId),
"File has been created successfully.")
);
Upload upload = new Upload();
String fileName = fileStorageService.storeFile(file);
upload.setFileName(fileName);
upload.setMimeType(file.getContentType());
upload.setSize(file.getSize());
upload.setOriginalFileName(file.getOriginalFilename());
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ApiResponse(false, null, e.getMessage()));
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/id/{id}")
public ResponseEntity<?> delete(@PathVariable Long id) {
try {
@@ -243,20 +229,4 @@ public class UploadController {
.orElse(ResponseEntity.notFound().build());
}
@GetMapping(path = "/by-piece/{pieceId}")
public ResponseEntity<?> getByPiece(@PathVariable("pieceId") Long pieceId) {
try{
return new ResponseEntity<>(new ApiResponse(true, uploadService.getAllUploadByPiece(pieceId), "Liste des fichier de la piece"), HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -28,7 +28,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Bloc")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class BlocController {
private final BlocService blocService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Mode d'acquisition")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ModeAcquisitionController {
private final ModeAcquisitionService modeAcquisitionService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Nature domaine")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class NatureDomaineController {
private final NatureDomaineService natureDomaineService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Position représentation")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class PositionRepresentationController {
private final PositionRepresentationService positionRepresentationService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Profession")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ProfessionController {
private final ProfessionService professionService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Situation géographique")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class SituationGeographiqueController {
private final SituationGeographiqueService situationGeographiqueService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Situation matrimoniale")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class SituationMatrimonialeController {
private final SituationMatrimonialeService situationMatrimonialeService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Source de droit")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class SourceDroitController {
private final SourceDroitService sourceDroitService;

View File

@@ -6,7 +6,6 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.StructurePaylaodWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -28,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Structure")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class StructureController {
private final StructureService structureService;
@@ -41,11 +40,11 @@ public class StructureController {
}
@PostMapping("/create")
public ResponseEntity<?> createStructure(@RequestBody StructurePaylaodWeb structurePaylaodWeb) {
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) {
try {
structurePaylaodWeb = structureService.createStructure(structurePaylaodWeb);
structure = structureService.createStructure(structure);
return new ResponseEntity<>(
new ApiResponse<>(true, structurePaylaodWeb, "Structure créé avec succès."),
new ApiResponse<>(true, structure, "Structure créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -65,10 +64,10 @@ public class StructureController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody StructurePaylaodWeb structurePaylaodWeb) {
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, structureService.updateStructure(id, structurePaylaodWeb), "Structure mise à jour avec succès."),
new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -135,6 +134,36 @@ public class StructureController {
}
@GetMapping("/all-by-arrondissement")
public ResponseEntity<?> getAllStructureListByArrondissement(@RequestParam Long arrondissementId) {
try {
if (arrondissementService.getArrondissementById(arrondissementId).isPresent()) {
return new ResponseEntity<>(
new ApiResponse<>(true, structureService.getStructuresByArrondissement(arrondissementId), "Liste des structures chargée avec succès."),
HttpStatus.OK
);
} else {
return new ResponseEntity<>(
new ApiResponse<>(false, "Impossible de trouver l'arrondissement spécifiée."),
HttpStatus.OK
);
}
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
@@ -160,53 +189,6 @@ public class StructureController {
}
@GetMapping("/by-commune/{communeId}")
public ResponseEntity<?> getAllStructureListByCommune(@PathVariable Long communeId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, structureService.getStructureListByCommuneId(communeId), "Liste des structures chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-commune/{communeId}")
public ResponseEntity<?> getAllStructureListByCommunePageable(@PathVariable Long communeId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, structureService.getStructureListByCommuneId(communeId,pageable), "Liste des structures chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
try {

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Type de contestation")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypeContestationController {
private final TypeContestationService typeContestationService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Type de domaine")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypeDomaineController {
private final TypeDomaineService typeDomaineService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Type de personne")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypePersonneController {
private final TypePersonneService typePersonneService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Type de pièce")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypePieceController {
private final TypePieceService typePieceService;

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Type de représentation")
@CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class TypeRepresentationController {
private final TypeRepresentationService typeRepresentationService;

View File

@@ -39,9 +39,9 @@ public class BatimentController {
@PostMapping("/create")
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) {
try {
batimentPaylaodWeb = batimentService.createBatiment(batimentPaylaodWeb);
Batiment batiment = batimentService.createBatiment(batimentPaylaodWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, batimentPaylaodWeb, "Batiment créé avec succès."),
new ApiResponse<>(true, batiment, "Batiment créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -154,53 +154,6 @@ public class BatimentController {
}
}
@GetMapping("/all/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllBatimentByParcelleList(@PathVariable Long parcelleId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.getBatimentListByParcelle(parcelleId), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllBatimentByParcellePaged(@PathVariable Long parcelleId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.getBatimentListByParcellePageable(parcelleId,pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
try {

View File

@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueBatimentPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -22,7 +21,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/caracteristique-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "api/caracteristique-caracteristiqueBatiment", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Caractéristique batiment")
@CrossOrigin(origins = "*")
@@ -36,25 +35,34 @@ public class CaracteristiqueBatimentController {
}
@PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) {
public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatiment caracteristiqueBatiment) {
try {
caracteristiqueBatimentPayloadWeb = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatimentPayloadWeb);
caracteristiqueBatiment = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentPayloadWeb, "Caracteristique du batiment créé avec succès."),
new ApiResponse<>(true, caracteristiqueBatiment, "Caracteristique du batiment créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) {
public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatiment caracteristiqueBatiment) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatimentPayloadWeb), "Caracteristique du batiment mise à jour avec succès."),
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -148,7 +156,7 @@ public class CaracteristiqueBatimentController {
public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentToDto(id), "Caracteristique du batiment trouvée avec succès."),
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -166,51 +174,4 @@ public class CaracteristiqueBatimentController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-batiment-id/{enqueteBatimentId}")
public ResponseEntity<?> getCaracteristiqueBatimentByBatimentId(@PathVariable Long enqueteBatimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentListByEnqueteBatiment(enqueteBatimentId), "Caracteristique du batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-enquete-batiment-id/{enqueteBatimentId}")
public ResponseEntity<?> getCaracteristiqueBatimentByEnqueteBatimentIdPaged(@PathVariable Long enqueteBatimentId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentListByEnqueteBatimentPageable(enqueteBatimentId,pageable), "Caracteristique du batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueParcellePayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -36,11 +35,11 @@ public class CaracteristiqueParcelleController {
}
@PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) {
try {
caracteristiqueParcellePayloadWeb = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcellePayloadWeb);
caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcellePayloadWeb, "Caracteristique parcelle créé avec succès."),
new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -60,10 +59,10 @@ public class CaracteristiqueParcelleController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcelle caracteristiqueParcelle) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcellePayloadWeb), "Caracteristique parcelle mise à jour avec succès."),
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -175,52 +174,4 @@ public class CaracteristiqueParcelleController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllCaracteristiqueParcelleList(@PathVariable Long enqueteId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleByEnqueteList(enqueteId), "Liste des Caracteristiques parcelles chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-enquete-id/{enqueteId}")
public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@PathVariable Long enqueteId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleByEnqueteListPageable(enqueteId,pageable), "Liste des Caracteristiques parcelles chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.CaracteristiqueUniteLogementPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -36,11 +35,11 @@ public class CaracteristiqueUniteLogementController {
}
@PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
try {
caracteristiqueUniteLogementPayloadWeb = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogementPayloadWeb);
caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementPayloadWeb, "Caracteristique Unite Logement créé avec succès."),
new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -60,10 +59,10 @@ public class CaracteristiqueUniteLogementController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogementPayloadWeb), "Caracteristique Unite Logement mise à jour avec succès."),
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -175,51 +174,4 @@ public class CaracteristiqueUniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-enquete-ulo-id/{enqueteUloId}")
public ResponseEntity<?> getAllCaracteristiqueUniteLogementListByEul(@PathVariable Long enqueteUloId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementListbyEul(enqueteUloId), "Liste des Caracteristiques Unite Logement chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-enquete-ulo-id/{enqueteUloId}")
public ResponseEntity<?> getAllCaracteristiqueUniteLogementByEulPaged(@PathVariable Long enqueteUloId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementListByEul(enqueteUloId,pageable), "Liste des Caracteristiques Unite Logement chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -1,226 +0,0 @@
package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@AllArgsConstructor
@RestController
@RequestMapping(value = "api/declaration-nc", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Déclaration NC")
@CrossOrigin(origins = "*")
public class DeclarationNcController {
private final DeclarationNcService declarationNcService;
private static final Logger logger = LoggerFactory.getLogger(DeclarationNcController.class);
@PostMapping("/create")
public ResponseEntity<?> createDeclarationNc(@RequestBody @Valid @Validated DeclarationNcPayloadWeb declarationNcPayloadWeb) {
try {
declarationNcPayloadWeb = declarationNcService.createDeclarationNc(declarationNcPayloadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcPayloadWeb, "Déclaration NC créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody DeclarationNcPayloadWeb declarationNcPayloadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.updateDeclarationNc(id, declarationNcPayloadWeb), "Enquete batiment mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) {
try {
declarationNcService.deleteDeclarationNc(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Déclaration Nc supprimée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllEnqueteBatimentList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcList(), "Liste des Enquetes batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcList(pageable), "Liste des Enquetes batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcById(id), "Enquete batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-personne-id/{personneId}")
public ResponseEntity<?> getDeclarationNcByPersonne(@PathVariable Long personneId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcByPersonneList(personneId), "Déclarations NC trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-personne-id/{personneId}")
public ResponseEntity<?> getDeclarationNcByPersonnePaged(@PathVariable Long personneId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, declarationNcService.getDeclarationNcByPersonneList(personneId,pageable), "Déclaration NC trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -7,10 +7,7 @@ import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -163,104 +160,6 @@ public class DonneesImpositionTfuController {
}
}
@GetMapping("/all-page/by-imposition-id/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdPageable(impositionId, pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/non-batie/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdNonBatiePaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdNonBatiePageable(impositionId, pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/batie-batiment/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdBatieBatimentPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdBatieBatimentPageable(impositionId, pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-page/by-imposition-id/batie-unite-logement/{impositionId}")
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdBatieUniteLogPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdBatieUniteLogPageable(impositionId, pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getDonneesImpositionTfuById(@PathVariable Long id) {
try {
@@ -283,91 +182,31 @@ public class DonneesImpositionTfuController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@Operation(summary = "Générer les données fiscales TFU des parcelle baties")
@PostMapping("/generer-batie")
public ResponseEntity<?> genererDonneesFiscaleBatie(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
@Operation(summary = "Générer les données fiscales TFU")
@PostMapping("/generer")
public ResponseEntity<?> genererDonneesFiscale(@RequestBody ImpositionsTfu impositionsTfu) {
try {
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfu.getId());
if(optionalImpositionsTfu.isEmpty()){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
new ApiResponse<>(false, null, "L'imposition tfu n'est pas trouvée."),
HttpStatus.OK
);
}
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.TFU_FNB_GENERE)){
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.CREE)){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
new ApiResponse<>(false, null, "le statut actuel ne permet pas cette opération."),
HttpStatus.OK
);
}
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
HttpStatus.OK
);
}
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
optionalImpositionsTfu.get().setStatusAvis(StatusAvis.GENERE);
return new ResponseEntity<>(
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition des fonciers batis Générées avec succès."),
new ApiResponse<>(true, donneesImpositionTfuService.genererDonneesFiscales(optionalImpositionsTfu.get()), "DonneesImpositionTfu trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@Operation(summary = "Générer les données fiscales TFU des parcelle baties")
@PostMapping("/generer-non-batie")
public ResponseEntity<?> genererDonneesImpositionNonBaties(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try {
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
if(optionalImpositionsTfu.isEmpty()){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
HttpStatus.OK
);
}
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.GENERATION_AUTORISE)){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
HttpStatus.OK
);
}
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
HttpStatus.OK
);
}
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleNonBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
return new ResponseEntity<>(
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition pour les fonciers non batis Générées avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);

View File

@@ -38,9 +38,9 @@ public class EnqueteBatimentController {
@PostMapping("/create")
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
try {
enqueteBatimentPayloadWeb = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb);
EnqueteBatiment enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentPayloadWeb, "Enquete batiment créé avec succès."),
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -176,51 +176,4 @@ public class EnqueteBatimentController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-batiment-id/{batimentId}")
public ResponseEntity<?> getEnqueteBatimentByBatimentId(@PathVariable Long batimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentByBatimentList(batimentId), "Enquete batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-batiment-id/{batimentId}")
public ResponseEntity<?> getEnqueteBatimentByBatimentIdPaged(@PathVariable Long batimentId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentByBatimentListPageable(batimentId,pageable), "Enquete batiment trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -38,9 +38,9 @@ public class EnqueteUniteLogementController {
@PostMapping("/create")
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
try {
enqueteUniteLogementPayloadWeb = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb);
EnqueteUniteLogement enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementPayloadWeb, "Enquete unite logement créé avec succès."),
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -176,51 +176,4 @@ public class EnqueteUniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-unite-logement-id/{uniteLogementId}")
public ResponseEntity<?> getEnqueteUniteLogementByUniteLogement(@PathVariable Long uniteLogementId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementUniteLogementList(uniteLogementId), "Enquete unite de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-unite-logement-id/{uniteLogementId}")
public ResponseEntity<?> getEnqueteUniteLogementByUniteLogementPaged(@PathVariable Long uniteLogementId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementByUniteLogementListPageable(uniteLogementId,pageable), "Enquete unite de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -2,21 +2,12 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.ws.rs.NotAcceptableException;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
@@ -30,7 +21,6 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController
@AllArgsConstructor
@RequestMapping(value = "api/impositions-tfu", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Impositions TFU")
@@ -38,32 +28,41 @@ import org.springframework.web.client.HttpClientErrorException;
public class ImpositionsTfuController {
private final ImpositionsTfuService impositionsTfuService;
private final EnqueteService enqueteService;
private static final Logger logger = LoggerFactory.getLogger(ImpositionsTfuController.class);
public ImpositionsTfuController(ImpositionsTfuService impositionsTfuService) {
this.impositionsTfuService = impositionsTfuService;
}
@PostMapping("/create")
public ResponseEntity<?> createImpositionsTfu(@CurrentUser UserPrincipal currentUser,@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
public ResponseEntity<?> createImpositionsTfu(@RequestBody @Valid @Validated ImpositionsTfu impositionsTfu) {
try {
if(currentUser==null){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
HttpStatus.OK
);
}
User user=currentUser.getUser();
if(user.getStructure().getId()!=impositionsTfuPaylaodWeb.getStructureId()){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
HttpStatus.OK
);
}
impositionsTfuPaylaodWeb = impositionsTfuService.createImpositionsTfu(impositionsTfuPaylaodWeb);
impositionsTfu = impositionsTfuService.createImpositionsTfu(impositionsTfu);
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuPaylaodWeb, "Unite de logement créé avec succès."),
new ApiResponse<>(true, impositionsTfu, "Unite de logement créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.updateImpositionsTfu(id, impositionsTfu), "Unite de logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -83,27 +82,11 @@ public class ImpositionsTfuController {
}
@PutMapping("/cloturer-enquete")
public ResponseEntity<?> cloturer(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb ) {
@PutMapping("/valider/{id}")
public ResponseEntity<?> validerImpositionsTfu(@RequestBody ImpositionsTfu impositionsTfu) {
try {
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(true, null, "Accès non autorisé"),
HttpStatus.NOT_ACCEPTABLE
);
}
User user= userPrincipal.getUser();
if(user.getStructure().getId()!=impositionsTfuPaylaodWeb.getStructureId()){
return new ResponseEntity<>(
new ApiResponse<>(true,null, "Vous n'êtes pas autorisé à cloturer les enquetes du : "+user.getStructure().getNom()),
HttpStatus.OK
);
}
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.cloturerImpositionsTfu(impositionsTfuPaylaodWeb), "enquete cloturées avec succès."),
new ApiResponse<>(true, impositionsTfuService.validerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -122,62 +105,11 @@ public class ImpositionsTfuController {
}
}
// @PutMapping("/update/{id}")
// public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
// try {
// return new ResponseEntity<>(
// new ApiResponse<>(true, impositionsTfuService.updateImpositionsTfu(id, impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
// HttpStatus.OK
// );
// } catch (HttpClientErrorException.MethodNotAllowed e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
// } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
// FileStorageException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
// } catch (NullPointerException e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage());
// return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
// }
// }
@Operation(
summary = "Autoriser la génération des avis d'un centre",
description = "Permet d'autoriser la génération des avis d'un centre pour un exervice données"
)
@PutMapping("/autoriser-generation-avis")
public ResponseEntity<?> autoriserImpositionsTfu(@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
@PutMapping("/annuler/{id}")
public ResponseEntity<?> annulerImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.autoriserGenerationImpositionsTfu(impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/rejeter")
public ResponseEntity<?> annulerImpositionsTfu(@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.rejeterImpositionsTfu(impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
new ApiResponse<>(true, impositionsTfuService.annulerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -220,19 +152,11 @@ public class ImpositionsTfuController {
}
}
@GetMapping("/all/by-user")
public ResponseEntity<?> getAllImpositionsTfuList(@CurrentUser UserPrincipal userPrincipal) {
@GetMapping("/all")
public ResponseEntity<?> getAllImpositionsTfuList() {
try {
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(true, null, "Vous n'êtes pas autorisé à acceder à cette ressource"),
HttpStatus.OK
);
}
User user= userPrincipal.getUser();
return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuByUserIdIds(user.getId()), "Liste des Enquetes des unites Logements chargée avec succès."),
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuList(), "Liste des Enquetes des unites Logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -36,11 +35,11 @@ public class UniteLogementController {
}
@PostMapping("/create")
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) {
try {
enqueteUniteLogementPaylaodWeb = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogementPaylaodWeb);
enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementPaylaodWeb, "Unite de logement créé avec succès."),
new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -60,10 +59,10 @@ public class UniteLogementController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogement enqueteUniteLogement) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogementPaylaodWeb), "Unite de logement mise à jour avec succès."),
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -154,54 +153,6 @@ public class UniteLogementController {
}
}
@GetMapping("/all/by-batiment-id/{batimentId}")
public ResponseEntity<?> getAllUniteLogementListByBatiment(@PathVariable Long batimentId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByBatiment(batimentId), "Liste des Enquetes des unites Logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged/by-batiment-id/{batimentId}")
public ResponseEntity<?> getAllUniteLogementByBatimentPaged(@PathVariable Long batimentId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByBatimentPageable(batimentId,pageable), "Liste des enquetes des unites de logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
try {
@@ -224,27 +175,4 @@ public class UniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-parcelle-id/{id}")
public ResponseEntity<?> getUniteLogementByParcelleId(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByParcelle(id), "Unite de de logement trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -2,9 +2,8 @@ package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuBati;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuBatiService;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.BaremRfuBatiPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -25,20 +24,20 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer")
@Tag(name = "Barem Rfu")
public class BaremRfuController {
private final BaremRfuBatiService baremRfuBatiService;
private final BaremRfuService baremRfuService;
private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class);
public BaremRfuController(BaremRfuBatiService baremRfuBatiService) {
this.baremRfuBatiService = baremRfuBatiService;
public BaremRfuController(BaremRfuService baremRfuService) {
this.baremRfuService = baremRfuService;
}
@PostMapping("/create")
public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBati baremRfuBati) {
try {
baremRfuBatiPayloadWeb = baremRfuBatiService.createBaremRfu(baremRfuBatiPayloadWeb);
baremRfuBati = baremRfuService.createBaremRfu(baremRfuBati);
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiPayloadWeb, "BaremRfuBati créé avec succès."),
new ApiResponse<>(true, baremRfuBati, "BaremRfuBati créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -58,10 +57,10 @@ public class BaremRfuController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateBaremRfu(@PathVariable Long id, @RequestBody BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
public ResponseEntity<?> updateBaremRfu(@PathVariable Long id, @RequestBody BaremRfuBati baremRfuBati) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.updateBaremRfu(id, baremRfuBatiPayloadWeb), "BaremRfuBati mis à jour avec succès."),
new ApiResponse<>(true, baremRfuService.updateBaremRfu(id, baremRfuBati), "BaremRfuBati mis à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -83,7 +82,7 @@ public class BaremRfuController {
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) {
try {
baremRfuBatiService.deleteBaremRfu(id);
baremRfuService.deleteBaremRfu(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "BaremRfuBati supprimée avec succès."),
HttpStatus.OK
@@ -108,7 +107,7 @@ public class BaremRfuController {
public ResponseEntity<?> getAllBaremRfuList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."),
new ApiResponse<>(true, baremRfuService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -133,7 +132,7 @@ public class BaremRfuController {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."),
new ApiResponse<>(true, baremRfuService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -156,7 +155,7 @@ public class BaremRfuController {
public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."),
new ApiResponse<>(true, baremRfuService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -175,68 +174,13 @@ public class BaremRfuController {
}
}
@GetMapping("/by-categorie-batiment-id/{idCategorieBatiment}")
@GetMapping("/categorie-batiment/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByType( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idCategorieBatiment) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuByCategorieBatiment(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-arrondissement-id/by-categorie-batiment-id/{idArrondissement}/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByArrondisementAndCategorie( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idArrondissement,
@PathVariable Long idCategorieBatiment
) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuByArrondissementAndCategorieBatiment(idArrondissement,idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-quartier-id/by-categorie-batiment-id/{idQuartier}/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByQuartierAndCategorie( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idQuartier,
@PathVariable Long idCategorieBatiment
) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuByQuartierAndCategorieBatiment(idQuartier,idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
new ApiResponse<>(true, baremRfuService.getBaremRfuByType(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -4,7 +4,6 @@ import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuNonBatiService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.BaremRfuNonBatiPayloadWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -35,11 +34,11 @@ public class BaremRfuNonBatiController {
@PostMapping("/create")
public ResponseEntity<?> createBaremRfuNonBati(@RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
public ResponseEntity<?> createBaremRfuNonBati(@RequestBody @Valid @Validated BaremRfuNonBati baremRfuNonBati) {
try {
baremRfuNonBatiPayloadWeb = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBatiPayloadWeb);
baremRfuNonBati = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBati);
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiPayloadWeb, "BaremRfuNonBati créé avec succès."),
new ApiResponse<>(true, baremRfuNonBati, "BaremRfuNonBati créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +58,10 @@ public class BaremRfuNonBatiController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateBaremRfuNonBati(@PathVariable Long id, @RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
public ResponseEntity<?> updateBaremRfuNonBati(@PathVariable Long id, @RequestBody BaremRfuNonBati baremRfuNonBati) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBatiPayloadWeb), "BaremRfuNonBati mis à jour avec succès."),
new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBati), "BaremRfuNonBati mis à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -157,31 +156,7 @@ public class BaremRfuNonBatiController {
public ResponseEntity<?> getBaremRfuNonBatiById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiById(id).orElse(null), "BaremRfuNonBati trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-commune-id/by-zone-id/{communeId}/{zoneId}")
public ResponseEntity<?> getBaremRfuNonBatiByCommineAndZoneId(@PathVariable Long communeId, Long zoneId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiByCommuneAndZoneId(communeId,zoneId).orElse(null), "BaremRfuNonBati trouvée avec succès."),
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiById(id), "BaremRfuNonBati trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -1,180 +0,0 @@
package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.UsageService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/usage", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Usage")
public class UsageController {
private final UsageService usageService;
private static final Logger logger = LoggerFactory.getLogger(UsageController.class);
public UsageController(UsageService usageService) {
this.usageService = usageService;
}
@PostMapping("/create")
public ResponseEntity<?> createUsage(@RequestBody @Valid @Validated Usage usage) {
try {
usage = usageService.createUsage(usage);
return new ResponseEntity<>(
new ApiResponse<>(true, usage, "Usage créé avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateUsage(@PathVariable Long id, @RequestBody Usage usage) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.updateUsage(id, usage), "Usage mis à jour avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteUsager(@PathVariable Long id) {
try {
usageService.deleteUsage(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Usage supprimée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all")
public ResponseEntity<?> getAllUsageList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.getUsageList(), "Liste des usages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllUsagePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.getUsageList(pageable), "Liste des usages chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getUsageById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, usageService.getUsageById(id), "Usage trouvée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -11,7 +11,6 @@ import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.JwtAuthenticationResponse;
import io.gmss.fiscad.paylaods.Login;
import io.gmss.fiscad.paylaods.UserRequest;
import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -91,13 +90,13 @@ public class AuthController {
}
@PostMapping("/signup")
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) {
try {
//User user = getUser(userRequest);
//user.setUsername(userRequest.getEmail());
userPaylaodWeb = userService.createUser(userPaylaodWeb);
User user = getUser(userRequest);
user.setUsername(userRequest.getEmail());
user = userService.createUser(user, true);
return new ResponseEntity<>(
new ApiResponse<>(true, userPaylaodWeb, "Inscription effectué avec succès."),
new ApiResponse<>(true, user, "Inscription effectué avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -116,5 +115,18 @@ public class AuthController {
}
}
private User getUser(UserRequest userRequest) {
User user = new User();
user.setNom(userRequest.getNom());
user.setPrenom(userRequest.getPrenom());
user.setTel(userRequest.getTelephone());
user.setEmail(userRequest.getEmail());
user.setUsername(userRequest.getEmail());
user.setPassword(userRequest.getPassword());
user.setActive(false);
//Set<Role> roleSet = new HashSet<>();
//user.setAvoirFonctions(roleSet);
user.setStructure(structureService.getStructureById(userRequest.getStructureId()).get());
return user;
}
}

View File

@@ -39,8 +39,9 @@ public class AvoirFonctionController {
@PostMapping("/create")
public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) {
try {
AvoirFonction avoirFonction = avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb), "Fonction utilisateur créée avec succès."),
new ApiResponse<>(true, avoirFonction, "Fonction utilisateur créée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -130,6 +131,52 @@ public class AvoirFonctionController {
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionById(id), "Fonction utilisateur trouvés avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/utilisateur-id/{userId}")
public ResponseEntity<?> getByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonctionService.getUserAvoirFonctionById(userId), "Fonctions de utilisateur trouvées avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
@@ -156,79 +203,4 @@ public class AvoirFonctionController {
}
}
@GetMapping("/id/{id}")
public ResponseEntity<?> getById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionById(id), "Fonction utilisateur trouvés avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/by-utilisateur-id/{userId}")
public ResponseEntity<?> getByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionByUserId(userId), "Fonctions de utilisateur trouvées avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/by-utilisateur-id/{userId}")
public ResponseEntity<?> getByUserIdPageable(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionByUserId(userId,pageable), "Fonctions de utilisateur trouvées avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -22,7 +22,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/profil", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "api/profile", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Profile")
@CrossOrigin(origins = "*")

View File

@@ -8,15 +8,12 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.user.UserService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.Login;
import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb;
import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -24,7 +21,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import java.util.Optional;
import java.util.Set;
@@ -44,11 +40,12 @@ public class UserController {
}
@PostMapping("/create")
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) {
try {
userPaylaodWeb = userService.createUser(userPaylaodWeb);
user.setUsername(user.getEmail());
user = userService.createUser(user, true);
return new ResponseEntity<>(
new ApiResponse<>(true, userPaylaodWeb, "Utilisateur créé avec succès"),
new ApiResponse<>(true, user, "Utilisateur créé avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -94,9 +91,9 @@ public class UserController {
@PostMapping("/reset-password")
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
try {
UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername());
User user = userService.resetPassword(login.getUsername(), login.getPassword());
return new ResponseEntity<>(
new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."),
new ApiResponse<>(true, user, "Votre mot de passe à été réinitialisée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -115,10 +112,10 @@ public class UserController {
}
}
@PostMapping("/validate-user-account/{userName}")
public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
@PostMapping("/validate-user-account")
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
try {
User user = userService.validateUserAccount(userName);
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
return new ResponseEntity<>(
new ApiResponse<>(true, user, "Cet compte à été activé avec succès."),
HttpStatus.OK
@@ -141,10 +138,10 @@ public class UserController {
@PutMapping("/update/{id}")
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody UserPaylaodWeb userPaylaodWeb) {
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody User user) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, userService.updateUser(id, userPaylaodWeb), "Utilisateur modifié avec succès."),
new ApiResponse<>(true, userService.updateUser(id, user), "Utilisateur modifié avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -163,37 +160,31 @@ public class UserController {
}
}
@GetMapping("/activate/{id}")
public ResponseEntity<?> acitvateUser(@PathVariable Long id) {
@GetMapping("/activate-or-not/{id}")
public ResponseEntity<?> acitvateOrNotUser(@PathVariable Long id) {
try {
User user = userService.activateUser(id);
return new ResponseEntity<>(
new ApiResponse<>(true, user, "Utilisateur activé avec succès"),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
User user = userService.getUserById(id);
// if(user.getAvoirFonctions().isEmpty()){
// return new ResponseEntity<>(
// new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
// HttpStatus.OK
// );
// }
@GetMapping("/desactivate/{id}")
public ResponseEntity<?> disacitvateUser(@PathVariable Long id) {
try {
User user = userService.disactivateUser(id);
if(user.isResetPassword()){
return new ResponseEntity<>(
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
HttpStatus.OK
);
}
user = userService.activateOrNotUser(id);
String message = "Utilisateur activé avec succès";
if (!user.isActive()) {
message = "Utilisateur désactivé avec succès";
}
return new ResponseEntity<>(
new ApiResponse<>(true, user, "Utilisateur désactivé avec succès"),
new ApiResponse<>(true, user, message),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -238,11 +229,17 @@ public class UserController {
@GetMapping("/all")
public ResponseEntity<?> getAll() {
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
try {
if(userPrincipal==null){
return new ResponseEntity<>(
new ApiResponse<>(false, null, "Vous n'êtes pas authorisés à accéder à la liste des utilisateurs"),
HttpStatus.OK
);
}
return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserToDto(), "Liste des utilisateurs chargée avec succès."),
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
@@ -260,65 +257,20 @@ public class UserController {
}
}
@GetMapping("/all-paged")
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
@GetMapping("/all-by-structure")
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserToDto(pageable), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/all-by-structure/{structureId}")
public ResponseEntity<?> getAllByStructure(@PathVariable Long structureId) {
try {
if (userPrincipal.getUser().getStructure() != null) {
return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs chargée avec succès."),
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/page/all-by-structure/{structureId}")
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
} else {
return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId,pageable), "Liste des utilisateurs chargée avec succès."),
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."),
HttpStatus.OK
);
}
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
@@ -336,6 +288,14 @@ public class UserController {
}
// @GetMapping("/all-paged")
// public ResponseEntity<?> getAllpaged(@RequestParam int pageNo, @RequestParam int pageSize) {
// Pageable pageable = PageRequest.of(pageNo, pageSize);
// return new ResponseEntity<>(
// new ApiResponse<>(true, userService.getUserList(pageable), "Liste des utilisateurs chargée avec succès."),
// HttpStatus.OK
// );
// }
@GetMapping("/id/{id}")
public ResponseEntity<?> getUserById(@PathVariable Long id) {
@@ -383,5 +343,26 @@ public class UserController {
}
}
@GetMapping("/all-by-role/{userrole}")
public ResponseEntity<?> getUserByUserRole(@PathVariable UserRole userrole) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, userService.getUserByProfil(userrole), "Users found."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -1,28 +0,0 @@
package io.gmss.fiscad.entities;
import io.gmss.fiscad.entities.audit.UserDateAudit;
import io.gmss.fiscad.enums.ParametersType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Entity
@Getter
@Setter
public class Parameters extends UserDateAudit implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
private ParametersType name;
private String value;
public Parameters() {
}
}

View File

@@ -1,43 +0,0 @@
package io.gmss.fiscad.entities.audit;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.io.Serializable;
import java.time.Instant;
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class DateAudit implements Serializable {
@JsonIgnore
@CreatedDate
// @Column(updatable = false)
private Instant createdAt= Instant.now() ;
@JsonIgnore
@LastModifiedDate
// @Column(nullable = false)
private Instant updatedAt=Instant.now();
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@@ -1,37 +0,0 @@
package io.gmss.fiscad.entities.audit;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import java.io.Serializable;
@MappedSuperclass
public abstract class UserDateAudit extends DateAudit implements Serializable {
@JsonIgnore
@CreatedBy
@Column(updatable = false)
private Long createdBy;
@JsonIgnore
@LastModifiedBy
private Long updatedBy;
public Long getCreatedBy() {
return createdBy;
}
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
public Long getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(Long updatedBy) {
this.updatedBy = updatedBy;
}
}

View File

@@ -29,8 +29,6 @@ public class Quartier extends BaseEntity implements Serializable {
@ManyToOne
private Arrondissement arrondissement;
private String longitude;
private String latitude;
// @JsonIgnore
// @OneToOne(mappedBy = "quartier")
// private Bloc bloc;

View File

@@ -8,7 +8,6 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.infocad.parametre.Bloc;
import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
@@ -55,29 +54,15 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
private Boolean litige;
private boolean litige;
@ManyToOne
private User user;
//@JsonIgnore
@ManyToOne
private Exercice exercice;
@JsonIgnore
@ManyToOne
private ModeAcquisition modeAcquisition;
private Exercice exercice;
private Long mobileDataId;
@@ -131,7 +116,7 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateSynchronisation;
private Boolean synchronise;
private boolean synchronise;
private String observationParticuliere;
@Transient
private String nomPrenomEnqueteur;
@@ -188,8 +173,6 @@ public class Enquete extends BaseEntity implements Serializable {
private Long montantAnnuelleLocation;
private Long valeurParcelleEstime;
private Long valeurParcelleReel;
private Long valeurParcelleCalcule;
private String ncProprietaire;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
@@ -199,20 +182,15 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExcemption;
private String representantNom;
private String representantPrenom;
private String representantTel;
private String representantNpi;
//
// @JsonIgnore
// @OneToMany(mappedBy = "enquete")
// @JsonManagedReference
// private List<EnqueteUniteLogement> enqueteUniteLogements;
@JsonIgnore
@OneToMany(mappedBy = "enquete")
@JsonManagedReference
private List<EnqueteUniteLogement> enqueteUniteLogements;
// @JsonIgnore
// @JsonManagedReference
// @OneToMany(mappedBy = "enquete")
// private List<EnqueteBatiment> enqueteBatiments;
@JsonIgnore
@JsonManagedReference
@OneToMany(mappedBy = "enquete")
private List<EnqueteBatiment> enqueteBatiments;
@JsonIgnore
@OneToMany(mappedBy = "enquete")

View File

@@ -1,15 +1,10 @@
package io.gmss.fiscad.entities.infocad.metier;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine;
import io.gmss.fiscad.entities.rfu.metier.Batiment;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
@@ -17,7 +12,6 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@@ -44,23 +38,21 @@ public class Parcelle extends BaseEntity implements Serializable {
private String altitude;
private String situationGeographique;
@ColumnDefault("0.0")
private Float superficie;
private float superficie;
@ManyToOne
private NatureDomaine natureDomaine;
@ManyToOne
private TypeDomaine typeDomaine;
@JsonIgnore
@ManyToOne
private Quartier quartier;
private String i;
private String p;
private String observation;
private String numeroTitreFoncier;
private LocalDate dateTitreFoncier ;
private String numTitreFoncier;
@JsonIgnore
@ManyToOne
private Tpe terminal;
private String autreNumeroTitreFoncier;
private Long typeDomaineId;
private Long numeroProvisoire;
private Long blocId;
@ColumnDefault("false")
@@ -72,18 +64,6 @@ public class Parcelle extends BaseEntity implements Serializable {
@ManyToOne
private Rue rue ;
private String numeroRue ;
private Boolean batie;
private Integer nombrePiscine;
@ManyToOne
private Usage usage;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
// private String ncProprietaire ;
// @JsonIgnore
// @OneToMany(mappedBy = "parcelle")
// private List<Batiment> batiments;

View File

@@ -10,7 +10,6 @@ import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.enums.SourceDonnee;
import io.gmss.fiscad.enums.StatutParcelle;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
@@ -25,7 +24,6 @@ import org.n52.jackson.datatype.jts.GeometryDeserializer;
import org.n52.jackson.datatype.jts.GeometrySerializer;
import java.io.Serializable;
import java.time.LocalDate;
@EqualsAndHashCode(callSuper = true)
@Entity
@@ -41,63 +39,27 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String NomDepartement;
private String NomCommune;
private String NomArrondissement;
private String NomVillageQuartier;
private String codeBloc;
private String q;
private String ilot;
private String zone;
private String p;
@Column(unique = true,nullable = true)
private String nup;
@Column(unique = true,nullable = true)
private String nupProvisoire;
private String longitude;
private String latitude;
private String codeDepartement;
private String nomDepartement;
private String codeCommune;
private String nomCommune;
private String codeArrondissement;
private String nomArrondissement;
private String codeQuartierVillage;
private String nomVillageQuartier;
private String codeBloc;
private String numeroRue;
private String numeroEntreePorte;
private String codeInstad;
private String numeroEtatLieux;
private String numeroTitreFoncier;
private LocalDate dateTitreFoncier;
private Boolean batie ;
private String npi;
private String ifu;
private String nom;
private String prenom;
private String raisonSociale;
private String nomEtPrenoms;
private String telephone;
private String adresse;
private String nomRepresentant;
private String prenomRepresentant;
private String raisonSocialeRepresentant;
private String nomEtPrenomsRepresentant;
private String telephoneRepresentant;
private String adresseRepresentant;
private String q;
private String zone;
private String ilot;
private String p;
private String qLotissement;
private String ilotLotissement;
private String pLotissement;
private String pointsPolygone;
private Integer superficie;
private String nomEtPrenoms;
private String dateCollecte;
@Enumerated(EnumType.STRING)
private SourceDonnee sourceDonnees;
private String sourceDonnees;
private String observations;
@Enumerated(EnumType.STRING)
private StatutParcelle statutParcelle;
private Long uploadId;
@@ -115,22 +77,35 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
private Arrondissement arrondissement;
@ManyToOne //(fetch = FetchType.LAZY)
@JsonBackReference
//@JsonBackReference
private Quartier quartier ;
@ColumnDefault("0")
private Integer geomSrid;
private int geomSrid;
@JsonSerialize(using = GeometrySerializer.class)
@JsonDeserialize(contentUsing = GeometryDeserializer.class)
@Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)")
private Polygon geometry;
@Column(columnDefinition = "TEXT")
private String geometryString;
private String codeInsae;
private String numeroEtatLieux;
private String numeroTitreFoncier;
private String telephone;
//private String codeParcelle;
//private String codeEquipe;
@JsonIgnore
@ManyToOne
@JsonBackReference
private Parcelle parcelle;
//private String elLot;
//private String elLettreParcelle;
//private String rfuQuartierOuZone;
//private String rfuIlot;
//private String rfuLettreParcelle;
//private String nomLotissement;
////////////
// @JsonIgnore
// @OneToOne
// private Parcelle parcelle;
// @JsonSerialize(using = GeometrySerializer.class)
// @JsonDeserialize(contentUsing = GeometryDeserializer.class)
// @Column(name = "geom",columnDefinition = "geometry(Polygon,4326)")

View File

@@ -11,8 +11,6 @@ import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.infocad.parametre.SourceDroit;
import io.gmss.fiscad.entities.infocad.parametre.TypePiece;
import io.gmss.fiscad.entities.rfu.metier.DeclarationNc;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -73,16 +71,6 @@ public class Piece extends BaseEntity implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
private Enquete enquete ;
@JsonIgnore
@JsonBackReference
@ManyToOne(fetch = FetchType.LAZY)
private EnqueteBatiment enqueteBatiment ;
@JsonIgnore
@JsonBackReference
@ManyToOne(fetch = FetchType.LAZY)
private EnqueteUniteLogement enqueteUniteLogement ;
@ManyToOne
private ModeAcquisition modeAcquisition;

View File

@@ -97,17 +97,17 @@ public class Upload extends BaseEntity implements Serializable {
System.out.println("url = " + url);
// return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null;
return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null;
}
private String serverContext() {
String url= ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/api/upload/downloadFile/")
.toUriString();
//System.out.println(url);
// if(!url.contains("8282/api")){
// url.replace("/api",":8282/api");
// }
//System.out.println(url);
if(!url.contains("8282/api")){
url.replace("/api",":8282/api");
}
return url;
}

View File

@@ -10,7 +10,6 @@ import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.metadata.MobileDataPersonne;
import io.gmss.fiscad.enums.Categorie;
import io.gmss.fiscad.enums.EtatIdentificationPersonne;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -80,12 +79,7 @@ public class Personne extends BaseEntity implements Serializable {
private int mustHaveRepresentant;
private String filePath;
@Enumerated(EnumType.STRING)
private EtatIdentificationPersonne etatIdentificationPersonne;
private String observation;
private String numeroRccm ;
private LocalDate dateRccm ;
private String email ;
@ColumnDefault("false")
private boolean synchronise;

View File

@@ -30,11 +30,11 @@ import java.util.Set;
@Data
@NoArgsConstructor
@AllArgsConstructor
//@SQLDelete(sql =
// "UPDATE structure " +
// "SET deleted = true " +
// "WHERE id = ?")
//@Where(clause = " deleted = false")
@SQLDelete(sql =
"UPDATE structure " +
"SET deleted = true " +
"WHERE id = ?")
@Where(clause = " deleted = false")
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Structure extends BaseEntity implements Serializable {
@@ -49,7 +49,7 @@ public class Structure extends BaseEntity implements Serializable {
private String tel;
private String email;
private String adresse;
//@NotNull(message = "Veuillez préciser la commune du centre d'impôts")
@NotNull
@ManyToOne
private Commune commune;
@@ -61,17 +61,4 @@ public class Structure extends BaseEntity implements Serializable {
)
private Set<Arrondissement> arrondissements;
@Override
public String toString() {
return "Structure{" +
"id=" + id +
", code='" + code + '\'' +
", nom='" + nom + '\'' +
", ifu='" + ifu + '\'' +
", rccm='" + rccm + '\'' +
", tel='" + tel + '\'' +
", email='" + email + '\'' +
", adresse='" + adresse + '\'' +
'}';
}
}

View File

@@ -7,14 +7,11 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.Internal;
import org.hibernate.annotations.Where;
import java.io.Serializable;
@@ -37,42 +34,16 @@ public class Batiment extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateConstruction;
private Long idDerniereEnquete;
private Float superficieLouee;
private Float superficieAuSol;
private Integer nombreEtage;
private Integer nombrePiscine;
private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelCalcule;
private Long montantLocatifAnnuelEstime;
private Long valeurBatimentEstime;
private Long valeurBatimentReel;
private Long valeurBatimentCalcule;
private Long montantMensuelLocation;
private Integer nbreUniteLogement;
private Integer idToitRfu;
@JsonIgnore
@ManyToOne
private Parcelle parcelle;
@ManyToOne
private Usage usage;
@ManyToOne
private CategorieBatiment categorieBatiment ;
private Long parcelleExternalKey;
@JsonIgnore
@ManyToOne
private Tpe terminal;
// private Long enqueteId;
private Long enqueteId;
private Long mobileDataId;
private Long parcelleExternalKey;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
}

View File

@@ -37,7 +37,6 @@ public class CaracteristiqueParcelle extends BaseEntity implements Serializable
@ManyToOne
private Caracteristique caracteristique;
private String valeur;
private String observation;
@JsonIgnore
@ManyToOne
private Tpe terminal;

View File

@@ -47,5 +47,3 @@ public class CaracteristiqueUniteLogement extends BaseEntity implements Serializ
private Long enqueteId;
private Long mobileDataId;
}

View File

@@ -32,23 +32,18 @@ public class DeclarationNc extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDerniereDeclaration;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDeclarationNc;
private String nc;
private String observation;
@OneToOne
private Structure structure;
@JsonIgnore
@ManyToOne
private Structure structure;
private Enquete enquete;
private Long enqueteExternalKey;
@JsonIgnore

View File

@@ -8,9 +8,6 @@ import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
import io.gmss.fiscad.enums.NatureImpot;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -74,17 +71,11 @@ public class DonneesImpositionTfu extends BaseEntity implements Serializable {
private int superficieParc;
private Long superficieAuSolBat;
private Long superficieAuSolUlog;
//private String batieOuiNon;
//private String exhonereOuiNon;
//private String batimentExhonereOuiNon;
//private String uniteLogementExhonereOuiNon;
private Boolean batie;
private Boolean exonere;
private Boolean batimentExonere;
private Boolean uniteLogementExonere;
private String batieOuiNon;
private String exhonereOuiNon;
private String batimentExhonereOuiNon;
private String uniteLogementExhonereOuiNon;
private Long valeurLocativeAdm;
private Long valeurLocativeAdm70Pour100;
private Long valeurLocativeAdmMetreCarre;
private Long montantLoyerAnnuel;
private Long tfuMetreCarre;
private Long tfuMinimum;
@@ -97,30 +88,14 @@ public class DonneesImpositionTfu extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete;
private Long enqueteId;
//private Long structureId;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "structure_id")
private Structure structure ;
private Long structureId;
private Long secteurId;
//private Long zoneRfuId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "zone_rfu_id")
private ZoneRfu zoneRfu ;
private Long zoneRfuId;
@ColumnDefault("0")
private Long valeurAdminParcelleNb;
private Float tauxTfu;
private Float montantTaxe;
private Long valeurAdminParcelleNbMetreCarre;
private float tauxParcelleNonBati;
private Long valeurAdministrativeParcelleNonBati;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "impositions_tfu_id", nullable = false)
private ImpositionsTfu impositionsTfu ;
@Enumerated(EnumType.STRING)
private NatureImpot natureImpot;
private Long valeurBatiment;
private Long valeurParcelle;
private ImpositionsTfu impositionsTfu;
}

View File

@@ -62,10 +62,10 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
@ManyToOne
private Batiment batiment;
private Long batimentExternalKey;
@OneToOne
private Parcelle parcelle;
private Long parcelleExternalKey;
@@ -74,12 +74,11 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
@OneToOne
private UniteLogement uniteLogement ;
private Long uniteLogementExternalKey;
// @JsonIgnore
// @ManyToOne
// private Enquete enquete;
@JsonIgnore
@ManyToOne
private Enquete enquete;
@JsonIgnore
@ManyToOne
@@ -91,12 +90,6 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
private Long mobileDataId;
private Long batimentExternalKey;
private Long uniteLogementExternalKey;
@Enumerated(EnumType.STRING)
@JsonIgnore
private StatutEnregistrement statutEnregistrement;

View File

@@ -12,11 +12,7 @@ import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.enums.StatutEnregistrement;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
@@ -46,32 +42,24 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// private Float surfaceAuSol;
private float surfaceAuSol;
private String autreMenuisierie;
private String autreMur;
private Boolean sbee;
private boolean sbee;
private String numCompteurSbee;
private Boolean soneb;
private boolean soneb;
private String numCompteurSoneb;
private Integer nbreLotUnite;
private Integer nbreUniteLogement;
private Integer nbrePiece;
private Integer nbreUniteLocation;
private Float superficieLouee;
private Float superficieAuSol;
private Integer nbreMenage;
private Integer nbreHabitant;
private int nbreLotUnite;
private int nbreUniteLocation;
private float surfaceLouee;
private int nbreMenage;
private int nbreHabitant;
private Long montantMensuelLocation;
private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelEstime;
private Long montantLocatifAnnuelCalcule;
private Long valeurBatimentEstime;
private Long valeurBatimentReel;
private Long valeurBatimentCalcule;
private Integer nombrePiscine;
private Integer nbreMoisLocation;
private int nbreMoisLocation;
private String autreCaracteristiquePhysique;
private String observation;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExcemption;
@@ -79,13 +67,6 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExcemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete;
@ManyToOne
private Exercice exercice;
//@JsonIgnore
@ManyToOne
private Personne personne;
@@ -104,15 +85,10 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
private Long batimentExternalKey;
private Long nbreEtage;
private String representantNom;
private String representantPrenom;
private String representantTel;
private String representantNpi;
// @JsonIgnore
// @ManyToOne(fetch = FetchType.LAZY)
// @JsonBackReference
// private Enquete enquete;
@ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference
private Enquete enquete;
@@ -131,12 +107,7 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
@OneToMany(mappedBy = "enqueteBatiment")
private List<Upload> uploads;
@Enumerated(EnumType.STRING)
@JsonIgnore
private StatutEnquete statutEnquete;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@ManyToOne
private Usage usage ;
//@Enumerated(EnumType.STRING)
//@JsonIgnore
//private StatutEnregistrement statutEnregistrement;
}

View File

@@ -11,11 +11,7 @@ import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.StatutEnquete;
import io.gmss.fiscad.enums.StatutEnregistrement;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
@@ -45,65 +41,42 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Integer nbrePiece;
private Integer nbreHabitant;
private Integer nbreMenage;
private Boolean enLocation;
private Long montantMensuelLocation;
private Integer nbreMoisLocation;
private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelCalcule;
private Long montantLocatifAnnuelEstime;
private int nbrePiece;
private int nbreHabitant;
private int nbreMenage;
private boolean enLocation;
private float montantMensuelLoyer;
private int nbreMoisLocation;
private float montantLocatifAnnuelDeclare;
private Long valeurUniteLogementEstime;
private Long valeurUniteLogementReel;
private Long valeurUniteLogementCalcule;
private Integer nombrePiscine;
private Float superficieLouee;
private Float superficieAuSol;
private Boolean sbee;
private Boolean soneb;
private float surfaceLouee;
private float SurfaceAuSol;
private boolean sbee;
private boolean soneb;
private String numCompteurSbee;
private String numCompteurSoneb;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
private LocalDate dateDebutExcemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete;
private String observation;
private Long uniteLogementExternalKey;
private LocalDate dateFinExcemption;
private String representantNom;
private String representantPrenom;
private String representantTel;
private String representantNpi;
@ManyToOne
private Exercice exercice;
// @JsonIgnore
// @ManyToOne(fetch = FetchType.LAZY)
// @JsonBackReference
// private Enquete enquete;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference
private Enquete enquete;
@ManyToOne
private UniteLogement uniteLogement;
private Long uniteLogementExternalKey;
@OneToOne
private Personne personne;
@JsonIgnore
@ManyToOne
private Tpe terminal;
@JsonIgnore
@ManyToOne
private User user;
private Long personneExternalKey;
private Long mobileDataId;
@@ -112,16 +85,16 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
@JsonManagedReference
private List<CaracteristiqueUniteLogement> caracteristiqueUniteLogements;
@JsonIgnore
@ManyToOne
private Tpe terminal;
@JsonIgnore
@ManyToOne
private User user;
//@JsonIgnore
@OneToMany(mappedBy = "enqueteUniteLogement")
private List<Upload> uploads;
@JsonIgnore
@Enumerated(EnumType.STRING)
private StatutEnquete statutEnquete;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@ManyToOne
private Usage usage ;
private StatutEnregistrement statutEnregistrement;
}

View File

@@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.entities.rfu.parametre.Participer;
import io.gmss.fiscad.enums.StatusAvis;
@@ -34,39 +33,24 @@ public class ImpositionsTfu extends BaseEntity implements Serializable {
private Long id;
@ManyToOne
private Exercice exercice;
@ManyToOne
private Commune commune;
@ManyToOne
private Structure structure ;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateGeneration;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateCloture;
private String referencePieceAdmin;
private String ReferencePieceAdmin;
private String datePieceAdmin;
@Enumerated(EnumType.STRING)
private StatusAvis statusAvis;
private Integer nombreAvis;
private Integer nombreAvisFnb;
private Integer nombreAvisBatiment;
private Integer nombreAvisUniteLog;
private Long nombreAvis;
@Column(columnDefinition = "TEXT")
private String motif;
@JsonIgnore
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "impositions_tfu_id")
private List<DonneesImpositionTfu> donneesImpositionTfus;
public Long getNombreAvis(){
return donneesImpositionTfus==null?0l:donneesImpositionTfus.size();
}
}

View File

@@ -1,45 +0,0 @@
package io.gmss.fiscad.entities.rfu.metier;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
import io.gmss.fiscad.enums.StatutParcelle;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import java.io.Serializable;
import java.time.LocalDate;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = " deleted = false")
public class SituationFiscaleParcelle extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Parcelle parcelle ;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDernierPaiement;
@ManyToOne
private Exercice exercice ;
private Long montantDu ;
private Long montantPaye ;
private Long resteAPayer ;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateSync;
}

View File

@@ -6,8 +6,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
import io.gmss.fiscad.entities.rfu.parametre.Usage;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -41,33 +39,11 @@ public class UniteLogement extends BaseEntity implements Serializable {
private List<EnqueteUniteLogement> enqueteUniteLogements;
@ManyToOne
private Batiment batiment;
@ManyToOne
private Usage usage;
private Long batimentExternalKey;
private Long idDerniereEnquete;
private Float SuperficieLouee;
private Float SuperficieAuSol;
private Long montantMensuelLocation;
private Long montantLocatifAnnuelDeclare;
private Long montantLocatifAnnuelCalcule;
private Long valeurUniteLogementEstime;
private Long valeurUniteLogementReel;
private Long valeurUniteLogementCalcule;
private Integer nombrePiscine;
@JsonIgnore
@ManyToOne
private Tpe terminal;
private Long enqueteId;
private Long mobileDataId;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateDebutExemption;
@JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExemption;
private Integer idToitRfu;
private Integer nombreEtage;
}

View File

@@ -2,7 +2,6 @@ package io.gmss.fiscad.entities.rfu.parametre;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Quartier;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -29,6 +28,4 @@ public class BaremRfuBati extends BaseEntity implements Serializable {
private CategorieBatiment categorieBatiment;
@ManyToOne
private Arrondissement arrondissement;
@ManyToOne
private Quartier quartier ;
}

View File

@@ -23,9 +23,7 @@ public class BaremRfuNonBati extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Long valeurAdministrative;
private Long valeurAdministrativeMetreCarre;
private Boolean auMetreCarre;
private Float taux;
private float taux;
@ManyToOne
private Commune commune;
@ManyToOne

View File

@@ -23,5 +23,4 @@ public class CategorieBatiment extends BaseEntity implements Serializable {
@Column(unique = true)
private String code;
private String nom;
private String standing;
}

View File

@@ -25,7 +25,7 @@ public class Exercice extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Integer annee;
private int annee;
private boolean estGenerer;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)

View File

@@ -1,29 +0,0 @@
package io.gmss.fiscad.entities.rfu.parametre;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.enums.CategorieUsage;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import java.io.Serializable;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = " deleted = false")
public class Usage extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String code;
private String nom;
@Enumerated(EnumType.STRING)
private CategorieUsage categorieUsage;
}

View File

@@ -32,17 +32,10 @@ import java.time.LocalDate;
// "SET deleted = true " +
// "WHERE id = ?")
//@Where(clause = " deleted = false")
@Table(
name = "fonction",
uniqueConstraints = {
@UniqueConstraint(columnNames = {"code"})
}
)
public class Fonction extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, unique = true)
private String code ;
private String nom ;

View File

@@ -1,8 +0,0 @@
package io.gmss.fiscad.enums;
public enum CategorieUsage {
HABITATION,
PROFESSIONNELLE,
MIXTE
}

View File

@@ -1,9 +0,0 @@
package io.gmss.fiscad.enums;
public enum EtatIdentificationPersonne {
IFU,
NPI,
IFU_NPI,
NEANT,
RFU;
}

View File

@@ -1,6 +0,0 @@
package io.gmss.fiscad.enums;
public enum NatureImpot {
TFU,
IRF
}

View File

@@ -1,19 +0,0 @@
package io.gmss.fiscad.enums;
public enum ParametersType {
EMAILS_TO,
EMAIL_FROM,
SMTP_PORT,
SMTP_HOST,
SMTP_USERNAME,
SMTP_PASSWORD,
MESSAGE_STATUT,
OBJET_RESET_PASSWORD,
CORPS_RESET_PASSWORD,
OBJET_CREATE_ACCOUNT,
CORPS_CREATE_ACCOUNT,
TOKEN_IFU_EN_LIGNE,
TAUX_TFU_HABITATION,
TAUX_TFU_PROFESSIONNELLE,
TAUX_DEFAUT_SUPERFICIE_AU_SOL;
}

View File

@@ -1,7 +0,0 @@
package io.gmss.fiscad.enums;
public enum SourceDonnee {
RFU,
ANDF,
SIGIBE
}

View File

@@ -1,11 +1,8 @@
package io.gmss.fiscad.enums;
public enum StatusAvis {
EN_COURS,
CLOTURE,
GENERATION_AUTORISE,
REJETE,
TFU_FNB_GENERE,
GENERE
CREE,
GENERE,
ANNULE,
VALIDE,
}

View File

@@ -2,10 +2,8 @@ package io.gmss.fiscad.enums;
public enum StatutEnquete {
EN_COURS,
// DECLARATION,
FINALISE,
REJETE,
VALIDE,
ECHEC,
CLOTURE
ECHEC
}

View File

@@ -1,7 +1,9 @@
package io.gmss.fiscad.enums;
public enum StatutParcelle {
NON_ENQUETER,
AJOUR,
NON_AJOUR;
ENQUETER_NON_BATIE,
ENQUETER_BATIE
}

View File

@@ -6,7 +6,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -56,28 +55,27 @@ public class ArrondissementServiceImpl implements ArrondissementService {
}
@Override
public Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable) {
return arrondissementRepository.findAllArrondissementToDtoPageable(pageable);
public Page<Arrondissement> getArrondissementList(Pageable pageable) {
return arrondissementRepository.findAll(pageable);
}
@Override
public List<ArrondissementPaylaodWeb> getArrondissementList() {
return arrondissementRepository.findAllArrondissementToDto();
public List<Arrondissement> getArrondissementList() {
return arrondissementRepository.findAll();
}
@Override
public List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId) {
return arrondissementRepository.findAllArrondissementByCommuneToDto(communeId);
public Optional<Arrondissement> getArrondissementById(Long id) {
return arrondissementRepository.findById(id);
}
@Override
public Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId, Pageable pageable) {
return arrondissementRepository.findAllArrondissementByCommuneToDtoPageable(communeId,pageable);
}
@Override
public Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id) {
return arrondissementRepository.findArrondissementToDtoById(id);
public List<Arrondissement> getArrondissementByComune(Long communeId) {
Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
if (communeOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver la commune spécifiée.");
}
return arrondissementRepository.findAllByCommune(communeOptional.get());
}

View File

@@ -6,8 +6,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -57,28 +55,27 @@ public class CommuneServiceImpl implements CommuneService {
}
@Override
public Page<CommunePaylaodWeb> getCommuneList(Pageable pageable) {
return communeRepository.findAllCommuneToDtoPageable(pageable);
public Page<Commune> getCommuneList(Pageable pageable) {
return communeRepository.findAll(pageable);
}
@Override
public List<Commune> getCommuneList() {
return communeRepository.findAll();
}
@Override
public List<CommunePaylaodWeb> getCommuneList() {
return communeRepository.findAllCommuneToDto();
public List<Commune> getCommunesByDepartement(Long departementId) {
Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
if (departementOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver le département spécifié.");
}
return communeRepository.findAllByDepartement(departementOptional.get());
}
@Override
public List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId) {
return communeRepository.findAllCommuneByDepartementToDto(departementId);
}
@Override
public Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId, Pageable pageable) {
return communeRepository.findAllCommuneByDepartementToDtoPageable(departementId,pageable);
}
@Override
public Optional<CommunePaylaodWeb> getCommuneById(Long id) {
return communeRepository.findCommuneToDtoById(id);
public Optional<Commune> getCommuneById(Long id) {
return communeRepository.findById(id);
}
}

View File

@@ -4,7 +4,6 @@ import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.DepartementRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -52,20 +51,20 @@ public class DepartementServiceImpl implements DepartementService {
}
@Override
public Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable) {
return departementRepository.findAllDepartementToDtoPageable(pageable);
public Page<Departement> getDepartementList(Pageable pageable) {
return departementRepository.findAll(pageable);
}
@Override
public List<DepartementPaylaodWeb> getDepartementList() {
return departementRepository.findAllDepartementToDto();
public List<Departement> getDepartementList() {
return departementRepository.findAll();
}
@Override
public Optional<DepartementPaylaodWeb> getDepartementById(Long id) {
public Optional<Departement> getDepartementById(Long id) {
if (departementRepository.existsById(id)) {
return departementRepository.findDepartementToDtoById(id);
return departementRepository.findById(id);
} else {
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
}

View File

@@ -6,7 +6,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -56,28 +55,31 @@ public class QuartierServiceImpl implements QuartierService {
}
@Override
public Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable) {
return quartierRepository.findAllQuartierToDtoPageable(pageable);
public Page<Quartier> getQuartierList(Pageable pageable) {
return quartierRepository.findAll(pageable);
}
@Override
public List<QuartierPaylaodWeb> getQuartierList() {
return quartierRepository.findAllQuartierToDto();
public List<Quartier> getQuartierList() {
return quartierRepository.findAll();
}
@Override
public List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId) {
return quartierRepository.findAllQuartierByArrondissementToDto(arrondissementId);
public Optional<Quartier> getQuartierById(Long id) {
if (quartierRepository.existsById(id)) {
return quartierRepository.findById(id);
} else {
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
}
}
@Override
public Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId, Pageable pageable) {
return quartierRepository.findAllQuartierByArrondissementToDtoPageable(arrondissementId,pageable);
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
if (arrondissementOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
}
return quartierRepository.getAllByArrondissement(arrondissementOptional.get());
}
@Override
public Optional<QuartierPaylaodWeb> getQuartierById(Long id) {
return quartierRepository.findQuartierToDtoById(id);
}
}

View File

@@ -6,12 +6,9 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -26,33 +23,26 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
private final SecteurDecoupageRepository secteurDecoupageRepository;
private final SecteurService secteurService;
private final ParcelleRepository parcelleRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
@Override
public SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws BadRequestException {
if (secteurDecoupagePaylaodWeb.getId() != null) {
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
if (secteurDecoupage.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
}
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
return secteurDecoupageRepository.save(secteurDecoupage);
}
@Override
public SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws NotFoundException {
if (secteurDecoupagePaylaodWeb.getId() == null) {
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
if (secteurDecoupage.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
}
if (!secteurDecoupageRepository.existsById(secteurDecoupagePaylaodWeb.getId())) {
if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) {
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
}
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
return secteurDecoupageRepository.save(secteurDecoupage);
}
@Override
@@ -66,28 +56,13 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
}
@Override
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable) {
return secteurDecoupageRepository.findAllSecteurDecoupageToDtoPageable(pageable);
public Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable) {
return secteurDecoupageRepository.findAll(pageable);
}
@Override
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList() {
return secteurDecoupageRepository.findAllSecteurDecoupageToDto();
}
@Override
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long secteurId, Pageable pageable) {
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDtoPageable(secteurId,pageable);
}
@Override
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId) {
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDto(sectionId);
}
@Override
public Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id) {
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(id);
public List<SecteurDecoupage> getSecteurDecoupageList() {
return secteurDecoupageRepository.findAll();
}

View File

@@ -50,6 +50,7 @@ public class SecteurServiceImpl implements SecteurService {
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
}
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
secteur = secteurRepository.save(secteur);
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
}
@@ -163,15 +164,8 @@ public class SecteurServiceImpl implements SecteurService {
secteurs.addAll(secteurRepository.findDistinctBySection_Id(avoirFonction.getFonction().getSection().getId()));
}else if(avoirFonction.getFonction().getStructure()!=null){
secteurs.addAll(secteurRepository.findDistinctBySection_Structure_Id(avoirFonction.getFonction().getStructure().getId()));
}else if(avoirFonction.getFonction().getDepartement()!=null){
secteurs.addAll(secteurRepository.findSectionsByDepartement(avoirFonction.getFonction().getDepartement().getId()));
}
});
return secteurs;
}
@Override
public List<Secteur> getListSecteurByDepartementId(Long departementId) {
return secteurRepository.findSectionsByDepartement(departementId);
}
}

View File

@@ -30,7 +30,6 @@ public class SectionServiceImpl implements SectionService {
throw new BadRequestException("Impossible de créer une nouvelle section ayant un id non null.");
}
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
section=sectionRepository.save(section);
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
}
@@ -44,7 +43,7 @@ public class SectionServiceImpl implements SectionService {
throw new NotFoundException("Impossible de trouver le section spécifié.");
}
Section section= entityFromPayLoadService.getSectionFromPayLoadWeb(sectionPaylaodWeb);
section=sectionRepository.save(section);
sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
return sectionRepository.findSectionToDtoById(section.getId()).orElse(null);
}

View File

@@ -43,7 +43,6 @@ import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.Query;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.data.domain.Page;
@@ -92,89 +91,14 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override
public EnquetePayLoadWeb createEnquete(EnquetePayLoadWeb enquetePayLoadWeb) throws BadRequestException {
Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId());
if (!optionalUser.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant");
}
Optional<Personne> optionalPersonne = personneRepository.findById(enquetePayLoadWeb.getPersonneId());
if (!optionalPersonne.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant");
}
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoadWeb.getParcelleId());
if (!optionalParcelle.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Parcelle inexistante");
}
Optional<ZoneRfu> optionalZoneRfu = zoneRfuRepository.findById(enquetePayLoadWeb.getZoneRfuId());
if (!optionalZoneRfu.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : zone inexistante");
}
if (enquetePayLoadWeb.getParcelleId() == null) {
throw new ApplicationException("Echec de l'enregistrement : La parcelle non renseignée.");
}
Enquete enquete = entityFromPayLoadService.getEnqueteFromPayLoadWeb(enquetePayLoadWeb);
////enregistrement de l'enquete
enquete=enqueteRepository.save(enquete);
//////Enregistrement des caractéristiques parcelle
// enquetePayLoadWeb.getCaracteristiqueParcellePayloadWebs().forEach(caracteristiqueParcellePayloadWeb -> {
// caracteristiqueParcellePayloadWeb.setEnqueteId(finalEnquete.getId());
// CaracteristiqueParcelle caracteristiqueParcelle=entityFromPayLoadService.getCaracteristiqueParcelleFromPayLoadWeb(caracteristiqueParcellePayloadWeb);
// caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
// });
/////Enregistrement des pièce de parcelles
// enquetePayLoadWeb.getPiecePayLoadWebs().forEach(piecePayLoadWeb -> {
// piecePayLoadWeb.setEnqueteId(finalEnquete.getId());
// //Piece piece=entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb);
// Piece piecefinal = pieceService.createPiece(entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb));
// piecePayLoadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> {
// uploadPayLoadWeb.setEnqueteId(finalEnquete.getId());
// Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb);
// upload.setPiece(piecefinal);
// uploadRepository.save(upload);
// });
// });
/////Enregistrement des pièce de parcelles
// enquetePayLoadWeb.getDeclarationNcPayloadWebs().forEach(declarationNcPayloadWeb -> {
// declarationNcPayloadWeb.setEnqueteId(finalEnquete.getId());
// DeclarationNc declarationNcfinal=declarationNcService.createDeclarationNc(entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb));
// declarationNcPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> {
// uploadPayLoadWeb.setEnqueteId(finalEnquete.getId());
// Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb);
// upload.setDeclarationNc(declarationNcfinal);
// uploadRepository.save(upload);
// });
// });
return enqueteRepository.findEnqueteToDto(enquete.getId()).orElse(null);
}
@Override
public EnquetePayLoadWeb updateEnquete(Long id,EnquetePayLoadWeb enquetePayLoadWeb) throws NotFoundException {
if (enquetePayLoadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
}
if (!enqueteRepository.existsById(enquetePayLoadWeb.getId())) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier.");
}
if (enquetePayLoadWeb.getParcelleId()==null) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
}
Optional<Parcelle> optionalParcelle=Optional.empty();
public Enquete createEnquete(EnquetePayLoadWeb enquetePayLoadWeb) throws BadRequestException {
Parcelle parcelle=new Parcelle();
Long rueId;
Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId());
if (!optionalUser.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant");
}
Optional<Personne> optionalProprietaire = personneRepository.findById(enquetePayLoadWeb.getPersonneId());
Optional<Personne> optionalProprietaire = personneRepository.findById(enquetePayLoadWeb.getProprietaireId());
if (!optionalProprietaire.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant");
}
@@ -183,16 +107,173 @@ public class EnqueteServiceImpl implements EnqueteService {
if (!optionalZoneRfu.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : zone inexistante");
}
///enregistrement de la pacelle
if (enquetePayLoadWeb.getParcelleId() == null) {
throw new ApplicationException("Echec de l'enregistrement : La parcelle non renseignée.");
} else {
optionalParcelle = parcelleService.getParcelleById(enquetePayLoadWeb.getParcelleId());
if(enquetePayLoadWeb.getZoneRfuId()!=null) {
Optional<Rue> optionalRue = rueRepository.findById(enquetePayLoadWeb.getZoneRfuId());
if (optionalRue.isPresent()) {
rueId = optionalRue.get().getId();
enquetePayLoadWeb.getParcellePayLoadWeb().setRueId(rueId);
}
}
Enquete enquete = entityFromPayLoadService.getEnqueteFromPayLoadWeb(enquetePayLoadWeb);
enquete=enqueteRepository.save(enquete);
return enqueteRepository.findEnqueteToDto(enquete.getId()).orElse(null);
Optional<Equipe> optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId());
///enregistrement de la pacelle
try {
if (enquetePayLoadWeb.getParcellePayLoadWeb().getId() == null) {
parcelle = parcelleService.createParcelle(enquetePayLoadWeb.getParcellePayLoadWeb());
} else {
parcelle = parcelleService.updateParcelle(enquetePayLoadWeb.getParcellePayLoadWeb().getId(),enquetePayLoadWeb.getParcellePayLoadWeb());
}
}catch (Exception e){
e.printStackTrace();
throw new ApplicationException("Echec de l'enregistrement : La parcelle non enregistrée.");
}
////enregistrement de l'enquete
Enquete enquete = new Enquete();
enquete.setDateEnquete(LocalDate.now());
//enquete.setBloc(optionalBloc.get());
enquete.setUser(optionalUser.get());
enquete.setParcelle(parcelle);
enquete.setLitige(enquetePayLoadWeb.isLitige());
enquete.setStatutEnquete(StatutEnquete.EN_COURS);
enquete.setObservationParticuliere(enquetePayLoadWeb.getObservation());
enquete.setPersonne(optionalProprietaire.orElse(null));
enquete.setZoneRfu(optionalZoneRfu.orElse(null));
enquete.setAutreAdresse(enquetePayLoadWeb.getAutreAdresse());
enquete.setAutreNumeroTitreFoncier(enquetePayLoadWeb.getAutreNumeroTitreFoncier());
enquete.setNumeroTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier());
enquete.setEquipe(optionalEquipe.orElse(null));
enquete.setDateDebutExcemption(enquetePayLoadWeb.getDateDebutExemption());
enquete.setDateFinExcemption(enquetePayLoadWeb.getDateFinExemption());
enquete.setNbreBatiment(enquetePayLoadWeb.getNbreBatiment());
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
enquete.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
enquete.setMontantMensuelleLocation(enquetePayLoadWeb.getMontantMensuelleLocation());
enquete.setMontantAnnuelleLocation(enquetePayLoadWeb.getMontantAnnuelleLocation());
enquete.setValeurParcelleEstime(enquetePayLoadWeb.getValeurParcelleEstime());
enquete.setValeurParcelleReel(enquetePayLoadWeb.getValeurParcelleReel());
Enquete finalEnquete=enqueteRepository.save(enquete);
//////Enregistrement des caractéristiques parcelle
enquetePayLoadWeb.getCaracteristiqueParcellePayloadWebs().forEach(caracteristiqueParcellePayloadWeb -> {
caracteristiqueParcellePayloadWeb.setEnqueteId(finalEnquete.getId());
CaracteristiqueParcelle caracteristiqueParcelle=entityFromPayLoadService.getCaracteristiqueParcelleFromPayLoadWeb(caracteristiqueParcellePayloadWeb);
caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
});
/////Enregistrement des pièce de parcelles
enquetePayLoadWeb.getPiecePayLoadWebs().forEach(piecePayLoadWeb -> {
piecePayLoadWeb.setEnqueteId(finalEnquete.getId());
//Piece piece=entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb);
Piece piecefinal = pieceService.createPiece(entityFromPayLoadService.getPieceFromPayLoadWeb(piecePayLoadWeb));
piecePayLoadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> {
uploadPayLoadWeb.setEnqueteId(finalEnquete.getId());
Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb);
upload.setPiece(piecefinal);
uploadRepository.save(upload);
});
});
/////Enregistrement des pièce de parcelles
enquetePayLoadWeb.getDeclarationNcPayloadWebs().forEach(declarationNcPayloadWeb -> {
declarationNcPayloadWeb.setEnqueteId(finalEnquete.getId());
DeclarationNc declarationNcfinal=declarationNcService.createDeclarationNc(entityFromPayLoadService.getDeclarationNcFromPayLoadWeb(declarationNcPayloadWeb));
declarationNcPayloadWeb.getUploadPayLoadWebs().forEach(uploadPayLoadWeb -> {
uploadPayLoadWeb.setEnqueteId(finalEnquete.getId());
Upload upload=entityFromPayLoadService.getUploadFromPayLoadWeb(uploadPayLoadWeb);
upload.setDeclarationNc(declarationNcfinal);
uploadRepository.save(upload);
});
});
return enquete;
}
@Override
public Enquete updateEnquete(Long id,EnquetePayLoadWeb enquetePayLoadWeb) throws NotFoundException {
if (enquetePayLoadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
}
if (!enqueteRepository.existsById(enquetePayLoadWeb.getId())) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier.");
}
if (enquetePayLoadWeb.getParcellePayLoadWeb()==null) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
}
Parcelle parcelle=new Parcelle();
Long rueId;
Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId());
if (!optionalUser.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant");
}
Optional<Personne> optionalProprietaire = personneRepository.findById(enquetePayLoadWeb.getProprietaireId());
if (!optionalProprietaire.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : Propriétaire inexistant");
}
Optional<ZoneRfu> optionalZoneRfu = zoneRfuRepository.findById(enquetePayLoadWeb.getZoneRfuId());
if (!optionalZoneRfu.isPresent()) {
throw new BadRequestException("Echec de l'enregistrement : zone inexistante");
}
Optional<Rue> optionalRue = rueRepository.findById(enquetePayLoadWeb.getZoneRfuId());
if (optionalRue.isPresent()) {
rueId=optionalRue.get().getId();
enquetePayLoadWeb.getParcellePayLoadWeb().setRueId(rueId);
}
Optional<Equipe> optionalEquipe = equipeRepository.findById(enquetePayLoadWeb.getEquipeId());
///enregistrement de la pacelle
try {
if (enquetePayLoadWeb.getParcellePayLoadWeb().getId() == null) {
parcelle = parcelleService.createParcelle(enquetePayLoadWeb.getParcellePayLoadWeb());
} else {
parcelle = parcelleService.updateParcelle(enquetePayLoadWeb.getParcellePayLoadWeb().getId(),enquetePayLoadWeb.getParcellePayLoadWeb());
}
}catch (Exception e){
throw new ApplicationException("Echec de l'enregistrement : La parcelle non enregistrée.");
}
////enregistrement de l'enquete
Enquete enquete = new Enquete();
enquete.setDateEnquete(LocalDate.now());
//enquete.setBloc(optionalBloc.get());
enquete.setUser(optionalUser.get());
enquete.setParcelle(parcelle);
enquete.setLitige(enquetePayLoadWeb.isLitige());
enquete.setStatutEnquete(StatutEnquete.EN_COURS);
enquete.setObservationParticuliere(enquetePayLoadWeb.getObservation());
enquete.setPersonne(optionalProprietaire.orElse(null));
enquete.setZoneRfu(optionalZoneRfu.orElse(null));
enquete.setAutreAdresse(enquetePayLoadWeb.getAutreAdresse());
enquete.setAutreNumeroTitreFoncier(enquetePayLoadWeb.getAutreNumeroTitreFoncier());
enquete.setNumeroTitreFoncier(enquetePayLoadWeb.getNumeroTitreFoncier());
enquete.setEquipe(optionalEquipe.orElse(null));
enquete.setDateDebutExcemption(enquetePayLoadWeb.getDateDebutExemption());
enquete.setDateFinExcemption(enquetePayLoadWeb.getDateFinExemption());
enquete.setNbreBatiment(enquetePayLoadWeb.getNbreBatiment());
enquete.setNbrePiscine(enquetePayLoadWeb.getNbrePiscine());
enquete.setNbreIndivisiaire(enquetePayLoadWeb.getNbreIndivisiaire());
enquete.setNbreCoProprietaire(enquetePayLoadWeb.getNbreCoProprietaire());
enquete.setNumEntreeParcelle(enquetePayLoadWeb.getNumEntreeParcelle());
enquete.setNomRue(enquetePayLoadWeb.getNomRue());
enquete.setNumRue(enquetePayLoadWeb.getNumRue());
enquete.setSuperficie(enquetePayLoadWeb.getSuperficie());
enquete.setMontantMensuelleLocation(enquetePayLoadWeb.getMontantMensuelleLocation());
enquete.setMontantAnnuelleLocation(enquetePayLoadWeb.getMontantAnnuelleLocation());
enquete.setValeurParcelleEstime(enquetePayLoadWeb.getValeurParcelleEstime());
enquete.setValeurParcelleReel(enquetePayLoadWeb.getValeurParcelleReel());
return enqueteRepository.save(enquete);
}
@@ -309,29 +390,24 @@ public class EnqueteServiceImpl implements EnqueteService {
}
@Override
public Page<EnquetePayLoadWeb> getEnqueteList(Pageable pageable) {
return enqueteRepository.findAllEnquetesToDtoPageable(pageable);
public Page<Enquete> getEnqueteList(Pageable pageable) {
return enqueteRepository.findAll(pageable);
}
@Override
public List<EnquetePayLoadWeb> getEnqueteList() {
return enqueteRepository.findAllEnquetesToDto();
public List<Enquete> getEnqueteList() {
return enqueteRepository.findAll();
}
@Override
public List<EnquetePayLoadWeb> getEnqueteListByParcelle(Long parcelleId) {
return enqueteRepository.findAllEnquetesByParcelleToDto(parcelleId);
public List<Enquete> getEnqueteListByParcelle(Long parcelleId) {
return enqueteRepository.findAllByParcelle_Id(parcelleId);
}
@Override
public Page<EnquetePayLoadWeb> getEnqueteListByParcellePageable(Long parcelleId, Pageable pageable) {
return enqueteRepository.findAllEnquetesByParcelleToDtoPageable(parcelleId,pageable);
}
@Override
public Optional<EnquetePayLoadWeb> getEnqueteById(Long id) {
public Optional<Enquete> getEnqueteById(Long id) {
if (enqueteRepository.existsById(id)) {
return enqueteRepository.findEnqueteToDto(id);
return enqueteRepository.findById(id);
} else {
throw new NotFoundException("Impossible de trouver l'enquête.");
}
@@ -349,7 +425,7 @@ public class EnqueteServiceImpl implements EnqueteService {
Enquete enquete = optionalEnquete.get();
enquete.setDateValidation(LocalDate.now());
enquete.setStatutEnquete(StatutEnquete.VALIDE);
enquete.setSynchronise(true);
enquete.setSynchronise(false);
return enqueteRepository.save(enquete);
}
@@ -523,13 +599,13 @@ public class EnqueteServiceImpl implements EnqueteService {
List<CaracteristiqueParcelle> caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId);
//List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId);
List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId);
// List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId);
List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId);
ficheEnquetesResponse.setCaracteristiquesParcelles(caracteristiqueParcelles);
// ficheEnquetesResponse.setEnquetesBatiments(enqueteBatiments);
// ficheEnquetesResponse.setEnquetesUniteLogements(enqueteUniteLogements);
ficheEnquetesResponse.setEnquetesBatiments(enqueteBatiments);
ficheEnquetesResponse.setEnquetesUniteLogements(enqueteUniteLogements);
ficheEnqueteResponse.setEnquete(ficheEnquetesResponse);
ficheEnqueteResponse.setActeurConcernes(acteurConcernes);
@@ -542,26 +618,4 @@ public class EnqueteServiceImpl implements EnqueteService {
}
@Override
@Transactional
public int cloturerEnqueteParcelleBatimentUniteLogementByUserIdAndExerciceId(Long userId,Long exerciceId) {
Optional<User> optionalUser= userRepository.findById(userId);
int nbreEnquete=0;
if(optionalUser.isPresent() && optionalUser.get().getStructure()!=null){
Long structureId=optionalUser.get().getStructure().getId();
nbreEnquete=cloturerEnqueteParcelleBatimentUniteLogementByStructureIdAndExerciceId(structureId,exerciceId);
}
return nbreEnquete;
}
@Override
@Transactional
public int cloturerEnqueteParcelleBatimentUniteLogementByStructureIdAndExerciceId(Long structureId,Long exerciceId) {
Integer nombreParcelleImpacte=enqueteRepository.clotureEnqueteParcelle(structureId,exerciceId);
Integer nombreBatiment=enqueteBatimentRepository.clotureEnqueteBatiment(structureId,exerciceId);
Integer nombreUniteLogement=enqueteUniteLogementRepository.clotureEnqueteUniteLogement(structureId,exerciceId);
return nombreParcelleImpacte;
}
}

View File

@@ -8,7 +8,6 @@ import io.gmss.fiscad.entities.infocad.metier.Upload;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleGeomService;
import io.gmss.fiscad.paylaods.request.crudweb.ParcelleGeomPaylaodWeb;
import io.gmss.fiscad.paylaods.response.EnqueteCheckResponse;
import io.gmss.fiscad.persistence.repositories.infocad.metier.EnqueteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleGeomRepository;
@@ -80,7 +79,6 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
return n;
}
private Upload saveGeoJsonUpload(MultipartFile file,String reference,String desc) {
Upload upload = new Upload();
String fileName = fileStorageService.storeFile(file);
@@ -178,16 +176,6 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
return parcelleGeomRepository.findAllByQuartier_Code(codeQuartier);
}
@Override
public List<ParcelleGeomPaylaodWeb> getParcelleGeomListByQuatierId(Long quartierId) {
return parcelleGeomRepository.findAllByQuartierId(quartierId);
}
@Override
public Page<ParcelleGeomPaylaodWeb> getParcelleGeomListByQuatierIdPaged(Long quartierId, Pageable pageable) {
return parcelleGeomRepository.findAllByQuartierIdPageable(quartierId,pageable);
}
@Override
public List<ParcelleGeom> getParcelleGeomListUnArrondissement(String codeArrondissement) {
return parcelleGeomRepository.findAllByQuartier_Arrondissement_Code(codeArrondissement);
@@ -274,9 +262,4 @@ public class ParcelleGeomServiceImpl implements ParcelleGeomService {
}
@Override
public int createParcelleGeomFromGeoJsonApi() throws BadRequestException {
return 0;
}
}

View File

@@ -10,7 +10,6 @@ import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
import io.gmss.fiscad.paylaods.FiltreParcelle;
import io.gmss.fiscad.paylaods.request.FiltreParcellePayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
import io.gmss.fiscad.paylaods.response.dataTableResponse.ParcelleDataTableResponse;
@@ -22,7 +21,6 @@ import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationGeogra
import io.gmss.fiscad.persistence.specification.ParcelleSpecification;
import io.gmss.fiscad.service.GeometryService;
import jakarta.persistence.Query;
import jakarta.transaction.Transactional;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
@@ -49,7 +47,7 @@ public class ParcelleServiceImpl implements ParcelleService {
@Override
public ParcellePayLoadWeb createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException {
public Parcelle createParcelle(ParcellePayLoadWeb parcellePayLoadWeb) throws BadRequestException {
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoadWeb.getNatureDomaineId());
if (!optionalNatureDomaine.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant");
@@ -62,12 +60,11 @@ public class ParcelleServiceImpl implements ParcelleService {
parcelle.setNatureDomaine(optionalNatureDomaine.orElse(null));
parcelle.setQuartier(optionalQuartier.orElse(null));
parcelle = getParcelleFromPayload(parcelle, parcellePayLoadWeb);
parcelle= parcelleRepository.save(parcelle);
return parcelleRepository.findParcelleToDtoById(parcelle.getId()).orElse(null);
return parcelleRepository.save(parcelle);
}
@Override
public ParcellePayLoadWeb updateParcelle(Long id, ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException {
public Parcelle updateParcelle(Long id, ParcellePayLoadWeb parcellePayLoadWeb) throws NotFoundException {
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoadWeb.getId());
if (!optionalParcelle.isPresent()) {
throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier");
@@ -88,8 +85,7 @@ public class ParcelleServiceImpl implements ParcelleService {
parcelle.setNatureDomaine(optionalNatureDomaine.orElse(null));
parcelle.setQuartier(optionalQuartier.orElse(null));
parcelle = getParcelleFromPayload(optionalParcelle.get(), parcellePayLoadWeb);
parcelle= parcelleRepository.save(parcelle);
return parcelleRepository.findParcelleToDtoById(parcelle.getId()).orElse(null);
return parcelleRepository.save(parcelle);
}
@Override
@@ -121,54 +117,6 @@ public class ParcelleServiceImpl implements ParcelleService {
return parcelleRepository.findAll();
}
@Override
public Optional<ParcellePayLoadWeb> getParcelleByIdToDto(Long userId, Long parcelleId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findParcelleToDtoById(secteurIds,parcelleId);
}
@Override
public List<ParcellePayLoadWeb> getParcelleListToDto(Long userId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleToDto(secteurIds);
}
@Override
public Page<ParcellePayLoadWeb> getParcelleListPageableToDto(Long userId, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleToDtoPageable(secteurIds,pageable);
}
@Override
public List<ParcellePayLoadWeb> getParcelleListByQuartierToDto(Long userId, Long quartierId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleByQuartierToDto(quartierId,secteurIds);
}
@Override
public Page<ParcellePayLoadWeb> getParcelleListByQuartierPageableToDto(Long userId, Long quartierId, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleByQuartierToDtoPageable(quartierId,secteurIds,pageable);
}
@Override
public List<ParcellePayLoadWeb> getParcelleListByRueToDto(Long userId, Long rueId) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
return parcelleRepository.findAllParcelleByRueToDto(rueId,secteurIds);
}
@Override
public Page<ParcellePayLoadWeb> getParcelleListByRuePageableToDto(Long userId, Long rueId, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
System.out.println(rueId);
secteurIds.forEach(aLong -> {
System.out.println(aLong);
});
return parcelleRepository.findAllParcelleByRueToDtoPageable(rueId,secteurIds,pageable);
}
@Override
public Optional<Parcelle> getParcelleById(Long id) {
if (parcelleRepository.existsById(id)) {
@@ -178,39 +126,37 @@ public class ParcelleServiceImpl implements ParcelleService {
}
}
@Override
public Page<ParcellePayLoadWeb> getParcelleByMultiFiltre(Long userId, FiltreParcelle filtreParcelle, Pageable pageable) {
List<Long> secteurIds = getSecteurIdListForUser(userId);
System.out.println(secteurIds.size());
if (secteurIds == null || secteurIds.isEmpty()) {
throw new IllegalArgumentException("Vous n'êtes pas autorisés à consulter ces parcelles");
}
return parcelleRepository.filtrerParcellesNative(
filtreParcelle,
secteurIds,
pageable
);
public Page<ParcelleDataTableResponse> getParcelleDataTableListByUserId(Long userId, Pageable pageable) {
}
@Override
@Transactional
public Integer majParcelleBatieNonbatie() {
return parcelleRepository.updateParcelleBatieTrue()+parcelleRepository.updateParcelleBatieFalse();
}
private List<Long> getSecteurIdListForUser(Long userId) {
List<Secteur> secteurs = secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
return secteurIds;
Page<ParcelleDataTableResponse> parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable);
return parcelleDataTableResponses ;
}
@Override
public Page<ParcelleDataTableResponse> getParcelleDataTableListByMultiFiltre(Long userId, FiltreParcellePayLoad filtreParcellePayLoad, Pageable pageable) {
List<Secteur> secteurs = secteurService.getListSecteurUserId(userId);
List<Long> secteurIds = secteurs.stream()
.map(Secteur::getId)
.toList();
//
// return parcelleRepository.findAll(
// ParcelleSpecification.filtre(filtreParcellePayLoad, secteurIds),
// pageable
// );
Page<ParcelleDataTableResponse> parcelleDataTableResponses=parcelleRepository.getParcelleDataTableResponse(secteurIds,pageable);
return parcelleDataTableResponses ;
}
private Parcelle getParcelleFromPayload(Parcelle parcelle, ParcellePayLoadWeb parcellePayLoadWeb) {
if(parcellePayLoadWeb.getRueId()!=null) {
Optional<Rue> optionalRue = rueRepository.findById(parcellePayLoadWeb.getRueId());

View File

@@ -2,17 +2,12 @@ package io.gmss.fiscad.implementations.infocad.metier;
import io.gmss.fiscad.entities.infocad.parametre.*;
import io.gmss.fiscad.enums.EtatIdentificationPersonne;
import io.gmss.fiscad.enums.Origine;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
import io.gmss.fiscad.paylaods.dto.*;
import io.gmss.fiscad.paylaods.request.IfuEnLigneRechercheBody;
import io.gmss.fiscad.paylaods.request.RecherchePersonneResquestBody;
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
import io.gmss.fiscad.paylaods.response.ifuenligne.IfuEnLigneContribuableResponse;
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
import io.gmss.fiscad.persistence.repositories.infocad.metier.MembreGroupeRepository;
@@ -22,7 +17,6 @@ import io.gmss.fiscad.persistence.repositories.infocad.parametre.PersonneReposit
import io.gmss.fiscad.persistence.repositories.infocad.parametre.ProfessionRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.SituationMatrimonialeRepository;
import io.gmss.fiscad.persistence.repositories.infocad.parametre.TypePersonneRepository;
import io.gmss.fiscad.service.CallAPIService;
import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.persistence.EntityNotFoundException;
import lombok.RequiredArgsConstructor;
@@ -30,13 +24,9 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.time.ZoneId;
@Service
@RequiredArgsConstructor
public class PersonneServiceImpl implements PersonneService {
@@ -51,19 +41,26 @@ public class PersonneServiceImpl implements PersonneService {
private final ProfessionRepository professionRepository;
private final SituationMatrimonialeRepository situationMatrimonialeRepository;
private final EntityFromPayLoadService entityFromPayLoadService;
private final CallAPIService callAPIService;
@Override
public PersonnePayLoadWeb createPersonne(PersonnePayLoadWeb personnePayLoadWeb) throws BadRequestException {
public Personne createPersonne(PersonnePayLoadWeb personnePayLoadWeb) throws BadRequestException {
// Optional<TypePersonne> optionalTypePersonne = typePersonneRepository.findById(personnePayLoadWeb.getTypePersonneId());
//
// Optional<Commune> optionalCommune = communeRepository.findById(personnePayLoadWeb.getCommuneId());
//
//
// Optional<Nationalite> optionalNationalite = nationaliteRepository.findById(personnePayLoadWeb.getNationaliteId());
//
// Optional<SituationMatrimoniale> optionalQuartier = situationMatrimonialeRepository.findById(personnePayLoadWeb.getSituationMatrimonialeId());
//
// Optional<Profession> optionalProfession = professionRepository.findById(personnePayLoadWeb.getProfessionId());
//
Personne personne = entityFromPayLoadService.getPersonneFromPayLoadWeb(personnePayLoadWeb);
personne =personneRepository.save(personne);
return personneRepository.findBypersonneId(personne.getId()).orElse(null);
return personneRepository.save(personne);
}
@Override
public PersonnePayLoadWeb updatePersonne(Long id, PersonnePayLoadWeb personnePayLoadWeb) throws NotFoundException {
public Personne updatePersonne(Long id, PersonnePayLoadWeb personnePayLoadWeb) throws NotFoundException {
if (personnePayLoadWeb.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
}
@@ -72,8 +69,7 @@ public class PersonneServiceImpl implements PersonneService {
}
Personne personne = entityFromPayLoadService.getPersonneFromPayLoadWeb(personnePayLoadWeb);
personne =personneRepository.save(personne);
return personneRepository.findBypersonneId(personne.getId()).orElse(null);
return personneRepository.save(personne);
}
@Override
@@ -82,18 +78,18 @@ public class PersonneServiceImpl implements PersonneService {
}
@Override
public Page<PersonnePayLoadWeb> getPersonneList(Pageable pageable) {
public Page<Personne> getPersonneList(Pageable pageable) {
return null;
}
@Override
public List<PersonnePayLoadWeb> getPersonneList() {
public List<Personne> getPersonneList() {
return null;
}
@Override
public Optional<PersonnePayLoadWeb> getPersonneById(Long id) {
return personneRepository.findBypersonneId(id);
public Optional<Personne> getPersonneById(Long id) {
return personneRepository.findById(id);
}
@Override
@@ -193,165 +189,5 @@ public class PersonneServiceImpl implements PersonneService {
membres
);
}
// @Override
// public List<PersonnePayLoadWeb> recherchePersonne(RecherchePersonneResquestBody recherchePersonneResquestBody) {
//
//
//
// List<PersonnePayLoadWeb> personnePayLoadWebsRfuLoggil = new ArrayList<>();
// personnePayLoadWebsRfuLoggil = recherchePersonneLocal(recherchePersonneResquestBody);
//
// try{
//
// LocalDate date = recherchePersonneResquestBody.getDateNaissance();
// String dateNaissance = date != null
// ? date.format(DateTimeFormatter.ISO_LOCAL_DATE)
// : null;
//
// IfuEnLigneRechercheBody ifuEnLigneRechercheBody =new IfuEnLigneRechercheBody();
// // ifuEnLigneRechercheBody.setIfu(recherchePersonneResquestBody.getIfu());
// ifuEnLigneRechercheBody.setNom(recherchePersonneResquestBody.getNom());
// ifuEnLigneRechercheBody.setPrenom(recherchePersonneResquestBody.getPrenom());
// ifuEnLigneRechercheBody.setDateNaissance(dateNaissance);
//
// List<IfuEnLigneContribuableResponse> ifuEnLigneContribuableResponses =callAPIService.callApiRechercheContribIfuEnLigne(ifuEnLigneRechercheBody);
// System.out.println(ifuEnLigneContribuableResponses);
// if(ifuEnLigneContribuableResponses!=null && !ifuEnLigneContribuableResponses.isEmpty()){
// //List<PersonnePayLoadWeb> finalPersonnePayLoadWebsRfuLoggil = personnePayLoadWebsRfuLoggil;
// ifuEnLigneContribuableResponses.forEach(ifuEnLigneContribuableResponse -> {
// PersonnePayLoadWeb personnePayLoadWeb=new PersonnePayLoadWeb();
// personnePayLoadWeb.setSource(Origine.SIGIBE);
// personnePayLoadWeb.setNpi(ifuEnLigneContribuableResponse.getNpi());
// personnePayLoadWeb.setIfu(ifuEnLigneContribuableResponse.getIfu());
// personnePayLoadWeb.setNomMere(ifuEnLigneContribuableResponse.getMotherlastname());
// personnePayLoadWeb.setNom(ifuEnLigneContribuableResponse.getLastname());
// personnePayLoadWeb.setPrenom(ifuEnLigneContribuableResponse.getFirstname());
// personnePayLoadWeb.setPrenomMere(ifuEnLigneContribuableResponse.getBjmotherfirstname());
//
// Date birthdate = ifuEnLigneContribuableResponse.getBirthdate();
// LocalDate localDate = birthdate != null
// ? birthdate.toInstant()
// .atZone(ZoneId.systemDefault())
// .toLocalDate()
// : null;
// personnePayLoadWeb.setDateNaissanceOuConsti(localDate);
// personnePayLoadWeb.setTel1(ifuEnLigneContribuableResponse.getPhonenumber());
// personnePayLoadWeb.setLieuNaissance(ifuEnLigneContribuableResponse.getBirthplace());
// personnePayLoadWeb.setSexe(ifuEnLigneContribuableResponse.getSexe());
//
// personnePayLoadWebsRfuLoggil.add(personnePayLoadWeb);
// });
// }
// }catch (Exception e){
// e.printStackTrace();
// }
//
// return personnePayLoadWebsRfuLoggil;
// }
@Override
public List<PersonnePayLoadWeb> recherchePersonne(RecherchePersonneResquestBody request) {
List<PersonnePayLoadWeb> result = new ArrayList<>(
recherchePersonneLocal(request)
);
try {
// Conversion date en String format yyyy-MM-dd
String dateNaissance = Optional.ofNullable(request.getDateNaissance())
.map(d -> d.format(DateTimeFormatter.ISO_LOCAL_DATE))
.orElse(null);
// Construction du body IFU
IfuEnLigneRechercheBody ifuRequest = new IfuEnLigneRechercheBody();
ifuRequest.setNom(request.getNom());
ifuRequest.setPrenom(request.getPrenom());
ifuRequest.setDateNaissance(dateNaissance);
List<IfuEnLigneContribuableResponse> responses =
callAPIService.callApiRechercheContribIfuEnLigne(ifuRequest);
if (responses == null || responses.isEmpty()) {
return result;
}
for (IfuEnLigneContribuableResponse r : responses) {
PersonnePayLoadWeb personne = new PersonnePayLoadWeb();
personne.setEtatIdentificationPersonne(EtatIdentificationPersonne.IFU);
personne.setNpi(r.getNpi());
personne.setIfu(r.getIfu());
personne.setNomMere(r.getMotherlastname());
personne.setNom(r.getLastname());
personne.setPrenom(r.getFirstname());
personne.setPrenomMere(r.getBjmotherfirstname());
personne.setTel1(r.getPhonenumber());
personne.setLieuNaissance(r.getBirthplace());
personne.setSexe(r.getSexe());
// Conversion Date → LocalDate
Date birthdate = r.getBirthdate();
LocalDate localDate = birthdate != null
? birthdate.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate()
: null;
personne.setDateNaissanceOuConsti(localDate);
personne.setEtatIdentificationPersonne(EtatIdentificationPersonne.IFU);
result.add(personne);
}
} catch (Exception e) {
// logger.error("Erreur appel IFU EN LIGNE", e);
}
return result;
}
private List<PersonnePayLoadWeb> recherchePersonneLocal(RecherchePersonneResquestBody recherchePersonneResquestBody) {
List<PersonnePayLoadWeb> personnePayLoadWebs=
personneRepository.findByFiltersInBaseIfuNpiCorrecte(
recherchePersonneResquestBody.getIfu()==null?null:recherchePersonneResquestBody.getIfu().trim().toLowerCase(),
recherchePersonneResquestBody.getNpi()==null?null:recherchePersonneResquestBody.getNpi().trim().toLowerCase(),
recherchePersonneResquestBody.getNom()==null?null:recherchePersonneResquestBody.getNom().trim().toLowerCase(),
recherchePersonneResquestBody.getPrenom()==null?null:recherchePersonneResquestBody.getPrenom().trim().toLowerCase(),
recherchePersonneResquestBody.getRaisonSociale()==null?null:recherchePersonneResquestBody.getRaisonSociale().trim().toLowerCase(),
recherchePersonneResquestBody.getNomMere()==null?null:recherchePersonneResquestBody.getNomMere().trim().toLowerCase(),
recherchePersonneResquestBody.getDateNaissance()
);
return personnePayLoadWebs ;
}
private List<PersonnePayLoadWeb> recherchePersonneSigibe(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
return null;
}
private List<PersonnePayLoadWeb> recherchePersonneAnip(RecherchePersonneResquestBody recherchePersonneResquestBody) {
// callAPIService.callGetIfuEnLigneToken();
return null;
}
private String like(String value) {
if (value == null) {
return null;
}
value = value.trim();
if (value.isEmpty()) {
return null;
}
return "%" + value + "%";
}
}

Some files were not shown because too many files have changed in this diff Show More