61 Commits

Author SHA1 Message Date
81bd7d9034 Generation tfu batie et non batie avec ressource de liste de données imposition
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-03-14 15:40:32 +01:00
cec02e24ae Generation tfu batie et non batie avec ressource de liste de données imposition
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-12 21:00:21 +01:00
dae64dc079 Generation tfu batie et non batie avec ressource de liste de données imposition
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 32s
2026-03-12 20:33:32 +01:00
9de2564108 Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-12 12:26:45 +01:00
b3e3e7109f Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-12 12:05:36 +01:00
b22b6c8288 Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-03-12 01:00:03 +01:00
d326e227c4 Generation tfu batie et non batie
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-03-11 01:09:42 +01:00
85be8a2e24 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-03-10 22:36:38 +01:00
fcc81e0607 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-09 21:12:09 +01:00
862b917689 Gestion des barem 2026-03-09 21:11:24 +01:00
9b4edcdcea Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-03-09 20:59:23 +01:00
db1fd2c821 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-03-09 20:31:09 +01:00
ee07fec0ac Gestion des barem 2026-03-09 20:03:25 +01:00
a5cabc8102 Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-03-09 19:52:00 +01:00
443b563d69 Gestion des barem 2026-03-09 19:51:44 +01:00
a799764d16 Gestion des barem 2026-03-09 19:51:40 +01:00
eba53a42aa Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-03-08 14:54:00 +01:00
bd8bd64a2d Gestion des barem
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-08 14:51:54 +01:00
5dcb2adf30 Gestion des barem
Some checks failed
CI - Build & Test (develop) / build-and-test (pull_request) Failing after 9s
2026-03-08 14:23:14 +01:00
d1c3cb190d Gestion cloture
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-03-06 20:08:05 +01:00
4897712e08 Gestion parcelle geom et changement https://gitea.com/actions/checkout@v4 #actions/checkout@v4
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 44s
2026-03-01 18:33:30 +01:00
dc28d88763 Gestion parcelle geom
Some checks failed
CI - Build & Test (develop) / build-and-test (pull_request) Failing after 31s
2026-03-01 18:29:12 +01:00
35393954c3 Gestion parcelle geom
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 38s
2026-03-01 02:39:38 +01:00
51845b085a prise en charge des données entrant dans la liquidation
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-23 00:17:01 +01:00
4567074f08 prise en charge des données entrant dans la liquidation 2026-02-23 00:16:43 +01:00
933c209f67 prise en charge des données entrant dans la liquidation
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-22 14:52:47 +01:00
dc59006e99 prise en charge des données entrant dans la liquidation 2026-02-22 11:50:39 +01:00
b0abdee729 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 32s
2026-02-21 13:41:44 +01:00
2a53e653c3 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 31s
2026-02-20 20:33:29 +01:00
1ce98edc32 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-20 19:52:44 +01:00
144a6af6f8 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-19 21:37:28 +01:00
e0a211d8bd gestion revu de code en utilisant uniquement les DTO 2026-02-19 21:22:46 +01:00
d1813d7460 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-19 20:06:45 +01:00
95bf4779f7 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 31s
2026-02-19 19:30:28 +01:00
5e9aae2bc2 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-19 11:23:50 +01:00
06fa55fe2a gestion revu de code en utilisant uniquement les DTO 2026-02-19 11:23:28 +01:00
c272257930 gestion revu de code en utilisant uniquement les DTO 2026-02-19 08:50:46 +01:00
2c38fa1926 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-19 00:04:41 +01:00
74a00a3856 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 36s
2026-02-18 21:41:28 +01:00
558f95869c gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 36s
2026-02-18 15:00:15 +01:00
554277f312 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 28s
2026-02-16 23:03:51 +01:00
e6e9407940 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-16 21:52:48 +01:00
0617d2f383 gestion revu de code en utilisant uniquement les DTO 2026-02-16 21:51:55 +01:00
962af9b48c gestion revu de code en utilisant uniquement les DTO 2026-02-16 14:48:46 +01:00
14816d9bd0 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-16 01:14:25 +01:00
8efe46fea8 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-14 15:07:50 +01:00
8031289509 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-13 18:53:39 +01:00
f49e8157e2 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-12 22:30:42 +01:00
88f7a7d7af gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-02-12 03:13:58 +01:00
ed73eb3f2e gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-11 22:14:15 +01:00
c4389abaf2 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-11 22:09:21 +01:00
ccfe1bfb4a gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-02-10 01:10:07 +01:00
f85191b47c gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-10 00:26:14 +01:00
c600d50ce4 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 35s
2026-02-08 23:22:09 +01:00
95eb4ad0b9 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 29s
2026-02-04 02:33:04 +01:00
743bb46b47 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 30s
2026-02-03 20:31:38 +01:00
2c0aad4d51 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-02-03 16:08:13 +01:00
fc6ff679f0 gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-02-03 00:01:45 +01:00
772f870dbd gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 27s
2026-02-01 23:48:05 +01:00
1c63303f3c gestion revu de code en utilisant uniquement les DTO
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 33s
2026-02-01 23:45:27 +01:00
9a118b41e5 gestion de profil, secteur, section et arbre decoupage
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 26s
2026-01-27 09:57:56 +01:00
645 changed files with 16997 additions and 3738 deletions

View File

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

View File

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

1
.gitignore vendored
View File

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

18
pom.xml
View File

@@ -73,6 +73,7 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.jasperreports</groupId> <groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId> <artifactId>jasperreports</artifactId>
@@ -149,7 +150,24 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </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> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

View File

@@ -1,11 +1,10 @@
package io.gmss.fiscad.component; package io.gmss.fiscad.component;
import io.gmss.fiscad.entities.user.Profile;
import io.gmss.fiscad.entities.user.Role; import io.gmss.fiscad.entities.user.Role;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole; import io.gmss.fiscad.enums.UserRole;
import io.gmss.fiscad.repositories.user.RoleRepository; import io.gmss.fiscad.persistence.repositories.user.RoleRepository;
import io.gmss.fiscad.repositories.user.UserRepository; import io.gmss.fiscad.persistence.repositories.user.UserRepository;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;

View File

@@ -1,9 +1,13 @@
package io.gmss.fiscad.configuration; 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.CustomUserDetailsService;
import io.gmss.fiscad.security.JwtAuthenticationFilter; import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
@@ -63,4 +67,7 @@ public class ApplicationConfig {
return authenticationManagerBuilder.build(); return authenticationManagerBuilder.build();
} }
} }

View File

@@ -1,7 +1,7 @@
package io.gmss.fiscad.configuration; package io.gmss.fiscad.configuration;
import io.gmss.fiscad.repositories.user.UserRepository; import io.gmss.fiscad.persistence.repositories.user.UserRepository;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware; import org.springframework.data.domain.AuditorAware;

View File

