Compare commits
16 Commits
develop
...
c8b0457195
| Author | SHA1 | Date | |
|---|---|---|---|
| c8b0457195 | |||
| 9cc74a9a38 | |||
| 8e6168d4ee | |||
| c1a8ce86a6 | |||
| 14feb49dcd | |||
| 39de1c48c0 | |||
| f9e2b32118 | |||
| 3ebb1cf165 | |||
| c84176b8d3 | |||
| 61f4dd513f | |||
| 5e9f437497 | |||
| 69af57f876 | |||
| 56f78e77f3 | |||
| 0c7dc082fd | |||
| 3f5d7e980c | |||
| 87be4e4483 |
4
.env
4
.env
@@ -1,3 +1,3 @@
|
|||||||
POSTGRES_DB=fiscad_db
|
POSTGRES_DB=abomey_db
|
||||||
POSTGRES_USER=fiscad_user
|
POSTGRES_USER=infocad_user
|
||||||
POSTGRES_PASSWORD=W5fwD({9*q53
|
POSTGRES_PASSWORD=W5fwD({9*q53
|
||||||
@@ -52,10 +52,8 @@ 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
|
||||||
run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 5) Informations de contexte (sans secrets)
|
# 5) Informations de contexte (sans secrets)
|
||||||
- name: Show context information
|
- name: Show context information
|
||||||
@@ -100,9 +98,6 @@ jobs:
|
|||||||
|
|
||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
echo "Workspace: $(pwd)"
|
echo "Workspace: $(pwd)"
|
||||||
cat secrets/postgresPassword.txt
|
|
||||||
echo "POSTGRES_DB_FISCAD=$POSTGRES_DB_FISCAD"
|
|
||||||
echo "POSTGRES_USER_FISCAD=$POSTGRES_USER_FISCAD"
|
|
||||||
ls -l secrets/
|
ls -l secrets/
|
||||||
|
|
||||||
docker-compose -f docker-compose-prod.yml pull || true
|
docker-compose -f docker-compose-prod.yml pull || true
|
||||||
@@ -128,9 +123,9 @@ jobs:
|
|||||||
-U ${POSTGRES_USER_FISCAD} \
|
-U ${POSTGRES_USER_FISCAD} \
|
||||||
-d ${POSTGRES_DB_FISCAD} \
|
-d ${POSTGRES_DB_FISCAD} \
|
||||||
-c 'SELECT 1;'
|
-c 'SELECT 1;'
|
||||||
"
|
"
|
||||||
|
|
||||||
# 11) OK Nettoyage des secrets (sécurité OBLIGATOIRE)
|
# 11) Nettoyage des secrets (sécurité OBLIGATOIRE)
|
||||||
- name: Cleanup secrets
|
- name: Cleanup secrets
|
||||||
if: always()
|
if: always()
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|||||||
@@ -52,10 +52,8 @@ 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
|
||||||
run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 5) Création des secrets runtime (CI uniquement)
|
# 5) Création des secrets runtime (CI uniquement)
|
||||||
- name: Create runtime secrets
|
- name: Create runtime secrets
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -4,5 +4,4 @@ fiscad.log*
|
|||||||
target/*
|
target/*
|
||||||
ansible
|
ansible
|
||||||
secrets/
|
secrets/
|
||||||
.env
|
.env
|
||||||
/uploads/
|
|
||||||
@@ -11,5 +11,4 @@ COPY ./target/Fiscad-0.0.1-SNAPSHOT.jar fiscad.jar
|
|||||||
EXPOSE 8282
|
EXPOSE 8282
|
||||||
|
|
||||||
# Lancer l'application
|
# Lancer l'application
|
||||||
#ENTRYPOINT ["java", "-jar", "fiscad.jar"]
|
ENTRYPOINT ["java", "-jar", "fiscad.jar"]
|
||||||
ENTRYPOINT ["sh", "-c", "export SPRING_DATASOURCE_PASSWORD=$(cat /run/secrets/postgresPassword) && export DEFAULT_USER_NAME=$(cat /run/secrets/defaultUserName) && export DEFAULT_USER_PASSWORD=$(cat /run/secrets/defaultUserPassword) && exec java -jar fiscad.jar"]
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
|
||||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
|
||||||
CREATE EXTENSION IF NOT EXISTS pg_cron;
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgis/postgis:15-3.4
|
image: postgres:15
|
||||||
container_name: fiscad-db
|
container_name: fiscad-db
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
@@ -18,10 +18,9 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- db-data-fiscad:/var/lib/postgresql/data
|
- db-data-fiscad:/var/lib/postgresql/data
|
||||||
- ./db-init:/docker-entrypoint-initdb.d
|
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER_FISCAD} -d ${POSTGRES_DB_FISCAD}"]
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER_FISCAD}"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
@@ -33,18 +32,17 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: fiscad-app
|
container_name: fiscad-app
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
- db
|
||||||
condition: service_healthy
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB_FISCAD}
|
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB_FISCAD}
|
||||||
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER_FISCAD}
|
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER_FISCAD}
|
||||||
|
SPRING_DATASOURCE_PASSWORD_FILE: /run/secrets/postgresPassword
|
||||||
|
|
||||||
SERVER_PORT: 8282
|
SERVER_PORT: 8282
|
||||||
IO_GMSS_FISCAD_PROFILE: dgi
|
IO_GMSS_FISCAD_PROFILE: abomey
|
||||||
SPRING_PROFILES_ACTIVE: dgi
|
SPRING_PROFILES_ACTIVE: abomey
|
||||||
|
|
||||||
DEFAULT_USER_NAME_FILE: /run/secrets/defaultUserName
|
DEFAULT_USER_NAME_FILE: /run/secrets/defaultUserName
|
||||||
DEFAULT_USER_PASSWORD_FILE: /run/secrets/defaultUserPassword
|
DEFAULT_USER_PASSWORD_FILE: /run/secrets/defaultUserPassword
|
||||||
|
|||||||
18
pom.xml
18
pom.xml
@@ -73,7 +73,6 @@
|
|||||||
<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>
|
||||||
@@ -150,24 +149,7 @@
|
|||||||
<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>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package io.gmss.fiscad.component;
|
|||||||
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.persistence.repositories.user.RoleRepository;
|
import io.gmss.fiscad.repositories.user.RoleRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
import io.gmss.fiscad.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;
|
||||||
@@ -20,13 +20,12 @@ public class DataLoadConfig {
|
|||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
@Value("${app.default-user.username}")
|
@Value("${DEFAULT_USER_NAME_FILE}")
|
||||||
private String usernameFile;
|
private String usernameFile;
|
||||||
|
|
||||||
@Value("${app.default-user.password}")
|
@Value("${DEFAULT_USER_PASSWORD_FILE}")
|
||||||
private String passwordFile;
|
private String passwordFile;
|
||||||
|
|
||||||
|
|
||||||
public DataLoadConfig(RoleRepository roleRepository, UserRepository userRepository, PasswordEncoder passwordEncoder) {
|
public DataLoadConfig(RoleRepository roleRepository, UserRepository userRepository, PasswordEncoder passwordEncoder) {
|
||||||
this.roleRepository = roleRepository;
|
this.roleRepository = roleRepository;
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
@@ -42,17 +41,21 @@ public class DataLoadConfig {
|
|||||||
|
|
||||||
|
|
||||||
public void loadRoles() {
|
public void loadRoles() {
|
||||||
|
|
||||||
if (roleRepository.count() > 0) return;
|
if (roleRepository.count() > 0) return;
|
||||||
Set<Role> roles = new HashSet<>();
|
Set<Role> roles = new HashSet<>();
|
||||||
roles.add(new Role(UserRole.CREATE_USER, "Peut créer un utilisation."));
|
roles.add(new Role(UserRole.ROLE_USER, "Role attribué aux utilisateurs simples."));
|
||||||
roles.add(new Role(UserRole.READ_USER, "peut lire un utilisation"));
|
roles.add(new Role(UserRole.ROLE_ADMIN, "Role attribué aux administrateurs du système."));
|
||||||
roles.add(new Role(UserRole.UPDATE_USER, "peut modifier un utilisation"));
|
roles.add(new Role(UserRole.ROLE_DIRECTEUR, "Role attribué aux directeurs des structures."));
|
||||||
roles.add(new Role(UserRole.DELETE_USER, "peut supprimer un utilisation"));
|
roles.add(new Role(UserRole.ROLE_SUPERVISEUR, "Role attribué aux superviseurs des structures sur le terrain."));
|
||||||
|
roles.add(new Role(UserRole.ROLE_ENQUETEUR, "Role attribué aux enquêteurs des structures sur le terrain."));
|
||||||
|
roles.add(new Role(UserRole.ROLE_ANONYMOUS, "Role attribué à toutes les personnes qui s'inscrivent en ligne pour le compte d'une structure."));
|
||||||
roleRepository.saveAll(roles);
|
roleRepository.saveAll(roles);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadUsers() {
|
public void loadUsers() {
|
||||||
if (!userRepository.existsByUsername(usernameFile) ) {
|
if (userRepository.existsByUsername(usernameFile) ) {
|
||||||
User admin = new User();
|
User admin = new User();
|
||||||
admin.setUsername(usernameFile);
|
admin.setUsername(usernameFile);
|
||||||
admin.setEmail("administrateur@infocad.bj");
|
admin.setEmail("administrateur@infocad.bj");
|
||||||
@@ -61,6 +64,9 @@ public class DataLoadConfig {
|
|||||||
admin.setPrenom("Principal");
|
admin.setPrenom("Principal");
|
||||||
admin.setPassword(passwordEncoder.encode(passwordFile));
|
admin.setPassword(passwordEncoder.encode(passwordFile));
|
||||||
admin.setActive(true);
|
admin.setActive(true);
|
||||||
|
Set<Role> roles = new HashSet<>();
|
||||||
|
roles.add(roleRepository.findRoleByNom(UserRole.ROLE_ADMIN).get());
|
||||||
|
admin.setRoles(roles);
|
||||||
userRepository.save(admin);
|
userRepository.save(admin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
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;
|
||||||
@@ -67,7 +63,4 @@ public class ApplicationConfig {
|
|||||||
|
|
||||||
return authenticationManagerBuilder.build();
|
return authenticationManagerBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.gmss.fiscad.configuration;
|
package io.gmss.fiscad.configuration;
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
import io.gmss.fiscad.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;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.gmss.fiscad.configuration;
|
package io.gmss.fiscad.configuration;
|
||||||
|
|
||||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
import io.gmss.fiscad.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;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import io.swagger.v3.oas.annotations.servers.Server;
|
|||||||
)
|
)
|
||||||
@SecurityScheme(
|
@SecurityScheme(
|
||||||
name = "bearer",
|
name = "bearer",
|
||||||
description = "Authentification Json BatimentPaylaodWeb Token",
|
description = "Authentification Json Web Token",
|
||||||
scheme = "Bearer",
|
scheme = "Bearer",
|
||||||
type = SecuritySchemeType.HTTP,
|
type = SecuritySchemeType.HTTP,
|
||||||
bearerFormat = "JWT",
|
bearerFormat = "JWT",
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package io.gmss.fiscad.configuration;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
||||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class RestTemplateConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ObjectMapper objectMapper() {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.registerModule(new JavaTimeModule());
|
|
||||||
mapper.registerModule(new Jdk8Module());
|
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
|
||||||
return mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
|
|
||||||
return builder -> {
|
|
||||||
builder.modules(new JavaTimeModule(), new Jdk8Module());
|
|
||||||
builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RestTemplate restTemplate(ObjectMapper mapper) {
|
|
||||||
|
|
||||||
mapper.registerModule(new JavaTimeModule());
|
|
||||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
|
||||||
|
|
||||||
MappingJackson2HttpMessageConverter converter =
|
|
||||||
new MappingJackson2HttpMessageConverter(mapper);
|
|
||||||
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.getMessageConverters().removeIf(
|
|
||||||
c -> c instanceof MappingJackson2HttpMessageConverter
|
|
||||||
);
|
|
||||||
restTemplate.getMessageConverters().add(converter);
|
|
||||||
|
|
||||||
return restTemplate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
//package io.gmss.fiscad.configuration;
|
|
||||||
//
|
|
||||||
//import com.backend.api.security.CustomUserDetailsService;
|
|
||||||
//import com.backend.api.security.JwtAuthenticationEntryPoint;
|
|
||||||
//import com.backend.api.security.JwtAuthenticationFilter;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.context.annotation.Bean;
|
|
||||||
//import org.springframework.context.annotation.Configuration;
|
|
||||||
//import org.springframework.http.HttpMethod;
|
|
||||||
//import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
//import org.springframework.security.config.BeanIds;
|
|
||||||
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
|
||||||
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
||||||
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
||||||
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
||||||
//import org.springframework.security.config.http.SessionCreationPolicy;
|
|
||||||
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
//import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
||||||
//
|
|
||||||
//@Configuration
|
|
||||||
//@EnableWebSecurity // active la sécurité web sur le projet
|
|
||||||
//@EnableGlobalMethodSecurity( // est utilisé pour définir la sécurité sur les méthodes
|
|
||||||
// securedEnabled = true, // est activé pour protéger un controlleur ou un service
|
|
||||||
// jsr250Enabled = true, // active le role qui doit être utilisé
|
|
||||||
// prePostEnabled = true // active le controle avant et après l'execution de la requête
|
|
||||||
//)
|
|
||||||
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Est utilisé pour authentifier un utlisateur ou pour définir un role
|
|
||||||
// */
|
|
||||||
// @Autowired
|
|
||||||
// CustomUserDetailsService customUserDetailsService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private JwtAuthenticationEntryPoint unauthorizedHandler;
|
|
||||||
//
|
|
||||||
// @Bean
|
|
||||||
// public JwtAuthenticationFilter jwtAuthenticationFilter() {
|
|
||||||
// return new JwtAuthenticationFilter();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private static final String[] AUTH_WHITELIST = {
|
|
||||||
//
|
|
||||||
// // -- swagger ui
|
|
||||||
// "/swagger-resources/**",
|
|
||||||
// "/swagger-ui.html",
|
|
||||||
// "/v3/api-docs",
|
|
||||||
// "/swagger-ui/**",
|
|
||||||
// "/webjars/**",
|
|
||||||
// "/api/**",
|
|
||||||
//// "/api/synonym/**",
|
|
||||||
// "/api/auth/**"
|
|
||||||
// };
|
|
||||||
// @Override
|
|
||||||
// public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
|
|
||||||
// authenticationManagerBuilder
|
|
||||||
// .userDetailsService(customUserDetailsService)
|
|
||||||
// .passwordEncoder(passwordEncoder());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Bean(BeanIds.AUTHENTICATION_MANAGER)
|
|
||||||
// @Override
|
|
||||||
// public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
||||||
// return super.authenticationManagerBean();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Bean
|
|
||||||
// public PasswordEncoder passwordEncoder() {
|
|
||||||
// return new BCryptPasswordEncoder();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// *
|
|
||||||
// * @param http
|
|
||||||
// * @throws Exception
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
// http
|
|
||||||
// .cors()
|
|
||||||
// .and()
|
|
||||||
// .csrf()
|
|
||||||
// .disable()
|
|
||||||
// .exceptionHandling()
|
|
||||||
// .authenticationEntryPoint(unauthorizedHandler)
|
|
||||||
// .and()
|
|
||||||
// .sessionManagement()
|
|
||||||
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
||||||
// .and()
|
|
||||||
// .authorizeRequests()
|
|
||||||
// .antMatchers("/",
|
|
||||||
// "/favicon.ico",
|
|
||||||
// "/**/*.png",
|
|
||||||
// "/**/*.gif",
|
|
||||||
// "/**/*.svg",
|
|
||||||
// "/**/*.jpg",
|
|
||||||
// "/**/*.html",
|
|
||||||
// "/**/*.css",
|
|
||||||
// "/**/*.js")
|
|
||||||
// .permitAll()
|
|
||||||
// .antMatchers(AUTH_WHITELIST).permitAll()
|
|
||||||
// .antMatchers("/api/auth/**")
|
|
||||||
// .permitAll()
|
|
||||||
// .antMatchers("/api/user/checkUsernameAvailability", "/api/user/checkEmailAvailability")
|
|
||||||
// .permitAll()
|
|
||||||
// .antMatchers(HttpMethod.GET, "/api/polls/**", "/api/users/**")
|
|
||||||
// .permitAll()
|
|
||||||
// .anyRequest()
|
|
||||||
// .authenticated();
|
|
||||||
//
|
|
||||||
// // Add our custom JWT security filter
|
|
||||||
// http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,113 +1,11 @@
|
|||||||
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 d’authentification
|
|
||||||
.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 d’authentification
|
|
||||||
.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;
|
||||||
@@ -129,15 +27,16 @@ 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"
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,7 +58,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()
|
||||||
@@ -167,8 +66,11 @@ 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();
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
@@ -45,7 +45,6 @@ public class ArrondissementController {
|
|||||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(description = "Unauthorized / Invalid Token", responseCode = "403")}
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(description = "Unauthorized / Invalid Token", responseCode = "403")}
|
||||||
)
|
)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_ARRONDISSEMENT')")
|
|
||||||
public ResponseEntity<?> createArrondissement(@RequestBody @Valid @Validated Arrondissement arrondissement) {
|
public ResponseEntity<?> createArrondissement(@RequestBody @Valid @Validated Arrondissement arrondissement) {
|
||||||
try {
|
try {
|
||||||
arrondissement = arrondissementService.createArrondissement(arrondissement);
|
arrondissement = arrondissementService.createArrondissement(arrondissement);
|
||||||
@@ -77,7 +76,6 @@ public class ArrondissementController {
|
|||||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(description = "Unauthorized / Invalid Token", responseCode = "403")}
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(description = "Unauthorized / Invalid Token", responseCode = "403")}
|
||||||
)
|
)
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ARRONDISSEMENT')")
|
|
||||||
public ResponseEntity<?> updateArrondissement(@PathVariable Long id, @RequestBody Arrondissement arrondissement) {
|
public ResponseEntity<?> updateArrondissement(@PathVariable Long id, @RequestBody Arrondissement arrondissement) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -101,7 +99,6 @@ public class ArrondissementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_ARRONDISSEMENT')")
|
|
||||||
public ResponseEntity<?> deleteArrondissement(@PathVariable Long id) {
|
public ResponseEntity<?> deleteArrondissement(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
arrondissementService.deleteArrondissement(id);
|
arrondissementService.deleteArrondissement(id);
|
||||||
@@ -126,7 +123,6 @@ public class ArrondissementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_ARRONDISSEMENT')")
|
|
||||||
public ResponseEntity<?> getAllArrondissementList() {
|
public ResponseEntity<?> getAllArrondissementList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -151,7 +147,6 @@ public class ArrondissementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_ARRONDISSEMENT')")
|
|
||||||
public ResponseEntity<?> getAllArrondissementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllArrondissementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -177,11 +172,10 @@ public class ArrondissementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ARRONDISSEMENT')")
|
|
||||||
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).orElse(null), "Arrondissement trouvé avec succès."),
|
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -202,36 +196,10 @@ public class ArrondissementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/commune/{communeId}")
|
@GetMapping("/commune/{communeId}")
|
||||||
@PreAuthorize("hasAuthority('READ_ARRONDISSEMENT')")
|
|
||||||
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, arrondissementService.getArrondissementListByCommuneId(communeId), "Liste des arrondissements par commune chargée avec succès."),
|
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ARRONDISSEMENT')")
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -38,7 +38,6 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_COMMUNE')")
|
|
||||||
public ResponseEntity<?> createCommune(@RequestBody @Valid @Validated Commune commune) {
|
public ResponseEntity<?> createCommune(@RequestBody @Valid @Validated Commune commune) {
|
||||||
try {
|
try {
|
||||||
commune = communeService.createCommune(commune);
|
commune = communeService.createCommune(commune);
|
||||||
@@ -63,7 +62,6 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_COMMUNE')")
|
|
||||||
public ResponseEntity<?> updateCommune(@PathVariable Long id, @RequestBody Commune commune) {
|
public ResponseEntity<?> updateCommune(@PathVariable Long id, @RequestBody Commune commune) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -87,7 +85,6 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_COMMUNE')")
|
|
||||||
public ResponseEntity<?> deleteCommuner(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCommuner(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
communeService.deleteCommune(id);
|
communeService.deleteCommune(id);
|
||||||
@@ -112,7 +109,6 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNE')")
|
|
||||||
public ResponseEntity<?> getAllCommuneList() {
|
public ResponseEntity<?> getAllCommuneList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -137,7 +133,6 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNE')")
|
|
||||||
public ResponseEntity<?> getAllCommunePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCommunePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -163,7 +158,6 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNE')")
|
|
||||||
public ResponseEntity<?> getCommuneById(@PathVariable Long id) {
|
public ResponseEntity<?> getCommuneById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -187,37 +181,11 @@ public class CommuneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/departement/{departementId}")
|
@GetMapping("/departement/{departementId}")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNE')")
|
|
||||||
public ResponseEntity<?> getCommuneByDepartement(@PathVariable Long departementId) {
|
public ResponseEntity<?> getCommuneByDepartement(@PathVariable Long departementId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, communeService.getCommunesByDepartementId(departementId), "Liste des communes par département chargée avec succès."),
|
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNE')")
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class DepartementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_DEPARTEMENT')")
|
|
||||||
public ResponseEntity<?> createDepartement(@RequestBody @Valid @Validated Departement departement) {
|
public ResponseEntity<?> createDepartement(@RequestBody @Valid @Validated Departement departement) {
|
||||||
try {
|
try {
|
||||||
departement = departementService.createDepartement(departement);
|
departement = departementService.createDepartement(departement);
|
||||||
@@ -62,7 +61,6 @@ public class DepartementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_DEPARTEMENT')")
|
|
||||||
public ResponseEntity<?> updateDepartement(@PathVariable Long id, @RequestBody Departement departement) {
|
public ResponseEntity<?> updateDepartement(@PathVariable Long id, @RequestBody Departement departement) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class DepartementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_DEPARTEMENT')")
|
|
||||||
public ResponseEntity<?> deleteDepartementr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteDepartementr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
departementService.deleteDepartement(id);
|
departementService.deleteDepartement(id);
|
||||||
@@ -111,7 +108,6 @@ public class DepartementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_DEPARTEMENT')")
|
|
||||||
public ResponseEntity<?> getAllDepartementList() {
|
public ResponseEntity<?> getAllDepartementList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -136,7 +132,6 @@ public class DepartementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_DEPARTEMENT')")
|
|
||||||
public ResponseEntity<?> getAllDepartementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllDepartementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -162,7 +157,6 @@ public class DepartementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_DEPARTEMENT')")
|
|
||||||
public ResponseEntity<?> getDepartementById(@PathVariable Long id) {
|
public ResponseEntity<?> getDepartementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class NationaliteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_NATIONALITE')")
|
|
||||||
public ResponseEntity<?> createNationalite(@RequestBody @Valid @Validated Nationalite nationalite) {
|
public ResponseEntity<?> createNationalite(@RequestBody @Valid @Validated Nationalite nationalite) {
|
||||||
try {
|
try {
|
||||||
nationalite = nationaliteService.createNationalite(nationalite);
|
nationalite = nationaliteService.createNationalite(nationalite);
|
||||||
@@ -62,7 +61,6 @@ public class NationaliteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_NATIONALITE')")
|
|
||||||
public ResponseEntity<?> updateNationalite(@PathVariable Long id, @RequestBody Nationalite nationalite) {
|
public ResponseEntity<?> updateNationalite(@PathVariable Long id, @RequestBody Nationalite nationalite) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class NationaliteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_NATIONALITE')")
|
|
||||||
public ResponseEntity<?> deleteNationaliter(@PathVariable Long id) {
|
public ResponseEntity<?> deleteNationaliter(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
nationaliteService.deleteNationalite(id);
|
nationaliteService.deleteNationalite(id);
|
||||||
@@ -111,7 +108,6 @@ public class NationaliteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_NATIONALITE')")
|
|
||||||
public ResponseEntity<?> getAllNationaliteList() {
|
public ResponseEntity<?> getAllNationaliteList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class NationaliteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_NATIONALITE')")
|
|
||||||
public ResponseEntity<?> getAllNationalitePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllNationalitePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -161,7 +156,6 @@ public class NationaliteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_NATIONALITE')")
|
|
||||||
public ResponseEntity<?> getNationaliteById(@PathVariable Long id) {
|
public ResponseEntity<?> getNationaliteById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_QUARTIER')")
|
|
||||||
public ResponseEntity<?> createQuartier(@RequestBody @Valid @Validated Quartier quartier) {
|
public ResponseEntity<?> createQuartier(@RequestBody @Valid @Validated Quartier quartier) {
|
||||||
try {
|
try {
|
||||||
quartier = quartierService.createQuartier(quartier);
|
quartier = quartierService.createQuartier(quartier);
|
||||||
@@ -62,7 +61,6 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_QUARTIER')")
|
|
||||||
public ResponseEntity<?> updateQuartier(@PathVariable Long id, @RequestBody Quartier quartier) {
|
public ResponseEntity<?> updateQuartier(@PathVariable Long id, @RequestBody Quartier quartier) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_QUARTIER')")
|
|
||||||
public ResponseEntity<?> deleteQuartier(@PathVariable Long id) {
|
public ResponseEntity<?> deleteQuartier(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
quartierService.deleteQuartier(id);
|
quartierService.deleteQuartier(id);
|
||||||
@@ -111,7 +108,6 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_QUARTIER')")
|
|
||||||
public ResponseEntity<?> getAllQuartierList() {
|
public ResponseEntity<?> getAllQuartierList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_QUARTIER')")
|
|
||||||
public ResponseEntity<?> getAllQuartierPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllQuartierPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,11 +155,10 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_QUARTIER')")
|
|
||||||
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).orElse(null), "Quartier trouvé avec succès."),
|
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -184,37 +178,11 @@ public class QuartierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/arrondissement/{arrondissementId}")
|
@GetMapping("/arrondissement/{arrondissementId}")
|
||||||
@PreAuthorize("hasAuthority('READ_QUARTIER')")
|
|
||||||
public ResponseEntity<?> getQuartierByArrondissement(@PathVariable Long arrondissementId) {
|
public ResponseEntity<?> getQuartierByArrondissement(@PathVariable Long arrondissementId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, quartierService.getQuartierListByArrondissementId(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
|
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_QUARTIER')")
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ 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.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;
|
||||||
@@ -25,9 +22,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;
|
||||||
@@ -37,17 +34,14 @@ 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")
|
||||||
@PreAuthorize("hasAuthority('CREATE_SECTEUR')")
|
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) {
|
||||||
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPaylaodWeb secteurPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
secteurPaylaodWeb = secteurService.createSecteur(secteurPaylaodWeb);
|
// Secteur secteur=getSecteurFromPayload(secteurPayload);
|
||||||
|
Secteur secteur = secteurService.createSecteur(secteurPayload);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurPaylaodWeb, "Secteur créé avec succès."),
|
new ApiResponse<>(true, secteur, "Secteur créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -66,16 +60,12 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "mettre à jour un secteur",
|
|
||||||
description = "Permet de modifier un secteur"
|
|
||||||
)
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_SECTEUR')")
|
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, secteurPayloadWeb), "Secteur mis à jour avec succès."),
|
new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayload), "Secteur mis à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -93,12 +83,8 @@ 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}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_SECTEUR')")
|
|
||||||
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
secteurService.deleteSecteur(id);
|
secteurService.deleteSecteur(id);
|
||||||
@@ -121,12 +107,8 @@ 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")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
public ResponseEntity<?> getAllSecteurList() {
|
public ResponseEntity<?> getAllSecteurList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -149,12 +131,7 @@ 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")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -178,12 +155,7 @@ 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}")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
|
public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -206,16 +178,12 @@ 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}")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
|
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurService.getSecteurListByStructureId(structureId), "Secteur trouvée avec succès."),
|
new ApiResponse<>(true, secteurService.getSecteurListUneStruture(structureId), "Secteur trouvée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -235,122 +203,4 @@ 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
package io.gmss.fiscad.controllers.decoupage;
|
package io.gmss.fiscad.controllers.decoupage;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
import io.gmss.fiscad.enums.StatutEnquete;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
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.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;
|
||||||
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;
|
||||||
@@ -22,27 +18,29 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@AllArgsConstructor
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/secteur-decoupage", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/secteur-decoupage", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "SecteurDecoupage")
|
@Tag(name = "SecteurDecoupage")
|
||||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class SecteurDecoupageController {
|
public class SecteurDecoupageController {
|
||||||
|
|
||||||
private final SecteurDecoupageService secteurDecoupageService;
|
private final SecteurDecoupageService secteurDecoupageService;
|
||||||
private final SecteurService secteurService;
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SecteurDecoupageController.class);
|
private static final Logger logger = LoggerFactory.getLogger(SecteurDecoupageController.class);
|
||||||
|
|
||||||
|
public SecteurDecoupageController(SecteurDecoupageService secteurDecoupageService) {
|
||||||
|
this.secteurDecoupageService = secteurDecoupageService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_SECTEUR_DECOUPAGE')")
|
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
|
||||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
secteurDecoupagePaylaodWeb = secteurDecoupageService.createSecteurDecoupage(secteurDecoupagePaylaodWeb);
|
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurDecoupagePaylaodWeb, "SecteurDecoupage créé avec succès."),
|
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -62,11 +60,10 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_SECTEUR_DECOUPAGE')")
|
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, secteurDecoupagePaylaodWeb), "SecteurDecoupage mis à jour avec succès."),
|
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -86,7 +83,6 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> deleteSecteurDecoupager(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSecteurDecoupager(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
secteurDecoupageService.deleteSecteurDecoupage(id);
|
secteurDecoupageService.deleteSecteurDecoupage(id);
|
||||||
@@ -111,7 +107,6 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getAllSecteurDecoupageList() {
|
public ResponseEntity<?> getAllSecteurDecoupageList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +130,6 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getAllSecteurDecoupagePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSecteurDecoupagePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -159,61 +153,11 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/by-secteur-id/{secteurId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
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}")
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
|
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -233,255 +177,4 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/arbre/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatParcelleDecoupageByUserId(userId), "SecteurDecoupage 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("/arbre/enquete-en-cours/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteEncoursByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteDecoupageByUserId(userId, StatutEnquete.EN_COURS.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-valide/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteValideByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteDecoupageByUserId(userId, StatutEnquete.VALIDE.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-cloture/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteClotureByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteDecoupageByUserId(userId, StatutEnquete.CLOTURE.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-batiment-en-cours/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteBatimentEncoursByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteBatimentDecoupageByUserId(userId, StatutEnquete.EN_COURS.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-batiment-valide/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteBatimentValideByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteBatimentDecoupageByUserId(userId, StatutEnquete.VALIDE.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-batiment-cloture/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteBatimentClotureByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteBatimentDecoupageByUserId(userId, StatutEnquete.CLOTURE.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-unitlog-en-cours/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteUniteLogEncoursByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteUniteLogementDecoupageByUserId(userId, StatutEnquete.EN_COURS.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-unitlog-valide/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteUniteLogValideByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteUniteLogementDecoupageByUserId(userId, StatutEnquete.VALIDE.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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("/arbre/enquete-unitlog-cloture/user-id/{userId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTEUR_DECOUPAGE')")
|
|
||||||
public ResponseEntity<?> getArborescenceEnqueteUniteLigClotureByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatEnqueteUniteLogementDecoupageByUserId(userId, StatutEnquete.CLOTURE.toString()), "SecteurDecoupage 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) {
|
|
||||||
e.printStackTrace();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,265 +0,0 @@
|
|||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_SECTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_SECTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_SECTION')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTION')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_SECTION')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.frontend;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.frontend.FonctionnaliteService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.FonctionnalitePayloadWeb;
|
|
||||||
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.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/fonctionnalite", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Fonctionnalite")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class FonctionnaliteController {
|
|
||||||
|
|
||||||
private final FonctionnaliteService fonctionnaliteService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FonctionnaliteController.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_FONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> createFonctionnalite(@RequestBody @Valid @Validated FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
fonctionnalitePayLoadWeb = fonctionnaliteService.createFonctionnalite(fonctionnalitePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionnalitePayLoadWeb, "Fonctionnalite 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_FONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> updateFonctionnalite(@PathVariable Long id, @RequestBody FonctionnalitePayloadWeb fonctionnalitePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionnaliteService.updateFonctionnalite(id,fonctionnalitePayLoadWeb), "Fonctionnalite 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_FONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> deleteFonctionnalite(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
fonctionnaliteService.deleteFonctionnalite(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Fonctionnalite 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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> getAllFonctionnaliteList() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionnaliteService.getFonctionnaliteListToDto(), "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-profil-id/{profilId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> getAllFonctionnaliteByProfilList(@PathVariable Long profilId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionnaliteService.getAllFonctionnaliteByProfilIdToDto(profilId), "Liste des fonctionnalites 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_FONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> getFonctionnaliteById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionnaliteService.getFonctionnaliteByIdToDto(id), "Fonctionnalite 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,185 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.frontend;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.frontend.ModuleService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.ModulePayloadWeb;
|
|
||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/module", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Module")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class ModuleController {
|
|
||||||
|
|
||||||
private final ModuleService moduleService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ModuleController.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_MODULE')")
|
|
||||||
public ResponseEntity<?> createModule(@RequestBody @Valid @Validated ModulePayloadWeb modulePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
modulePayLoadWeb = moduleService.createModule(modulePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, modulePayLoadWeb, "Module 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_MODULE')")
|
|
||||||
public ResponseEntity<?> updateModule(@PathVariable Long id, @RequestBody ModulePayloadWeb modulePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, moduleService.updateModule(id,modulePayLoadWeb), "Module 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_MODULE')")
|
|
||||||
public ResponseEntity<?> deleteModule(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
moduleService.deleteModule(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Module 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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_MODULE')")
|
|
||||||
public ResponseEntity<?> getAllModuleList() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, moduleService.getModuleListToDto(), "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-profil-id/{profilId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_MODULE')")
|
|
||||||
public ResponseEntity<?> getAllModuleByProfilList(@PathVariable Long profilId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, moduleService.getAllModuleByProfilIdToDto(profilId), "Liste des modules 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_MODULE')")
|
|
||||||
public ResponseEntity<?> getModuleById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, moduleService.getModuleByIdToDto(id), "Module 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Actuer concerné")
|
@Tag(name = "Actuer concerné")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public class ActeurConcerneController {
|
public class ActeurConcerneController {
|
||||||
|
|
||||||
private final ActeurConcerneService acteurConcerneService;
|
private final ActeurConcerneService acteurConcerneService;
|
||||||
@@ -36,7 +36,6 @@ public class ActeurConcerneController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ACTEURCONCERNE')")
|
|
||||||
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -59,7 +58,6 @@ public class ActeurConcerneController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@GetMapping("/get-details/{id}")
|
@GetMapping("/get-details/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ACTEURCONCERNE')")
|
|
||||||
public ResponseEntity<?> getDetails(@PathVariable Long id) {
|
public ResponseEntity<?> getDetails(@PathVariable Long id) {
|
||||||
try{
|
try{
|
||||||
PersonneCompletDTO personneCompletDTO = personneService.getPersonneComplete(id);
|
PersonneCompletDTO personneCompletDTO = personneService.getPersonneComplete(id);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.gmss.fiscad.entities.infocad.metier.Commentaire;
|
|||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService;
|
import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.CommentaireRequest;
|
import io.gmss.fiscad.paylaods.request.CommentaireRequest;
|
||||||
import io.gmss.fiscad.paylaods.request.SyncCommentaireRequest;
|
import io.gmss.fiscad.paylaods.request.SyncCommentaireRequest;
|
||||||
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;
|
||||||
@@ -39,9 +39,8 @@ public class CommentaireController {
|
|||||||
this.commentaireService = commentaireService;
|
this.commentaireService = commentaireService;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> createcommentaire(@RequestBody @Valid @Validated Commentaire commentaire) {
|
public ResponseEntity<?> createcommentaire(@RequestBody @Valid @Validated Commentaire commentaire) {
|
||||||
try {
|
try {
|
||||||
commentaire.setDateCommentaire(LocalDateTime.now());
|
commentaire.setDateCommentaire(LocalDateTime.now());
|
||||||
@@ -65,9 +64,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> updatecommentaire(@PathVariable Long id, @RequestBody Commentaire commentaire) {
|
public ResponseEntity<?> updatecommentaire(@PathVariable Long id, @RequestBody Commentaire commentaire) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -89,9 +87,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> deletecommentaire(@PathVariable Long id) {
|
public ResponseEntity<?> deletecommentaire(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
commentaireService.deleteCommentaire(id);
|
commentaireService.deleteCommentaire(id);
|
||||||
@@ -114,9 +111,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> getAllcommentaireList() {
|
public ResponseEntity<?> getAllcommentaireList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -138,9 +134,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> getcommentaireById(@PathVariable Long id) {
|
public ResponseEntity<?> getcommentaireById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -162,9 +157,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@GetMapping("/nup/{nup}")
|
@GetMapping("/nup/{nup}")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> getcommentaireByNup(@PathVariable String nup) {
|
public ResponseEntity<?> getcommentaireByNup(@PathVariable String nup) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -186,9 +180,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@PostMapping("/enquete")
|
@PostMapping("/enquete")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
|
||||||
public ResponseEntity<?> getcommentaireByEnquete(@RequestBody Commentaire commentaire) {
|
public ResponseEntity<?> getcommentaireByEnquete(@RequestBody Commentaire commentaire) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -210,9 +203,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@PostMapping("/enquete-and-state")
|
@PostMapping("/enquete-and-state")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
|
||||||
//@ApiOperation(value = "Cette ressource permet d'avoir la liste de tous les commentaires d'une enquête avec le statut (lu ou non lu). Les champs a renseigner pour le payload sont idEnquete et lu")
|
//@ApiOperation(value = "Cette ressource permet d'avoir la liste de tous les commentaires d'une enquête avec le statut (lu ou non lu). Les champs a renseigner pour le payload sont idEnquete et lu")
|
||||||
public ResponseEntity<?> getcommentaireByEnqueteAndStatut(@RequestBody Commentaire commentaire) {
|
public ResponseEntity<?> getcommentaireByEnqueteAndStatut(@RequestBody Commentaire commentaire) {
|
||||||
try {
|
try {
|
||||||
@@ -235,10 +227,9 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@PostMapping("/all-by-params")
|
@PostMapping("/all-by-params")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
//@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non lus provenant du Web. \n 2 - Liste des commentaires lus provenant du Web \n 3 - Liste des commentaires non lus provenant du mobile. \n 4 - Liste des commentaires lus provenant du mobile. \n A savoir : Les variables Origine et lu sont à varier pour avoir le résultat")
|
||||||
//@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non lus provenant du BatimentPaylaodWeb. \n 2 - Liste des commentaires lus provenant du BatimentPaylaodWeb \n 3 - Liste des commentaires non lus provenant du mobile. \n 4 - Liste des commentaires lus provenant du mobile. \n A savoir : Les variables Origine et lu sont à varier pour avoir le résultat")
|
|
||||||
public ResponseEntity<?> getcommentaireByParams(@RequestBody CommentaireRequest commentaireRequest) {
|
public ResponseEntity<?> getcommentaireByParams(@RequestBody CommentaireRequest commentaireRequest) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -262,7 +253,6 @@ public class CommentaireController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("synchronise/from-mobile")
|
@PostMapping("synchronise/from-mobile")
|
||||||
@PreAuthorize("hasAuthority('CREATE_COMMENTAIRE')")
|
|
||||||
//@ApiOperation(value = "Cette ressource permet de synchroniser tous les commentaires effectués sur le mobile vers le backend.")
|
//@ApiOperation(value = "Cette ressource permet de synchroniser tous les commentaires effectués sur le mobile vers le backend.")
|
||||||
public ResponseEntity<?> synchroniseCommentairesFromMobile(@RequestBody List<Commentaire> commentaires) {
|
public ResponseEntity<?> synchroniseCommentairesFromMobile(@RequestBody List<Commentaire> commentaires) {
|
||||||
try {
|
try {
|
||||||
@@ -287,8 +277,7 @@ public class CommentaireController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("synchronise/from-web")
|
@PostMapping("synchronise/from-web")
|
||||||
@PreAuthorize("hasAuthority('READ_COMMENTAIRE')")
|
//@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non synchronisés provenant du Web. \n 2 - Liste des commentaires synchronisés provenant du Web \n 3 - Liste des commentaires non synchronisés provenant du mobile. \n 4 - Liste des commentaires synchronisés provenant du mobile. \n A savoir : Les variables Origine et Synchronise sont à varier pour avoir le résultat")
|
||||||
//@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non synchronisés provenant du BatimentPaylaodWeb. \n 2 - Liste des commentaires synchronisés provenant du BatimentPaylaodWeb \n 3 - Liste des commentaires non synchronisés provenant du mobile. \n 4 - Liste des commentaires synchronisés provenant du mobile. \n A savoir : Les variables Origine et Synchronise sont à varier pour avoir le résultat")
|
|
||||||
public ResponseEntity<?> synchroniseCommentairesFromWeb(@RequestBody CommentaireRequest commentaireRequest) {
|
public ResponseEntity<?> synchroniseCommentairesFromWeb(@RequestBody CommentaireRequest commentaireRequest) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -310,9 +299,8 @@ public class CommentaireController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
@PostMapping("synchronise/notify-done-from-mobile")
|
@PostMapping("synchronise/notify-done-from-mobile")
|
||||||
@PreAuthorize("hasAuthority('CREATE_COMMENTAIRE')")
|
|
||||||
//@ApiOperation(value = "Cette ressource permet matérialiser coté backend les commentaires du WEB déjà synchronisé avec le MOBILE pour que les prochaines extractions ne prennent pas en compte cela. ")
|
//@ApiOperation(value = "Cette ressource permet matérialiser coté backend les commentaires du WEB déjà synchronisé avec le MOBILE pour que les prochaines extractions ne prennent pas en compte cela. ")
|
||||||
public ResponseEntity<?> notifyDoneSynchronizedFromMobile(@RequestBody List<SyncCommentaireRequest> syncCommentaireRequests) {
|
public ResponseEntity<?> notifyDoneSynchronizedFromMobile(@RequestBody List<SyncCommentaireRequest> syncCommentaireRequests) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,20 +1,11 @@
|
|||||||
package io.gmss.fiscad.controllers.infocad.metier;
|
package io.gmss.fiscad.controllers.infocad.metier;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
|
||||||
import io.gmss.fiscad.enums.StatutEnquete;
|
|
||||||
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;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
|
import io.gmss.fiscad.paylaods.request.EnquetePayLoad;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
|
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
|
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
import io.gmss.fiscad.paylaods.request.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;
|
||||||
@@ -37,7 +28,7 @@ import java.util.List;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Enquête")
|
@Tag(name = "Enquête")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public class EnqueteController {
|
public class EnqueteController {
|
||||||
|
|
||||||
private final EnqueteService enqueteService;
|
private final EnqueteService enqueteService;
|
||||||
@@ -50,58 +41,23 @@ public class EnqueteController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_ENQUETE')")
|
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated EnquetePayLoad enquetePayLoad) {
|
||||||
public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) {
|
// try{
|
||||||
try {
|
// enquete = enqueteService.createEnquete(enquete);
|
||||||
enquetePayLoadWeb = enqueteService.createEnquete(enquetePayLoadWeb);
|
// return new ResponseEntity<>(
|
||||||
return new ResponseEntity<>(
|
// new ApiResponse<>(true, structure, "Structure créé avec succès."),
|
||||||
new ApiResponse<>(true, enquetePayLoadWeb, "Enquete batiment créé avec succès."),
|
// HttpStatus.OK
|
||||||
HttpStatus.OK
|
// );
|
||||||
);
|
// }catch (Exception e){
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
// return new ResponseEntity<>(
|
||||||
logger.error(e.getLocalizedMessage());
|
// new ApiResponse<>(false, e.getMessage()),
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
// HttpStatus.OK
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
// );
|
||||||
FileStorageException e) {
|
// }
|
||||||
logger.error(e.getLocalizedMessage());
|
return null;
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
// logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETE')")
|
|
||||||
public ResponseEntity<?> updateEnquete(@PathVariable Long id, @RequestBody EnquetePayLoadWeb enquetePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteService.updateEnquete(id,enquetePayLoadWeb), "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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/validation")
|
@PutMapping("/validation")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETE')")
|
|
||||||
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -125,10 +81,8 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/rejet")
|
@PutMapping("/rejet")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETE')")
|
|
||||||
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
|
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
@@ -150,7 +104,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/validation-lot")
|
@PutMapping("/validation-lot")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETE')")
|
|
||||||
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -174,7 +127,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/rejet-lot")
|
@PutMapping("/rejet-lot")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETE')")
|
|
||||||
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -198,7 +150,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all/decoupage-admin-for-enquete")
|
@GetMapping("/all/decoupage-admin-for-enquete")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin() {
|
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -221,70 +172,8 @@ 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
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")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
|
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -309,7 +198,6 @@ public class EnqueteController {
|
|||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_ENQUETE')")
|
|
||||||
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
enqueteService.deleteEnquete(id);
|
enqueteService.deleteEnquete(id);
|
||||||
@@ -334,7 +222,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllStructureList() {
|
public ResponseEntity<?> getAllStructureList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -358,7 +245,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all/com-arrond-bloc")
|
@GetMapping("/all/com-arrond-bloc")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllByCommuneArrondBloc() {
|
public ResponseEntity<?> getAllByCommuneArrondBloc() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -382,7 +268,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/all/com-arrond-bloc/filtre")
|
@PostMapping("/all/com-arrond-bloc/filtre")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllByCommuneArrondBlocFiltre(@RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad) {
|
public ResponseEntity<?> getAllByCommuneArrondBlocFiltre(@RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -406,7 +291,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -431,7 +315,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/fiche/id/{id}")
|
@GetMapping("/fiche/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getFicheEnqueteById(@PathVariable Long id) {
|
public ResponseEntity<?> getFicheEnqueteById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -455,7 +338,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/fiche/nup-provisoir/{nupProvisoir}")
|
@GetMapping("/fiche/nup-provisoir/{nupProvisoir}")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getFicheEnqueteByNupProvisoir(@PathVariable String nupProvisoir) {
|
public ResponseEntity<?> getFicheEnqueteByNupProvisoir(@PathVariable String nupProvisoir) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -479,7 +361,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -504,67 +385,5 @@ public class EnqueteController {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged/en-cours/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteEncoursByQuartierPaged(@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, enqueteService.getEnqueteListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.EN_COURS, pageable), "Liste des enquetes en cours 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/cloture/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETE')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteClotureByQuartierPaged(@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, enqueteService.getEnqueteListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.CLOTURE, pageable), "Liste des enquetes en cours 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,461 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.infocad.metier;
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
|
|
||||||
import io.gmss.fiscad.interfaces.infocad.metier.ParcelleService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.FiltreParcelle;
|
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
|
||||||
import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnquetePayLoadWeb;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.ParcellePayLoadWeb;
|
|
||||||
import io.gmss.fiscad.security.CurrentUser;
|
|
||||||
import io.gmss.fiscad.security.UserPrincipal;
|
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/parcelle", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
//@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Parcelle")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
|
||||||
public class ParcelleController {
|
|
||||||
|
|
||||||
private final EnqueteService enqueteService;
|
|
||||||
private final ParcelleService parcelleService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ParcelleController.class);
|
|
||||||
|
|
||||||
public ParcelleController(EnqueteService enqueteService, ParcelleService parcelleService) {
|
|
||||||
this.enqueteService = enqueteService;
|
|
||||||
this.parcelleService = parcelleService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_PARCELLE')")
|
|
||||||
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
parcellePayLoadWeb = parcelleService.createParcelle(parcellePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcellePayLoadWeb, "parcelle créée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_PARCELLE')")
|
|
||||||
public ResponseEntity<?> updateEnquete(@PathVariable Long id, @RequestBody ParcellePayLoadWeb parcellePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.updateParcelle(id,parcellePayLoadWeb), "parcelle 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_PARCELLE')")
|
|
||||||
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
parcelleService.deleteParcelle(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "parcelle 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/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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
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), "parcelle 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("/all")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
public ResponseEntity<?> getAllParcelle(@CurrentUser UserPrincipal currentUser) {
|
|
||||||
try {
|
|
||||||
if(currentUser==null)
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
Long userId = currentUser.getUser().getId();
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleListToDto(userId), "Liste des enquetes chargée avec succès."),
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
public ResponseEntity<?> getAllParcellePaged(@CurrentUser UserPrincipal currentUser,@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
if(currentUser==null)
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
Long userId = currentUser.getUser().getId();
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleListPageableToDto(userId,pageable), "Liste des enquetes chargée avec succès."),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/all-paged/multi-criteres")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
public ResponseEntity<?> getAllParcelleFiltrePaged(@CurrentUser UserPrincipal currentUser, @RequestParam int pageNo, @RequestParam int pageSize, @RequestBody FiltreParcelle filtreParcelle) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
if(currentUser==null)
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
Long userId = currentUser.getUser().getId();
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleByMultiFiltre(userId,filtreParcelle,pageable), "Liste des enquetes chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLE')")
|
|
||||||
public ResponseEntity<?> getAllParcelleByRuePaged(@CurrentUser UserPrincipal currentUser,@PathVariable Long rueId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
if(currentUser==null)
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true,null, "Vous ne pouvez pas accéder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
Long userId = currentUser.getUser().getId();
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleListByRuePageableToDto(userId,rueId,pageable), "Liste des enquetes chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/syncrhonise-etat-batie-parcelle")
|
|
||||||
@PreAuthorize("hasAuthority('READ_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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -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;
|
||||||
@@ -31,7 +31,6 @@ public class ParcelleGeomController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/create-from-geojsonfile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/create-from-geojsonfile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
@PreAuthorize("hasAuthority('CREATE_PARCELLEGEOM')")
|
|
||||||
public ResponseEntity<?> createTpe(@RequestPart(required = true) MultipartFile file,@RequestParam String reference,@RequestParam String description) {
|
public ResponseEntity<?> createTpe(@RequestPart(required = true) MultipartFile file,@RequestParam String reference,@RequestParam String description) {
|
||||||
try{
|
try{
|
||||||
int n = parcelleGeomService.createParcelleFromGeoJsonFile(file, reference, description);
|
int n = parcelleGeomService.createParcelleFromGeoJsonFile(file, reference, description);
|
||||||
@@ -49,7 +48,6 @@ public class ParcelleGeomController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
public ResponseEntity<?> getAllTpeList() {
|
public ResponseEntity<?> getAllTpeList() {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(), "Liste des parcelle chargée avec succès."),
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomList(), "Liste des parcelle chargée avec succès."),
|
||||||
@@ -58,7 +56,6 @@ public class ParcelleGeomController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/by-quartier/{codeQuartier}")
|
@GetMapping("/by-quartier/{codeQuartier}")
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
public ResponseEntity<?> getParcellesGeomsByQuartier(@PathVariable String codeQuartier) {
|
public ResponseEntity<?> getParcellesGeomsByQuartier(@PathVariable String codeQuartier) {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListUnQuatier(codeQuartier), "Liste des parcelle chargée avec succès."),
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListUnQuatier(codeQuartier), "Liste des parcelle chargée avec succès."),
|
||||||
@@ -66,28 +63,7 @@ public class ParcelleGeomController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
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}")
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) {
|
public ResponseEntity<?> getParcellesGeomsByArrondissement(@PathVariable String codeArrondissement) {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListUnArrondissement(codeArrondissement), "Liste des parcelle chargée avec succès."),
|
new ApiResponse<>(true, parcelleGeomService.getParcelleGeomListUnArrondissement(codeArrondissement), "Liste des parcelle chargée avec succès."),
|
||||||
@@ -97,7 +73,6 @@ public class ParcelleGeomController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -107,7 +82,6 @@ public class ParcelleGeomController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_PARCELLEGEOM')")
|
|
||||||
public ResponseEntity<?> getParcelleGeomById(@PathVariable Long id) {
|
public ResponseEntity<?> getParcelleGeomById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -1,94 +1,29 @@
|
|||||||
package io.gmss.fiscad.controllers.infocad.metier;
|
package io.gmss.fiscad.controllers.infocad.metier;
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
|
||||||
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.PersonnePayLoadWeb;
|
|
||||||
import io.gmss.fiscad.security.CurrentUser;
|
|
||||||
import io.gmss.fiscad.security.UserPrincipal;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/personne", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/personne", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public class PersonneController {
|
public class PersonneController {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PersonneController.class);
|
|
||||||
|
|
||||||
private final PersonneService personneService;
|
private final PersonneService personneService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_PERSONNE')")
|
|
||||||
public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
personnePayLoadWeb = personneService.createPersonne(personnePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, personnePayLoadWeb, "Contribuable 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_PERSONNE')")
|
|
||||||
public ResponseEntity<?> updatePersonne(@PathVariable Long id, @RequestBody PersonnePayLoadWeb personnePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, personneService.updatePersonne(id,personnePayLoadWeb), "Personne 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@GetMapping("/get-details/{id}")
|
@GetMapping("/get-details/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_PERSONNE')")
|
|
||||||
public ResponseEntity<?> getDetails(@PathVariable Long id) {
|
public ResponseEntity<?> getDetails(@PathVariable Long id) {
|
||||||
try{
|
try{
|
||||||
PersonneCompletDTO personneCompletDTO = personneService.getPersonneComplete(id);
|
PersonneCompletDTO personneCompletDTO = personneService.getPersonneComplete(id);
|
||||||
@@ -103,90 +38,4 @@ public class PersonneController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PERSONNE')")
|
|
||||||
public ResponseEntity<?> getPersonneById(@PathVariable Long id) {
|
|
||||||
try{
|
|
||||||
Optional<PersonnePayLoadWeb> optionalPersonne= personneService.getPersonneById(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, optionalPersonne.orElse(null), "Personne retrouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}catch (Exception e){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, e.getMessage()),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/recherche")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PERSONNE')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PERSONNE')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PERSONNE')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,283 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.infocad.metier;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.infocad.metier.PieceService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.PiecePayLoadWeb;
|
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_PIECE')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PIECE')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Tpe")
|
@Tag(name = "Tpe")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public class TpeController {
|
public class TpeController {
|
||||||
|
|
||||||
private final TpeService tpeService;
|
private final TpeService tpeService;
|
||||||
@@ -37,7 +37,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TPE')")
|
|
||||||
public ResponseEntity<?> createTpe(@RequestBody @Valid @Validated Tpe tpe) {
|
public ResponseEntity<?> createTpe(@RequestBody @Valid @Validated Tpe tpe) {
|
||||||
try {
|
try {
|
||||||
tpe = tpeService.createTpe(tpe);
|
tpe = tpeService.createTpe(tpe);
|
||||||
@@ -61,7 +60,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@PostMapping("/re-create")
|
@PostMapping("/re-create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TPE')")
|
|
||||||
public ResponseEntity<?> reCreateTpe(@RequestBody @Valid @Validated Tpe tpe) {
|
public ResponseEntity<?> reCreateTpe(@RequestBody @Valid @Validated Tpe tpe) {
|
||||||
try{
|
try{
|
||||||
tpe = tpeService.majTpe(tpe.getId(),tpe);
|
tpe = tpeService.majTpe(tpe.getId(),tpe);
|
||||||
@@ -77,7 +75,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TPE')")
|
|
||||||
public ResponseEntity<?> majTpe(@PathVariable Long id, @RequestBody Tpe tpe) {
|
public ResponseEntity<?> majTpe(@PathVariable Long id, @RequestBody Tpe tpe) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -102,7 +99,6 @@ public class TpeController {
|
|||||||
|
|
||||||
|
|
||||||
@PutMapping("/restaure/{id}")
|
@PutMapping("/restaure/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TPE')")
|
|
||||||
public ResponseEntity<?> updateTpe(@PathVariable Long id, @RequestBody Tpe tpe) {
|
public ResponseEntity<?> updateTpe(@PathVariable Long id, @RequestBody Tpe tpe) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -126,7 +122,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TPE')")
|
|
||||||
public ResponseEntity<?> deleteTper(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTper(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
tpeService.deleteTpe(id);
|
tpeService.deleteTpe(id);
|
||||||
@@ -151,7 +146,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TPE')")
|
|
||||||
public ResponseEntity<?> getAllTpeList() {
|
public ResponseEntity<?> getAllTpeList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -175,7 +169,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-by-model/{model}")
|
@GetMapping("/all-by-model/{model}")
|
||||||
@PreAuthorize("hasAuthority('READ_TPE')")
|
|
||||||
public ResponseEntity<?> getAllTpeListByModel(@PathVariable String model) {
|
public ResponseEntity<?> getAllTpeListByModel(@PathVariable String model) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -199,7 +192,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-by-userId/{userId}")
|
@GetMapping("/all-by-userId/{userId}")
|
||||||
@PreAuthorize("hasAuthority('READ_TPE')")
|
|
||||||
public ResponseEntity<?> getAllTpeListByUserId(@PathVariable Long userId) {
|
public ResponseEntity<?> getAllTpeListByUserId(@PathVariable Long userId) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -224,7 +216,6 @@ public class TpeController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TPE')")
|
|
||||||
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -249,7 +240,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TPE')")
|
|
||||||
public ResponseEntity<?> getTpeById(@PathVariable Long id) {
|
public ResponseEntity<?> getTpeById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -273,7 +263,6 @@ public class TpeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/identifier/{identifier}")
|
@GetMapping("/identifier/{identifier}")
|
||||||
@PreAuthorize("hasAuthority('READ_TPE')")
|
|
||||||
public ResponseEntity<?> getTpeByIdentifier(@PathVariable String identifier) {
|
public ResponseEntity<?> getTpeByIdentifier(@PathVariable String identifier) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
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.persistence.repositories.infocad.metier.UploadRepository;
|
import io.gmss.fiscad.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;
|
||||||
@@ -49,13 +45,12 @@ 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
|
||||||
@@ -76,7 +71,6 @@ public class UploadController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_UPLOAD')")
|
|
||||||
public ResponseEntity<?> all() {
|
public ResponseEntity<?> all() {
|
||||||
try {
|
try {
|
||||||
if (uploadRepository.findAll().isEmpty()) {
|
if (uploadRepository.findAll().isEmpty()) {
|
||||||
@@ -96,12 +90,11 @@ public class UploadController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_UPLOAD')")
|
|
||||||
public ResponseEntity<?> one(@PathVariable Long id) {
|
public ResponseEntity<?> one(@PathVariable Long id) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (uploadRepository.findById(id).isPresent()) {
|
if (uploadRepository.findById(id).isPresent()) {
|
||||||
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findById(id), "File with id {" + id + "} is found."), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK);
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
@@ -123,7 +116,6 @@ public class UploadController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/downloadfile/{fileName:.+}")
|
@GetMapping("/downloadfile/{fileName:.+}")
|
||||||
@PreAuthorize("hasAuthority('READ_UPLOAD')")
|
|
||||||
public ResponseEntity<Resource> downloadFile(@PathVariable String fileName, HttpServletRequest request) {
|
public ResponseEntity<Resource> downloadFile(@PathVariable String fileName, HttpServletRequest request) {
|
||||||
// Load file as Resource
|
// Load file as Resource
|
||||||
Resource resource = fileStorageService.loadFileAsResource(fileName);
|
Resource resource = fileStorageService.loadFileAsResource(fileName);
|
||||||
@@ -147,42 +139,31 @@ public class UploadController {
|
|||||||
.body(resource);
|
.body(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(
|
@PostMapping("/save")
|
||||||
value = "/save",
|
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file, @RequestParam String reference, @RequestParam String description /*, @RequestParam Long idTypeUpload*/) {
|
||||||
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
|
|
||||||
)
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_UPLOAD')")
|
|
||||||
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 {
|
||||||
return ResponseEntity.ok(
|
Upload upload = new Upload();
|
||||||
new ApiResponse(true,
|
String fileName = fileStorageService.storeFile(file);
|
||||||
uploadService.createUpload(file, pieceId),
|
upload.setFileName(fileName);
|
||||||
"File has been created successfully.")
|
upload.setMimeType(file.getContentType());
|
||||||
);
|
upload.setSize(file.getSize());
|
||||||
|
upload.setOriginalFileName(file.getOriginalFilename());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK);
|
||||||
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getLocalizedMessage());
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
.body(new ApiResponse(false, null, e.getMessage()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/delete/id/{id}")
|
@DeleteMapping("/delete/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_UPLOAD')")
|
|
||||||
public ResponseEntity<?> delete(@PathVariable Long id) {
|
public ResponseEntity<?> delete(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
if (id != null || uploadRepository.findById(id).isPresent()) {
|
if (id != null || uploadRepository.findById(id).isPresent()) {
|
||||||
@@ -209,7 +190,6 @@ public class UploadController {
|
|||||||
consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
|
consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE
|
produces = MediaType.APPLICATION_JSON_VALUE
|
||||||
)
|
)
|
||||||
@PreAuthorize("hasAuthority('CREATE_UPLOAD')")
|
|
||||||
public ResponseEntity<?> submit(@RequestPart("file") MultipartFile file) throws Exception {
|
public ResponseEntity<?> submit(@RequestPart("file") MultipartFile file) throws Exception {
|
||||||
if (file == null || file.isEmpty())
|
if (file == null || file.isEmpty())
|
||||||
return new ResponseEntity<>(new ApiResponse(false,null, "Le fichier envoyé est introuvable ou inexistant."), HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(new ApiResponse(false,null, "Le fichier envoyé est introuvable ou inexistant."), HttpStatus.BAD_REQUEST);
|
||||||
@@ -249,21 +229,4 @@ public class UploadController {
|
|||||||
.orElse(ResponseEntity.notFound().build());
|
.orElse(ResponseEntity.notFound().build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/by-piece/{pieceId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_UPLOAD')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -39,7 +39,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_BLOC')")
|
|
||||||
public ResponseEntity<?> createBloc(@RequestBody @Valid @Validated Bloc bloc, @CurrentUser UserPrincipal userPrincipal) {
|
public ResponseEntity<?> createBloc(@RequestBody @Valid @Validated Bloc bloc, @CurrentUser UserPrincipal userPrincipal) {
|
||||||
try {
|
try {
|
||||||
bloc = blocService.createBloc(bloc);
|
bloc = blocService.createBloc(bloc);
|
||||||
@@ -64,7 +63,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_BLOC')")
|
|
||||||
public ResponseEntity<?> updateBloc(@PathVariable Long id, @RequestBody Bloc bloc) {
|
public ResponseEntity<?> updateBloc(@PathVariable Long id, @RequestBody Bloc bloc) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -88,7 +86,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_BLOC')")
|
|
||||||
public ResponseEntity<?> deleteBlocr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteBlocr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
blocService.deleteBloc(id);
|
blocService.deleteBloc(id);
|
||||||
@@ -113,7 +110,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_BLOC')")
|
|
||||||
public ResponseEntity<?> getAllBlocList() {
|
public ResponseEntity<?> getAllBlocList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -138,7 +134,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list-by-arrondissement")
|
@GetMapping("/list-by-arrondissement")
|
||||||
@PreAuthorize("hasAuthority('READ_BLOC')")
|
|
||||||
public ResponseEntity<?> getAllBlocListByArrondissement(@RequestParam Long idArrondissement) {
|
public ResponseEntity<?> getAllBlocListByArrondissement(@RequestParam Long idArrondissement) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -164,7 +159,6 @@ public class BlocController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/list-by-structure")
|
@GetMapping("/list-by-structure")
|
||||||
@PreAuthorize("hasAuthority('READ_BLOC')")
|
|
||||||
public ResponseEntity<?> getAllBlocListByStructure(@RequestParam Long idStructure) {
|
public ResponseEntity<?> getAllBlocListByStructure(@RequestParam Long idStructure) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -189,7 +183,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list-by-secteur")
|
@GetMapping("/list-by-secteur")
|
||||||
@PreAuthorize("hasAuthority('READ_BLOC')")
|
|
||||||
@Tag(name = "Liste blocs", description = "Liste des blocs d'un secteur")
|
@Tag(name = "Liste blocs", description = "Liste des blocs d'un secteur")
|
||||||
public ResponseEntity<?> getAllBlocListBySecteur(@RequestParam Long idSecteur) {
|
public ResponseEntity<?> getAllBlocListBySecteur(@RequestParam Long idSecteur) {
|
||||||
try {
|
try {
|
||||||
@@ -214,7 +207,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_BLOC')")
|
|
||||||
public ResponseEntity<?> getAllBlocPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllBlocPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -241,7 +233,6 @@ public class BlocController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_BLOC')")
|
|
||||||
public ResponseEntity<?> getBlocById(@PathVariable Long id) {
|
public ResponseEntity<?> getBlocById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -38,7 +38,6 @@ public class ModeAcquisitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_MODEACQUISITION')")
|
|
||||||
public ResponseEntity<?> createModeAcquisition(@RequestBody @Valid @Validated ModeAcquisition modeAcquisition) {
|
public ResponseEntity<?> createModeAcquisition(@RequestBody @Valid @Validated ModeAcquisition modeAcquisition) {
|
||||||
try {
|
try {
|
||||||
modeAcquisition = modeAcquisitionService.createModeAcquisition(modeAcquisition);
|
modeAcquisition = modeAcquisitionService.createModeAcquisition(modeAcquisition);
|
||||||
@@ -63,7 +62,6 @@ public class ModeAcquisitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_MODEACQUISITION')")
|
|
||||||
public ResponseEntity<?> updateModeAcquisition(@PathVariable Long id, @RequestBody ModeAcquisition modeAcquisition) {
|
public ResponseEntity<?> updateModeAcquisition(@PathVariable Long id, @RequestBody ModeAcquisition modeAcquisition) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -87,7 +85,6 @@ public class ModeAcquisitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_MODEACQUISITION')")
|
|
||||||
public ResponseEntity<?> deleteModeAcquisitionr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteModeAcquisitionr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
modeAcquisitionService.deleteModeAcquisition(id);
|
modeAcquisitionService.deleteModeAcquisition(id);
|
||||||
@@ -112,7 +109,6 @@ public class ModeAcquisitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_MODEACQUISITION')")
|
|
||||||
public ResponseEntity<?> getAllModeAcquisitionList() {
|
public ResponseEntity<?> getAllModeAcquisitionList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -136,7 +132,6 @@ public class ModeAcquisitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_MODEACQUISITION')")
|
|
||||||
public ResponseEntity<?> getAllModeAcquisitionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllModeAcquisitionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -161,7 +156,6 @@ public class ModeAcquisitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_MODEACQUISITION')")
|
|
||||||
public ResponseEntity<?> getModeAcquisitionById(@PathVariable Long id) {
|
public ResponseEntity<?> getModeAcquisitionById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class NatureDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_NATUREDOMAINE')")
|
|
||||||
public ResponseEntity<?> createNatureDomaine(@RequestBody @Valid @Validated NatureDomaine natureDomaine) {
|
public ResponseEntity<?> createNatureDomaine(@RequestBody @Valid @Validated NatureDomaine natureDomaine) {
|
||||||
try {
|
try {
|
||||||
natureDomaine = natureDomaineService.createNatureDomaine(natureDomaine);
|
natureDomaine = natureDomaineService.createNatureDomaine(natureDomaine);
|
||||||
@@ -62,7 +61,6 @@ public class NatureDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_NATUREDOMAINE')")
|
|
||||||
public ResponseEntity<?> updateNatureDomaine(@PathVariable Long id, @RequestBody NatureDomaine natureDomaine) {
|
public ResponseEntity<?> updateNatureDomaine(@PathVariable Long id, @RequestBody NatureDomaine natureDomaine) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class NatureDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_NATUREDOMAINE')")
|
|
||||||
public ResponseEntity<?> deleteNatureDomainer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteNatureDomainer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
natureDomaineService.deleteNatureDomaine(id);
|
natureDomaineService.deleteNatureDomaine(id);
|
||||||
@@ -111,7 +108,6 @@ public class NatureDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_NATUREDOMAINE')")
|
|
||||||
public ResponseEntity<?> getAllNatureDomaineList() {
|
public ResponseEntity<?> getAllNatureDomaineList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class NatureDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_NATUREDOMAINE')")
|
|
||||||
public ResponseEntity<?> getAllNatureDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllNatureDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class NatureDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_NATUREDOMAINE')")
|
|
||||||
public ResponseEntity<?> getNatureDomaineById(@PathVariable Long id) {
|
public ResponseEntity<?> getNatureDomaineById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class PositionRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_POSITIONREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> createPositionRepresentation(@RequestBody @Valid @Validated PositionRepresentation positionRepresentation) {
|
public ResponseEntity<?> createPositionRepresentation(@RequestBody @Valid @Validated PositionRepresentation positionRepresentation) {
|
||||||
try {
|
try {
|
||||||
positionRepresentation = positionRepresentationService.createPositionRepresentation(positionRepresentation);
|
positionRepresentation = positionRepresentationService.createPositionRepresentation(positionRepresentation);
|
||||||
@@ -62,7 +61,6 @@ public class PositionRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_POSITIONREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> updatePositionRepresentation(@PathVariable Long id, @RequestBody PositionRepresentation positionRepresentation) {
|
public ResponseEntity<?> updatePositionRepresentation(@PathVariable Long id, @RequestBody PositionRepresentation positionRepresentation) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class PositionRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_POSITIONREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> deletePositionRepresentation(@PathVariable Long id) {
|
public ResponseEntity<?> deletePositionRepresentation(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
positionRepresentationService.deletePositionRepresentation(id);
|
positionRepresentationService.deletePositionRepresentation(id);
|
||||||
@@ -111,7 +108,6 @@ public class PositionRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_POSITIONREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> getAllPositionRepresentationList() {
|
public ResponseEntity<?> getAllPositionRepresentationList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class PositionRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_POSITIONREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> getAllPositionRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllPositionRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -162,7 +157,6 @@ public class PositionRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_POSITIONREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> getPositionRepresentationById(@PathVariable Long id) {
|
public ResponseEntity<?> getPositionRepresentationById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -38,7 +38,6 @@ public class ProfessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_PROFESSION')")
|
|
||||||
public ResponseEntity<?> createProfession(@RequestBody @Valid @Validated Profession profession) {
|
public ResponseEntity<?> createProfession(@RequestBody @Valid @Validated Profession profession) {
|
||||||
try {
|
try {
|
||||||
profession = professionService.createProfession(profession);
|
profession = professionService.createProfession(profession);
|
||||||
@@ -63,7 +62,6 @@ public class ProfessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_PROFESSION')")
|
|
||||||
public ResponseEntity<?> updateProfession(@PathVariable Long id, @RequestBody Profession profession) {
|
public ResponseEntity<?> updateProfession(@PathVariable Long id, @RequestBody Profession profession) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -87,7 +85,6 @@ public class ProfessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_PROFESSION')")
|
|
||||||
public ResponseEntity<?> deleteProfessionr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteProfessionr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
professionService.deleteProfession(id);
|
professionService.deleteProfession(id);
|
||||||
@@ -112,7 +109,6 @@ public class ProfessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_PROFESSION')")
|
|
||||||
public ResponseEntity<?> getAllProfessionList() {
|
public ResponseEntity<?> getAllProfessionList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -137,7 +133,6 @@ public class ProfessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_PROFESSION')")
|
|
||||||
public ResponseEntity<?> getAllProfessionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllProfessionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -163,7 +158,6 @@ public class ProfessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_PROFESSION')")
|
|
||||||
public ResponseEntity<?> getProfessionById(@PathVariable Long id) {
|
public ResponseEntity<?> getProfessionById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class SituationGeographiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_SITUATIONGEOGRAPHIQUE')")
|
|
||||||
public ResponseEntity<?> createSituationGeographique(@RequestBody @Valid @Validated SituationGeographique situationGeographique) {
|
public ResponseEntity<?> createSituationGeographique(@RequestBody @Valid @Validated SituationGeographique situationGeographique) {
|
||||||
try {
|
try {
|
||||||
situationGeographique = situationGeographiqueService.createSituationGeographique(situationGeographique);
|
situationGeographique = situationGeographiqueService.createSituationGeographique(situationGeographique);
|
||||||
@@ -62,7 +61,6 @@ public class SituationGeographiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_SITUATIONGEOGRAPHIQUE')")
|
|
||||||
public ResponseEntity<?> updateSituationGeographique(@PathVariable Long id, @RequestBody SituationGeographique situationGeographique) {
|
public ResponseEntity<?> updateSituationGeographique(@PathVariable Long id, @RequestBody SituationGeographique situationGeographique) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class SituationGeographiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_SITUATIONGEOGRAPHIQUE')")
|
|
||||||
public ResponseEntity<?> deleteSituationGeographiquer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSituationGeographiquer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
situationGeographiqueService.deleteSituationGeographique(id);
|
situationGeographiqueService.deleteSituationGeographique(id);
|
||||||
@@ -111,7 +108,6 @@ public class SituationGeographiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_SITUATIONGEOGRAPHIQUE')")
|
|
||||||
public ResponseEntity<?> getAllSituationGeographiqueList() {
|
public ResponseEntity<?> getAllSituationGeographiqueList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class SituationGeographiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_SITUATIONGEOGRAPHIQUE')")
|
|
||||||
public ResponseEntity<?> getAllSituationGeographiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSituationGeographiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class SituationGeographiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_SITUATIONGEOGRAPHIQUE')")
|
|
||||||
public ResponseEntity<?> getSituationGeographiqueById(@PathVariable Long id) {
|
public ResponseEntity<?> getSituationGeographiqueById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class SituationMatrimonialeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_SITUATIONMATRIMONIALE')")
|
|
||||||
public ResponseEntity<?> createSituationMatrimoniale(@RequestBody @Valid @Validated SituationMatrimoniale situationMatrimoniale) {
|
public ResponseEntity<?> createSituationMatrimoniale(@RequestBody @Valid @Validated SituationMatrimoniale situationMatrimoniale) {
|
||||||
try {
|
try {
|
||||||
situationMatrimoniale = situationMatrimonialeService.createSituationMatrimoniale(situationMatrimoniale);
|
situationMatrimoniale = situationMatrimonialeService.createSituationMatrimoniale(situationMatrimoniale);
|
||||||
@@ -62,7 +61,6 @@ public class SituationMatrimonialeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_SITUATIONMATRIMONIALE')")
|
|
||||||
public ResponseEntity<?> updateSituationMatrimoniale(@PathVariable Long id, @RequestBody SituationMatrimoniale situationMatrimoniale) {
|
public ResponseEntity<?> updateSituationMatrimoniale(@PathVariable Long id, @RequestBody SituationMatrimoniale situationMatrimoniale) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class SituationMatrimonialeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_SITUATIONMATRIMONIALE')")
|
|
||||||
public ResponseEntity<?> deleteSituationMatrimonialer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSituationMatrimonialer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
situationMatrimonialeService.deleteSituationMatrimoniale(id);
|
situationMatrimonialeService.deleteSituationMatrimoniale(id);
|
||||||
@@ -111,7 +108,6 @@ public class SituationMatrimonialeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_SITUATIONMATRIMONIALE')")
|
|
||||||
public ResponseEntity<?> getAllSituationMatrimonialeList() {
|
public ResponseEntity<?> getAllSituationMatrimonialeList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class SituationMatrimonialeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_SITUATIONMATRIMONIALE')")
|
|
||||||
public ResponseEntity<?> getAllSituationMatrimonialePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSituationMatrimonialePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class SituationMatrimonialeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_SITUATIONMATRIMONIALE')")
|
|
||||||
public ResponseEntity<?> getSituationMatrimonialeById(@PathVariable Long id) {
|
public ResponseEntity<?> getSituationMatrimonialeById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class SourceDroitController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_SOURCEDROIT')")
|
|
||||||
public ResponseEntity<?> createSourceDroit(@RequestBody @Valid @Validated SourceDroit sourceDroit) {
|
public ResponseEntity<?> createSourceDroit(@RequestBody @Valid @Validated SourceDroit sourceDroit) {
|
||||||
try {
|
try {
|
||||||
sourceDroit = sourceDroitService.createSourceDroit(sourceDroit);
|
sourceDroit = sourceDroitService.createSourceDroit(sourceDroit);
|
||||||
@@ -62,7 +61,6 @@ public class SourceDroitController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_SOURCEDROIT')")
|
|
||||||
public ResponseEntity<?> updateSourceDroit(@PathVariable Long id, @RequestBody SourceDroit sourceDroit) {
|
public ResponseEntity<?> updateSourceDroit(@PathVariable Long id, @RequestBody SourceDroit sourceDroit) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class SourceDroitController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_SOURCEDROIT')")
|
|
||||||
public ResponseEntity<?> deleteSourceDroitr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSourceDroitr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
sourceDroitService.deleteSourceDroit(id);
|
sourceDroitService.deleteSourceDroit(id);
|
||||||
@@ -111,7 +108,6 @@ public class SourceDroitController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_SOURCEDROIT')")
|
|
||||||
public ResponseEntity<?> getAllSourceDroitList() {
|
public ResponseEntity<?> getAllSourceDroitList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class SourceDroitController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_SOURCEDROIT')")
|
|
||||||
public ResponseEntity<?> getAllSourceDroitPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSourceDroitPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class SourceDroitController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_SOURCEDROIT')")
|
|
||||||
public ResponseEntity<?> getSourceDroitById(@PathVariable Long id) {
|
public ResponseEntity<?> getSourceDroitById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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;
|
||||||
@@ -28,7 +27,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;
|
||||||
@@ -41,12 +40,11 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_STRUCTURE')")
|
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) {
|
||||||
public ResponseEntity<?> createStructure(@RequestBody StructurePaylaodWeb structurePaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
structurePaylaodWeb = structureService.createStructure(structurePaylaodWeb);
|
structure = structureService.createStructure(structure);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, structurePaylaodWeb, "Structure créé avec succès."),
|
new ApiResponse<>(true, structure, "Structure créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -66,11 +64,10 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_STRUCTURE')")
|
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, structurePaylaodWeb), "Structure mise à jour avec succès."),
|
new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -90,7 +87,6 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_STRUCTURE')")
|
|
||||||
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
structureService.deleteStructure(id);
|
structureService.deleteStructure(id);
|
||||||
@@ -115,7 +111,6 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_STRUCTURE')")
|
|
||||||
public ResponseEntity<?> getAllStructureList() {
|
public ResponseEntity<?> getAllStructureList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -139,8 +134,37 @@ 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")
|
||||||
@PreAuthorize("hasAuthority('READ_STRUCTURE')")
|
|
||||||
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -165,57 +189,7 @@ public class StructureController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/by-commune/{communeId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_STRUCTURE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_STRUCTURE')")
|
|
||||||
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}")
|
||||||
@PreAuthorize("hasAuthority('READ_STRUCTURE')")
|
|
||||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class TypeContestationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TYPECONTESTATION')")
|
|
||||||
public ResponseEntity<?> createTypeContestation(@RequestBody @Valid @Validated TypeContestation typeContestation) {
|
public ResponseEntity<?> createTypeContestation(@RequestBody @Valid @Validated TypeContestation typeContestation) {
|
||||||
try {
|
try {
|
||||||
typeContestation = typeContestationService.createTypeContestation(typeContestation);
|
typeContestation = typeContestationService.createTypeContestation(typeContestation);
|
||||||
@@ -62,7 +61,6 @@ public class TypeContestationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TYPECONTESTATION')")
|
|
||||||
public ResponseEntity<?> updateTypeContestation(@PathVariable Long id, @RequestBody TypeContestation typeContestation) {
|
public ResponseEntity<?> updateTypeContestation(@PathVariable Long id, @RequestBody TypeContestation typeContestation) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class TypeContestationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TYPECONTESTATION')")
|
|
||||||
public ResponseEntity<?> deleteTypeContestationr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTypeContestationr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
typeContestationService.deleteTypeContestation(id);
|
typeContestationService.deleteTypeContestation(id);
|
||||||
@@ -111,7 +108,6 @@ public class TypeContestationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPECONTESTATION')")
|
|
||||||
public ResponseEntity<?> getAllTypeContestationList() {
|
public ResponseEntity<?> getAllTypeContestationList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class TypeContestationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPECONTESTATION')")
|
|
||||||
public ResponseEntity<?> getAllTypeContestationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTypeContestationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class TypeContestationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPECONTESTATION')")
|
|
||||||
public ResponseEntity<?> getTypeContestationById(@PathVariable Long id) {
|
public ResponseEntity<?> getTypeContestationById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class TypeDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TYPEDOMAINE')")
|
|
||||||
public ResponseEntity<?> createTypeDomaine(@RequestBody @Valid @Validated TypeDomaine typeDomaine) {
|
public ResponseEntity<?> createTypeDomaine(@RequestBody @Valid @Validated TypeDomaine typeDomaine) {
|
||||||
try {
|
try {
|
||||||
typeDomaine = typeDomaineService.createTypeDomaine(typeDomaine);
|
typeDomaine = typeDomaineService.createTypeDomaine(typeDomaine);
|
||||||
@@ -62,7 +61,6 @@ public class TypeDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TYPEDOMAINE')")
|
|
||||||
public ResponseEntity<?> updateTypeDomaine(@PathVariable Long id, @RequestBody TypeDomaine typeDomaine) {
|
public ResponseEntity<?> updateTypeDomaine(@PathVariable Long id, @RequestBody TypeDomaine typeDomaine) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class TypeDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TYPEDOMAINE')")
|
|
||||||
public ResponseEntity<?> deleteTypeDomainer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTypeDomainer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
typeDomaineService.deleteTypeDomaine(id);
|
typeDomaineService.deleteTypeDomaine(id);
|
||||||
@@ -111,7 +108,6 @@ public class TypeDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEDOMAINE')")
|
|
||||||
public ResponseEntity<?> getAllTypeDomaineList() {
|
public ResponseEntity<?> getAllTypeDomaineList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class TypeDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEDOMAINE')")
|
|
||||||
public ResponseEntity<?> getAllTypeDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTypeDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class TypeDomaineController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEDOMAINE')")
|
|
||||||
public ResponseEntity<?> getTypeDomaineById(@PathVariable Long id) {
|
public ResponseEntity<?> getTypeDomaineById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class TypePersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TYPEPERSONNE')")
|
|
||||||
public ResponseEntity<?> createTypePersonne(@RequestBody @Valid @Validated TypePersonne typePersonne) {
|
public ResponseEntity<?> createTypePersonne(@RequestBody @Valid @Validated TypePersonne typePersonne) {
|
||||||
try {
|
try {
|
||||||
typePersonne = typePersonneService.createTypePersonne(typePersonne);
|
typePersonne = typePersonneService.createTypePersonne(typePersonne);
|
||||||
@@ -62,7 +61,6 @@ public class TypePersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TYPEPERSONNE')")
|
|
||||||
public ResponseEntity<?> updateTypePersonne(@PathVariable Long id, @RequestBody TypePersonne typePersonne) {
|
public ResponseEntity<?> updateTypePersonne(@PathVariable Long id, @RequestBody TypePersonne typePersonne) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class TypePersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TYPEPERSONNE')")
|
|
||||||
public ResponseEntity<?> deleteTypePersonner(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTypePersonner(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
typePersonneService.deleteTypePersonne(id);
|
typePersonneService.deleteTypePersonne(id);
|
||||||
@@ -111,7 +108,6 @@ public class TypePersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEPERSONNE')")
|
|
||||||
public ResponseEntity<?> getAllTypePersonneList() {
|
public ResponseEntity<?> getAllTypePersonneList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class TypePersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEPERSONNE')")
|
|
||||||
public ResponseEntity<?> getAllTypePersonnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTypePersonnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class TypePersonneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEPERSONNE')")
|
|
||||||
public ResponseEntity<?> getTypePersonneById(@PathVariable Long id) {
|
public ResponseEntity<?> getTypePersonneById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class TypePieceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TYPEPIECE')")
|
|
||||||
public ResponseEntity<?> createTypePiece(@RequestBody @Valid @Validated TypePiece typePiece) {
|
public ResponseEntity<?> createTypePiece(@RequestBody @Valid @Validated TypePiece typePiece) {
|
||||||
try {
|
try {
|
||||||
typePiece = typePieceService.createTypePiece(typePiece);
|
typePiece = typePieceService.createTypePiece(typePiece);
|
||||||
@@ -62,7 +61,6 @@ public class TypePieceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TYPEPIECE')")
|
|
||||||
public ResponseEntity<?> updateTypePiece(@PathVariable Long id, @RequestBody TypePiece typePiece) {
|
public ResponseEntity<?> updateTypePiece(@PathVariable Long id, @RequestBody TypePiece typePiece) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class TypePieceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TYPEPIECE')")
|
|
||||||
public ResponseEntity<?> deleteTypePiecer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTypePiecer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
typePieceService.deleteTypePiece(id);
|
typePieceService.deleteTypePiece(id);
|
||||||
@@ -111,7 +108,6 @@ public class TypePieceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEPIECE')")
|
|
||||||
public ResponseEntity<?> getAllTypePieceList() {
|
public ResponseEntity<?> getAllTypePieceList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class TypePieceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEPIECE')")
|
|
||||||
public ResponseEntity<?> getAllTypePiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTypePiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class TypePieceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEPIECE')")
|
|
||||||
public ResponseEntity<?> getTypePieceById(@PathVariable Long id) {
|
public ResponseEntity<?> getTypePieceById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,7 +37,6 @@ public class TypeRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TYPEREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> createTypeRepresentation(@RequestBody @Valid @Validated TypeRepresentation typeRepresentation) {
|
public ResponseEntity<?> createTypeRepresentation(@RequestBody @Valid @Validated TypeRepresentation typeRepresentation) {
|
||||||
try {
|
try {
|
||||||
typeRepresentation = typeRepresentationService.createTypeRepresentation(typeRepresentation);
|
typeRepresentation = typeRepresentationService.createTypeRepresentation(typeRepresentation);
|
||||||
@@ -62,7 +61,6 @@ public class TypeRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TYPEREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> updateTypeRepresentation(@PathVariable Long id, @RequestBody TypeRepresentation typeRepresentation) {
|
public ResponseEntity<?> updateTypeRepresentation(@PathVariable Long id, @RequestBody TypeRepresentation typeRepresentation) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -86,7 +84,6 @@ public class TypeRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TYPEREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> deleteTypeRepresentationr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTypeRepresentationr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
typeRepresentationService.deleteTypeRepresentation(id);
|
typeRepresentationService.deleteTypeRepresentation(id);
|
||||||
@@ -111,7 +108,6 @@ public class TypeRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> getAllTypeRepresentationList() {
|
public ResponseEntity<?> getAllTypeRepresentationList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +131,6 @@ public class TypeRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> getAllTypeRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTypeRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +155,6 @@ public class TypeRepresentationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPEREPRESENTATION')")
|
|
||||||
public ResponseEntity<?> getTypeRepresentationById(@PathVariable Long id) {
|
public ResponseEntity<?> getTypeRepresentationById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -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.persistence.repositories.infocad.parametre.BlocRepository;
|
import io.gmss.fiscad.repositories.infocad.parametre.BlocRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
import io.gmss.fiscad.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;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
|||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
|
|
||||||
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;
|
||||||
@@ -16,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -38,12 +36,11 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_BATIMENT')")
|
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated Batiment batiment) {
|
||||||
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
batimentPaylaodWeb = batimentService.createBatiment(batimentPaylaodWeb);
|
batiment = batimentService.createBatiment(batiment);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, batimentPaylaodWeb, "Batiment créé avec succès."),
|
new ApiResponse<>(true, batiment, "Batiment créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -63,11 +60,10 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_BATIMENT')")
|
public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody Batiment batiment) {
|
||||||
public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody BatimentPaylaodWeb batimentPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, batimentService.updateBatiment(id,batimentPaylaodWeb), "Batiment mise à jour avec succès."),
|
new ApiResponse<>(true, batimentService.updateBatiment(id, batiment), "Batiment mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -87,7 +83,6 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_BATIMENT')")
|
|
||||||
public ResponseEntity<?> deleteBatiment(@PathVariable Long id) {
|
public ResponseEntity<?> deleteBatiment(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
batimentService.deleteBatiment(id);
|
batimentService.deleteBatiment(id);
|
||||||
@@ -112,7 +107,6 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllBatimentList() {
|
public ResponseEntity<?> getAllBatimentList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -136,7 +130,6 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,57 +153,7 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all/by-parcelle-id/{parcelleId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
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}")
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
|
public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -232,54 +175,4 @@ public class BatimentController {
|
|||||||
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-paged/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllBatimentByQuartierPaged(@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, batimentService.getBatimentListByquartierPageable(quartierId,pageable), "Liste des 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/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllBatimentByQuartier(@PathVariable Long quartierId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, batimentService.getBatimentListByquartier(quartierId), "Liste des 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
|||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
|
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
|
||||||
import io.gmss.fiscad.enums.RoleActeur;
|
|
||||||
import io.gmss.fiscad.enums.UserRole;
|
|
||||||
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;
|
||||||
@@ -18,14 +15,13 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/caracteristique-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/caracteristique-caracteristiqueBatiment", 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 = "*")
|
||||||
@@ -39,28 +35,34 @@ public class CaracteristiqueBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_CARACTERISTIQUEBATIMENT')")
|
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, caracteristiqueBatimentPayloadWeb, "Caracteristique du batiment créé avec succès."),
|
new ApiResponse<>(true, caracteristiqueBatiment, "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}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_CARACTERISTIQUEBATIMENT')")
|
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, caracteristiqueBatimentPayloadWeb), "Caracteristique du batiment mise à jour avec succès."),
|
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -80,7 +82,6 @@ public class CaracteristiqueBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_CARACTERISTIQUEBATIMENT')")
|
|
||||||
public ResponseEntity<?> deleteCaracteristiqueBatiment(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCaracteristiqueBatiment(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
caracteristiqueBatimentService.deleteCaracteristiqueBatiment(id);
|
caracteristiqueBatimentService.deleteCaracteristiqueBatiment(id);
|
||||||
@@ -105,7 +106,6 @@ public class CaracteristiqueBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueBatimentList() {
|
public ResponseEntity<?> getAllCaracteristiqueBatimentList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -129,7 +129,6 @@ public class CaracteristiqueBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCaracteristiqueBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -154,11 +153,10 @@ public class CaracteristiqueBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
|
public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentToDto(id), "Caracteristique du batiment trouvée avec succès."),
|
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -176,53 +174,4 @@ public class CaracteristiqueBatimentController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEBATIMENT')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getCaracteristiqueBatimentByEnqueteBatimentIdPaged(@PathVariable Long enqueteBatimentId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentListByEnqueteBatimentPageable(enqueteBatimentId,pageable), "Caracteristique du batiment trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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;
|
||||||
@@ -16,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -37,12 +35,11 @@ public class CaracteristiqueParcelleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_CARACTERISTIQUEPARCELLE')")
|
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) {
|
||||||
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcellePayloadWeb caracteristiqueParcellePayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
caracteristiqueParcellePayloadWeb = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcellePayloadWeb);
|
caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, caracteristiqueParcellePayloadWeb, "Caracteristique parcelle créé avec succès."),
|
new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -62,11 +59,10 @@ public class CaracteristiqueParcelleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_CARACTERISTIQUEPARCELLE')")
|
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, caracteristiqueParcellePayloadWeb), "Caracteristique parcelle mise à jour avec succès."),
|
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -86,7 +82,6 @@ public class CaracteristiqueParcelleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_CARACTERISTIQUEPARCELLE')")
|
|
||||||
public ResponseEntity<?> deleteCaracteristiqueParcelle(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCaracteristiqueParcelle(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
caracteristiqueParcelleService.deleteCaracteristiqueParcelle(id);
|
caracteristiqueParcelleService.deleteCaracteristiqueParcelle(id);
|
||||||
@@ -111,7 +106,6 @@ public class CaracteristiqueParcelleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEPARCELLE')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueParcelleList() {
|
public ResponseEntity<?> getAllCaracteristiqueParcelleList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +129,6 @@ public class CaracteristiqueParcelleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEPARCELLE')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +153,6 @@ public class CaracteristiqueParcelleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEPARCELLE')")
|
|
||||||
public ResponseEntity<?> getCaracteristiqueParcelleById(@PathVariable Long id) {
|
public ResponseEntity<?> getCaracteristiqueParcelleById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -182,54 +174,4 @@ public class CaracteristiqueParcelleController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEPARCELLE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEPARCELLE')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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;
|
||||||
@@ -16,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -37,12 +35,11 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_CARACTERISTIQUEUNITELOGEMENT')")
|
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
|
||||||
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogementPayloadWeb caracteristiqueUniteLogementPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
caracteristiqueUniteLogementPayloadWeb = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogementPayloadWeb);
|
caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, caracteristiqueUniteLogementPayloadWeb, "Caracteristique Unite Logement créé avec succès."),
|
new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -62,11 +59,10 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_CARACTERISTIQUEUNITELOGEMENT')")
|
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, caracteristiqueUniteLogementPayloadWeb), "Caracteristique Unite Logement mise à jour avec succès."),
|
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -86,7 +82,6 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_CARACTERISTIQUEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> deleteCaracteristiqueUniteLogement(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCaracteristiqueUniteLogement(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
caracteristiqueUniteLogementService.deleteCaracteristiqueUniteLogement(id);
|
caracteristiqueUniteLogementService.deleteCaracteristiqueUniteLogement(id);
|
||||||
@@ -111,7 +106,6 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueUniteLogementList() {
|
public ResponseEntity<?> getAllCaracteristiqueUniteLogementList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +129,6 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCaracteristiqueUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +153,6 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getCaracteristiqueUniteLogementById(@PathVariable Long id) {
|
public ResponseEntity<?> getCaracteristiqueUniteLogementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -182,53 +174,4 @@ public class CaracteristiqueUniteLogementController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEUNITELOGEMENT')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUEUNITELOGEMENT')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,325 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.rfu.metier;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.implementations.infocad.metier.PersonneServiceImpl;
|
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.CommuneCentreAssignationService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.CommuneCentreAssignationPaylaodWeb;
|
|
||||||
import io.gmss.fiscad.security.CurrentUser;
|
|
||||||
import io.gmss.fiscad.security.UserPrincipal;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import 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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RequestMapping(value = "api/commune-centre-assignation", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "CommuneCentreAssignation")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class CommuneCentreAssignationController {
|
|
||||||
|
|
||||||
private final CommuneCentreAssignationService communeCentreAssignationService;
|
|
||||||
private final PersonneServiceImpl personneService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CommuneCentreAssignationController.class);
|
|
||||||
|
|
||||||
// public CommuneCentreAssignationController(CommuneCentreAssignationService communeCentreAssignationService) {
|
|
||||||
// this.communeCentreAssignationService = communeCentreAssignationService;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@PostMapping("/assigne-centre")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> AssigneCommuneCentre(@CurrentUser UserPrincipal userPrincipal, @RequestBody CommuneCentreAssignationPaylaodWeb communeCentreAssignationPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
if(userPrincipal==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "vous ne pouvez pas faire cette action."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
User user = userPrincipal.getUser();
|
|
||||||
communeCentreAssignationPaylaodWeb = communeCentreAssignationService.createCommuneCentreAssignation(user,communeCentreAssignationPaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationPaylaodWeb, "CommuneCentreAssignation 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/detache-centre")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> detacheCommuneCentre(@CurrentUser UserPrincipal userPrincipal, @RequestBody CommuneCentreAssignationPaylaodWeb communeCentreAssignationPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
if(userPrincipal==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "vous ne pouvez pas faire cette action."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
User user = userPrincipal.getUser();
|
|
||||||
communeCentreAssignationPaylaodWeb = communeCentreAssignationService.detacherCommuneCentreAssignation(user,communeCentreAssignationPaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationPaylaodWeb, "CommuneCentreAssignation 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> updateCommuneCentreAssignation(@PathVariable Long id, @RequestBody CommuneCentreAssignationPaylaodWeb communeCentreAssignationPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationService.updateCommuneCentreAssignation(id,communeCentreAssignationPaylaodWeb), "CommuneCentreAssignation 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> deleteCommuneCentreAssignation(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
communeCentreAssignationService.deleteCommuneCentreAssignation(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "CommuneCentreAssignation 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-paged")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> getAllCommuneCentreAssignationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationService.getCommuneCentreAssignationList(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-paged/by-commune-id/{communeId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> getAllCommuneCentreAssignationByCommuneList(@PathVariable Long communeId,@RequestParam int pageNo, @RequestParam int pageSize ) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationService.getCommuneCentreAssignationListByCommunePageable(communeId,pageable), "Liste des assignation de centre 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> getCommuneCentreAssignationById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationService.getCommuneCentreAssignationById(id), "CommuneCentreAssignation 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 = "Liste des contribuables ayant un centre d'assignation")
|
|
||||||
@GetMapping("/all-paged/by-structure-id/{structureId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> getAllCommuneCentreAssignationByStrucutrePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationService.getCommuneCentreAssignationListByCentrePageable(structureId, pageable), "Liste des communeCentreAssignations 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 = "Liste des contribuables sans centre d'assignation")
|
|
||||||
@GetMapping("/all-paged/sans-centre-assignation")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> getAllPersonneSansCentreAssignationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, personneService.getPersonneListNonAssigneePage(pageable), "Liste des contribuables sans centre d'assignation 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 = "Vérifier l'assignation d'un contribuable",description = "permet de vérifier si un contribuable a déjà un centre d'assignation dans la commune de l'utilisateur connecté")
|
|
||||||
@GetMapping("/contribuable/{personneId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_COMMUNECENTREASSIGNATION')")
|
|
||||||
public ResponseEntity<?> getAssignationPersonne(@CurrentUser UserPrincipal currentUser, @PathVariable Long personneId) {
|
|
||||||
try {
|
|
||||||
if(currentUser==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "vous ne pouvez pas faire cette action."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
User user = currentUser.getUser();
|
|
||||||
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, communeCentreAssignationService.getCommuneCentreAssignationByPersonneIdCommune(user,personneId).orElse(null), "Assignation 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.rfu.metier;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.DeclarationNcService;
|
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.DeclarationNcPayloadWeb;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
|
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_DECLARATIONNC')")
|
|
||||||
public ResponseEntity<?> createDeclarationNc(@RequestBody 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_DECLARATIONNC')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_DECLARATIONNC')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DECLARATIONNC')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DECLARATIONNC')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DECLARATIONNC')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DECLARATIONNC')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DECLARATIONNC')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,10 +7,7 @@ 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.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
|
import io.gmss.fiscad.repositories.rfu.metier.ImpositionsTfuRepository;
|
||||||
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;
|
||||||
@@ -23,7 +20,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -47,7 +43,6 @@ public class DonneesImpositionTfuController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> createDonneesImpositionTfu(@RequestBody @Valid @Validated DonneesImpositionTfu donneesImpositionTfu) {
|
public ResponseEntity<?> createDonneesImpositionTfu(@RequestBody @Valid @Validated DonneesImpositionTfu donneesImpositionTfu) {
|
||||||
try {
|
try {
|
||||||
donneesImpositionTfu = donneesImpositionTfuService.createDonneesImpositionTfu(donneesImpositionTfu);
|
donneesImpositionTfu = donneesImpositionTfuService.createDonneesImpositionTfu(donneesImpositionTfu);
|
||||||
@@ -72,7 +67,6 @@ public class DonneesImpositionTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> updateDonneesImpositionTfu(@PathVariable Long id, @RequestBody DonneesImpositionTfu donneesImpositionTfu) {
|
public ResponseEntity<?> updateDonneesImpositionTfu(@PathVariable Long id, @RequestBody DonneesImpositionTfu donneesImpositionTfu) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -96,7 +90,6 @@ public class DonneesImpositionTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> deleteDonneesImpositionTfu(@PathVariable Long id) {
|
public ResponseEntity<?> deleteDonneesImpositionTfu(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
donneesImpositionTfuService.deleteDonneesImpositionTfu(id);
|
donneesImpositionTfuService.deleteDonneesImpositionTfu(id);
|
||||||
@@ -120,61 +113,11 @@ public class DonneesImpositionTfuController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping("/all")
|
@GetMapping("/all")
|
||||||
// public ResponseEntity<?> getAllDonneesImpositionTfuList() {
|
public ResponseEntity<?> getAllDonneesImpositionTfuList() {
|
||||||
// try {
|
|
||||||
// return new ResponseEntity<>(
|
|
||||||
// new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(), "Liste des impositions 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<?> getAllDonneesImpositionTfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
// try {
|
|
||||||
// Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
// return new ResponseEntity<>(
|
|
||||||
// new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(pageable), "Liste des impositions 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/{impositionId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdPaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdPageable(impositionId, pageable), "Liste des impositions chargée avec succès."),
|
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(), "Liste des caractéristiques chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -193,64 +136,12 @@ public class DonneesImpositionTfuController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-page/by-imposition-id/non-batie/{impositionId}")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
public ResponseEntity<?> getAllDonneesImpositionTfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
public ResponseEntity<?> getAllDonneesImpositionTfuByImpositionIdNonBatiePaged(@PathVariable Long impositionId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByImpositionTfuIdNonBatiePageable(impositionId, pageable), "Liste des impositions chargée avec succès."),
|
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesImpositionTfuList(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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
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 impositions 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
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 impositions chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -270,7 +161,6 @@ public class DonneesImpositionTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getDonneesImpositionTfuById(@PathVariable Long id) {
|
public ResponseEntity<?> getDonneesImpositionTfuById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -292,201 +182,31 @@ public class DonneesImpositionTfuController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
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")
|
@Operation(summary = "Générer les données fiscales TFU")
|
||||||
@PostMapping("/generer-batie")
|
@PostMapping("/generer")
|
||||||
@PreAuthorize("hasAnyAuthority('CREATE_DONNEESIMPOSITIONTFU', 'UPDATE_DONNEESIMPOSITIONTFU')")
|
public ResponseEntity<?> genererDonneesFiscale(@RequestBody ImpositionsTfu impositionsTfu) {
|
||||||
public ResponseEntity<?> genererDonneesFiscaleBatie(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
|
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfu.getId());
|
||||||
|
|
||||||
if(optionalImpositionsTfu.isEmpty()){
|
if(optionalImpositionsTfu.isEmpty()){
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
|
new ApiResponse<>(false, null, "L'imposition tfu n'est pas trouvée."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.TFU_FNB_GENERE)){
|
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.CREE)){
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
|
new ApiResponse<>(false, null, "le statut actuel ne permet pas cette opération."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(userPrincipal==null){
|
optionalImpositionsTfu.get().setStatusAvis(StatusAvis.GENERE);
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition des fonciers batis Générées avec succès."),
|
new ApiResponse<>(true, donneesImpositionTfuService.genererDonneesFiscales(optionalImpositionsTfu.get()), "DonneesImpositionTfu trouvée avec succès."),
|
||||||
HttpStatus.OK
|
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 pour une seule parcelle",
|
|
||||||
description = "Génère les impositions TFU pour une parcelle bâtie donnée"
|
|
||||||
)
|
|
||||||
@PostMapping("/generer-batie/{parcelleId}")
|
|
||||||
@PreAuthorize("hasAnyAuthority('CREATE_DONNEESIMPOSITIONTFU', 'UPDATE_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> genererDonneesFiscaleBatieUneParcelle(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb,@PathVariable Long parcelleId) {
|
|
||||||
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.TFU_FNB_GENERE)){
|
|
||||||
// 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.genererDonneesFiscalesParcelleBatieUneParcelle(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId(),parcelleId);
|
|
||||||
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAnyAuthority('CREATE_DONNEESIMPOSITIONTFU', 'UPDATE_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> genererDonneesImpositionNonBaties(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
Optional<ImpositionsTfu> optionalImpositionsTfu =impositionsTfuRepository.findById(impositionsTfuPaylaodWeb.getId());
|
|
||||||
|
|
||||||
if(optionalImpositionsTfu.isEmpty()){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "L'instance d'imposition n'est pas trouvée."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!optionalImpositionsTfu.get().getStatusAvis().equals(StatusAvis.GENERATION_AUTORISE)){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "l'état actuel : "+optionalImpositionsTfu.get().getStatusAvis()+" ne permet pas cette opération."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(userPrincipal==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "Vous n'êtes pas autorisé à accéder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
impositionsTfuPaylaodWeb=donneesImpositionTfuService.genererDonneesFiscalesParcelleNonBatie(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId());
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true,impositionsTfuPaylaodWeb, "Données d'imposition pour les fonciers non batis Générées avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} 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 pour une seule parcelle",
|
|
||||||
description = "Génère les impositions TFU pour une parcelle non bâtie donnée"
|
|
||||||
)
|
|
||||||
@PostMapping("/generer-non-batie/{parcelleId}")
|
|
||||||
@PreAuthorize("hasAnyAuthority('CREATE_DONNEESIMPOSITIONTFU', 'UPDATE_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> genererDonneesImpositionNonBatiesUneParcelle(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, @PathVariable Long parcelleId) {
|
|
||||||
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.genererDonneesFiscalesParcelleNonBatieUneParcelle(impositionsTfuPaylaodWeb,userPrincipal.getUser().getId(),parcelleId);
|
|
||||||
|
|
||||||
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);
|
||||||
@@ -505,7 +225,6 @@ public class DonneesImpositionTfuController {
|
|||||||
|
|
||||||
@Operation(summary = "Récuperer les avis d'id d'une imposition")
|
@Operation(summary = "Récuperer les avis d'id d'une imposition")
|
||||||
@GetMapping("/by-impositions-id/{impositionsId}")
|
@GetMapping("/by-impositions-id/{impositionsId}")
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getDonneesFiscale(@PathVariable Long impositionsId) {
|
public ResponseEntity<?> getDonneesFiscale(@PathVariable Long impositionsId) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -532,7 +251,6 @@ public class DonneesImpositionTfuController {
|
|||||||
|
|
||||||
@Operation(summary = "Récuperer les avis d'id d'une imposition et l'id d'un arrondissement")
|
@Operation(summary = "Récuperer les avis d'id d'une imposition et l'id d'un arrondissement")
|
||||||
@GetMapping("/by-impositions-id/by-arrondissement/{impositionsId}/{arrondissementId}")
|
@GetMapping("/by-impositions-id/by-arrondissement/{impositionsId}/{arrondissementId}")
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getDonneesFiscaleParImpositionArrondissement(@PathVariable Long impositionsId,@PathVariable Long arrondissementId) {
|
public ResponseEntity<?> getDonneesFiscaleParImpositionArrondissement(@PathVariable Long impositionsId,@PathVariable Long arrondissementId) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -555,82 +273,4 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-page/by-exercice-id/by-structure-id/{exerciceId}/{structureId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getAllDonneesImpositionTfuByExerciceIdAndStructureIdPaged(@PathVariable Long exerciceId, @PathVariable Long structureId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
System.out.println("NOUS SOMMES ICI");
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByExerciceAndStructureIdPageable(exerciceId,structureId, pageable), "Liste des impositions 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-exercice-id/by-structure-id/by-quartier-id/{exerciceId}/{structureId}/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getAllDonneesImpositionTfuByExerciceIdAndStructureId(@PathVariable Long exerciceId, @PathVariable Long structureId, @PathVariable Long quartierId) {
|
|
||||||
try {
|
|
||||||
System.out.println("NOUS SOMMES ICI");
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByExerciceAndStructureId(exerciceId,structureId,quartierId), "Liste des imposition 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-personne-id/{personneId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_DONNEESIMPOSITIONTFU')")
|
|
||||||
public ResponseEntity<?> getAllDonneesImpositionTfuByPersonneId(@PathVariable Long personneId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, donneesImpositionTfuService.getDonneesFiscalesByPersonneId(personneId), "Liste des impositions 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,186 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.rfu.metier;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteActivite;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteActiviteService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteActivitePayLoadWeb ;
|
|
||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/enquete-activite", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "EnqueteActivite")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class EnqueteActiviteController {
|
|
||||||
|
|
||||||
private final EnqueteActiviteService enqueteActiviteService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(EnqueteActiviteController.class);
|
|
||||||
|
|
||||||
public EnqueteActiviteController(EnqueteActiviteService enqueteActiviteService) {
|
|
||||||
this.enqueteActiviteService = enqueteActiviteService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_ENQUETEACTIVITE')")
|
|
||||||
public ResponseEntity<?> createEnqueteActivite(@RequestBody @Valid @Validated EnqueteActivitePayLoadWeb enqueteActivitePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
EnqueteActivite enqueteActivite = enqueteActiviteService.createEnqueteActivite(enqueteActivitePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteActivite, "Enquete Activite 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEACTIVITE')")
|
|
||||||
public ResponseEntity<?> updateEnqueteActivite(@PathVariable Long id, @RequestBody EnqueteActivitePayLoadWeb enqueteActivitePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteActiviteService.updateEnqueteActivite(id,enqueteActivitePayLoadWeb), "EnqueteActivite 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_ENQUETEACTIVITE')")
|
|
||||||
public ResponseEntity<?> deleteEnqueteActivite(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
enqueteActiviteService.deleteEnqueteActivite(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Enquete Activite 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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEACTIVITE')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteActiviteList() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteActiviteService.getEnqueteActiviteList(), "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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEACTIVITE')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteActivitePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteActiviteService.getEnqueteActiviteList(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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEACTIVITE')")
|
|
||||||
public ResponseEntity<?> getEnqueteActiviteById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteActiviteService.getEnqueteActiviteById(id), "EnqueteActivite 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,9 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
|||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
||||||
import io.gmss.fiscad.enums.StatutEnquete;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
|
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteBatimentPayloadWeb;
|
|
||||||
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;
|
||||||
@@ -20,13 +15,10 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/enquete-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/enquete-batiment", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@@ -43,12 +35,11 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_ENQUETEBATIMENT')")
|
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatiment enqueteBatiment) {
|
||||||
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
enqueteBatimentPayloadWeb = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb);
|
enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatiment);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteBatimentPayloadWeb, "Enquete batiment créé avec succès."),
|
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -59,7 +50,6 @@ public class EnqueteBatimentController {
|
|||||||
logger.error(e.getLocalizedMessage());
|
logger.error(e.getLocalizedMessage());
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
e.printStackTrace();
|
|
||||||
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) {
|
||||||
@@ -69,11 +59,10 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEBATIMENT')")
|
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatiment enqueteBatiment) {
|
||||||
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteBatimentService.updateEnqueteBatiment(id, enqueteBatimentPayloadWeb), "Enquete batiment mise à jour avec succès."),
|
new ApiResponse<>(true, enqueteBatimentService.updateEnqueteBatiment(id, enqueteBatiment), "Enquete batiment mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -93,7 +82,6 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) {
|
public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
enqueteBatimentService.deleteEnqueteBatiment(id);
|
enqueteBatimentService.deleteEnqueteBatiment(id);
|
||||||
@@ -118,7 +106,6 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteBatimentList() {
|
public ResponseEntity<?> getAllEnqueteBatimentList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -142,7 +129,6 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -168,7 +154,6 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) {
|
public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -190,214 +175,4 @@ 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged/en-cours/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteBatimentEnCoursByQuartierPaged(@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, enqueteBatimentService.getEnqueteBatimentListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.EN_COURS, pageable), "Liste des enquetes en cours 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/cloture/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteBatimentClotureByQuartierPaged(@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, enqueteBatimentService.getEnqueteBatimentListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.CLOTURE, pageable), "Liste des enquetes en cours chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/validation")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteBatimentService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/rejet")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteBatimentService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/validation-lot")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteBatimentService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/rejet-lot")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEBATIMENT')")
|
|
||||||
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteBatimentService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectué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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,9 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
|||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
||||||
import io.gmss.fiscad.enums.StatutEnquete;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
|
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteTraitementPayLoad;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.EnqueteUniteLogementPayloadWeb;
|
|
||||||
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;
|
||||||
@@ -20,13 +15,10 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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.List;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "api/enquete-unite-logement", produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "api/enquete-unite-logement", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@@ -43,12 +35,11 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_ENQUETEUNITELOGEMENT')")
|
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogement enqueteUniteLogement) {
|
||||||
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
enqueteUniteLogementPayloadWeb = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb);
|
enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogement);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteUniteLogementPayloadWeb, "Enquete unite logement créé avec succès."),
|
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -68,11 +59,10 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEUNITELOGEMENT')")
|
public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogement enqueteUniteLogement) {
|
||||||
public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.updateEnqueteUniteLogement(id, enqueteUniteLogementPayloadWeb), "Enquete unite logement mise à jour avec succès."),
|
new ApiResponse<>(true, enqueteUniteLogementService.updateEnqueteUniteLogement(id, enqueteUniteLogement), "Enquete unite logement mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -92,7 +82,6 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> deleteEnqueteUniteLogement(@PathVariable Long id) {
|
public ResponseEntity<?> deleteEnqueteUniteLogement(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
enqueteUniteLogementService.deleteEnqueteUniteLogement(id);
|
enqueteUniteLogementService.deleteEnqueteUniteLogement(id);
|
||||||
@@ -117,7 +106,6 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteUniteLogementList() {
|
public ResponseEntity<?> getAllEnqueteUniteLogementList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -141,7 +129,6 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllEnqueteUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -167,7 +154,6 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getEnqueteUniteLogementById(@PathVariable Long id) {
|
public ResponseEntity<?> getEnqueteUniteLogementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -189,215 +175,4 @@ 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged/en-cours/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteUniteLogementEncoursByQuartierPaged(@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, enqueteUniteLogementService.getEnqueteUniteLogementListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.EN_COURS, pageable), "Liste des enquetes en cours 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/cloture/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllEnqueteUniteLogementClotureByQuartierPaged(@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, enqueteUniteLogementService.getEnqueteUniteLogementListByQuartierByStatutPageableToDto(userId,quartierId, StatutEnquete.CLOTURE, pageable), "Liste des enquetes en cours chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/validation")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/rejet")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/validation-lot")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/rejet-lot")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ENQUETEUNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectué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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,12 @@ 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;
|
||||||
@@ -24,14 +15,12 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
|
|
||||||
|
|
||||||
@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")
|
||||||
@@ -39,33 +28,41 @@ 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")
|
||||||
@PreAuthorize("hasAuthority('CREATE_IMPOSITIONSTFU')")
|
public ResponseEntity<?> createImpositionsTfu(@RequestBody @Valid @Validated ImpositionsTfu impositionsTfu) {
|
||||||
public ResponseEntity<?> createImpositionsTfu(@CurrentUser UserPrincipal currentUser,@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
if(currentUser==null){
|
impositionsTfu = impositionsTfuService.createImpositionsTfu(impositionsTfu);
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
User user=currentUser.getUser();
|
|
||||||
|
|
||||||
if(user.getStructure().getId()!=impositionsTfuPaylaodWeb.getStructureId()){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(false, null, "Vous n'etes pas autorisé à accéder à cette ressource."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impositionsTfuPaylaodWeb = impositionsTfuService.createImpositionsTfu(impositionsTfuPaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, impositionsTfuPaylaodWeb, "Unite de logement créé avec succès."),
|
new ApiResponse<>(true, impositionsTfu, "Unite de logement créé avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
|
FileStorageException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) {
|
||||||
|
try {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, impositionsTfuService.updateImpositionsTfu(id, impositionsTfu), "Unite de logement mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -85,28 +82,11 @@ public class ImpositionsTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/cloturer-enquete")
|
@PutMapping("/valider/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_IMPOSITIONSTFU')")
|
public ResponseEntity<?> validerImpositionsTfu(@RequestBody ImpositionsTfu impositionsTfu) {
|
||||||
public ResponseEntity<?> cloturer(@CurrentUser UserPrincipal userPrincipal, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb ) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(userPrincipal==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, null, "Accès non autorisé"),
|
|
||||||
HttpStatus.NOT_ACCEPTABLE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
User user= userPrincipal.getUser();
|
|
||||||
if(user.getStructure().getId()!=impositionsTfuPaylaodWeb.getStructureId()){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true,null, "Vous n'êtes pas autorisé à cloturer les enquetes du : "+user.getStructure().getNom()),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, impositionsTfuService.cloturerImpositionsTfu(impositionsTfuPaylaodWeb), "enquete cloturées avec succès."),
|
new ApiResponse<>(true, impositionsTfuService.validerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -125,64 +105,11 @@ public class ImpositionsTfuController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PutMapping("/update/{id}")
|
@PutMapping("/annuler/{id}")
|
||||||
// public ResponseEntity<?> updateImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
|
public ResponseEntity<?> annulerImpositionsTfu(@PathVariable Long id, @RequestBody ImpositionsTfu impositionsTfu) {
|
||||||
// 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")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_IMPOSITIONSTFU')")
|
|
||||||
public ResponseEntity<?> autoriserImpositionsTfu(@RequestBody ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, impositionsTfuService.autoriserGenerationImpositionsTfu(impositionsTfuPaylaodWeb), "Unite de logement mise à jour avec succès."),
|
new ApiResponse<>(true, impositionsTfuService.annulerImpositionsTfu(impositionsTfu), "Unite de logement mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_IMPOSITIONSTFU')")
|
|
||||||
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) {
|
||||||
@@ -202,7 +129,6 @@ public class ImpositionsTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_IMPOSITIONSTFU')")
|
|
||||||
public ResponseEntity<?> deleteImpositionsTfu(@PathVariable Long id) {
|
public ResponseEntity<?> deleteImpositionsTfu(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
impositionsTfuService.deleteImpositionsTfu(id);
|
impositionsTfuService.deleteImpositionsTfu(id);
|
||||||
@@ -226,20 +152,11 @@ public class ImpositionsTfuController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all/by-user")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_IMPOSITIONSTFU')")
|
public ResponseEntity<?> getAllImpositionsTfuList() {
|
||||||
public ResponseEntity<?> getAllImpositionsTfuList(@CurrentUser UserPrincipal userPrincipal) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(userPrincipal==null){
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, null, "Vous n'êtes pas autorisé à acceder à cette ressource"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
}
|
|
||||||
User user= userPrincipal.getUser();
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuByUserIdIds(user.getId()), "Liste des Enquetes des unites Logements chargée avec succès."),
|
new ApiResponse<>(true, impositionsTfuService.getImpositionsTfuList(), "Liste des Enquetes des unites Logements chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -259,7 +176,6 @@ public class ImpositionsTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_IMPOSITIONSTFU')")
|
|
||||||
public ResponseEntity<?> getAllImpositionsTfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllImpositionsTfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -285,7 +201,6 @@ public class ImpositionsTfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_IMPOSITIONSTFU')")
|
|
||||||
public ResponseEntity<?> getImpositionsTfuById(@PathVariable Long id) {
|
public ResponseEntity<?> getImpositionsTfuById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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;
|
||||||
@@ -16,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -37,12 +35,11 @@ public class UniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_UNITELOGEMENT')")
|
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) {
|
||||||
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogementPaylaodWeb enqueteUniteLogementPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
enqueteUniteLogementPaylaodWeb = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogementPaylaodWeb);
|
enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteUniteLogementPaylaodWeb, "Unite de logement créé avec succès."),
|
new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -62,11 +59,10 @@ public class UniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_UNITELOGEMENT')")
|
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, enqueteUniteLogementPaylaodWeb), "Unite de logement mise à jour avec succès."),
|
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -86,7 +82,6 @@ public class UniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_UNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> deleteUniteLogement(@PathVariable Long id) {
|
public ResponseEntity<?> deleteUniteLogement(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
enqueteUniteLogementService.deleteUniteLogement(id);
|
enqueteUniteLogementService.deleteUniteLogement(id);
|
||||||
@@ -111,7 +106,6 @@ public class UniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllUniteLogementList() {
|
public ResponseEntity<?> getAllUniteLogementList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -135,7 +129,6 @@ public class UniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,58 +153,7 @@ public class UniteLogementController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all/by-batiment-id/{batimentId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
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}")
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
|
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -233,80 +175,4 @@ public class UniteLogementController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllUniteLogementByQuartierPaged(@PathVariable Long quartierId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByQuartierPageable(quartierId,pageable), "Liste 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("/all/by-quartier-id/{quartierId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_UNITELOGEMENT')")
|
|
||||||
public ResponseEntity<?> getAllUniteLogementByQuartier(@PathVariable Long quartierId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementListByQuartier(quartierId), "Liste 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ 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.BaremRfuBatiService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.BaremRfuService;
|
||||||
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;
|
||||||
@@ -15,7 +14,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -26,21 +24,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 BaremRfuBatiService baremRfuBatiService;
|
private final BaremRfuService baremRfuService;
|
||||||
private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class);
|
private static final Logger logger = LoggerFactory.getLogger(BaremRfuController.class);
|
||||||
|
|
||||||
public BaremRfuController(BaremRfuBatiService baremRfuBatiService) {
|
public BaremRfuController(BaremRfuService baremRfuService) {
|
||||||
this.baremRfuBatiService = baremRfuBatiService;
|
this.baremRfuService = baremRfuService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_BAREMRFUBATI')")
|
public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBati baremRfuBati) {
|
||||||
public ResponseEntity<?> createBaremRfu(@RequestBody @Valid @Validated BaremRfuBatiPayloadWeb baremRfuBatiPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
baremRfuBatiPayloadWeb = baremRfuBatiService.createBaremRfu(baremRfuBatiPayloadWeb);
|
baremRfuBati = baremRfuService.createBaremRfu(baremRfuBati);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, baremRfuBatiPayloadWeb, "BaremRfuBati créé avec succès."),
|
new ApiResponse<>(true, baremRfuBati, "BaremRfuBati créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -60,11 +57,10 @@ public class BaremRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_BAREMRFUBATI')")
|
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, baremRfuBatiService.updateBaremRfu(id, baremRfuBatiPayloadWeb), "BaremRfuBati mis à jour avec succès."),
|
new ApiResponse<>(true, baremRfuService.updateBaremRfu(id, baremRfuBati), "BaremRfuBati mis à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -84,10 +80,9 @@ public class BaremRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_BAREMRFUBATI')")
|
|
||||||
public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) {
|
public ResponseEntity<?> deleteBaremRfur(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
baremRfuBatiService.deleteBaremRfu(id);
|
baremRfuService.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
|
||||||
@@ -109,11 +104,10 @@ public class BaremRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUBATI')")
|
|
||||||
public ResponseEntity<?> getAllBaremRfuList() {
|
public ResponseEntity<?> getAllBaremRfuList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."),
|
new ApiResponse<>(true, baremRfuService.getBaremRfuList(), "Liste des baremRfus chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -133,13 +127,12 @@ public class BaremRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUBATI')")
|
|
||||||
public ResponseEntity<?> getAllBaremRfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllBaremRfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."),
|
new ApiResponse<>(true, baremRfuService.getBaremRfuList(pageable), "Liste des baremRfus chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -159,11 +152,10 @@ public class BaremRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUBATI')")
|
|
||||||
public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) {
|
public ResponseEntity<?> getBaremRfuById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, baremRfuBatiService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."),
|
new ApiResponse<>(true, baremRfuService.getBaremRfuById(id), "BaremRfuBati trouvée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -182,71 +174,13 @@ public class BaremRfuController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/by-categorie-batiment-id/{idCategorieBatiment}")
|
@GetMapping("/categorie-batiment/{idCategorieBatiment}")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUBATI')")
|
|
||||||
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, baremRfuBatiService.getBaremRfuByCategorieBatiment(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
|
new ApiResponse<>(true, baremRfuService.getBaremRfuByType(idCategorieBatiment), "Liste des baremRfu par categorie de batiments chargée avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUBATI')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUBATI')")
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ 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;
|
||||||
@@ -15,7 +14,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -36,12 +34,11 @@ public class BaremRfuNonBatiController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_BAREMRFUNONBATI')")
|
public ResponseEntity<?> createBaremRfuNonBati(@RequestBody @Valid @Validated BaremRfuNonBati baremRfuNonBati) {
|
||||||
public ResponseEntity<?> createBaremRfuNonBati(@RequestBody BaremRfuNonBatiPayloadWeb baremRfuNonBatiPayloadWeb) {
|
|
||||||
try {
|
try {
|
||||||
baremRfuNonBatiPayloadWeb = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBatiPayloadWeb);
|
baremRfuNonBati = baremRfuNonBatiService.createBaremRfuNonBati(baremRfuNonBati);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, baremRfuNonBatiPayloadWeb, "BaremRfuNonBati créé avec succès."),
|
new ApiResponse<>(true, baremRfuNonBati, "BaremRfuNonBati créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -61,11 +58,10 @@ public class BaremRfuNonBatiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_BAREMRFUNONBATI')")
|
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, baremRfuNonBatiPayloadWeb), "BaremRfuNonBati mis à jour avec succès."),
|
new ApiResponse<>(true, baremRfuNonBatiService.updateBaremRfuNonBati(id, baremRfuNonBati), "BaremRfuNonBati mis à jour avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -85,7 +81,6 @@ public class BaremRfuNonBatiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_BAREMRFUNONBATI')")
|
|
||||||
public ResponseEntity<?> deleteBaremRfuNonBatir(@PathVariable Long id) {
|
public ResponseEntity<?> deleteBaremRfuNonBatir(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
baremRfuNonBatiService.deleteBaremRfuNonBati(id);
|
baremRfuNonBatiService.deleteBaremRfuNonBati(id);
|
||||||
@@ -110,7 +105,6 @@ public class BaremRfuNonBatiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUNONBATI')")
|
|
||||||
public ResponseEntity<?> getAllBaremRfuNonBatiList() {
|
public ResponseEntity<?> getAllBaremRfuNonBatiList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -134,7 +128,6 @@ public class BaremRfuNonBatiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUNONBATI')")
|
|
||||||
public ResponseEntity<?> getAllBaremRfuNonBatiPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllBaremRfuNonBatiPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,36 +153,10 @@ public class BaremRfuNonBatiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUNONBATI')")
|
|
||||||
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).orElse(null), "BaremRfuNonBati trouvée avec succès."),
|
new ApiResponse<>(true, baremRfuNonBatiService.getBaremRfuNonBatiById(id), "BaremRfuNonBati trouvée avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_BAREMRFUNONBATI')")
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -36,7 +35,6 @@ public class CampagneController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> createCampagne(@RequestBody @Valid @Validated Campagne campagne) {
|
public ResponseEntity<?> createCampagne(@RequestBody @Valid @Validated Campagne campagne) {
|
||||||
try {
|
try {
|
||||||
campagne = campagneService.createCampagne(campagne);
|
campagne = campagneService.createCampagne(campagne);
|
||||||
@@ -61,7 +59,6 @@ public class CampagneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> updateCampagne(@PathVariable Long id, @RequestBody Campagne campagne) {
|
public ResponseEntity<?> updateCampagne(@PathVariable Long id, @RequestBody Campagne campagne) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -85,7 +82,6 @@ public class CampagneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> deleteCampagner(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCampagner(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
campagneService.deleteCampagne(id);
|
campagneService.deleteCampagne(id);
|
||||||
@@ -110,7 +106,6 @@ public class CampagneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> getAllCampagneList() {
|
public ResponseEntity<?> getAllCampagneList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -134,7 +129,6 @@ public class CampagneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> getAllCampagnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCampagnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +154,6 @@ public class CampagneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> getCampagneById(@PathVariable Long id) {
|
public ResponseEntity<?> getCampagneById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -184,7 +177,6 @@ public class CampagneController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/type-campagne/{typeCampagne}")
|
@GetMapping("/type-campagne/{typeCampagne}")
|
||||||
@PreAuthorize("hasAuthority('READ_CAMPAGNE')")
|
|
||||||
public ResponseEntity<?> getCampagneByType(@PathVariable TypeCampagne typeCampagne) {
|
public ResponseEntity<?> getCampagneByType(@PathVariable TypeCampagne typeCampagne) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -35,7 +34,6 @@ public class CaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_CARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> createCaracteristique(@RequestBody @Valid @Validated Caracteristique caracteristique) {
|
public ResponseEntity<?> createCaracteristique(@RequestBody @Valid @Validated Caracteristique caracteristique) {
|
||||||
try {
|
try {
|
||||||
caracteristique = caracteristiqueService.createCaracteristique(caracteristique);
|
caracteristique = caracteristiqueService.createCaracteristique(caracteristique);
|
||||||
@@ -60,7 +58,6 @@ public class CaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_CARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> updateCaracteristique(@PathVariable Long id, @RequestBody Caracteristique caracteristique) {
|
public ResponseEntity<?> updateCaracteristique(@PathVariable Long id, @RequestBody Caracteristique caracteristique) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -84,7 +81,6 @@ public class CaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_CARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> deleteCaracteristique(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCaracteristique(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
caracteristiqueService.deleteCaracteristique(id);
|
caracteristiqueService.deleteCaracteristique(id);
|
||||||
@@ -109,7 +105,6 @@ public class CaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiqueList() {
|
public ResponseEntity<?> getAllCaracteristiqueList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -133,7 +128,6 @@ public class CaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> getAllCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -159,7 +153,6 @@ public class CaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_CARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> getCaracteristiqueById(@PathVariable Long id) {
|
public ResponseEntity<?> getCaracteristiqueById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -35,7 +34,6 @@ public class CategorieBatimentController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_CATEGORIEBATIMENT')")
|
|
||||||
public ResponseEntity<?> createCategorieBatiment(@RequestBody @Valid @Validated CategorieBatiment categorieBatiment) {
|
public ResponseEntity<?> createCategorieBatiment(@RequestBody @Valid @Validated CategorieBatiment categorieBatiment) {
|
||||||
try {
|
try {
|
||||||
categorieBatiment = categorieBatimentService.createCategorieBatiment(categorieBatiment);
|
categorieBatiment = categorieBatimentService.createCategorieBatiment(categorieBatiment);
|
||||||
@@ -60,7 +58,6 @@ public class CategorieBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_CATEGORIEBATIMENT')")
|
|
||||||
public ResponseEntity<?> updateCategorieBatiment(@PathVariable Long id, @RequestBody CategorieBatiment categorieBatiment) {
|
public ResponseEntity<?> updateCategorieBatiment(@PathVariable Long id, @RequestBody CategorieBatiment categorieBatiment) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -84,7 +81,6 @@ public class CategorieBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_CATEGORIEBATIMENT')")
|
|
||||||
public ResponseEntity<?> deleteCategorieBatimentr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteCategorieBatimentr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
categorieBatimentService.deleteCategorieBatiment(id);
|
categorieBatimentService.deleteCategorieBatiment(id);
|
||||||
@@ -109,7 +105,6 @@ public class CategorieBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_CATEGORIEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllCategorieBatimentList() {
|
public ResponseEntity<?> getAllCategorieBatimentList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -133,7 +128,6 @@ public class CategorieBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_CATEGORIEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getAllCategorieBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllCategorieBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -159,7 +153,6 @@ public class CategorieBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_CATEGORIEBATIMENT')")
|
|
||||||
public ResponseEntity<?> getCategorieBatimentById(@PathVariable Long id) {
|
public ResponseEntity<?> getCategorieBatimentById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.rfu.parametre.Equipe;
|
|||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService;
|
import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EquipePayload;
|
import io.gmss.fiscad.paylaods.request.EquipePayload;
|
||||||
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;
|
||||||
@@ -15,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -36,7 +35,6 @@ public class EquipeController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_EQUIPE')")
|
|
||||||
public ResponseEntity<?> createEquipe(@RequestBody @Valid @Validated EquipePayload equipePayload) {
|
public ResponseEntity<?> createEquipe(@RequestBody @Valid @Validated EquipePayload equipePayload) {
|
||||||
try {
|
try {
|
||||||
Equipe equipe = equipeService.createEquipe(equipePayload);
|
Equipe equipe = equipeService.createEquipe(equipePayload);
|
||||||
@@ -61,7 +59,6 @@ public class EquipeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_EQUIPE')")
|
|
||||||
public ResponseEntity<?> updateEquipe(@PathVariable Long id, @RequestBody EquipePayload equipePayload) {
|
public ResponseEntity<?> updateEquipe(@PathVariable Long id, @RequestBody EquipePayload equipePayload) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -85,7 +82,6 @@ public class EquipeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_EQUIPE')")
|
|
||||||
public ResponseEntity<?> deleteEquiper(@PathVariable Long id) {
|
public ResponseEntity<?> deleteEquiper(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
equipeService.deleteEquipe(id);
|
equipeService.deleteEquipe(id);
|
||||||
@@ -110,7 +106,6 @@ public class EquipeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_EQUIPE')")
|
|
||||||
public ResponseEntity<?> getAllEquipeList() {
|
public ResponseEntity<?> getAllEquipeList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -134,7 +129,6 @@ public class EquipeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_EQUIPE')")
|
|
||||||
public ResponseEntity<?> getAllEquipePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllEquipePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -160,7 +154,6 @@ public class EquipeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_EQUIPE')")
|
|
||||||
public ResponseEntity<?> getEquipeById(@PathVariable Long id) {
|
public ResponseEntity<?> getEquipeById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -35,7 +34,6 @@ public class ExerciceController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_EXERCICE')")
|
|
||||||
public ResponseEntity<?> createExercice(@RequestBody @Valid @Validated Exercice exercice) {
|
public ResponseEntity<?> createExercice(@RequestBody @Valid @Validated Exercice exercice) {
|
||||||
try {
|
try {
|
||||||
exercice = exerciceService.createExercice(exercice);
|
exercice = exerciceService.createExercice(exercice);
|
||||||
@@ -60,7 +58,6 @@ public class ExerciceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_EXERCICE')")
|
|
||||||
public ResponseEntity<?> updateExercice(@PathVariable Long id, @RequestBody Exercice exercice) {
|
public ResponseEntity<?> updateExercice(@PathVariable Long id, @RequestBody Exercice exercice) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -84,7 +81,6 @@ public class ExerciceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_EXERCICE')")
|
|
||||||
public ResponseEntity<?> deleteExercicer(@PathVariable Long id) {
|
public ResponseEntity<?> deleteExercicer(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
exerciceService.deleteExercice(id);
|
exerciceService.deleteExercice(id);
|
||||||
@@ -109,7 +105,6 @@ public class ExerciceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_EXERCICE')")
|
|
||||||
public ResponseEntity<?> getAllExerciceList() {
|
public ResponseEntity<?> getAllExerciceList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -133,7 +128,6 @@ public class ExerciceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_EXERCICE')")
|
|
||||||
public ResponseEntity<?> getAllExercicePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllExercicePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -159,7 +153,6 @@ public class ExerciceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_EXERCICE')")
|
|
||||||
public ResponseEntity<?> getExerciceById(@PathVariable Long id) {
|
public ResponseEntity<?> getExerciceById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -182,5 +175,6 @@ public class ExerciceController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -35,7 +34,6 @@ public class TypeCaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_TYPECARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> createTypeCaracteristique(@RequestBody @Valid @Validated TypeCaracteristique typeCaracteristique) {
|
public ResponseEntity<?> createTypeCaracteristique(@RequestBody @Valid @Validated TypeCaracteristique typeCaracteristique) {
|
||||||
try {
|
try {
|
||||||
typeCaracteristique = typeCaracteristiqueService.createTypeCaracteristique(typeCaracteristique);
|
typeCaracteristique = typeCaracteristiqueService.createTypeCaracteristique(typeCaracteristique);
|
||||||
@@ -60,7 +58,6 @@ public class TypeCaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_TYPECARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> updateTypeCaracteristique(@PathVariable Long id, @RequestBody TypeCaracteristique typeCaracteristique) {
|
public ResponseEntity<?> updateTypeCaracteristique(@PathVariable Long id, @RequestBody TypeCaracteristique typeCaracteristique) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -84,7 +81,6 @@ public class TypeCaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_TYPECARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> deleteTypeCaracteristique(@PathVariable Long id) {
|
public ResponseEntity<?> deleteTypeCaracteristique(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
typeCaracteristiqueService.deleteTypeCaracteristique(id);
|
typeCaracteristiqueService.deleteTypeCaracteristique(id);
|
||||||
@@ -109,7 +105,6 @@ public class TypeCaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPECARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> getAllTypeCaracteristiqueList() {
|
public ResponseEntity<?> getAllTypeCaracteristiqueList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -133,7 +128,6 @@ public class TypeCaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPECARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> getAllTypeCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllTypeCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -159,7 +153,6 @@ public class TypeCaracteristiqueController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_TYPECARACTERISTIQUE')")
|
|
||||||
public ResponseEntity<?> getTypeCaracteristiqueById(@PathVariable Long id) {
|
public ResponseEntity<?> getTypeCaracteristiqueById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -1,187 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.rfu.parametre;
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Usage;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.rfu.parametre.UsageService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_USAGE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USAGE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_USAGE')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_USAGE')")
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_USAGE')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_USAGE')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -14,7 +14,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -35,7 +34,6 @@ public class ZoneRfuController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_ZONERFU')")
|
|
||||||
public ResponseEntity<?> createZoneRfu(@RequestBody @Valid @Validated ZoneRfu zoneRfu) {
|
public ResponseEntity<?> createZoneRfu(@RequestBody @Valid @Validated ZoneRfu zoneRfu) {
|
||||||
try {
|
try {
|
||||||
zoneRfu = zoneRfuService.createZoneRfu(zoneRfu);
|
zoneRfu = zoneRfuService.createZoneRfu(zoneRfu);
|
||||||
@@ -60,7 +58,6 @@ public class ZoneRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ZONERFU')")
|
|
||||||
public ResponseEntity<?> updateZoneRfu(@PathVariable Long id, @RequestBody ZoneRfu zoneRfu) {
|
public ResponseEntity<?> updateZoneRfu(@PathVariable Long id, @RequestBody ZoneRfu zoneRfu) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -84,7 +81,6 @@ public class ZoneRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_ZONERFU')")
|
|
||||||
public ResponseEntity<?> deleteZoneRfur(@PathVariable Long id) {
|
public ResponseEntity<?> deleteZoneRfur(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
zoneRfuService.deleteZoneRfu(id);
|
zoneRfuService.deleteZoneRfu(id);
|
||||||
@@ -109,7 +105,6 @@ public class ZoneRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_ZONERFU')")
|
|
||||||
public ResponseEntity<?> getAllZoneRfuList() {
|
public ResponseEntity<?> getAllZoneRfuList() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -133,7 +128,6 @@ public class ZoneRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_ZONERFU')")
|
|
||||||
public ResponseEntity<?> getAllZoneRfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllZoneRfuPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -159,7 +153,6 @@ public class ZoneRfuController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_ZONERFU')")
|
|
||||||
public ResponseEntity<?> getZoneRfuById(@PathVariable Long id) {
|
public ResponseEntity<?> getZoneRfuById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package io.gmss.fiscad.controllers.statistique;
|
package io.gmss.fiscad.controllers.statistique;
|
||||||
|
|
||||||
import io.gmss.fiscad.enums.NiveauDecoupage;
|
import io.gmss.fiscad.enums.NiveauDecoupage;
|
||||||
import io.gmss.fiscad.enums.StatutEnquete;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
import io.gmss.fiscad.exceptions.*;
|
||||||
import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
|
import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
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;
|
||||||
@@ -177,77 +174,4 @@ public class StatistiqueController {
|
|||||||
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 = "Statistique des enquetes en cours par object ",
|
|
||||||
description = "Donnes le nombre d'enquetes en coures par objet"
|
|
||||||
)
|
|
||||||
@GetMapping(path = "/nombre-enquete/par-objet/en-cours")
|
|
||||||
public ResponseEntity<?> getStatistiquesEnqueteEnCoursParObjet(@CurrentUser UserPrincipal currentUser) {
|
|
||||||
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, statistiquesService.getStatNombreEnqueteParObjetUserConnect(userId,StatutEnquete.EN_COURS.toString()), "Statistique des personne par type."),
|
|
||||||
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 = "Statistique des enquetes en cours par object ",
|
|
||||||
description = "Donnes le nombre d'enquetes en coures par objet"
|
|
||||||
)
|
|
||||||
@GetMapping(path = "/nombre-enquete/par-objet/cloture")
|
|
||||||
public ResponseEntity<?> getStatistiquesEnqueteClotureParObjet(@CurrentUser UserPrincipal currentUser) {
|
|
||||||
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, statistiquesService.getStatNombreEnqueteParObjetUserConnect(userId, StatutEnquete.CLOTURE.toString()), "Statistique des personne par type."),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Restauration")
|
@Tag(name = "Restauration")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR') or hasRole('ROLE_ENQUETEUR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR') or hasRole('ROLE_ENQUETEUR')")
|
||||||
public class RestaurationController {
|
public class RestaurationController {
|
||||||
public final RestaurationService restaurationService;
|
public final RestaurationService restaurationService;
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ 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.synchronisation.SynchronisationService;
|
import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService;
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||||
import io.gmss.fiscad.paylaods.request.EnqueteAllDataPayload;
|
import io.gmss.fiscad.paylaods.request.*;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.*;
|
|
||||||
import io.gmss.fiscad.service.ZipService;
|
import io.gmss.fiscad.service.ZipService;
|
||||||
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;
|
||||||
@@ -84,7 +83,7 @@ public class SynchronisationController {
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@PostMapping("/personnes")
|
@PostMapping("/personnes")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncPersonne(@RequestBody List<PersonnePayLoad> personnePayLoads) {
|
public ResponseEntity<?> syncPersonne(@RequestBody List<PersonnePayLoad> personnePayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -108,7 +107,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/membre-groupe")
|
@PostMapping("/membre-groupe")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncMembreGroupe(@RequestBody List<MembreGroupePayLoad> membreGroupePayLoads) {
|
public ResponseEntity<?> syncMembreGroupe(@RequestBody List<MembreGroupePayLoad> membreGroupePayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -132,7 +131,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/enquete")
|
@PostMapping("/enquete")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncEnquete(@RequestBody List<EnquetePayLoad> enquetePayLoads) {
|
public ResponseEntity<?> syncEnquete(@RequestBody List<EnquetePayLoad> enquetePayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -156,7 +155,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/parcelle")
|
@PostMapping("/parcelle")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncParcelle(@RequestBody List<ParcellePayLoad> parcellePayLoads) {
|
public ResponseEntity<?> syncParcelle(@RequestBody List<ParcellePayLoad> parcellePayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -180,7 +179,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/piece")
|
@PostMapping("/piece")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncPiece(@RequestBody List<PiecePayLoad> piecePayLoads) {
|
public ResponseEntity<?> syncPiece(@RequestBody List<PiecePayLoad> piecePayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -205,7 +204,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/acteur-concerne")
|
@PostMapping("/acteur-concerne")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncActeurConcerne(@RequestBody List<ActeurConcernePayLoad> piecePayLoads) {
|
public ResponseEntity<?> syncActeurConcerne(@RequestBody List<ActeurConcernePayLoad> piecePayLoads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -230,7 +229,7 @@ public class SynchronisationController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/enquete-activite")
|
@PostMapping("/enquete-activite")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncEnqueteActivite(@RequestBody List<EnqueteActivitePayload> enqueteActivitePayloads) {
|
public ResponseEntity<?> syncEnqueteActivite(@RequestBody List<EnqueteActivitePayload> enqueteActivitePayloads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -255,7 +254,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/declaraction-nc")
|
@PostMapping("/declaraction-nc")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncDeclarationNc(@RequestBody List<DeclarationNcPayload> declarationNcPayloads) {
|
public ResponseEntity<?> syncDeclarationNc(@RequestBody List<DeclarationNcPayload> declarationNcPayloads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -335,7 +334,7 @@ public class SynchronisationController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@PostMapping(path = "/uploads")
|
@PostMapping(path = "/uploads")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncUploads(@RequestBody List<UploadPayLoad> uploadPayLoads) {
|
public ResponseEntity<?> syncUploads(@RequestBody List<UploadPayLoad> uploadPayLoads) {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, synchronisationService.syncUpload(uploadPayLoads), "Liste des uploads synchronisée avec succès."),
|
new ApiResponse<>(true, synchronisationService.syncUpload(uploadPayLoads), "Liste des uploads synchronisée avec succès."),
|
||||||
@@ -369,7 +368,7 @@ public class SynchronisationController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@PostMapping(path = "/synchronise/all-enquete-data")
|
@PostMapping(path = "/synchronise/all-enquete-data")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncAllEnqueteData(@ModelAttribute EnqueteAllDataPayload enqueteAllDataPayload) {
|
public ResponseEntity<?> syncAllEnqueteData(@ModelAttribute EnqueteAllDataPayload enqueteAllDataPayload) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -393,7 +392,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/synchronise/enquete/confirme-from-mobile")
|
@PostMapping(path = "/synchronise/enquete/confirme-from-mobile")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncAllEnqueteData(@RequestBody List<Long> longList) {
|
public ResponseEntity<?> syncAllEnqueteData(@RequestBody List<Long> longList) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -418,7 +417,7 @@ public class SynchronisationController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping(path = "/batiment")
|
@PostMapping(path = "/batiment")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncBatiment(@RequestBody List<BatimentPaylaod> batimentPaylaods) {
|
public ResponseEntity<?> syncBatiment(@RequestBody List<BatimentPaylaod> batimentPaylaods) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -443,7 +442,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/unite-logement")
|
@PostMapping(path = "/unite-logement")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncUniteLogement(@RequestBody List<UniteLogementPaylaod> uniteLogementPaylaods) {
|
public ResponseEntity<?> syncUniteLogement(@RequestBody List<UniteLogementPaylaod> uniteLogementPaylaods) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -468,12 +467,12 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/caracteristique-batiment")
|
@PostMapping(path = "/caracteristique-batiment")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncCaracteristiqueBatiment(@RequestBody List<CaracteristiqueBatimentPayload> CaracteristiqueBatimentPayloads) {
|
public ResponseEntity<?> syncCaracteristiqueBatiment(@RequestBody List<CaracteristiqueBatimentPaylod> caracteristiqueBatimentPaylods) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
//new ApiResponse<>(true, null, "Liste des caractéristiques des bâtiments synchronisée avec succès."),
|
//new ApiResponse<>(true, null, "Liste des caractéristiques des bâtiments synchronisée avec succès."),
|
||||||
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueBatiment(CaracteristiqueBatimentPayloads), "Liste des caractéristiques des bâtiments synchronisée avec succès."),
|
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueBatiment(caracteristiqueBatimentPaylods), "Liste des caractéristiques des bâtiments synchronisée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -493,12 +492,12 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/caracteristique-parcelle")
|
@PostMapping(path = "/caracteristique-parcelle")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncCaracteristiqueParcelle(@RequestBody List<CaracteristiqueParcellePayload> CaracteristiqueParcellePayloads) {
|
public ResponseEntity<?> syncCaracteristiqueParcelle(@RequestBody List<CaracteristiqueParcellePaylod> caracteristiqueParcellePaylods) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
//new ApiResponse<>(true, null, "Liste des caractéristiques des parcelles synchronisée avec succès."),
|
//new ApiResponse<>(true, null, "Liste des caractéristiques des parcelles synchronisée avec succès."),
|
||||||
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueParcelle(CaracteristiqueParcellePayloads), "Liste des caractéristiques des parcelles synchronisée avec succès."),
|
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueParcelle(caracteristiqueParcellePaylods), "Liste des caractéristiques des parcelles synchronisée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -518,12 +517,12 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/caracteristique-unite-logement")
|
@PostMapping(path = "/caracteristique-unite-logement")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncCaracteristiqueUniteLogement(@RequestBody List<CaracteristiqueUniteLogementPayload> CaracteristiqueUniteLogementPayloads) {
|
public ResponseEntity<?> syncCaracteristiqueUniteLogement(@RequestBody List<CaracteristiqueUniteLogementPaylod> caracteristiqueUniteLogementPaylods) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
//new ApiResponse<>(true, null, "Liste des caractéristiques des unités de logement synchronisée avec succès."),
|
//new ApiResponse<>(true, null, "Liste des caractéristiques des unités de logement synchronisée avec succès."),
|
||||||
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueUniteLogement(CaracteristiqueUniteLogementPayloads), "Liste des caractéristiques des unités de logement synchronisée avec succès."),
|
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueUniteLogement(caracteristiqueUniteLogementPaylods), "Liste des caractéristiques des unités de logement synchronisée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -543,7 +542,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/enquete-batiment")
|
@PostMapping("/enquete-batiment")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncEnqueteBatiment(@RequestBody List<EnqueteBatimentPayload> enqueteBatimentPayloads) {
|
public ResponseEntity<?> syncEnqueteBatiment(@RequestBody List<EnqueteBatimentPayload> enqueteBatimentPayloads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -568,7 +567,7 @@ public class SynchronisationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/enquete-unite-logement")
|
@PostMapping("/enquete-unite-logement")
|
||||||
// @PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('SUPERVISEUR') or hasRole('ENQUETEUR')")
|
||||||
public ResponseEntity<?> syncEnqueteUniteLogement(@RequestBody List<EnqueteUniteLogementPayload> enqueteUniteLogementPayloads) {
|
public ResponseEntity<?> syncEnqueteUniteLogement(@RequestBody List<EnqueteUniteLogementPayload> enqueteUniteLogementPayloads) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ 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;
|
||||||
@@ -91,13 +90,13 @@ public class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/signup")
|
@PostMapping("/signup")
|
||||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
|
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) {
|
||||||
try {
|
try {
|
||||||
//User user = getUser(userRequest);
|
User user = getUser(userRequest);
|
||||||
//user.setUsername(userRequest.getEmail());
|
user.setUsername(userRequest.getEmail());
|
||||||
userPaylaodWeb = userService.createUser(userPaylaodWeb);
|
user = userService.createUser(user, true);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userPaylaodWeb, "Inscription effectué avec succès."),
|
new ApiResponse<>(true, user, "Inscription effectué avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -116,5 +115,19 @@ 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<>();
|
||||||
|
roleSet.add(roleService.getRoleByRoleName(UserRole.ROLE_ANONYMOUS).get());
|
||||||
|
user.setRoles(roleSet);
|
||||||
|
user.setStructure(structureService.getStructureById(userRequest.getStructureId()).get());
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,243 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.user;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.user.AvoirFonction;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.user.AvoirFonctionService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.AvoirFonctionPaylaodWeb;
|
|
||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/fonction-utilisateur", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Fonction Utilisateur")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class AvoirFonctionController {
|
|
||||||
|
|
||||||
private final AvoirFonctionService avoirFonctionService;
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AvoirFonctionController.class);
|
|
||||||
|
|
||||||
public AvoirFonctionController(AvoirFonctionService avoirFonctionService) {
|
|
||||||
this.avoirFonctionService = avoirFonctionService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_AVOIRFONCTION')")
|
|
||||||
public ResponseEntity<?> createAvoirFonction(@RequestBody @Valid @Validated AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb ) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.createAvoirFonction(avoirFonctionPaylaodWeb), "Fonction utilisateur créée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_AVOIRFONCTION')")
|
|
||||||
public ResponseEntity<?> updateAvoirFonction(@PathVariable Long id, @RequestBody AvoirFonctionPaylaodWeb avoirFonctionPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.updateAvoirFonction(id, avoirFonctionPaylaodWeb), "Fonction utilisateur 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_AVOIRFONCTION')")
|
|
||||||
public ResponseEntity<?> deleteAvoirFonction(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
avoirFonctionService.deleteAvoirFonction(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Fonction Utilisateur 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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_AVOIRFONCTION')")
|
|
||||||
public ResponseEntity<?> getAll() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionList(), "Liste des fonctions utilisateur."),
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_AVOIRFONCTION')")
|
|
||||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionList(pageable), "Liste des fonction utilisateurs."),
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_AVOIRFONCTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_AVOIRFONCTION')")
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_AVOIRFONCTION')")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/create")
|
@GetMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_DEMANDEREINITIALISATIONMP')")
|
|
||||||
public ResponseEntity<?> createDemandeReinitialisationMP(@RequestParam String usernamrOrEmail) {
|
public ResponseEntity<?> createDemandeReinitialisationMP(@RequestParam String usernamrOrEmail) {
|
||||||
try {
|
try {
|
||||||
demandeReinitialisationMPService.createDemandeReinitialisationMP(usernamrOrEmail);
|
demandeReinitialisationMPService.createDemandeReinitialisationMP(usernamrOrEmail);
|
||||||
@@ -69,7 +67,6 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_DEMANDEREINITIALISATIONMP')")
|
|
||||||
public ResponseEntity<?> updateDemandeReinitialisationMP(@PathVariable Long id, @RequestBody DemandeReinitialisationMP demandeReinitialisationMP) {
|
public ResponseEntity<?> updateDemandeReinitialisationMP(@PathVariable Long id, @RequestBody DemandeReinitialisationMP demandeReinitialisationMP) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -93,7 +90,6 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_DEMANDEREINITIALISATIONMP')")
|
|
||||||
public ResponseEntity<?> deleteDemandeReinitialisationMPr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteDemandeReinitialisationMPr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
demandeReinitialisationMPService.deleteDemandeReinitialisationMP(id);
|
demandeReinitialisationMPService.deleteDemandeReinitialisationMP(id);
|
||||||
@@ -117,18 +113,31 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping("/all")
|
@GetMapping("/all")
|
||||||
// public ResponseEntity<?> getAllDemandeReinitialisationMPList(@CurrentUser UserPrincipal userPrincipal) {
|
public ResponseEntity<?> getAllDemandeReinitialisationMPList(@CurrentUser UserPrincipal userPrincipal) {
|
||||||
// try {
|
try {
|
||||||
//
|
|
||||||
// User user = userPrincipal.getUser();
|
User user = userPrincipal.getUser();
|
||||||
//
|
|
||||||
// if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
||||||
// return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
// new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."),
|
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."),
|
||||||
// HttpStatus.OK
|
HttpStatus.OK
|
||||||
// );
|
);
|
||||||
// } else {
|
} else {
|
||||||
|
if (user.getStructure() == null) {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPNonTraiteList(user.getStructure()), "Liste des demande de Reinitialisation chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// }else {
|
||||||
// if (user.getStructure() == null) {
|
// if (user.getStructure() == null) {
|
||||||
// return new ResponseEntity<>(
|
// return new ResponseEntity<>(
|
||||||
// new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
// new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
||||||
@@ -141,38 +150,24 @@ public class DemandeReinitialisationMPController {
|
|||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//// }else {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
//// if (user.getStructure() == null) {
|
logger.error(e.getLocalizedMessage());
|
||||||
//// return new ResponseEntity<>(
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
//// new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
//// HttpStatus.OK
|
FileStorageException e) {
|
||||||
//// );
|
logger.error(e.getLocalizedMessage());
|
||||||
//// } else {
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
//// return new ResponseEntity<>(
|
} catch (NullPointerException e) {
|
||||||
//// new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPNonTraiteList(user.getStructure()), "Liste des demande de Reinitialisation chargée avec succès."),
|
logger.error(e.getLocalizedMessage());
|
||||||
//// HttpStatus.OK
|
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);
|
||||||
// } 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")
|
||||||
@PreAuthorize("hasAuthority('READ_DEMANDEREINITIALISATIONMP')")
|
|
||||||
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
@@ -198,7 +193,6 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
@PreAuthorize("hasAuthority('READ_DEMANDEREINITIALISATIONMP')")
|
|
||||||
public ResponseEntity<?> getDemandeReinitialisationMPById(@PathVariable Long id) {
|
public ResponseEntity<?> getDemandeReinitialisationMPById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -222,7 +216,6 @@ public class DemandeReinitialisationMPController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/reset")
|
@GetMapping("/reset")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_DEMANDEREINITIALISATIONMP')")
|
|
||||||
public ResponseEntity<?> traiterDemande(@RequestParam Long id, @RequestParam String password) {
|
public ResponseEntity<?> traiterDemande(@RequestParam Long id, @RequestParam String password) {
|
||||||
try {
|
try {
|
||||||
DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPService.traiterDemandeReinitialisation(id, password);
|
DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPService.traiterDemandeReinitialisation(id, password);
|
||||||
|
|||||||
@@ -1,186 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.user;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.user.Fonction;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.rfu.metier.FonctionService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.FonctionPaylaodWeb;
|
|
||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/fonction", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Fonction")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class FonctionController {
|
|
||||||
|
|
||||||
private final FonctionService fonctionService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FonctionController.class);
|
|
||||||
|
|
||||||
public FonctionController(FonctionService fonctionService) {
|
|
||||||
this.fonctionService = fonctionService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_FONCTION')")
|
|
||||||
public ResponseEntity<?> createFonction(@RequestBody @Valid @Validated FonctionPaylaodWeb fonctionPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
Fonction fonction = fonctionService.createFonction(fonctionPaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonction, "Secteur affecté 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_FONCTION')")
|
|
||||||
public ResponseEntity<?> updateFonction(@PathVariable Long id, @RequestBody FonctionPaylaodWeb fonctionPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionService.updateFonction(id, fonctionPaylaodWeb), "Affectation de Secteur 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_FONCTION')")
|
|
||||||
public ResponseEntity<?> deleteFonction(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
fonctionService.deleteFonction(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Fonction 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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_FONCTION')")
|
|
||||||
public ResponseEntity<?> getAllFonctionList() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionService.getFonctionListToDto(), "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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_FONCTION')")
|
|
||||||
public ResponseEntity<?> getAllFonctionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionService.getFonctionListToDtoPageable(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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_FONCTION')")
|
|
||||||
public ResponseEntity<?> getFonctionById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, fonctionService.getFonctionById(id), "Fonction 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,189 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.user;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.user.Profile;
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.user.ProfileService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.ProfilePaylaodWeb;
|
|
||||||
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.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/profil", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Profile")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class ProfileController {
|
|
||||||
|
|
||||||
private final ProfileService profileService;
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProfileController.class);
|
|
||||||
|
|
||||||
public ProfileController(ProfileService profileService) {
|
|
||||||
this.profileService = profileService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_PROFILE')")
|
|
||||||
public ResponseEntity<?> createProfile(@RequestBody @Valid @Validated ProfilePaylaodWeb profilePaylaodWeb ) {
|
|
||||||
try {
|
|
||||||
Profile profile = profileService.createProfile(profilePaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profile, "Profile created successully."),
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_PROFILE')")
|
|
||||||
public ResponseEntity<?> updateProfile(@PathVariable Long id, @RequestBody ProfilePaylaodWeb profilePaylaodWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileService.updateProfile(id, profilePaylaodWeb), "Profile updated successully."),
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_PROFILE')")
|
|
||||||
public ResponseEntity<?> deleteProfile(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
profileService.deleteProfile(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Profile deleted successully"),
|
|
||||||
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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PROFILE')")
|
|
||||||
public ResponseEntity<?> getAll() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileService.getProfileList(), "Liste des profiles."),
|
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PROFILE')")
|
|
||||||
public ResponseEntity<?> getById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileService.getProfileById(id), "Profile 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-paged")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PROFILE')")
|
|
||||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileService.getProfileList(pageable), "Liste des profiles."),
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
package io.gmss.fiscad.controllers.user;
|
|
||||||
|
|
||||||
|
|
||||||
import io.gmss.fiscad.exceptions.*;
|
|
||||||
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
|
|
||||||
import io.gmss.fiscad.interfaces.user.ProfileModuleFonctionnaliteService;
|
|
||||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.ProfileModuleFonctionnalitePayloadWeb;
|
|
||||||
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.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/profile-module-fonctionnalite", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "ProfileModuleFonctionnalite")
|
|
||||||
@CrossOrigin(origins = "*")
|
|
||||||
public class ProfileModuleFonctionnaliteController {
|
|
||||||
|
|
||||||
private final ProfileModuleFonctionnaliteService profileModuleFonctionnaliteService;
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProfileModuleFonctionnaliteController.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@PreAuthorize("hasAuthority('CREATE_PROFILEMODULEFONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> createProfileModuleFonctionnalite(@RequestBody @Valid @Validated ProfileModuleFonctionnalitePayloadWeb modulePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
modulePayLoadWeb = profileModuleFonctionnaliteService.createProfileModuleFonctionnalite(modulePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, modulePayLoadWeb, "ProfileModuleFonctionnalite 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}")
|
|
||||||
@PreAuthorize("hasAuthority('UPDATE_PROFILEMODULEFONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> updateProfileModuleFonctionnalite(@PathVariable Long id, @RequestBody ProfileModuleFonctionnalitePayloadWeb modulePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.updateProfileModuleFonctionnalite(id,modulePayLoadWeb), "ProfileModuleFonctionnalite 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}")
|
|
||||||
@PreAuthorize("hasAuthority('DELETE_PROFILEMODULEFONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> deleteProfileModuleFonctionnalite(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
profileModuleFonctionnaliteService.deleteProfileModuleFonctionnalite(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "ProfileModuleFonctionnalite 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")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> getAllProfileModuleFonctionnaliteList() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.getProfileModuleFonctionnaliteListToDto(), "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-profil-id/{profilId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> getAllProfileModuleFonctionnaliteByProfilList(@PathVariable Long profilId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.getAllProfileModuleFonctionnaliteByProfilIdToDto(profilId), "Liste des modules 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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_PROFILEMODULEFONCTIONNALITE')")
|
|
||||||
public ResponseEntity<?> getProfileModuleFonctionnaliteById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, profileModuleFonctionnaliteService.getProfileModuleFonctionnaliteByIdToDto(id), "ProfileModuleFonctionnalite 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,6 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
@@ -37,7 +36,6 @@ public class RoleController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_ROLE')")
|
|
||||||
public ResponseEntity<?> createRole(@RequestBody @Valid @Validated Role role) {
|
public ResponseEntity<?> createRole(@RequestBody @Valid @Validated Role role) {
|
||||||
try {
|
try {
|
||||||
role = roleService.createRole(role);
|
role = roleService.createRole(role);
|
||||||
@@ -63,7 +61,6 @@ public class RoleController {
|
|||||||
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_ROLE')")
|
|
||||||
public ResponseEntity<?> updateRole(@PathVariable Long id, @RequestBody Role role) {
|
public ResponseEntity<?> updateRole(@PathVariable Long id, @RequestBody Role role) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -87,7 +84,6 @@ public class RoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_ROLE')")
|
|
||||||
public ResponseEntity<?> deleteRole(@PathVariable Long id) {
|
public ResponseEntity<?> deleteRole(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
roleService.deleteRole(id);
|
roleService.deleteRole(id);
|
||||||
@@ -112,7 +108,6 @@ public class RoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_ROLE')")
|
|
||||||
public ResponseEntity<?> getAll() {
|
public ResponseEntity<?> getAll() {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -136,7 +131,6 @@ public class RoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
@PreAuthorize("hasAuthority('READ_ROLE')")
|
|
||||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||||
|
|||||||
@@ -8,24 +8,19 @@ 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;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
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;
|
||||||
|
|
||||||
|
|
||||||
@@ -45,12 +40,12 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@PreAuthorize("hasAuthority('CREATE_USER')")
|
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) {
|
||||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
|
|
||||||
try {
|
try {
|
||||||
userPaylaodWeb = userService.createUser(userPaylaodWeb);
|
user.setUsername(user.getEmail());
|
||||||
|
user = userService.createUser(user, true);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userPaylaodWeb, "Utilisateur créé avec succès"),
|
new ApiResponse<>(true, user, "Utilisateur créé avec succès"),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -70,7 +65,6 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/change-password")
|
@PostMapping("/change-password")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USER')")
|
|
||||||
public ResponseEntity<?> changeUserPassword(@RequestBody @Valid @Validated Login login) {
|
public ResponseEntity<?> changeUserPassword(@RequestBody @Valid @Validated Login login) {
|
||||||
try {
|
try {
|
||||||
userService.updatePassword(login.getUsername(), login.getPassword());
|
userService.updatePassword(login.getUsername(), login.getPassword());
|
||||||
@@ -95,12 +89,11 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/reset-password")
|
@PostMapping("/reset-password")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USER')")
|
|
||||||
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
||||||
try {
|
try {
|
||||||
UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername());
|
User user = userService.resetPassword(login.getUsername(), login.getPassword());
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userPaylaodWeb, "Votre mot de passe à été réinitialisée avec succès."),
|
new ApiResponse<>(true, user, "Votre mot de passe à été réinitialisée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -119,11 +112,10 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/validate-user-account/{userName}")
|
@PostMapping("/validate-user-account")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USER')")
|
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
|
||||||
public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
|
|
||||||
try {
|
try {
|
||||||
User user = userService.validateUserAccount(userName);
|
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
|
||||||
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
|
||||||
@@ -146,11 +138,10 @@ public class UserController {
|
|||||||
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USER')")
|
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, userPaylaodWeb), "Utilisateur modifié avec succès."),
|
new ApiResponse<>(true, userService.updateUser(id, user), "Utilisateur modifié avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -169,39 +160,30 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/activate/{id}")
|
@GetMapping("/activate-or-not/{id}")
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USER')")
|
public ResponseEntity<?> acitvateOrNotUser(@PathVariable Long id) {
|
||||||
public ResponseEntity<?> acitvateUser(@PathVariable Long id) {
|
|
||||||
try {
|
try {
|
||||||
User user = userService.activateUser(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, user, "Utilisateur activé avec succès"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
User user = userService.getUserById(id);
|
||||||
@GetMapping("/desactivate/{id}")
|
if(containsRoleAnonyme(user.getRoles())){
|
||||||
@PreAuthorize("hasAuthority('UPDATE_USER')")
|
return new ResponseEntity<>(
|
||||||
public ResponseEntity<?> disacitvateUser(@PathVariable Long id) {
|
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
||||||
try {
|
HttpStatus.OK
|
||||||
User user = userService.disactivateUser(id);
|
);
|
||||||
|
}
|
||||||
|
if(user.isResetPassword()){
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
user = userService.activateOrNotUser(id);
|
||||||
|
String message = "Utilisateur activé avec succès";
|
||||||
|
if (!user.isActive()) {
|
||||||
|
message = "Utilisateur désactivé avec succès";
|
||||||
|
}
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, user, "Utilisateur désactivé avec succès"),
|
new ApiResponse<>(true, user, message),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
@@ -221,7 +203,6 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
@PreAuthorize("hasAuthority('DELETE_USER')")
|
|
||||||
public ResponseEntity<?> deleteUser(@PathVariable Long id) {
|
public ResponseEntity<?> deleteUser(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
userService.deleteUser(id);
|
userService.deleteUser(id);
|
||||||
@@ -247,91 +228,57 @@ public class UserController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@PreAuthorize("hasAuthority('READ_USER')")
|
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
|
||||||
public ResponseEntity<?> getAll() {
|
|
||||||
try {
|
try {
|
||||||
|
if(userPrincipal==null){
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, userService.getListUserToDto(), "Liste des utilisateurs chargée avec succès."),
|
|
||||||
HttpStatus.OK);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
|
||||||
@PreAuthorize("hasAuthority('READ_USER')")
|
|
||||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, userService.getListUserToDto(pageable), "Liste des utilisateurs chargée avec succès."),
|
|
||||||
HttpStatus.OK);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all-by-structure/{structureId}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_USER')")
|
|
||||||
public ResponseEntity<?> getAllByStructure(@PathVariable Long structureId) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs chargée avec succès."),
|
new ApiResponse<>(false, null, "Vous n'êtes pas authorisés à accéder à la liste des utilisateurs"),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
User user = userPrincipal.getUser();
|
||||||
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
||||||
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}")
|
|
||||||
@PreAuthorize("hasAuthority('READ_USER')")
|
|
||||||
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId,pageable), "Liste des utilisateurs chargée avec succès."),
|
new ApiResponse<>(true, userService.getAllUserListResponse(), "Liste des utilisateurs chargée avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
|
FileStorageException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/all-by-structure")
|
||||||
|
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
|
||||||
|
try {
|
||||||
|
if (userPrincipal.getUser().getStructure() != null) {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."),
|
||||||
|
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);
|
||||||
@@ -349,9 +296,16 @@ 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}")
|
||||||
@PreAuthorize("hasAuthority('READ_USER')")
|
|
||||||
public ResponseEntity<?> getUserById(@PathVariable Long id) {
|
public ResponseEntity<?> getUserById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -375,7 +329,6 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/username/{username}")
|
@GetMapping("/username/{username}")
|
||||||
@PreAuthorize("hasAuthority('READ_USER')")
|
|
||||||
public ResponseEntity<?> getUserByUsername(@PathVariable String username) {
|
public ResponseEntity<?> getUserByUsername(@PathVariable String username) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -398,5 +351,35 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsRoleAnonyme(Set<Role> roles){
|
||||||
|
for(Role r: roles ){
|
||||||
|
if(r.getNom().equals(UserRole.ROLE_ANONYMOUS)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class BaseEntity implements Serializable {
|
|||||||
|
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Instant createdAt ;
|
private Instant createdAt;
|
||||||
@LastModifiedDate
|
@LastModifiedDate
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Instant updatedAt;
|
private Instant updatedAt;
|
||||||
@@ -37,6 +37,4 @@ public class BaseEntity implements Serializable {
|
|||||||
private boolean deleted;
|
private boolean deleted;
|
||||||
private Long externalKey;
|
private Long externalKey;
|
||||||
private Long enqueteExternalKey;
|
private Long enqueteExternalKey;
|
||||||
@JsonIgnore
|
|
||||||
private String source ;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities;
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.audit.UserDateAudit;
|
|
||||||
import io.gmss.fiscad.enums.ParametersType;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class Parameters extends UserDateAudit implements Serializable {
|
|
||||||
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private ParametersType name;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public Parameters() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.audit;
|
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import jakarta.persistence.EntityListeners;
|
|
||||||
import jakarta.persistence.MappedSuperclass;
|
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
|
||||||
import org.springframework.data.annotation.LastModifiedDate;
|
|
||||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
|
||||||
@EntityListeners(AuditingEntityListener.class)
|
|
||||||
public abstract class DateAudit implements Serializable {
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@CreatedDate
|
|
||||||
// @Column(updatable = false)
|
|
||||||
private Instant createdAt= Instant.now() ;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@LastModifiedDate
|
|
||||||
// @Column(nullable = false)
|
|
||||||
private Instant updatedAt=Instant.now();
|
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(Instant createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getUpdatedAt() {
|
|
||||||
return updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdatedAt(Instant updatedAt) {
|
|
||||||
this.updatedAt = updatedAt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.audit;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.MappedSuperclass;
|
|
||||||
import org.springframework.data.annotation.CreatedBy;
|
|
||||||
import org.springframework.data.annotation.LastModifiedBy;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@MappedSuperclass
|
|
||||||
public abstract class UserDateAudit extends DateAudit implements Serializable {
|
|
||||||
@JsonIgnore
|
|
||||||
@CreatedBy
|
|
||||||
@Column(updatable = false)
|
|
||||||
private Long createdBy;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@LastModifiedBy
|
|
||||||
private Long updatedBy;
|
|
||||||
|
|
||||||
public Long getCreatedBy() {
|
|
||||||
return createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedBy(Long createdBy) {
|
|
||||||
this.createdBy = createdBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getUpdatedBy() {
|
|
||||||
return updatedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdatedBy(Long updatedBy) {
|
|
||||||
this.updatedBy = updatedBy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,13 +24,9 @@ public class Quartier extends BaseEntity implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
private String nom;
|
||||||
private String codeExterne;
|
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
@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;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.gmss.fiscad.entities.decoupage;
|
package io.gmss.fiscad.entities.decoupage;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
@@ -27,16 +26,16 @@ public class Secteur extends BaseEntity implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String code;
|
private String code;
|
||||||
private String nom;
|
private String nom;
|
||||||
|
|
||||||
// @ManyToOne
|
|
||||||
// private Structure structure;
|
|
||||||
|
|
||||||
//@JsonBackReference
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Section section ;
|
private User chefSecteur;
|
||||||
|
@ManyToOne
|
||||||
|
private Structure structure;
|
||||||
|
|
||||||
//@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;
|
||||||
|
|
||||||
|
///Creer un payload pour la creation de secteur découpage
|
||||||
|
/// ressource pour envoyer les découpage d'un secteur
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ 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;
|
||||||
@@ -35,20 +36,16 @@ 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;
|
||||||
|
|
||||||
private String codeSecteur ;
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Arrondissement arrondissement;
|
private Arrondissement arrondissement;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Quartier quartier;
|
private Quartier quartier;
|
||||||
|
|
||||||
private String codeQuartier ;
|
|
||||||
|
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
// @OneToMany(mappedBy = "secteurDecoupage")
|
// @OneToMany(mappedBy = "secteurDecoupage")
|
||||||
// private List<Bloc> blocs;
|
// private List<Bloc> blocs;
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.decoupage;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
|
||||||
import io.gmss.fiscad.entities.user.Fonction;
|
|
||||||
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.util.List;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Where(clause = " deleted = false")
|
|
||||||
public class Section extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
private String code;
|
|
||||||
private String nom;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
private Structure structure;
|
|
||||||
|
|
||||||
//@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
|
||||||
//@JoinColumn(name = "section_id")
|
|
||||||
//@JsonManagedReference
|
|
||||||
//private List<Secteur> secteurs;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.frontend;
|
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Fonctionnalite extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
private String code;
|
|
||||||
private String nom;
|
|
||||||
private String lien;
|
|
||||||
@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT true")
|
|
||||||
private Boolean actif;
|
|
||||||
@ManyToOne
|
|
||||||
private ModuleApp moduleApp;
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.frontend;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ModuleApp extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
private String code;
|
|
||||||
private String nom;
|
|
||||||
private String lien;
|
|
||||||
@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT true")
|
|
||||||
private Boolean actif;
|
|
||||||
@JsonIgnore
|
|
||||||
@OneToMany(mappedBy = "moduleApp")
|
|
||||||
private List<Fonctionnalite> fonctionnalites;
|
|
||||||
}
|
|
||||||
@@ -55,9 +55,9 @@ public class ActeurConcerne extends BaseEntity implements Serializable {
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private RoleActeur roleActeur;
|
private RoleActeur roleActeur;
|
||||||
|
|
||||||
// @OneToMany(mappedBy = "acteurConcerne")
|
@OneToMany(mappedBy = "acteurConcerne")
|
||||||
// @JsonManagedReference
|
@JsonManagedReference
|
||||||
// private List<Piece> pieces;
|
private List<Piece> pieces;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ 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;
|
||||||
@@ -16,16 +15,18 @@ import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
|||||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Campagne;
|
import io.gmss.fiscad.entities.rfu.parametre.Campagne;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Equipe;
|
import io.gmss.fiscad.entities.rfu.parametre.Equipe;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Exercice;
|
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
|
import io.gmss.fiscad.entities.rfu.parametre.ZoneRfu;
|
||||||
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.StatusEnquete;
|
||||||
import io.gmss.fiscad.enums.StatutEnregistrement;
|
import io.gmss.fiscad.enums.StatutEnregistrement;
|
||||||
|
import io.gmss.fiscad.repositories.infocad.parametre.PersonneRepository;
|
||||||
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.annotations.SQLDelete;
|
||||||
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -55,29 +56,11 @@ 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
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
//@JsonIgnore
|
|
||||||
@ManyToOne
|
|
||||||
private Exercice exercice;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private ModeAcquisition modeAcquisition;
|
private User user;
|
||||||
|
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
|
|
||||||
@@ -85,7 +68,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
@OneToMany(mappedBy = "enquete")
|
@OneToMany(mappedBy = "enquete")
|
||||||
private List<ActeurConcerne> acteurConcernes;
|
private List<ActeurConcerne> acteurConcernes;
|
||||||
|
|
||||||
//@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Parcelle parcelle;
|
private Parcelle parcelle;
|
||||||
|
|
||||||
@@ -99,11 +82,11 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Campagne campagne;
|
private Campagne campagne;
|
||||||
|
|
||||||
// @JsonIgnore
|
@JsonIgnore
|
||||||
// @ManyToOne
|
@ManyToOne
|
||||||
// private Equipe equipe;
|
private Equipe equipe;
|
||||||
|
|
||||||
// @JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "proprietaire_id")
|
@JoinColumn(name = "proprietaire_id")
|
||||||
private Personne personne ;
|
private Personne personne ;
|
||||||
@@ -114,7 +97,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
private String autreNumeroTitreFoncier;
|
private String autreNumeroTitreFoncier;
|
||||||
private Long personneId;
|
private Long personneId;
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private StatutEnquete statutEnquete;
|
private StatusEnquete statusEnquete;
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateValidation;
|
private LocalDate dateValidation;
|
||||||
@@ -131,7 +114,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;
|
||||||
@@ -172,24 +155,18 @@ 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 numEntreeParcelle;
|
private String numEnterParcelle;
|
||||||
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 Integer nbreCoProprietaire;
|
private int nbreCoProprietaire;
|
||||||
private Integer nbreIndivisiaire;
|
private int nbreIndivisiaire;
|
||||||
private String autreAdresse;
|
private String autreAdresse;
|
||||||
private Float superficie ;
|
private String surface;
|
||||||
private Integer nbreBatiment;
|
private int nbreBatiment;
|
||||||
private Integer nbrePiscine;
|
private int nbrePiscine;
|
||||||
private Long montantMensuelleLocation;
|
|
||||||
private Long montantAnnuelleLocation;
|
|
||||||
private Long valeurParcelleEstime;
|
|
||||||
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)
|
||||||
@@ -199,27 +176,20 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateFinExcemption;
|
private LocalDate dateFinExcemption;
|
||||||
|
|
||||||
private String representantNom;
|
@JsonIgnore
|
||||||
private String representantPrenom;
|
@OneToMany(mappedBy = "enquete")
|
||||||
private String representantTel;
|
private List<EnqueteUniteLogement> enqueteUniteLogements;
|
||||||
private String representantNpi;
|
|
||||||
//
|
|
||||||
// @JsonIgnore
|
|
||||||
// @OneToMany(mappedBy = "enquete")
|
|
||||||
// @JsonManagedReference
|
|
||||||
// private List<EnqueteUniteLogement> enqueteUniteLogements;
|
|
||||||
|
|
||||||
// @JsonIgnore
|
@JsonIgnore
|
||||||
// @JsonManagedReference
|
@OneToMany(mappedBy = "enquete")
|
||||||
// @OneToMany(mappedBy = "enquete")
|
private List<EnqueteBatiment> enqueteBatiments;
|
||||||
// private List<EnqueteBatiment> enqueteBatiments;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@OneToMany(mappedBy = "enquete")
|
@OneToMany(mappedBy = "enquete")
|
||||||
private List<CaracteristiqueParcelle> caracteristiqueParcelles;
|
private List<CaracteristiqueParcelle> caracteristiqueParcelles;
|
||||||
|
|
||||||
//@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
//private StatutEnregistrement statutEnregistrement;
|
private StatutEnregistrement statutEnregistrement;
|
||||||
|
|
||||||
|
|
||||||
public Long getTerminalId() {
|
public Long getTerminalId() {
|
||||||
@@ -250,7 +220,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
public String getDepartement() {
|
public String getDepartement() {
|
||||||
if (this.bloc != null) {
|
if (this.bloc != null) {
|
||||||
Arrondissement arrondissement = this.bloc.getArrondissement();
|
Arrondissement arrondissement = this.bloc.getArrondissement();
|
||||||
if (arrondissement != null && arrondissement.getCommune()!=null && arrondissement.getCommune().getDepartement()!=null) {
|
if (arrondissement != null) {
|
||||||
return arrondissement.getCommune().getDepartement().getNom();
|
return arrondissement.getCommune().getDepartement().getNom();
|
||||||
} else return "";
|
} else return "";
|
||||||
} else return "";
|
} else return "";
|
||||||
@@ -259,7 +229,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
public String getCommune() {
|
public String getCommune() {
|
||||||
if (this.bloc != null) {
|
if (this.bloc != null) {
|
||||||
Arrondissement arrondissement = this.bloc.getArrondissement();
|
Arrondissement arrondissement = this.bloc.getArrondissement();
|
||||||
if (arrondissement != null && arrondissement.getCommune()!=null) {
|
if (arrondissement != null) {
|
||||||
return arrondissement.getCommune().getNom();
|
return arrondissement.getCommune().getNom();
|
||||||
} else return "";
|
} else return "";
|
||||||
} else return "";
|
} else return "";
|
||||||
@@ -277,7 +247,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
public String getTypeDomaine() {
|
public String getTypeDomaine() {
|
||||||
if (this.parcelle != null) {
|
if (this.parcelle != null) {
|
||||||
NatureDomaine natureDomaine = this.parcelle.getNatureDomaine();
|
NatureDomaine natureDomaine = this.parcelle.getNatureDomaine();
|
||||||
if (natureDomaine != null && natureDomaine.getTypeDomaine()!=null ) {
|
if (natureDomaine != null) {
|
||||||
return natureDomaine.getTypeDomaine().getLibelle();
|
return natureDomaine.getTypeDomaine().getLibelle();
|
||||||
} else return "";
|
} else return "";
|
||||||
} else return "";
|
} else return "";
|
||||||
@@ -290,7 +260,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getStructureEnqueteur() {
|
public String getStructureEnqueteur() {
|
||||||
if (this.user != null && this.user.getStructure()!=null) {
|
if (this.user != null) {
|
||||||
return this.user.getStructure().getNom();
|
return this.user.getStructure().getNom();
|
||||||
} else return "";
|
} else return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
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;
|
||||||
@@ -17,7 +12,6 @@ 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)
|
||||||
@@ -31,6 +25,7 @@ import java.util.List;
|
|||||||
// "WHERE id = ?")
|
// "WHERE id = ?")
|
||||||
//@Where(clause = " deleted = false")
|
//@Where(clause = " deleted = false")
|
||||||
public class Parcelle extends BaseEntity implements Serializable {
|
public class Parcelle extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -41,49 +36,30 @@ public class Parcelle extends BaseEntity implements Serializable {
|
|||||||
private String numeroParcelle;
|
private String numeroParcelle;
|
||||||
private String longitude;
|
private String longitude;
|
||||||
private String latitude;
|
private String latitude;
|
||||||
private String altitude;
|
|
||||||
private String situationGeographique;
|
private String situationGeographique;
|
||||||
@ColumnDefault("0.0")
|
@ColumnDefault("0")
|
||||||
private Float superficie;
|
private int 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 numeroTitreFoncier;
|
private String numTitreFoncier;
|
||||||
private LocalDate dateTitreFoncier ;
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Tpe terminal;
|
private Tpe terminal;
|
||||||
private String autreNumeroTitreFoncier;
|
private String autreNumeroTitreFoncier;
|
||||||
private String numeroProvisoire;
|
|
||||||
|
private Long typeDomaineId;
|
||||||
|
private Long numeroProvisoire;
|
||||||
private Long blocId;
|
private Long blocId;
|
||||||
@ColumnDefault("false")
|
@ColumnDefault("false")
|
||||||
private boolean synchronise;
|
private boolean synchronise;
|
||||||
private Long idDerniereEnquete;
|
private Long idDerniereEnquete;
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
private String numEntreeParcelle;
|
|
||||||
private String codeQuartier;
|
|
||||||
@ManyToOne
|
|
||||||
private Rue rue ;
|
|
||||||
private String numeroRue ;
|
|
||||||
private Boolean batie;
|
|
||||||
private Integer nombrePiscine;
|
|
||||||
@ManyToOne
|
|
||||||
private Usage usage;
|
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
|
||||||
private LocalDate dateDebutExemption;
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
|
||||||
private LocalDate dateFinExemption;
|
|
||||||
// private String ncProprietaire ;
|
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
// @OneToMany(mappedBy = "parcelle")
|
// @OneToMany(mappedBy = "parcelle")
|
||||||
// private List<Batiment> batiments;
|
// private List<Batiment> batiments;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.gmss.fiscad.entities.infocad.metier;
|
package io.gmss.fiscad.entities.infocad.metier;
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
@@ -10,7 +9,6 @@ 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;
|
||||||
@@ -25,7 +23,6 @@ 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
|
||||||
@@ -41,96 +38,64 @@ 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;
|
||||||
@Enumerated(EnumType.STRING)
|
private String sourceDonnees;
|
||||||
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;
|
||||||
|
@ManyToOne
|
||||||
@ManyToOne //(fetch = FetchType.LAZY)
|
|
||||||
// @JsonBackReference
|
|
||||||
private Departement departement;
|
private Departement departement;
|
||||||
|
@ManyToOne
|
||||||
@ManyToOne //(fetch = FetchType.LAZY)
|
|
||||||
//@JsonBackReference
|
|
||||||
private Commune commune;
|
private Commune commune;
|
||||||
|
@ManyToOne
|
||||||
@ManyToOne //(fetch = FetchType.LAZY)
|
|
||||||
// @JsonBackReference
|
|
||||||
private Arrondissement arrondissement;
|
private Arrondissement arrondissement;
|
||||||
|
@ManyToOne
|
||||||
@ManyToOne //(fetch = FetchType.LAZY)
|
|
||||||
@JsonBackReference
|
|
||||||
private Quartier quartier ;
|
private Quartier quartier ;
|
||||||
|
|
||||||
@ColumnDefault("0")
|
@ColumnDefault("0")
|
||||||
private Integer geomSrid;
|
private int 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;
|
||||||
|
|
||||||
@JsonIgnore
|
//private String elLot;
|
||||||
@ManyToOne
|
//private String elLettreParcelle;
|
||||||
@JsonBackReference
|
//private String rfuQuartierOuZone;
|
||||||
private Parcelle parcelle;
|
//private String rfuIlot;
|
||||||
|
//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)")
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
|||||||
import io.gmss.fiscad.entities.infocad.parametre.SourceDroit;
|
import io.gmss.fiscad.entities.infocad.parametre.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;
|
||||||
@@ -24,7 +22,6 @@ import org.hibernate.annotations.Where;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@@ -47,10 +44,6 @@ public class Piece extends BaseEntity implements Serializable {
|
|||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateExpiration;
|
private LocalDate dateExpiration;
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
|
||||||
private LocalDate dateEtablissement;
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private TypePiece typePiece;
|
private TypePiece typePiece;
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
@@ -58,38 +51,21 @@ public class Piece extends BaseEntity implements Serializable {
|
|||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Personne personne;
|
private Personne personne;
|
||||||
private Long personneExternalKey;
|
private Long personneExternalKey;
|
||||||
|
@JsonIgnore
|
||||||
// @JsonIgnore
|
@JsonBackReference
|
||||||
// @JsonBackReference
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
private ActeurConcerne acteurConcerne;
|
||||||
// private ActeurConcerne acteurConcerne;
|
private Long acteurConcerneExternalKey;
|
||||||
// private Long acteurConcerneExternalKey;
|
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private SourceDroit sourceDroit;
|
private SourceDroit sourceDroit;
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@JsonBackReference
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
private Enquete enquete ;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@JsonBackReference
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
private EnqueteBatiment enqueteBatiment ;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@JsonBackReference
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
private EnqueteUniteLogement enqueteUniteLogement ;
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private ModeAcquisition modeAcquisition;
|
private ModeAcquisition modeAcquisition;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "piece")
|
@OneToMany(mappedBy = "piece")
|
||||||
private List<Upload> uploads=new ArrayList<>();
|
private List<Upload> uploads;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@@ -98,15 +74,10 @@ public class Piece extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
private Long max_numero_piece_id;
|
private Long max_numero_piece_id;
|
||||||
private Long max_numero_acteur_concerne_id;
|
private Long max_numero_acteur_concerne_id;
|
||||||
//private Long enqueteId;
|
private Long enqueteId;
|
||||||
private Long blocId;
|
private Long blocId;
|
||||||
@ColumnDefault("false")
|
@ColumnDefault("false")
|
||||||
private boolean synchronise;
|
private boolean synchronise;
|
||||||
private String observation;
|
private String observation;
|
||||||
|
|
||||||
private Long nombreFichier;
|
|
||||||
|
|
||||||
public Long getNombreFichier() {
|
|
||||||
return uploads==null? 0l:uploads.size() ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.infocad.metier;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.TypeRue;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.hibernate.annotations.SQLDelete;
|
|
||||||
import org.hibernate.annotations.Where;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Rue extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
private String numero ;
|
|
||||||
private String nom ;
|
|
||||||
@ManyToOne
|
|
||||||
private TypeRue typeRue ;
|
|
||||||
}
|
|
||||||
@@ -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();
|
||||||
//System.out.println(url);
|
if(!url.contains("8282/api")){
|
||||||
// if(!url.contains("8282/api")){
|
url.replace("/api",":8282/api");
|
||||||
// url.replace("/api",":8282/api");
|
}
|
||||||
// }
|
|
||||||
//System.out.println(url);
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user