@@ -1,6 +1,6 @@
package io.gmss.fiscad.configuration; package io.gmss.fiscad.configuration;
import io.gmss.fiscad.repositories.user.UserRepository; import io.gmss.fiscad.persistence.repositories.user.UserRepository;
import io.gmss.fiscad.security.UserPrincipal; import io.gmss.fiscad.security.UserPrincipal;
import org.springframework.data.domain.AuditorAware; import org.springframework.data.domain.AuditorAware;
import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.authentication.AnonymousAuthenticationToken;

View File

@@ -0,0 +1,50 @@
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

@@ -0,0 +1,120 @@
//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,11 +1,113 @@
package io.gmss.fiscad.configuration; package io.gmss.fiscad.configuration;
import io.gmss.fiscad.security.JwtAuthenticationEntryPoint; import io.gmss.fiscad.security.JwtAuthenticationEntryPoint;
import io.gmss.fiscad.security.JwtAuthenticationFilter; import io.gmss.fiscad.security.JwtAuthenticationFilter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; 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.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 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.builders.HttpSecurity;
@@ -27,16 +129,15 @@ public class SpringSecurityConfig {
private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final AuthenticationProvider authenticationProvider; private final AuthenticationProvider authenticationProvider;
private final JwtAuthenticationFilter jwtAuthenticationFilter; private final JwtAuthenticationFilter jwtAuthenticationFilter;
private static final String[] AUTH_WHITELIST = { private static final String[] AUTH_WHITELIST = {
"/api/**", // "/api/**",
"/api/auth/login", "/api/auth/login",
"/api/open/**", "/api/open/**",
"/api/synchronisation/references", "/api/synchronisation/references",
"/v3/api-docs/**", "/v3/api-docs/**",
"/swagger-ui/**", "/swagger-ui/**",
"/swagger-ui.html" "/swagger-ui.html",
"/error"
}; };
@@ -58,7 +159,7 @@ public class SpringSecurityConfig {
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint)) .exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
.authorizeHttpRequests(req -> .authorizeHttpRequests(req ->
req req
//.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers(AUTH_WHITELIST).permitAll() .requestMatchers(AUTH_WHITELIST).permitAll()
.anyRequest() .anyRequest()
.authenticated() .authenticated()
@@ -66,11 +167,8 @@ public class SpringSecurityConfig {
.authenticationProvider(authenticationProvider) .authenticationProvider(authenticationProvider)
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS)) .sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
; ;
return http.build(); return http.build();
} }
}*/
}

View File

@@ -27,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Arrondissement") @Tag(name = "Arrondissement")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class ArrondissementController { public class ArrondissementController {
private final ArrondissementService arrondissementService; private final ArrondissementService arrondissementService;
@@ -175,7 +175,7 @@ public class ArrondissementController {
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) { public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."), new ApiResponse<>(true, arrondissementService.getArrondissementById(id).orElse(null), "Arrondissement trouvé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -199,7 +199,31 @@ public class ArrondissementController {
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) { public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Commune") @Tag(name = "Commune")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')") //@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class CommuneController { public class CommuneController {
private final CommuneService communeService; private final CommuneService communeService;
@@ -185,7 +185,31 @@ public class CommuneController {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

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

View File

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

View File

@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Quartier") @Tag(name = "Quartier")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')") //@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class QuartierController { public class QuartierController {
private final QuartierService quartierService; private final QuartierService quartierService;
@@ -158,7 +158,7 @@ public class QuartierController {
public ResponseEntity<?> getQuartierById(@PathVariable Long id) { public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."), new ApiResponse<>(true, quartierService.getQuartierById(id).orElse(null), "Quartier trouvé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -182,7 +182,31 @@ public class QuartierController {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -4,7 +4,10 @@ import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload; 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 io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -22,9 +25,9 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/secteur", produces = MediaType.APPLICATION_JSON_VALUE)
//@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Secteur") @Tag(name = "Secteur")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')") //@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class SecteurController { public class SecteurController {
private final SecteurService secteurService; private final SecteurService secteurService;
@@ -34,14 +37,16 @@ public class SecteurController {
this.secteurService = secteurService; this.secteurService = secteurService;
} }
@Operation(
summary = "Créer un secteur",
description = "Permet de Créer un secteur"
)
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) { public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPaylaodWeb secteurPaylaodWeb) {
try { try {
// Secteur secteur=getSecteurFromPayload(secteurPayload); secteurPaylaodWeb = secteurService.createSecteur(secteurPaylaodWeb);
Secteur secteur = secteurService.createSecteur(secteurPayload);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteur, "Secteur créé avec succès."), new ApiResponse<>(true, secteurPaylaodWeb, "Secteur créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -60,12 +65,15 @@ public class SecteurController {
} }
} }
@Operation(
summary = "mettre à jour un secteur",
description = "Permet de modifier un secteur"
)
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPayload secteurPayload) { public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPaylaodWeb secteurPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayload), "Secteur mis à jour avec succès."), new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayloadWeb), "Secteur mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -83,7 +91,10 @@ public class SecteurController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@Operation(
summary = "supprimer un secteur",
description = "Permet de supprimer un secteur"
)
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) { public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
try { try {
@@ -107,7 +118,10 @@ public class SecteurController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@Operation(
summary = "recuperer tous les secteurs",
description = "Permet de récuperer l'ensemble des secteurs"
)
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllSecteurList() { public ResponseEntity<?> getAllSecteurList() {
try { try {
@@ -131,6 +145,10 @@ public class SecteurController {
} }
} }
@Operation(
summary = "recuperer tous les secteurs avec pagination",
description = "Permet de récuperer l'ensemble des secteurs avec pagination"
)
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try { try {
@@ -155,6 +173,10 @@ public class SecteurController {
} }
} }
@Operation(
summary = "recuperer un secteurs par son ID ",
description = "Permet de récuperer le secteur ayant l'ID fournie en path"
)
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSecteurById(@PathVariable Long id) { public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
try { try {
@@ -178,12 +200,15 @@ public class SecteurController {
} }
} }
@Operation(
summary = "recuperer tous les secteurs d'une structure",
description = "Permet de récuperer l'ensemble des secteurs de la structure dont l'ID est fourni en path"
)
@GetMapping("/by-structure-id/{structureId}") @GetMapping("/by-structure-id/{structureId}")
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) { public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getSecteurListUneStruture(structureId), "Secteur trouvée avec succès."), new ApiResponse<>(true, secteurService.getSecteurListByStructureId(structureId), "Secteur trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -203,4 +228,118 @@ public class SecteurController {
} }
@Operation(
summary = "recuperer tous les secteurs d'une structure",
description = "Permet de récuperer l'ensemble des secteurs de la structure dont l'ID est fourni en path avec pagination"
)
@GetMapping("/page/by-structure-id/{structureId}")
public ResponseEntity<?> getSecteurByStructureIdPage(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getSecteurListByStructureId(structureId,pageable), "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);
}
}
@Operation(
summary = "recuperer tous les secteurs d'une section",
description = "Permet de récuperer l'ensemble des secteurs de la section dont l'ID est fourni en path"
)
@GetMapping("/by-section-id/{sectionId}")
public ResponseEntity<?> getSecteurBySectionId(@PathVariable Long sectionId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getSecteurListBySectionId(sectionId), "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);
}
}
@Operation(
summary = "recuperer tous les secteurs d'une section avec pagination",
description = "Permet de récuperer l'ensemble des secteurs de la section dont l'ID est fourni en path avec pagination"
)
@GetMapping("/page/by-section-id/{sectionId}")
public ResponseEntity<?> getSecteurBySectionIdPage(@PathVariable Long sectionId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getSecteurListBySectionId(sectionId,pageable), "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);
}
}
@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,6 +5,7 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService; import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class SecteurDecoupageController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) { public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
try { try {
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage); secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."), new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class SecteurDecoupageController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) { public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."), new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupagePaylaodWeb), "SecteurDecoupage mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -152,11 +153,58 @@ 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}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) { public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."), new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -180,7 +228,7 @@ public class SecteurDecoupageController {
public ResponseEntity<?> getArborescenceByUserId(@PathVariable Long userId) { public ResponseEntity<?> getArborescenceByUserId(@PathVariable Long userId) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.getStatParcelleDecoupageByUserId(userId), "SecteurDecoupage trouvée avec succès."), new ApiResponse<>(true, secteurDecoupageService.getStatParcelleDecoupageByUserId(userId), "SecteurDecoupage trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -0,0 +1,256 @@
package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.exceptions.*;
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;
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/section", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Section")
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
public class SectionController {
private final SectionService sectionService;
private static final Logger logger = LoggerFactory.getLogger(SectionController.class);
public SectionController(SectionService sectionService) {
this.sectionService = sectionService;
}
@Operation(
summary = "Créer un section",
description = "Permet de Créer un section"
)
@PostMapping("/create")
public ResponseEntity<?> createSection(@RequestBody @Valid @Validated SectionPaylaodWeb sectionPaylaodWeb) {
try {
sectionPaylaodWeb = sectionService.createSection(sectionPaylaodWeb);
return new ResponseEntity<>(
new ApiResponse<>(true, sectionPaylaodWeb, "Section 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);
}
}
@Operation(
summary = "mettre à jour un section",
description = "Permet de modifier un section"
)
@PutMapping("/update/{id}")
public ResponseEntity<?> updateSection(@PathVariable Long id, @RequestBody SectionPaylaodWeb sectionPayloadWeb) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, sectionService.updateSection(id, sectionPayloadWeb), "Section 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);
}
}
@Operation(
summary = "supprimer un section",
description = "Permet de supprimer un section"
)
@DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSection(@PathVariable Long id) {
try {
sectionService.deleteSection(id);
return new ResponseEntity<>(
new ApiResponse<>(true, "Section 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);
}
}
@Operation(
summary = "recuperer tous les sections",
description = "Permet de récuperer l'ensemble des sections"
)
@GetMapping("/all")
public ResponseEntity<?> getAllSectionList() {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, sectionService.getSectionList(), "Liste des sections 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);
}
}
@Operation(
summary = "recuperer tous les sections avec pagination",
description = "Permet de récuperer l'ensemble des sections avec pagination"
)
@GetMapping("/all-paged")
public ResponseEntity<?> getAllSectionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, sectionService.getSectionList(pageable), "Liste des sections 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);
}
}
@Operation(
summary = "recuperer un sections par son ID ",
description = "Permet de récuperer le section ayant l'ID fournie en path"
)
@GetMapping("/id/{id}")
public ResponseEntity<?> getSectionById(@PathVariable Long id) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, sectionService.getSectionById(id).orElse(null), "Section 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 = "recuperer tous les sections d'une structure",
description = "Permet de récuperer l'ensemble des sections de la structure dont l'ID est fourni en path"
)
@GetMapping("/by-structure-id/{structureId}")
public ResponseEntity<?> getSectionByStructureId(@PathVariable Long structureId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, sectionService.getSectionListByStructureId(structureId), "Section 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 = "recuperer tous les sections d'une structure",
description = "Permet de récuperer l'ensemble des sections de la structure dont l'ID est fourni en path avec pagination"
)
@GetMapping("/page/by-structure-id/{structureId}")
public ResponseEntity<?> getSectionByStructureIdPage(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>(
new ApiResponse<>(true, sectionService.getSectionListByStructureId(structureId,pageable), "Section 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,6 +2,7 @@ package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Enquete; import io.gmss.fiscad.entities.infocad.metier.Enquete;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment; import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService; import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
@@ -10,6 +11,9 @@ import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad; import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad; import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -47,9 +51,9 @@ public class EnqueteController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) { public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) {
try { try {
Enquete enquete = enqueteService.createEnquete(enquetePayLoadWeb); enquetePayLoadWeb = enqueteService.createEnquete(enquetePayLoadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enquete, "Enquete batiment créé avec succès."), new ApiResponse<>(true, enquetePayLoadWeb, "Enquete batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -207,6 +211,65 @@ 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("/by-parcelle-id/{parcelleId}")
public ResponseEntity<?> getAllByParcelle(@PathVariable Long parcelleId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "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);
}
}
@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") @GetMapping("/all/dgi/decoupage-admin-for-enquete")
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() { public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
@@ -420,5 +483,8 @@ public class EnqueteController {
} }

View File

@@ -6,10 +6,13 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService; import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService; import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.EnqueteTraitementPayLoad;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb; import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -28,7 +31,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") //@SecurityRequirement(name = "bearer")
@Tag(name = "Parcelle") @Tag(name = "Parcelle")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
@@ -48,9 +51,9 @@ public class ParcelleController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) { public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
try { try {
Parcelle parcelle = parcelleService.createParcelle(parcellePayLoadWeb); parcellePayLoadWeb = parcelleService.createParcelle(parcellePayLoadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelle, "parcelle créée avec succès."), new ApiResponse<>(true, parcellePayLoadWeb, "parcelle créée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -88,6 +91,7 @@ public class ParcelleController {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
@@ -118,12 +122,67 @@ public class ParcelleController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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") @GetMapping("/all")
public ResponseEntity<?> getAllParcelle() { public ResponseEntity<?> getAllParcelle(@CurrentUser UserPrincipal currentUser) {
try { try {
if(currentUser==null)
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleList(), "Liste des enquetes chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -142,37 +201,19 @@ 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") @GetMapping("/all-paged")
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllParcellePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) {
try { try {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleList(pageable), "Liste des enquetes chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -192,12 +233,141 @@ public class ParcelleController {
} }
@PostMapping("/all-paged/multi-criteres")
@GetMapping("/id/{id}") public ResponseEntity<?> getAllParcelleFiltrePaged(@CurrentUser UserPrincipal currentUser, @RequestParam int pageNo, @RequestParam int pageSize, @RequestBody FiltreParcelle filtreParcelle) {
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
try { try {
Pageable pageable = PageRequest.of(pageNo, pageSize);
if(currentUser==null)
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, parcelleService.getParcelleById(id), "enquete trouvé avec succès."), 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."),
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-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 HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -218,5 +388,61 @@ public class ParcelleController {
@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") @SecurityRequirement(name = "bearer")
@Tag(name = "ParcelleGeometrie") @Tag(name = "ParcelleGeometrie")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class ParcelleGeomController { public class ParcelleGeomController {
private final ParcelleGeomService parcelleGeomService; private final ParcelleGeomService parcelleGeomService;
@@ -63,6 +63,24 @@ 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}") @GetMapping("/by-arrondissement/{codeArrondissement}")
public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) { public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) {
return new ResponseEntity<>( return new ResponseEntity<>(

View File

@@ -7,12 +7,17 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.PersonneService; import io.gmss.fiscad.interfaces.infocad.metier.PersonneService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.dto.PersonneCompletDTO; 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.EnquetePayLoadWeb;
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb; 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 jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -36,9 +41,9 @@ public class PersonneController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) { public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) {
try { try {
Personne personne = personneService.createPersonne(personnePayLoadWeb); personnePayLoadWeb = personneService.createPersonne(personnePayLoadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, personne, "Contribuable créé avec succès."), new ApiResponse<>(true, personnePayLoadWeb, "Contribuable créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -99,7 +104,7 @@ public class PersonneController {
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getPersonneById(@PathVariable Long id) { public ResponseEntity<?> getPersonneById(@PathVariable Long id) {
try{ try{
Optional<Personne> optionalPersonne= personneService.getPersonneById(id); Optional<PersonnePayLoadWeb> optionalPersonne= personneService.getPersonneById(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, optionalPersonne.orElse(null), "Personne retrouvée avec succès."), new ApiResponse<>(true, optionalPersonne.orElse(null), "Personne retrouvée avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -111,4 +116,70 @@ 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

@@ -0,0 +1,272 @@
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,13 +1,17 @@
package io.gmss.fiscad.controllers.infocad.metier; package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Upload; 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.ApiResponse;
import io.gmss.fiscad.paylaods.JobModels; import io.gmss.fiscad.paylaods.JobModels;
import io.gmss.fiscad.proprietes.ZipStorageProperties; import io.gmss.fiscad.proprietes.ZipStorageProperties;
import io.gmss.fiscad.repositories.infocad.metier.UploadRepository; import io.gmss.fiscad.persistence.repositories.infocad.metier.UploadRepository;
import io.gmss.fiscad.service.FileStorageService; import io.gmss.fiscad.service.FileStorageService;
import io.gmss.fiscad.service.StringManager; import io.gmss.fiscad.service.StringManager;
import io.gmss.fiscad.service.ZipAsyncService; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
@@ -45,12 +49,13 @@ import java.util.UUID;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Upload") @Tag(name = "Upload")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class UploadController { public class UploadController {
boolean headIsValid = false; boolean headIsValid = false;
private final ZipAsyncService service; private final ZipAsyncService service;
private final ZipStorageProperties props; private final ZipStorageProperties props;
private final UploadService uploadService;
private static final Logger logger = LoggerFactory.getLogger(UploadController.class); private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
@Autowired @Autowired
@@ -94,7 +99,7 @@ public class UploadController {
try { try {
if (uploadRepository.findById(id).isPresent()) { if (uploadRepository.findById(id).isPresent()) {
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findById(id), "File with id {" + id + "} is found."), HttpStatus.OK);
} else { } else {
return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK);
} }
@@ -139,30 +144,39 @@ public class UploadController {
.body(resource); .body(resource);
} }
@PostMapping("/save") @PostMapping(
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file, @RequestParam String reference, @RequestParam String description /*, @RequestParam Long idTypeUpload*/) { 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,
@Parameter(description = "ID de la pièce", required = true)
@RequestParam("pieceId") Long pieceId
) {
try { try {
Upload upload = new Upload(); return ResponseEntity.ok(
String fileName = fileStorageService.storeFile(file); new ApiResponse(true,
upload.setFileName(fileName); uploadService.createUpload(file, pieceId),
upload.setMimeType(file.getContentType()); "File has been created successfully.")
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) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getMessage(), e);
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ApiResponse(false, null, e.getMessage()));
} }
} }
@DeleteMapping("/delete/id/{id}") @DeleteMapping("/delete/id/{id}")
public ResponseEntity<?> delete(@PathVariable Long id) { public ResponseEntity<?> delete(@PathVariable Long id) {
try { try {
@@ -229,4 +243,20 @@ public class UploadController {
.orElse(ResponseEntity.notFound().build()); .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") @SecurityRequirement(name = "bearer")
@Tag(name = "Bloc") @Tag(name = "Bloc")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class BlocController { public class BlocController {
private final BlocService blocService; private final BlocService blocService;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,6 +6,7 @@ import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService; import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService; import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -27,7 +28,7 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Structure") @Tag(name = "Structure")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')") //@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
public class StructureController { public class StructureController {
private final StructureService structureService; private final StructureService structureService;
@@ -40,11 +41,11 @@ public class StructureController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) { public ResponseEntity<?> createStructure(@RequestBody StructurePaylaodWeb structurePaylaodWeb) {
try { try {
structure = structureService.createStructure(structure); structurePaylaodWeb = structureService.createStructure(structurePaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, structure, "Structure créé avec succès."), new ApiResponse<>(true, structurePaylaodWeb, "Structure créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -64,10 +65,10 @@ public class StructureController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) { public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody StructurePaylaodWeb structurePaylaodWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."), new ApiResponse<>(true, structureService.updateStructure(id, structurePaylaodWeb), "Structure mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -134,36 +135,6 @@ 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") @GetMapping("/all-paged")
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
try { try {
@@ -189,6 +160,53 @@ 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}") @GetMapping("/id/{id}")
public ResponseEntity<?> getStructureById(@PathVariable Long id) { public ResponseEntity<?> getStructureById(@PathVariable Long id) {
try { try {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,8 +7,8 @@ package io.gmss.fiscad.controllers.report;
import io.gmss.fiscad.enums.FormatRapport; import io.gmss.fiscad.enums.FormatRapport;
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad; import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.gmss.fiscad.repositories.infocad.parametre.BlocRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.BlocRepository;
import io.gmss.fiscad.repositories.infocad.parametre.StructureRepository; import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
import io.gmss.fiscad.service.ReportService; import io.gmss.fiscad.service.ReportService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;

View File

@@ -39,9 +39,9 @@ public class BatimentController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) { public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) {
try { try {
Batiment batiment = batimentService.createBatiment(batimentPaylaodWeb); batimentPaylaodWeb = batimentService.createBatiment(batimentPaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, batiment, "Batiment créé avec succès."), new ApiResponse<>(true, batimentPaylaodWeb, "Batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -154,6 +154,53 @@ 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}") @GetMapping("/id/{id}")
public ResponseEntity<?> getBatimentById(@PathVariable Long id) { public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
try { try {

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -21,7 +22,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/caracteristique-caracteristiqueBatiment", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/caracteristique-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Caractéristique batiment") @Tag(name = "Caractéristique batiment")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@@ -35,34 +36,25 @@ public class CaracteristiqueBatimentController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatiment caracteristiqueBatiment) { public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) {
try { try {
caracteristiqueBatiment = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment); caracteristiqueBatimentPayloadWeb = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatimentPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatiment, "Caracteristique du batiment créé avec succès."), new ApiResponse<>(true, caracteristiqueBatimentPayloadWeb, "Caracteristique du batiment créé avec succès."),
HttpStatus.OK 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) { } catch (Exception e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatiment caracteristiqueBatiment) { public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatimentPayloadWeb caracteristiqueBatimentPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatimentPayloadWeb), "Caracteristique du batiment mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -156,7 +148,54 @@ public class CaracteristiqueBatimentController {
public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) { public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."), new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentToDto(id), "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("/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 HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class CaracteristiqueParcelleController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) { public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
try { try {
caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle); caracteristiqueParcellePayloadWeb = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcellePayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."), new ApiResponse<>(true, caracteristiqueParcellePayloadWeb, "Caracteristique parcelle créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class CaracteristiqueParcelleController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcelle caracteristiqueParcelle) { public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcellePayloadWeb), "Caracteristique parcelle mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -174,4 +175,52 @@ public class CaracteristiqueParcelleController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class CaracteristiqueUniteLogementController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) { public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
try { try {
caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement); caracteristiqueUniteLogementPayloadWeb = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogementPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."), new ApiResponse<>(true, caracteristiqueUniteLogementPayloadWeb, "Caracteristique Unite Logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class CaracteristiqueUniteLogementController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogement caracteristiqueUniteLogement) { public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogementPayloadWeb), "Caracteristique Unite Logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -174,4 +175,51 @@ public class CaracteristiqueUniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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

@@ -0,0 +1,226 @@
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,7 +7,10 @@ import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService; import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.repositories.rfu.metier.ImpositionsTfuRepository; 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.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -160,6 +163,104 @@ 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}") @GetMapping("/id/{id}")
public ResponseEntity<?> getDonneesImpositionTfuById(@PathVariable Long id) { public ResponseEntity<?> getDonneesImpositionTfuById(@PathVariable Long id) {
try { try {
@@ -182,31 +283,91 @@ public class DonneesImpositionTfuController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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") @Operation(summary = "Générer les données fiscales TFU des parcelle baties")
@PostMapping("/generer") @PostMapping("/generer-batie")
public ResponseEntity<?> genererDonneesFiscale(@RequestBody ImpositionsTfu impositionsTfu) { public ResponseEntity<?> genererDonneesFiscaleBatie(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try { try {
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfu.getId()); Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
if(optionalImpositionsTfu.isEmpty()){ if(optionalImpositionsTfu.isEmpty()){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, null, "L'imposition tfu n'est pas trouvée."), new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
HttpStatus.OK HttpStatus.OK
); );
} }
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.CREE)){ if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.TFU_FNB_GENERE)){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, null, "le statut actuel ne permet pas cette opération."), new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
HttpStatus.OK HttpStatus.OK
); );
} }
optionalImpositionsTfu.get().setStatusAvis(StatusAvis.GENERE); if(userPrincipal==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, donneesImpositionTfuService.genererDonneesFiscales(optionalImpositionsTfu.get()), "DonneesImpositionTfu trouvée avec succès."), new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
HttpStatus.OK HttpStatus.OK
); );
}
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
return new ResponseEntity<>(
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition des fonciers 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);
} 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) { } catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK); 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") @PostMapping("/create")
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) { public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
try { try {
EnqueteBatiment enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb); enqueteBatimentPayloadWeb = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."), new ApiResponse<>(true, enqueteBatimentPayloadWeb, "Enquete batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -176,4 +176,51 @@ public class EnqueteBatimentController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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") @PostMapping("/create")
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) { public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
try { try {
EnqueteUniteLogement enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb); enqueteUniteLogementPayloadWeb = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."), new ApiResponse<>(true, enqueteUniteLogementPayloadWeb, "Enquete unite logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -176,4 +176,51 @@ public class EnqueteUniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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,12 +2,21 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu; 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.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService; import io.gmss.fiscad.interfaces.rfu.metier.ImpositionsTfuService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.ws.rs.NotAcceptableException;
import lombok.AllArgsConstructor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
@@ -21,6 +30,7 @@ import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@AllArgsConstructor
@RequestMapping(value = "api/impositions-tfu", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/impositions-tfu", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Impositions TFU") @Tag(name = "Impositions TFU")
@@ -28,41 +38,32 @@ import org.springframework.web.client.HttpClientErrorException;
public class ImpositionsTfuController { public class ImpositionsTfuController {
private final ImpositionsTfuService impositionsTfuService; private final ImpositionsTfuService impositionsTfuService;
private final EnqueteService enqueteService;
private static final Logger logger = LoggerFactory.getLogger(ImpositionsTfuController.class); private static final Logger logger = LoggerFactory.getLogger(ImpositionsTfuController.class);
public ImpositionsTfuController(ImpositionsTfuService impositionsTfuService) {
this.impositionsTfuService = impositionsTfuService;
}
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createImpositionsTfu(@RequestBody @Valid @Validated ImpositionsTfu impositionsTfu) { public ResponseEntity<?> createImpositionsTfu(@CurrentUser UserPrincipal currentUser,@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
try { try {
impositionsTfu = impositionsTfuService.createImpositionsTfu(impositionsTfu); if(currentUser==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfu, "Unite de logement créé avec succès."), new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
HttpStatus.OK 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=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
);
} }
@PutMapping("/update/{id}") impositionsTfuPaylaodWeb = impositionsTfuService.createImpositionsTfu(impositionsTfuPaylaodWeb);
public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) {
try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.updateImpositionsTfu(id, impositionsTfu), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, impositionsTfuPaylaodWeb, "Unite de logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -82,11 +83,27 @@ public class ImpositionsTfuController {
} }
@PutMapping("/valider/{id}") @PutMapping("/cloturer-enquete")
public ResponseEntity<?> validerImpositionsTfu(@RequestBody ImpositionsTfu impositionsTfu) { public ResponseEntity<?> cloturer(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb ) {
try { try {
if(userPrincipal==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.validerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -105,11 +122,62 @@ public class ImpositionsTfuController {
} }
} }
@PutMapping("/annuler/{id}") // @PutMapping("/update/{id}")
public ResponseEntity<?> annulerImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) { // 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) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.annulerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -152,11 +220,19 @@ public class ImpositionsTfuController {
} }
} }
@GetMapping("/all") @GetMapping("/all/by-user")
public ResponseEntity<?> getAllImpositionsTfuList() { public ResponseEntity<?> getAllImpositionsTfuList(@CurrentUser UserPrincipal userPrincipal) {
try { try {
if(userPrincipal==null){
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuList(), "Liste des Enquetes des unites Logements chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -5,6 +5,7 @@ import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -35,11 +36,11 @@ public class UniteLogementController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) { public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
try { try {
enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement); enqueteUniteLogementPaylaodWeb = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogementPaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."), new ApiResponse<>(true, enqueteUniteLogementPaylaodWeb, "Unite de logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -59,10 +60,10 @@ public class UniteLogementController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogement enqueteUniteLogement) { public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogementPaylaodWeb), "Unite de logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -153,6 +154,54 @@ 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}") @GetMapping("/id/{id}")
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) { public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
try { try {
@@ -175,4 +224,27 @@ public class UniteLogementController {
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); 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,8 +2,9 @@ package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuBati; import io.gmss.fiscad.entities.rfu.parametre.BaremRfuBati;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuService; import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuBatiService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -24,20 +25,20 @@ import org.springframework.web.client.HttpClientErrorException;
@SecurityRequirement(name = "bearer") @SecurityRequirement(name = "bearer")
@Tag(name = "Barem Rfu") @Tag(name = "Barem Rfu")
public class BaremRfuController { public class BaremRfuController {
private final BaremRfuService baremRfuService; private final BaremRfuBatiService baremRfuBatiService;
private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class); private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class);
public BaremRfuController(BaremRfuService baremRfuService) { public BaremRfuController(BaremRfuBatiService baremRfuBatiService) {
this.baremRfuService = baremRfuService; this.baremRfuBatiService = baremRfuBatiService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBati baremRfuBati) { public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
try { try {
baremRfuBati = baremRfuService.createBaremRfu(baremRfuBati); baremRfuBatiPayloadWeb = baremRfuBatiService.createBaremRfu(baremRfuBatiPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuBati, "BaremRfuBati créé avec succès."), new ApiResponse<>(true, baremRfuBatiPayloadWeb, "BaremRfuBati créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -57,10 +58,10 @@ public class BaremRfuController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateBaremRfu(@PathVariable Long id, @RequestBody BaremRfuBati baremRfuBati) { public ResponseEntity<?> updateBaremRfu(@PathVariable Long id, @RequestBody BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.updateBaremRfu(id, baremRfuBati), "BaremRfuBati mis à jour avec succès."), new ApiResponse<>(true, baremRfuBatiService.updateBaremRfu(id, baremRfuBatiPayloadWeb), "BaremRfuBati mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -82,7 +83,7 @@ public class BaremRfuController {
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) { public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) {
try { try {
baremRfuService.deleteBaremRfu(id); baremRfuBatiService.deleteBaremRfu(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, "BaremRfuBati supprimée avec succès."), new ApiResponse<>(true, "BaremRfuBati supprimée avec succès."),
HttpStatus.OK HttpStatus.OK
@@ -107,7 +108,7 @@ public class BaremRfuController {
public ResponseEntity<?> getAllBaremRfuList() { public ResponseEntity<?> getAllBaremRfuList() {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -132,7 +133,7 @@ public class BaremRfuController {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -155,7 +156,7 @@ public class BaremRfuController {
public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) { public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."), new ApiResponse<>(true, baremRfuBatiService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -174,13 +175,68 @@ public class BaremRfuController {
} }
} }
@GetMapping("/categorie-batiment/{idCategorieBatiment}") @GetMapping("/by-categorie-batiment-id/{idCategorieBatiment}")
public ResponseEntity<?> getBaremRfuByType( //@Parameter(description = "ID de la catégorie de bâtiment", required = true) public ResponseEntity<?> getBaremRfuByType( //@Parameter(description = "ID de la catégorie de bâtiment", required = true)
@PathVariable Long idCategorieBatiment) { @PathVariable Long idCategorieBatiment) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuService.getBaremRfuByType(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -4,6 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
import io.gmss.fiscad.exceptions.*; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuNonBatiService; import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuNonBatiService;
import io.gmss.fiscad.paylaods.ApiResponse; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -34,11 +35,11 @@ public class BaremRfuNonBatiController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBaremRfuNonBati(@RequestBody @Valid @Validated BaremRfuNonBati baremRfuNonBati) { public ResponseEntity<?> createBaremRfuNonBati(@RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
try { try {
baremRfuNonBati = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBati); baremRfuNonBatiPayloadWeb = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBatiPayloadWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBati, "BaremRfuNonBati créé avec succès."), new ApiResponse<>(true, baremRfuNonBatiPayloadWeb, "BaremRfuNonBati créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -58,10 +59,10 @@ public class BaremRfuNonBatiController {
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateBaremRfuNonBati(@PathVariable Long id, @RequestBody BaremRfuNonBati baremRfuNonBati) { public ResponseEntity<?> updateBaremRfuNonBati(@PathVariable Long id, @RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBati), "BaremRfuNonBati mis à jour avec succès."), new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBatiPayloadWeb), "BaremRfuNonBati mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -156,7 +157,31 @@ public class BaremRfuNonBatiController {
public ResponseEntity<?> getBaremRfuNonBatiById(@PathVariable Long id) { public ResponseEntity<?> getBaremRfuNonBatiById(@PathVariable Long id) {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiById(id), "BaremRfuNonBati trouvée avec succès."), 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."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

@@ -0,0 +1,180 @@
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,6 +11,7 @@ import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.JwtAuthenticationResponse; import io.gmss.fiscad.paylaods.JwtAuthenticationResponse;
import io.gmss.fiscad.paylaods.Login; import io.gmss.fiscad.paylaods.Login;
import io.gmss.fiscad.paylaods.UserRequest; 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.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
@@ -90,13 +91,13 @@ public class AuthController {
} }
@PostMapping("/signup") @PostMapping("/signup")
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) { public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
try { try {
User user = getUser(userRequest); //User user = getUser(userRequest);
user.setUsername(userRequest.getEmail()); //user.setUsername(userRequest.getEmail());
user = userService.createUser(user, true); userPaylaodWeb = userService.createUser(userPaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user, "Inscription effectué avec succès."), new ApiResponse<>(true, userPaylaodWeb, "Inscription effectué avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -115,18 +116,5 @@ 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,9 +39,8 @@ public class AvoirFonctionController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) { public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) {
try { try {
AvoirFonction avoirFonction = avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, avoirFonction, "Fonction utilisateur créée avec succès."), new ApiResponse<>(true, avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb), "Fonction utilisateur créée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -131,52 +130,6 @@ 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") @GetMapping("/all-paged")
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
@@ -203,4 +156,79 @@ 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

@@ -111,7 +111,7 @@ public class FonctionController {
public ResponseEntity<?> getAllFonctionList() { public ResponseEntity<?> getAllFonctionList() {
try { try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, fonctionService.getFonctionList(), "Liste des caractéristiques chargée avec succès."), new ApiResponse<>(true, fonctionService.getFonctionListToDto(), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
@@ -135,7 +135,7 @@ public class FonctionController {
try { try {
Pageable pageable = PageRequest.of(pageNo, pageSize); Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, fonctionService.getFonctionList(pageable), "Liste des caractéristiques chargée avec succès."), new ApiResponse<>(true, fonctionService.getFonctionListToDtoPageable(pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {

View File

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

View File

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

@@ -0,0 +1,28 @@
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

@@ -0,0 +1,43 @@
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

@@ -0,0 +1,37 @@
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,6 +29,8 @@ public class Quartier extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Arrondissement arrondissement; private Arrondissement arrondissement;
private String longitude;
private String latitude;
// @JsonIgnore // @JsonIgnore
// @OneToOne(mappedBy = "quartier") // @OneToOne(mappedBy = "quartier")
// private Bloc bloc; // private Bloc bloc;

View File

@@ -28,15 +28,15 @@ public class Secteur extends BaseEntity implements Serializable {
private String code; private String code;
private String nom; private String nom;
@ManyToOne // @ManyToOne
private Structure structure; // private Structure structure;
//@JsonBackReference //@JsonBackReference
@ManyToOne @ManyToOne
private Section section ; private Section section ;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) //@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "secteur_id") // @JoinColumn(name = "secteur_id")
@JsonManagedReference // @JsonManagedReference
private List<SecteurDecoupage> secteurDecoupages; // private List<SecteurDecoupage> secteurDecoupages;
} }

View File

@@ -25,7 +25,6 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@Where(clause = " deleted = false") @Where(clause = " deleted = false")
public class SecteurDecoupage extends BaseEntity implements Serializable { public class SecteurDecoupage extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@@ -36,7 +35,7 @@ public class SecteurDecoupage extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFin; private LocalDate dateFin;
@JsonBackReference //@JsonBackReference
@ManyToOne @ManyToOne
private Secteur secteur; private Secteur secteur;

View File

@@ -26,11 +26,12 @@ public class Section extends BaseEntity implements Serializable {
private Long id; private Long id;
private String code; private String code;
private String nom; private String nom;
@ManyToOne @ManyToOne
private Structure structure; private Structure structure;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) //@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "section_id") //@JoinColumn(name = "section_id")
//@JsonManagedReference //@JsonManagedReference
private List<Secteur> fonctionList; //private List<Secteur> secteurs;
} }

View File

@@ -8,6 +8,7 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.infocad.parametre.Bloc; 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.NatureDomaine;
import io.gmss.fiscad.entities.infocad.parametre.Personne; import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
@@ -54,16 +55,30 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateEnquete; private LocalDate dateEnquete;
private boolean litige;
@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;
@ManyToOne @ManyToOne
private User user; private User user;
@JsonIgnore //@JsonIgnore
@ManyToOne @ManyToOne
private Exercice exercice; private Exercice exercice;
@JsonIgnore
@ManyToOne
private ModeAcquisition modeAcquisition;
private Long mobileDataId; private Long mobileDataId;
@JsonIgnore @JsonIgnore
@@ -116,7 +131,7 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateSynchronisation; private LocalDate dateSynchronisation;
private boolean synchronise; private Boolean synchronise;
private String observationParticuliere; private String observationParticuliere;
@Transient @Transient
private String nomPrenomEnqueteur; private String nomPrenomEnqueteur;
@@ -157,22 +172,24 @@ public class Enquete extends BaseEntity implements Serializable {
private String numeroTitreFoncier; private String numeroTitreFoncier;
/// Nouveau champs ajoutés pour RFU Abomey /// Nouveau champs ajoutés pour RFU Abomey
private String numEnterParcelle; private String numEntreeParcelle;
private String numRue; private String numRue;
private String nomRue; private String nomRue;
private String emplacement; private String emplacement;
private float altitude; private Float altitude;
private float precision; private Float precision;
private int nbreCoProprietaire; private Integer nbreCoProprietaire;
private int nbreIndivisiaire; private Integer nbreIndivisiaire;
private String autreAdresse; private String autreAdresse;
private float superficie ; private Float superficie ;
private int nbreBatiment; private Integer nbreBatiment;
private int nbrePiscine; private Integer nbrePiscine;
private Long montantMensuelleLocation; private Long montantMensuelleLocation;
private Long montantAnnuelleLocation; private Long montantAnnuelleLocation;
private Long valeurParcelleEstime; private Long valeurParcelleEstime;
private Long valeurParcelleReel; private Long valeurParcelleReel;
private Long valeurParcelleCalcule;
private String ncProprietaire;
@JsonFormat(pattern = "dd-MM-yyyy") @JsonFormat(pattern = "dd-MM-yyyy")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
@@ -182,15 +199,20 @@ public class Enquete extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateFinExcemption; private LocalDate dateFinExcemption;
@JsonIgnore private String representantNom;
@OneToMany(mappedBy = "enquete") private String representantPrenom;
@JsonManagedReference private String representantTel;
private List<EnqueteUniteLogement> enqueteUniteLogements; private String representantNpi;
//
// @JsonIgnore
// @OneToMany(mappedBy = "enquete")
// @JsonManagedReference
// private List<EnqueteUniteLogement> enqueteUniteLogements;
@JsonIgnore // @JsonIgnore
@JsonManagedReference // @JsonManagedReference
@OneToMany(mappedBy = "enquete") // @OneToMany(mappedBy = "enquete")
private List<EnqueteBatiment> enqueteBatiments; // private List<EnqueteBatiment> enqueteBatiments;
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "enquete") @OneToMany(mappedBy = "enquete")

View File

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

View File

@@ -10,6 +10,7 @@ import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.decoupage.Departement; import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.enums.SourceDonnee;
import io.gmss.fiscad.enums.StatutParcelle; import io.gmss.fiscad.enums.StatutParcelle;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -24,6 +25,7 @@ import org.n52.jackson.datatype.jts.GeometryDeserializer;
import org.n52.jackson.datatype.jts.GeometrySerializer; import org.n52.jackson.datatype.jts.GeometrySerializer;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Entity @Entity
@@ -39,27 +41,63 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; 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) @Column(unique = true,nullable = true)
private String nup; private String nup;
@Column(unique = true,nullable = true) @Column(unique = true,nullable = true)
private String nupProvisoire; private String nupProvisoire;
private String longitude; private String longitude;
private String latitude; 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 String pointsPolygone;
private Integer superficie; private Integer superficie;
private String nomEtPrenoms;
private String dateCollecte; private String dateCollecte;
private String sourceDonnees; @Enumerated(EnumType.STRING)
private SourceDonnee sourceDonnees;
private String observations; private String observations;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private StatutParcelle statutParcelle; private StatutParcelle statutParcelle;
private Long uploadId; private Long uploadId;
@@ -77,35 +115,22 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
private Arrondissement arrondissement; private Arrondissement arrondissement;
@ManyToOne //(fetch = FetchType.LAZY) @ManyToOne //(fetch = FetchType.LAZY)
//@JsonBackReference @JsonBackReference
private Quartier quartier ; private Quartier quartier ;
@ColumnDefault("0") @ColumnDefault("0")
private int geomSrid; private Integer geomSrid;
@JsonSerialize(using = GeometrySerializer.class) @JsonSerialize(using = GeometrySerializer.class)
@JsonDeserialize(contentUsing = GeometryDeserializer.class) @JsonDeserialize(contentUsing = GeometryDeserializer.class)
@Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)") @Column(name = "geometry",columnDefinition = "geometry(Polygon,32631)")
private Polygon geometry; private Polygon geometry;
@Column(columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String geometryString; private String geometryString;
private String codeInsae;
private String numeroEtatLieux;
private String numeroTitreFoncier;
private String telephone;
//private String codeParcelle;
//private String codeEquipe;
//private String elLot; @JsonIgnore
//private String elLettreParcelle; @ManyToOne
//private String rfuQuartierOuZone; @JsonBackReference
//private String rfuIlot; private Parcelle parcelle;
//private String rfuLettreParcelle;
//private String nomLotissement;
////////////
// @JsonIgnore
// @OneToOne
// private Parcelle parcelle;
// @JsonSerialize(using = GeometrySerializer.class) // @JsonSerialize(using = GeometrySerializer.class)
// @JsonDeserialize(contentUsing = GeometryDeserializer.class) // @JsonDeserialize(contentUsing = GeometryDeserializer.class)
// @Column(name = "geom",columnDefinition = "geometry(Polygon,4326)") // @Column(name = "geom",columnDefinition = "geometry(Polygon,4326)")

View File

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

View File

@@ -97,17 +97,17 @@ public class Upload extends BaseEntity implements Serializable {
System.out.println("url = " + url); 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;
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() { private String serverContext() {
String url= ServletUriComponentsBuilder.fromCurrentContextPath() String url= ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/api/upload/downloadFile/") .path("/api/upload/downloadFile/")
.toUriString(); .toUriString();
if(!url.contains("8282/api")){ //System.out.println(url);
url.replace("/api",":8282/api"); // if(!url.contains("8282/api")){
} // url.replace("/api",":8282/api");
// }
//System.out.println(url);
return url; return url;
} }

View File

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

View File

@@ -2,9 +2,11 @@ package io.gmss.fiscad.entities.infocad.parametre;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.entities.user.Fonction;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@@ -28,11 +30,11 @@ import java.util.Set;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SQLDelete(sql = //@SQLDelete(sql =
"UPDATE structure " + // "UPDATE structure " +
"SET deleted = true " + // "SET deleted = true " +
"WHERE id = ?") // "WHERE id = ?")
@Where(clause = " deleted = false") //@Where(clause = " deleted = false")
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) //@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Structure extends BaseEntity implements Serializable { public class Structure extends BaseEntity implements Serializable {
@@ -47,7 +49,7 @@ public class Structure extends BaseEntity implements Serializable {
private String tel; private String tel;
private String email; private String email;
private String adresse; private String adresse;
@NotNull //@NotNull(message = "Veuillez préciser la commune du centre d'impôts")
@ManyToOne @ManyToOne
private Commune commune; private Commune commune;
@@ -58,11 +60,18 @@ public class Structure extends BaseEntity implements Serializable {
inverseJoinColumns = @JoinColumn(name = "arrondissement_id") inverseJoinColumns = @JoinColumn(name = "arrondissement_id")
) )
private Set<Arrondissement> arrondissements; private Set<Arrondissement> arrondissements;
// @JsonIgnore
// @OneToMany(mappedBy = "structure")
// private List<User> agents;
// @JsonIgnore
// @OneToMany(mappedBy = "structure")
// private List<Bloc> blocs;
@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,11 +7,14 @@ import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Parcelle; import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.infocad.metier.Tpe; 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 jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.Internal;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import java.io.Serializable; import java.io.Serializable;
@@ -34,16 +37,42 @@ public class Batiment extends BaseEntity implements Serializable {
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate dateConstruction; private LocalDate dateConstruction;
private Long idDerniereEnquete; 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 @JsonIgnore
@ManyToOne @ManyToOne
private Parcelle parcelle; private Parcelle parcelle;
private Long parcelleExternalKey; @ManyToOne
private Usage usage;
@ManyToOne
private CategorieBatiment categorieBatiment ;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;
private Long enqueteId; // private Long enqueteId;
private Long mobileDataId; 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,6 +37,7 @@ public class CaracteristiqueParcelle extends BaseEntity implements Serializable
@ManyToOne @ManyToOne
private Caracteristique caracteristique; private Caracteristique caracteristique;
private String valeur; private String valeur;
private String observation;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,45 @@
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,6 +6,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer; import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Tpe; 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 jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -39,11 +41,33 @@ public class UniteLogement extends BaseEntity implements Serializable {
private List<EnqueteUniteLogement> enqueteUniteLogements; private List<EnqueteUniteLogement> enqueteUniteLogements;
@ManyToOne @ManyToOne
private Batiment batiment; private Batiment batiment;
@ManyToOne
private Usage usage;
private Long batimentExternalKey; private Long batimentExternalKey;
private Long idDerniereEnquete; 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 @JsonIgnore
@ManyToOne @ManyToOne
private Tpe terminal; private Tpe terminal;
private Long enqueteId; private Long enqueteId;
private Long mobileDataId; 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,6 +2,7 @@ package io.gmss.fiscad.entities.rfu.parametre;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Quartier;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -28,4 +29,6 @@ public class BaremRfuBati extends BaseEntity implements Serializable {
private CategorieBatiment categorieBatiment; private CategorieBatiment categorieBatiment;
@ManyToOne @ManyToOne
private Arrondissement arrondissement; private Arrondissement arrondissement;
@ManyToOne
private Quartier quartier ;
} }

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,29 @@
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

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer; import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.entities.decoupage.Secteur; import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.entities.decoupage.Section; import io.gmss.fiscad.entities.decoupage.Section;
import io.gmss.fiscad.entities.infocad.parametre.Structure; import io.gmss.fiscad.entities.infocad.parametre.Structure;
@@ -31,10 +32,17 @@ import java.time.LocalDate;
// "SET deleted = true " + // "SET deleted = true " +
// "WHERE id = ?") // "WHERE id = ?")
//@Where(clause = " deleted = false") //@Where(clause = " deleted = false")
@Table(
name = "fonction",
uniqueConstraints = {
@UniqueConstraint(columnNames = {"code"})
}
)
public class Fonction extends BaseEntity implements Serializable { public class Fonction extends BaseEntity implements Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Column(nullable = false, unique = true)
private String code ; private String code ;
private String nom ; private String nom ;
@@ -42,14 +50,17 @@ public class Fonction extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Secteur secteur; private Secteur secteur;
@JsonBackReference //@JsonBackReference
@ManyToOne @ManyToOne
private Section section; private Section section;
//@JsonBackReference
@ManyToOne @ManyToOne
@JoinColumn(name = "structure_id")
private Structure structure; private Structure structure;
@ManyToOne
private Departement departement;
//@JsonIgnore //@JsonIgnore
@ManyToOne //(fetch = FetchType.LAZY, optional = false) @ManyToOne //(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "profile_id", nullable = false) @JoinColumn(name = "profile_id", nullable = false)

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,19 @@
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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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