Compare commits
11 Commits
features/c
...
69af57f876
| Author | SHA1 | Date | |
|---|---|---|---|
| 69af57f876 | |||
| c80b40082c | |||
| 56f78e77f3 | |||
| 4a88af6487 | |||
| 0c7dc082fd | |||
| 966b0af1c2 | |||
| 3f5d7e980c | |||
| 58aa088ac3 | |||
| 87be4e4483 | |||
| 033b430051 | |||
| b8dbc7f625 |
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
|
||||||
@@ -1,48 +1,52 @@
|
|||||||
name: CD - Deploy on main
|
name: CD - Deploy on main
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: [self-hosted, prod]
|
runs-on: self-hosted
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# 1) S'assurer que Node.js est installé
|
||||||
# 1) Vérifier Node.js (pas d'installation dynamique)
|
- name: Ensure Node.js is installed
|
||||||
- name: Verify Node.js
|
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
if command -v node >/dev/null 2>&1; then
|
if command -v node >/dev/null 2>&1; then
|
||||||
echo "Node.js version:"
|
echo "Node.js already installed: $(node -v)"
|
||||||
node -v
|
|
||||||
else
|
else
|
||||||
echo "❌ Node.js is not installed on the runner"
|
echo "Node.js not found, installing..."
|
||||||
exit 1
|
apk update && apk add --no-cache nodejs
|
||||||
|
echo "Node.js installed: $(node -v)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2) Vérifier Java 17 & Maven (préinstallés sur le VPS)
|
# 2) S'assurer que Java & Maven sont installés
|
||||||
- name: Verify Java & Maven
|
- name: Ensure Java & Maven are installed
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
if ! command -v java >/dev/null 2>&1; then
|
if command -v java >/dev/null 2>&1; then
|
||||||
echo "❌ Java is not installed on the runner"
|
echo "Java already installed:"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v mvn >/dev/null 2>&1; then
|
|
||||||
echo "❌ Maven is not installed on the runner"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Java version:"
|
|
||||||
java -version
|
java -version
|
||||||
echo "Maven version:"
|
else
|
||||||
mvn -version
|
echo "Java not found, installing OpenJDK 17..."
|
||||||
|
apk update && apk add --no-cache openjdk17-jdk
|
||||||
|
echo "Java installed:"
|
||||||
|
java -version
|
||||||
|
fi
|
||||||
|
|
||||||
# 3) Détecter JAVA_HOME dynamiquement
|
if command -v mvn >/dev/null 2>&1; then
|
||||||
|
echo "Maven already installed:"
|
||||||
|
mvn -version
|
||||||
|
else
|
||||||
|
echo "Maven not found, installing Maven..."
|
||||||
|
apk update && apk add --no-cache maven
|
||||||
|
echo "Maven installed:"
|
||||||
|
mvn -version
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3) Détecter JAVA_HOME dynamiquement et le propager
|
||||||
- name: Detect JAVA_HOME dynamically
|
- name: Detect JAVA_HOME dynamically
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
@@ -55,88 +59,60 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 5) Informations de contexte (sans secrets)
|
# 5) Afficher quelques infos utiles
|
||||||
- name: Show context information
|
- name: Show current commit and tools
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
echo "Commit:"
|
echo "Current commit:"
|
||||||
git rev-parse HEAD
|
git rev-parse HEAD
|
||||||
echo "JAVA_HOME=$JAVA_HOME"
|
echo "JAVA_HOME is: $JAVA_HOME"
|
||||||
java -version
|
java -version
|
||||||
mvn -version
|
mvn -version
|
||||||
docker --version
|
|
||||||
docker-compose --version || docker compose version
|
|
||||||
|
|
||||||
# 6) Export de la configuration NON sensible
|
# 6) S'assurer que le client Docker + docker-compose sont installés
|
||||||
- name: Export database configuration
|
- name: Ensure Docker CLI is installed
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
echo "POSTGRES_DB_FISCAD=fiscad_db" >> "$GITHUB_ENV"
|
if command -v docker >/dev/null 2>&1; then
|
||||||
echo "POSTGRES_USER_FISCAD=fiscad_user" >> "$GITHUB_ENV"
|
echo "Docker CLI already installed:"
|
||||||
|
docker version || true
|
||||||
|
else
|
||||||
|
echo "Docker CLI not found, installing..."
|
||||||
|
apk update && apk add --no-cache docker docker-compose
|
||||||
|
echo "Docker CLI installed:"
|
||||||
|
docker version || true
|
||||||
|
fi
|
||||||
|
|
||||||
# 7) Création des secrets runtime (PRODUCTION)
|
# 7) Générer le .env utilisé par docker-compose-prod.yml
|
||||||
- name: Create runtime secrets
|
- name: Generate .env from Gitea secrets
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
mkdir -p secrets
|
cat > .env <<EOF
|
||||||
echo "${{ secrets.DEFAULT_USER_NAME }}" > secrets/defaultUserName.txt
|
POSTGRES_DB_FISCAD=${{ secrets.POSTGRES_DB_FISCAD }}
|
||||||
echo "${{ secrets.DEFAULT_USER_PASSWORD }}" > secrets/defaultUserPassword.txt
|
POSTGRES_USER_FISCAD=${{ secrets.POSTGRES_USER_FISCAD }}
|
||||||
echo "${{ secrets.POSTGRES_PASSWORD_FISCAD }}" > secrets/postgresPassword.txt
|
POSTGRES_PASSWORD_FISCAD=${{ secrets.POSTGRES_PASSWORD_FISCAD }}
|
||||||
chmod 600 secrets/*
|
EOF
|
||||||
|
echo "Generated .env:"
|
||||||
|
cat .env
|
||||||
|
|
||||||
# 8) Build Maven (jar final)
|
# 8) Build Maven pour générer le jar dans target/
|
||||||
- name: Build backend with Maven
|
- name: Build backend with Maven
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: mvn -B clean package
|
||||||
mvn -B clean package -DskipTests
|
|
||||||
|
|
||||||
# 9) Déploiement avec docker-compose (prod)
|
# 9) Déploiement en prod avec docker-compose-prod.yml
|
||||||
- name: Deploy using docker-compose (prod)
|
- name: Deploy using docker-compose (prod)
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
|
# IMPORTANT : on fixe le nom du projet compose
|
||||||
export COMPOSE_PROJECT_NAME=fiscad
|
export COMPOSE_PROJECT_NAME=fiscad
|
||||||
|
|
||||||
cd "$GITHUB_WORKSPACE"
|
# Puis on déploie avec un nom de projet fixe
|
||||||
echo "Workspace: $(pwd)"
|
|
||||||
cat secrets/postgresPassword.txt
|
|
||||||
echo "POSTGRES_DB_FISCAD=$POSTGRES_DB_FISCAD"
|
|
||||||
echo "POSTGRES_USER_FISCAD=$POSTGRES_USER_FISCAD"
|
|
||||||
ls -l secrets/
|
|
||||||
|
|
||||||
docker-compose -f docker-compose-prod.yml pull || true
|
docker-compose -f docker-compose-prod.yml pull || true
|
||||||
docker-compose -f docker-compose-prod.yml down --remove-orphans
|
docker-compose -f docker-compose-prod.yml down --remove-orphans
|
||||||
docker-compose -f docker-compose-prod.yml up -d --build
|
docker-compose -f docker-compose-prod.yml up -d --build
|
||||||
|
|
||||||
# 10) Test bloquant : connexion PostgreSQL
|
# 10) Nettoyage des images non utilisées
|
||||||
- name: Test database connection
|
- name: Cleanup unused images
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: docker image prune -f || true
|
||||||
echo "⏳ Waiting for PostgreSQL to be ready..."
|
|
||||||
for i in $(seq 1 12); do
|
|
||||||
if docker exec fiscad-db pg_isready -U ${POSTGRES_USER_FISCAD} >/dev/null 2>&1; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "🔍 Testing database connection..."
|
|
||||||
docker exec fiscad-db sh -c "
|
|
||||||
export PGPASSWORD=\$(cat /run/secrets/postgresPassword) &&
|
|
||||||
psql -h localhost \
|
|
||||||
-U ${POSTGRES_USER_FISCAD} \
|
|
||||||
-d ${POSTGRES_DB_FISCAD} \
|
|
||||||
-c 'SELECT 1;'
|
|
||||||
"
|
|
||||||
|
|
||||||
# 11) OK Nettoyage des secrets (sécurité OBLIGATOIRE)
|
|
||||||
- name: Cleanup secrets
|
|
||||||
if: always()
|
|
||||||
shell: sh
|
|
||||||
run: |
|
|
||||||
rm -rf secrets
|
|
||||||
|
|
||||||
# 12) Nettoyage des images Docker inutilisées
|
|
||||||
- name: Cleanup unused Docker images
|
|
||||||
shell: sh
|
|
||||||
run: |
|
|
||||||
docker image prune -f || true
|
|
||||||
@@ -10,39 +10,43 @@ jobs:
|
|||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# 1) S'assurer que Node.js est installé (utile pour les actions JS comme actions/checkout)
|
||||||
# 1) Vérifier Node.js (aucune installation automatique en CI natif)
|
- name: Ensure Node.js is installed
|
||||||
- name: Verify Node.js
|
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
if command -v node >/dev/null 2>&1; then
|
if command -v node >/dev/null 2>&1; then
|
||||||
echo "Node.js version:"
|
echo "Node.js already installed: $(node -v)"
|
||||||
node -v
|
|
||||||
else
|
else
|
||||||
echo "❌ Node.js is not installed on the runner"
|
echo "Node.js not found, installing..."
|
||||||
exit 1
|
apk update && apk add --no-cache nodejs
|
||||||
|
echo "Node.js installed: $(node -v)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2) Vérifier Java & Maven (préinstallés sur le VPS)
|
# 2) S'assurer que Java + Maven sont installés
|
||||||
- name: Verify Java & Maven
|
- name: Ensure Java & Maven are installed
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
if ! command -v java >/dev/null 2>&1; then
|
if command -v java >/dev/null 2>&1; then
|
||||||
echo "❌ Java is not installed on the runner"
|
echo "Java already installed:"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v mvn >/dev/null 2>&1; then
|
|
||||||
echo "❌ Maven is not installed on the runner"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Java version:"
|
|
||||||
java -version
|
java -version
|
||||||
echo "Maven version:"
|
else
|
||||||
mvn -version
|
echo "Java not found, installing OpenJDK 17..."
|
||||||
|
apk update && apk add --no-cache openjdk17-jdk
|
||||||
|
echo "Java installed:"
|
||||||
|
java -version
|
||||||
|
fi
|
||||||
|
|
||||||
# 3) Détecter JAVA_HOME dynamiquement
|
if command -v mvn >/dev/null 2>&1; then
|
||||||
|
echo "Maven already installed:"
|
||||||
|
mvn -version
|
||||||
|
else
|
||||||
|
echo "Maven not found, installing Maven..."
|
||||||
|
apk update && apk add --no-cache maven
|
||||||
|
echo "Maven installed:"
|
||||||
|
mvn -version
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3) Détecter automatiquement JAVA_HOME et le propager au reste du job
|
||||||
- name: Detect JAVA_HOME dynamically
|
- name: Detect JAVA_HOME dynamically
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
@@ -51,29 +55,19 @@ jobs:
|
|||||||
echo "Detected JAVA_HOME=$JAVA_HOME"
|
echo "Detected JAVA_HOME=$JAVA_HOME"
|
||||||
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 (Node est déjà garanti à ce stade)
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 5) Création des secrets runtime (CI uniquement)
|
# 5) Vérification des versions (pour les logs)
|
||||||
- name: Create runtime secrets
|
- name: Show Java & Maven versions
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
mkdir -p secrets
|
echo "JAVA_HOME is: $JAVA_HOME"
|
||||||
echo "${{ secrets.DEFAULT_USER_NAME }}" > secrets/defaultUserName.txt
|
java -version
|
||||||
echo "${{ secrets.DEFAULT_USER_PASSWORD }}" > secrets/defaultUserPassword.txt
|
mvn -version
|
||||||
echo "${{ secrets.POSTGRES_PASSWORD_FISCAD }}" > secrets/postgresPassword.txt
|
|
||||||
chmod 600 secrets/*
|
|
||||||
|
|
||||||
# 6) Build & tests Maven
|
# 6) Build Maven
|
||||||
- name: Build & Test with Maven
|
- name: Build with Maven
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: mvn -B clean verify
|
||||||
mvn -B clean verify
|
|
||||||
|
|
||||||
# 7) Nettoyage des secrets (sécurité)
|
|
||||||
- name: Cleanup secrets
|
|
||||||
if: always()
|
|
||||||
shell: sh
|
|
||||||
run: |
|
|
||||||
rm -rf secrets
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,5 +3,3 @@ fiscad.log*
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
target/*
|
target/*
|
||||||
ansible
|
ansible
|
||||||
secrets/
|
|
||||||
.env
|
|
||||||
@@ -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,76 +1,46 @@
|
|||||||
|
version: '3.9'
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB_FISCAD}
|
POSTGRES_DB: ${POSTGRES_DB_FISCAD}
|
||||||
POSTGRES_USER: ${POSTGRES_USER_FISCAD}
|
POSTGRES_USER: ${POSTGRES_USER_FISCAD}
|
||||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgresPassword
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD_FISCAD}
|
||||||
|
|
||||||
secrets:
|
|
||||||
- postgresPassword
|
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: fiscad-app
|
container_name: fiscad-app
|
||||||
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: ${POSTGRES_PASSWORD_FISCAD}
|
||||||
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_PASSWORD_FILE: /run/secrets/defaultUserPassword
|
|
||||||
|
|
||||||
secrets:
|
|
||||||
- postgresPassword
|
|
||||||
- defaultUserName
|
|
||||||
- defaultUserPassword
|
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "8282:8282"
|
- "8282:8282"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- /fiscad/uploads:/app/uploads
|
- /fiscad/uploads:/app/uploads
|
||||||
- /fiscad/jasperReport:/app/jasperReport
|
- /fiscad/jasperReport:/app/jasperReport
|
||||||
- /fiscad/logs:/app/logs
|
- /fiscad/logs:/app/logs
|
||||||
|
restart: on-failure
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db-data-fiscad:
|
db-data-fiscad:
|
||||||
|
|
||||||
|
|
||||||
secrets:
|
|
||||||
postgresPassword:
|
|
||||||
file: ./secrets/postgresPassword.txt
|
|
||||||
defaultUserName:
|
|
||||||
file: ./secrets/defaultUserName.txt
|
|
||||||
defaultUserPassword:
|
|
||||||
file: ./secrets/defaultUserPassword.txt
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#version: '3.9'
|
version: '3.9'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
@@ -6,73 +6,41 @@ services:
|
|||||||
image: postgres:15
|
image: postgres:15
|
||||||
container_name: fiscad-db
|
container_name: fiscad-db
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB_FISCAD}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
POSTGRES_USER: ${POSTGRES_USER_FISCAD}
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgresPassword
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
|
||||||
secrets:
|
|
||||||
- postgresPassword
|
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- db-data:/var/lib/postgresql/data
|
- db-data:/var/lib/postgresql/data
|
||||||
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: fiscad-app
|
container_name: fiscad-app
|
||||||
restart: on-failure
|
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB_FISCAD}
|
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB}
|
||||||
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER_FISCAD}
|
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER}
|
||||||
SPRING_DATASOURCE_PASSWORD_FILE: /run/secrets/postgresPassword
|
SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
|
||||||
SERVER_PORT: 8282
|
SERVER_PORT: 8282
|
||||||
IO_GMSS_FISCAD_PROFILE: dgi
|
IO_GMSS_FISCAD_PROFILE: dgi
|
||||||
SPRING_PROFILES_ACTIVE: dgi
|
SPRING_PROFILES_ACTIVE: dgi
|
||||||
|
|
||||||
# 🔐 Secrets Spring (fichiers)
|
|
||||||
DEFAULT_USER_NAME_FILE: /run/secrets/defaultUserName
|
|
||||||
DEFAULT_USER_PASSWORD_FILE: /run/secrets/defaultUserPassword
|
|
||||||
|
|
||||||
secrets:
|
|
||||||
- defaultUserName
|
|
||||||
- defaultUserPassword
|
|
||||||
- postgresPassword
|
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "8282:8282"
|
- "8282:8282"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./uploads:/app/uploads
|
- ./uploads:/app/uploads
|
||||||
- ./jasperReport:/app/jasperReport
|
- ./jasperReport:/app/jasperReport
|
||||||
- ./logs:/app/logs
|
- ./logs:/app/logs
|
||||||
|
restart: on-failure
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db-data:
|
db-data:
|
||||||
|
|
||||||
|
|
||||||
secrets:
|
|
||||||
defaultUserName:
|
|
||||||
file: /secrets/defaultUserName.txt
|
|
||||||
defaultUserPassword:
|
|
||||||
file: ./secrets/defaultUserPassword.txt
|
|
||||||
postgresPassword:
|
|
||||||
file: ./secrets/postgresPassword.txt
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
infocad_admin
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
admin@123
|
|
||||||
@@ -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,12 +20,8 @@ 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("${app.sourcemind.env.defaultpassword}")
|
||||||
private String usernameFile;
|
private String defaultPassword;
|
||||||
|
|
||||||
@Value("${app.default-user.password}")
|
|
||||||
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;
|
||||||
@@ -42,25 +38,32 @@ 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.countAllByUsernameIsNotNull() == 0) {
|
||||||
User admin = new User();
|
User admin = new User();
|
||||||
admin.setUsername(usernameFile);
|
admin.setUsername("administrateur@infocad.bj");
|
||||||
admin.setEmail("administrateur@infocad.bj");
|
admin.setEmail("administrateur@infocad.bj");
|
||||||
admin.setTel("N/A");
|
admin.setTel("N/A");
|
||||||
admin.setNom("Administrateur");
|
admin.setNom("Administrateur");
|
||||||
admin.setPrenom("Principal");
|
admin.setPrenom("Principal");
|
||||||
admin.setPassword(passwordEncoder.encode(passwordFile));
|
admin.setPassword(passwordEncoder.encode(defaultPassword));
|
||||||
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,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;
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ import io.swagger.v3.oas.annotations.servers.Server;
|
|||||||
@OpenAPIDefinition(
|
@OpenAPIDefinition(
|
||||||
info = @Info(
|
info = @Info(
|
||||||
contact = @Contact(
|
contact = @Contact(
|
||||||
name = "ABS Company Bénin",
|
name = "Novatic",
|
||||||
email = "contact@abs.org",
|
email = "contact@novatic.org",
|
||||||
url = "https://abs.org"
|
url = "https://novatic.org"
|
||||||
),
|
),
|
||||||
description = "Cette page présente toutes les ressources API pour la gestion des données socio-foncières et fiscales",
|
description = "Cette page présente toutes les ressources API pour la gestion des données socio-foncières et fiscales",
|
||||||
title = "FISCAD",
|
title = "FISCAD",
|
||||||
version = "1.0",
|
version = "1.0",
|
||||||
license = @License(
|
license = @License(
|
||||||
name = "Licence name",
|
name = "Licence name",
|
||||||
url = "https://abs.org"
|
url = "https://novatic.org"
|
||||||
),
|
),
|
||||||
termsOfService = "Terms of service"
|
termsOfService = "Terms of service"
|
||||||
),
|
),
|
||||||
@@ -33,7 +33,7 @@ import io.swagger.v3.oas.annotations.servers.Server;
|
|||||||
),
|
),
|
||||||
@Server(
|
@Server(
|
||||||
description = "TEST ENV (http)",
|
description = "TEST ENV (http)",
|
||||||
url = "https://backend.fiscad-test.novatic.org"
|
url = "http://novatic.vps.webdock.cloud:8282"
|
||||||
),
|
),
|
||||||
@Server(
|
@Server(
|
||||||
description = "PROD ENV (https)",
|
description = "PROD ENV (https)",
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Arrondissement")
|
@Tag(name = "Arrondissement")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
//@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
@PreAuthorize("hasRole('ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class ArrondissementController {
|
public class ArrondissementController {
|
||||||
|
|
||||||
private final ArrondissementService arrondissementService;
|
private final ArrondissementService arrondissementService;
|
||||||
@@ -175,7 +175,7 @@ public class ArrondissementController {
|
|||||||
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, arrondissementService.getArrondissementById(id).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) {
|
||||||
@@ -199,31 +199,7 @@ public class ArrondissementController {
|
|||||||
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, arrondissementService.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}")
|
|
||||||
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;
|
||||||
@@ -185,31 +185,7 @@ public class CommuneController {
|
|||||||
|
|
||||||
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}")
|
|
||||||
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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@SecurityRequirement(name = "bearer")
|
@SecurityRequirement(name = "bearer")
|
||||||
@Tag(name = "Quartier")
|
@Tag(name = "Quartier")
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
||||||
public class QuartierController {
|
public class QuartierController {
|
||||||
|
|
||||||
private final QuartierService quartierService;
|
private final QuartierService quartierService;
|
||||||
@@ -158,7 +158,7 @@ public class QuartierController {
|
|||||||
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
|
public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, quartierService.getQuartierById(id).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) {
|
||||||
@@ -182,31 +182,7 @@ public class QuartierController {
|
|||||||
|
|
||||||
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}")
|
|
||||||
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,9 +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.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;
|
||||||
@@ -26,7 +24,7 @@ import org.springframework.web.client.HttpClientErrorException;
|
|||||||
@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;
|
||||||
@@ -36,16 +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")
|
||||||
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPaylaodWeb secteurPaylaodWeb) {
|
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) {
|
||||||
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) {
|
||||||
@@ -64,15 +60,12 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "mettre à jour un secteur",
|
|
||||||
description = "Permet de modifier un secteur"
|
|
||||||
)
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPaylaodWeb secteurPayloadWeb) {
|
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPayload secteurPayload) {
|
||||||
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) {
|
||||||
@@ -90,10 +83,7 @@ public class SecteurController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Operation(
|
|
||||||
summary = "supprimer un secteur",
|
|
||||||
description = "Permet de supprimer un secteur"
|
|
||||||
)
|
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
@@ -117,10 +107,7 @@ public class SecteurController {
|
|||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les secteurs",
|
|
||||||
description = "Permet de récuperer l'ensemble des secteurs"
|
|
||||||
)
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
public ResponseEntity<?> getAllSecteurList() {
|
public ResponseEntity<?> getAllSecteurList() {
|
||||||
try {
|
try {
|
||||||
@@ -144,10 +131,6 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les secteurs avec pagination",
|
|
||||||
description = "Permet de récuperer l'ensemble des secteurs avec pagination"
|
|
||||||
)
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
@@ -172,10 +155,6 @@ public class SecteurController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer un secteurs par son ID ",
|
|
||||||
description = "Permet de récuperer le secteur ayant l'ID fournie en path"
|
|
||||||
)
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
|
public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
@@ -199,15 +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}")
|
||||||
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) {
|
||||||
@@ -227,92 +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}")
|
|
||||||
public ResponseEntity<?> getSecteurByStructureIdPage(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurService.getSecteurListByStructureId(structureId,pageable), "Secteur trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les secteurs d'une section",
|
|
||||||
description = "Permet de récuperer l'ensemble des secteurs de la section dont l'ID est fourni en path"
|
|
||||||
)
|
|
||||||
@GetMapping("/by-section-id/{sectionId}")
|
|
||||||
public ResponseEntity<?> getSecteurBySectionId(@PathVariable Long sectionId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurService.getSecteurListBySectionId(sectionId), "Secteur trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les secteurs d'une section avec pagination",
|
|
||||||
description = "Permet de récuperer l'ensemble des secteurs de la section dont l'ID est fourni en path avec pagination"
|
|
||||||
)
|
|
||||||
@GetMapping("/page/by-section-id/{sectionId}")
|
|
||||||
public ResponseEntity<?> getSecteurBySectionIdPage(@PathVariable Long sectionId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurService.getSecteurListBySectionId(sectionId,pageable), "Secteur trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,10 @@ package io.gmss.fiscad.controllers.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
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;
|
||||||
@@ -21,26 +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")
|
||||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
|
||||||
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) {
|
||||||
@@ -60,10 +60,10 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) {
|
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
|
||||||
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) {
|
||||||
@@ -153,82 +153,11 @@ public class SecteurDecoupageController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/by-secteur-id/{secteurId}")
|
|
||||||
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurId(@PathVariable Long secteurId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId), "Liste des secteurDecoupages chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/page/by-secteur-decoupage-id/{secteurId}")
|
|
||||||
public ResponseEntity<?> getAllSecteurDecoupageListBySecteurIdPaged(@PathVariable Long secteurId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageListBySecteurId(secteurId,pageable), "Liste des secteurDecoupages chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageByIdToDto(id), "SecteurDecoupage trouvée avec succès."),
|
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
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/user-id/{userId}")
|
|
||||||
public ResponseEntity<?> getArborescenceByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, secteurDecoupageService.getStatParcelleDecoupageByUserId(userId), "SecteurDecoupage trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
|||||||
@@ -1,255 +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.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/section", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
//@SecurityRequirement(name = "bearer")
|
|
||||||
@Tag(name = "Section")
|
|
||||||
//@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_SUPERVISEUR')")
|
|
||||||
public class SectionController {
|
|
||||||
|
|
||||||
private final SectionService sectionService;
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SectionController.class);
|
|
||||||
|
|
||||||
public SectionController(SectionService sectionService) {
|
|
||||||
this.sectionService = sectionService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "Créer un section",
|
|
||||||
description = "Permet de Créer un section"
|
|
||||||
)
|
|
||||||
@PostMapping("/create")
|
|
||||||
public ResponseEntity<?> createSection(@RequestBody @Valid @Validated SectionPaylaodWeb sectionPaylaodWeb) {
|
|
||||||
try {
|
|
||||||
sectionPaylaodWeb = sectionService.createSection(sectionPaylaodWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionPaylaodWeb, "Section créé avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "mettre à jour un section",
|
|
||||||
description = "Permet de modifier un section"
|
|
||||||
)
|
|
||||||
@PutMapping("/update/{id}")
|
|
||||||
public ResponseEntity<?> updateSection(@PathVariable Long id, @RequestBody SectionPaylaodWeb sectionPayloadWeb) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionService.updateSection(id, sectionPayloadWeb), "Section mis à jour avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Operation(
|
|
||||||
summary = "supprimer un section",
|
|
||||||
description = "Permet de supprimer un section"
|
|
||||||
)
|
|
||||||
@DeleteMapping("/delete/{id}")
|
|
||||||
public ResponseEntity<?> deleteSection(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
sectionService.deleteSection(id);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, "Section supprimée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les sections",
|
|
||||||
description = "Permet de récuperer l'ensemble des sections"
|
|
||||||
)
|
|
||||||
@GetMapping("/all")
|
|
||||||
public ResponseEntity<?> getAllSectionList() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionService.getSectionList(), "Liste des sections chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les sections avec pagination",
|
|
||||||
description = "Permet de récuperer l'ensemble des sections avec pagination"
|
|
||||||
)
|
|
||||||
@GetMapping("/all-paged")
|
|
||||||
public ResponseEntity<?> getAllSectionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionService.getSectionList(pageable), "Liste des sections chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer un sections par son ID ",
|
|
||||||
description = "Permet de récuperer le section ayant l'ID fournie en path"
|
|
||||||
)
|
|
||||||
@GetMapping("/id/{id}")
|
|
||||||
public ResponseEntity<?> getSectionById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionService.getSectionById(id).orElse(null), "Section trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les sections d'une structure",
|
|
||||||
description = "Permet de récuperer l'ensemble des sections de la structure dont l'ID est fourni en path"
|
|
||||||
)
|
|
||||||
@GetMapping("/by-structure-id/{structureId}")
|
|
||||||
public ResponseEntity<?> getSectionByStructureId(@PathVariable Long structureId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionService.getSectionListByStructureId(structureId), "Section trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "recuperer tous les sections d'une structure",
|
|
||||||
description = "Permet de récuperer l'ensemble des sections de la structure dont l'ID est fourni en path avec pagination"
|
|
||||||
)
|
|
||||||
@GetMapping("/page/by-structure-id/{structureId}")
|
|
||||||
public ResponseEntity<?> getSectionByStructureIdPage(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, sectionService.getSectionListByStructureId(structureId,pageable), "Section trouvée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
@@ -229,7 +229,7 @@ public class CommentaireController {
|
|||||||
}
|
}
|
||||||
@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")
|
||||||
//@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")
|
//@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")
|
||||||
public ResponseEntity<?> getcommentaireByParams(@RequestBody CommentaireRequest commentaireRequest) {
|
public ResponseEntity<?> getcommentaireByParams(@RequestBody CommentaireRequest commentaireRequest) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -277,7 +277,7 @@ public class CommentaireController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("synchronise/from-web")
|
@PostMapping("synchronise/from-web")
|
||||||
//@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")
|
//@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")
|
||||||
public ResponseEntity<?> synchroniseCommentairesFromWeb(@RequestBody CommentaireRequest commentaireRequest) {
|
public ResponseEntity<?> synchroniseCommentairesFromWeb(@RequestBody CommentaireRequest commentaireRequest) {
|
||||||
try {
|
try {
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
|
|||||||
@@ -1,16 +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.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.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;
|
||||||
@@ -33,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;
|
||||||
@@ -46,51 +41,20 @@ public class EnqueteController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createEnquete(@RequestBody @Valid @Validated EnquetePayLoadWeb enquetePayLoadWeb) {
|
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated EnquetePayLoad enquetePayLoad) {
|
||||||
try {
|
// try{
|
||||||
Enquete enquete = enqueteService.createEnquete(enquetePayLoadWeb);
|
// enquete = enqueteService.createEnquete(enquete);
|
||||||
return new ResponseEntity<>(
|
// return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enquete, "Enquete batiment créé avec succès."),
|
// new ApiResponse<>(true, structure, "Structure créé avec succès."),
|
||||||
HttpStatus.OK
|
// HttpStatus.OK
|
||||||
);
|
// );
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
// }catch (Exception e){
|
||||||
logger.error(e.getLocalizedMessage());
|
// return new ResponseEntity<>(
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
// new ApiResponse<>(false, e.getMessage()),
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
// HttpStatus.OK
|
||||||
FileStorageException e) {
|
// );
|
||||||
logger.error(e.getLocalizedMessage());
|
// }
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
return null;
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
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<?> 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")
|
||||||
@@ -208,35 +172,6 @@ public class EnqueteController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "Récupérer les enquetes d'une parcelle",
|
|
||||||
description = "Permet de récuperer les enquêtes déjà réalisées sur une parcelles"
|
|
||||||
)
|
|
||||||
@GetMapping("/all/by-parcelle-id/{parcelleId}")
|
|
||||||
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin(@PathVariable Long parcelleId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteService.getEnqueteListByParcelle(parcelleId), "Liste des enquetes chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all/dgi/decoupage-admin-for-enquete")
|
@GetMapping("/all/dgi/decoupage-admin-for-enquete")
|
||||||
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
|
public ResponseEntity<?> getAllByEnqueteDecoupageAdminForDgi() {
|
||||||
|
|||||||
@@ -1,248 +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.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.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
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")
|
|
||||||
public ResponseEntity<?> createParcelle(@RequestBody @Valid @Validated ParcellePayLoadWeb parcellePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
Parcelle parcelle = parcelleService.createParcelle(parcellePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelle, "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}")
|
|
||||||
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}")
|
|
||||||
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")
|
|
||||||
public ResponseEntity<?> getAllParcelle() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleList(), "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-decoupage")
|
|
||||||
public ResponseEntity<?> getAllByDecoupage() {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
|
||||||
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleList(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("/id/{id}")
|
|
||||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, parcelleService.getParcelleById(id), "enquete trouvé avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/user-id/{userId}")
|
|
||||||
public ResponseEntity<?> getParcellesByUserId(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,85 +1,28 @@
|
|||||||
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.crudweb.EnquetePayLoadWeb;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.PersonnePayLoadWeb;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
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")
|
|
||||||
public ResponseEntity<?> createPersonne(@RequestBody @Valid @Validated PersonnePayLoadWeb personnePayLoadWeb) {
|
|
||||||
try {
|
|
||||||
Personne personne = personneService.createPersonne(personnePayLoadWeb);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, personne, "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}")
|
|
||||||
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}")
|
||||||
public ResponseEntity<?> getDetails(@PathVariable Long id) {
|
public ResponseEntity<?> getDetails(@PathVariable Long id) {
|
||||||
try{
|
try{
|
||||||
@@ -95,20 +38,4 @@ public class PersonneController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
|
||||||
public ResponseEntity<?> getPersonneById(@PathVariable Long id) {
|
|
||||||
try{
|
|
||||||
Optional<Personne> 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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.infocad.metier.Upload;
|
|||||||
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;
|
||||||
|
|||||||
@@ -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,11 +40,11 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createStructure(@RequestBody StructurePaylaodWeb structurePaylaodWeb) {
|
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) {
|
||||||
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) {
|
||||||
@@ -65,10 +64,10 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody StructurePaylaodWeb structurePaylaodWeb) {
|
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) {
|
||||||
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) {
|
||||||
@@ -135,6 +134,36 @@ public class StructureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/all-by-arrondissement")
|
||||||
|
public ResponseEntity<?> getAllStructureListByArrondissement(@RequestParam Long arrondissementId) {
|
||||||
|
try {
|
||||||
|
if (arrondissementService.getArrondissementById(arrondissementId).isPresent()) {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, structureService.getStructuresByArrondissement(arrondissementId), "Liste des structures chargée avec succès."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(false, "Impossible de trouver l'arrondissement spécifiée."),
|
||||||
|
HttpStatus.OK
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||||
|
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||||
|
FileStorageException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
@GetMapping("/all-paged")
|
||||||
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
try {
|
try {
|
||||||
@@ -160,53 +189,6 @@ public class StructureController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/by-commune/{communeId}")
|
|
||||||
public ResponseEntity<?> getAllStructureListByCommune(@PathVariable Long communeId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, structureService.getStructureListByCommuneId(communeId), "Liste des structures chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/page/by-commune/{communeId}")
|
|
||||||
public ResponseEntity<?> getAllStructureListByCommunePageable(@PathVariable Long communeId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, structureService.getStructureListByCommuneId(communeId,pageable), "Liste des structures chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/id/{id}")
|
@GetMapping("/id/{id}")
|
||||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -37,9 +36,9 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated BatimentPaylaodWeb batimentPaylaodWeb) {
|
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated Batiment batiment) {
|
||||||
try {
|
try {
|
||||||
Batiment batiment = batimentService.createBatiment(batimentPaylaodWeb);
|
batiment = batimentService.createBatiment(batiment);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, batiment, "Batiment créé avec succès."),
|
new ApiResponse<>(true, batiment, "Batiment créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
@@ -61,10 +60,10 @@ public class BatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody BatimentPaylaodWeb batimentPaylaodWeb) {
|
public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody Batiment batiment) {
|
||||||
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) {
|
||||||
|
|||||||
@@ -7,7 +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.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
|
import io.gmss.fiscad.repositories.rfu.metier.ImpositionsTfuRepository;
|
||||||
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;
|
||||||
|
|||||||
@@ -1,179 +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.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")
|
|
||||||
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}")
|
|
||||||
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}")
|
|
||||||
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")
|
|
||||||
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")
|
|
||||||
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}")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
|||||||
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.crudweb.EnqueteBatimentPayloadWeb;
|
|
||||||
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;
|
||||||
@@ -36,9 +35,9 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
|
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatiment enqueteBatiment) {
|
||||||
try {
|
try {
|
||||||
EnqueteBatiment enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatimentPayloadWeb);
|
enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatiment);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."),
|
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
@@ -60,10 +59,10 @@ public class EnqueteBatimentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) {
|
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatiment enqueteBatiment) {
|
||||||
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) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
|||||||
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.crudweb.EnqueteUniteLogementPayloadWeb;
|
|
||||||
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;
|
||||||
@@ -36,9 +35,9 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
|
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogement enqueteUniteLogement) {
|
||||||
try {
|
try {
|
||||||
EnqueteUniteLogement enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogementPayloadWeb);
|
enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogement);
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."),
|
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."),
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
@@ -60,10 +59,10 @@ public class EnqueteUniteLogementController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogementPayloadWeb enqueteUniteLogementPayloadWeb) {
|
public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogement enqueteUniteLogement) {
|
||||||
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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -469,11 +468,11 @@ 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) {
|
||||||
@@ -494,11 +493,11 @@ 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) {
|
||||||
@@ -519,11 +518,11 @@ 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) {
|
||||||
|
|||||||
@@ -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,234 +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.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")
|
|
||||||
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}")
|
|
||||||
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}")
|
|
||||||
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")
|
|
||||||
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")
|
|
||||||
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}")
|
|
||||||
public ResponseEntity<?> getById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionById(id), "Fonction utilisateur trouvés avec succès"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/by-utilisateur-id/{userId}")
|
|
||||||
public ResponseEntity<?> getByUserId(@PathVariable Long userId) {
|
|
||||||
try {
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionByUserId(userId), "Fonctions de utilisateur trouvées avec succès"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/page/by-utilisateur-id/{userId}")
|
|
||||||
public ResponseEntity<?> getByUserIdPageable(@PathVariable Long userId,@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, avoirFonctionService.getAvoirFonctionByUserId(userId,pageable), "Fonctions de utilisateur trouvées avec succès"),
|
|
||||||
HttpStatus.OK
|
|
||||||
);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -113,17 +113,30 @@ 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 {
|
||||||
|
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 {
|
// }else {
|
||||||
// if (user.getStructure() == null) {
|
// if (user.getStructure() == null) {
|
||||||
// return new ResponseEntity<>(
|
// return new ResponseEntity<>(
|
||||||
@@ -137,35 +150,22 @@ 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")
|
||||||
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||||
|
|||||||
@@ -1,179 +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.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")
|
|
||||||
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}")
|
|
||||||
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}")
|
|
||||||
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")
|
|
||||||
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")
|
|
||||||
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}")
|
|
||||||
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,182 +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.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(value = "api/profile", 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")
|
|
||||||
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}")
|
|
||||||
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}")
|
|
||||||
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")
|
|
||||||
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}")
|
|
||||||
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")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,15 +8,12 @@ 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;
|
||||||
@@ -24,7 +21,6 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
@@ -44,11 +40,12 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserPaylaodWeb userPaylaodWeb) {
|
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) {
|
||||||
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) {
|
||||||
@@ -94,9 +91,9 @@ public class UserController {
|
|||||||
@PostMapping("/reset-password")
|
@PostMapping("/reset-password")
|
||||||
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
||||||
try {
|
try {
|
||||||
UserPaylaodWeb userPaylaodWeb= userService.resetPassword(login.getUsername(), login.getPassword());
|
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) {
|
||||||
@@ -115,10 +112,10 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/validate-user-account/{userName}")
|
@PostMapping("/validate-user-account")
|
||||||
public ResponseEntity<?> validateUserAccount(@PathVariable String userName) {
|
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
|
||||||
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
|
||||||
@@ -141,10 +138,10 @@ public class UserController {
|
|||||||
|
|
||||||
|
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody UserPaylaodWeb userPaylaodWeb) {
|
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody User user) {
|
||||||
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) {
|
||||||
@@ -168,13 +165,12 @@ public class UserController {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
User user = userService.getUserById(id);
|
User user = userService.getUserById(id);
|
||||||
// if(user.getAvoirFonctions().isEmpty()){
|
if(containsRoleAnonyme(user.getRoles())){
|
||||||
// return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
// new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
||||||
// HttpStatus.OK
|
HttpStatus.OK
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
if(user.isResetPassword()){
|
if(user.isResetPassword()){
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
new ApiResponse<>(false, user , "Ce compte n'est pas encore validé."),
|
||||||
@@ -232,60 +228,27 @@ public class UserController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
public ResponseEntity<?> getAll() {
|
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
|
||||||
try {
|
try {
|
||||||
|
if(userPrincipal==null){
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
new ApiResponse<>(true, userService.getListUserToDto(), "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);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all-paged")
|
|
||||||
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
|
||||||
try {
|
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, userService.getListUserToDto(pageable), "Liste des utilisateurs chargée avec succès."),
|
|
||||||
HttpStatus.OK);
|
|
||||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
|
||||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
|
||||||
FileStorageException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getLocalizedMessage());
|
|
||||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/all-by-structure/{structureId}")
|
|
||||||
public ResponseEntity<?> getAllByStructure(@PathVariable Long structureId) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
|
||||||
new ApiResponse<>(true, userService.getListUserByStructureToDto(structureId), "Liste des utilisateurs chargée avec succès."),
|
|
||||||
HttpStatus.OK
|
HttpStatus.OK
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
User user = userPrincipal.getUser();
|
||||||
|
|
||||||
|
if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
|
||||||
|
return new ResponseEntity<>(
|
||||||
|
new ApiResponse<>(true, userService.getAllUserListResponse(), "Liste des utilisateurs chargée avec succès."),
|
||||||
|
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) {
|
} 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);
|
||||||
@@ -300,19 +263,22 @@ public class UserController {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page/all-by-structure/{structureId}")
|
@GetMapping("/all-by-structure")
|
||||||
public ResponseEntity<?> getAllByStructurePaged(@PathVariable Long structureId, @RequestParam int pageNo, @RequestParam int pageSize) {
|
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
|
||||||
try {
|
try {
|
||||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
if (userPrincipal.getUser().getStructure() != null) {
|
||||||
|
|
||||||
|
|
||||||
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.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||||
HttpStatus.OK
|
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);
|
||||||
@@ -385,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +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;
|
||||||
|
|
||||||
// @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;
|
|
||||||
}
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -15,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;
|
||||||
@@ -56,13 +58,9 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
private boolean litige;
|
private boolean litige;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Exercice exercice;
|
private User user;
|
||||||
|
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
|
|
||||||
@@ -70,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;
|
||||||
|
|
||||||
@@ -88,7 +86,7 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
@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 ;
|
||||||
@@ -99,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;
|
||||||
@@ -157,22 +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;
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
@@ -184,11 +178,9 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@OneToMany(mappedBy = "enquete")
|
@OneToMany(mappedBy = "enquete")
|
||||||
@JsonManagedReference
|
|
||||||
private List<EnqueteUniteLogement> enqueteUniteLogements;
|
private List<EnqueteUniteLogement> enqueteUniteLogements;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@JsonManagedReference
|
|
||||||
@OneToMany(mappedBy = "enquete")
|
@OneToMany(mappedBy = "enquete")
|
||||||
private List<EnqueteBatiment> enqueteBatiments;
|
private List<EnqueteBatiment> enqueteBatiments;
|
||||||
|
|
||||||
@@ -196,8 +188,8 @@ public class Enquete extends BaseEntity implements Serializable {
|
|||||||
@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() {
|
||||||
@@ -228,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 "";
|
||||||
@@ -237,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 "";
|
||||||
@@ -255,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 "";
|
||||||
@@ -268,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 "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,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;
|
||||||
@@ -35,10 +36,9 @@ 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;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -52,6 +52,7 @@ public class Parcelle extends BaseEntity implements Serializable {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Tpe terminal;
|
private Tpe terminal;
|
||||||
private String autreNumeroTitreFoncier;
|
private String autreNumeroTitreFoncier;
|
||||||
|
|
||||||
private Long typeDomaineId;
|
private Long typeDomaineId;
|
||||||
private Long numeroProvisoire;
|
private Long numeroProvisoire;
|
||||||
private Long blocId;
|
private Long blocId;
|
||||||
@@ -59,11 +60,6 @@ public class Parcelle extends BaseEntity implements Serializable {
|
|||||||
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 ;
|
|
||||||
// @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;
|
||||||
@@ -63,23 +62,14 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
|
|||||||
@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 int geomSrid;
|
private int geomSrid;
|
||||||
@JsonSerialize(using = GeometrySerializer.class)
|
@JsonSerialize(using = GeometrySerializer.class)
|
||||||
|
|||||||
@@ -44,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;
|
||||||
@@ -55,21 +51,14 @@ 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
|
|
||||||
// @JsonBackReference
|
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
// private ActeurConcerne acteurConcerne;
|
|
||||||
// private Long acteurConcerneExternalKey;
|
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
private SourceDroit sourceDroit;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@JsonBackReference
|
@JsonBackReference
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Enquete enquete ;
|
private ActeurConcerne acteurConcerne;
|
||||||
|
private Long acteurConcerneExternalKey;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private SourceDroit sourceDroit;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private ModeAcquisition modeAcquisition;
|
private ModeAcquisition modeAcquisition;
|
||||||
@@ -85,7 +74,7 @@ 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;
|
||||||
|
|||||||
@@ -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 ;
|
|
||||||
}
|
|
||||||
@@ -34,6 +34,7 @@ import java.util.Set;
|
|||||||
"WHERE id = ?")
|
"WHERE id = ?")
|
||||||
@Where(clause = " deleted = false")
|
@Where(clause = " deleted = false")
|
||||||
public class Bloc extends BaseEntity implements Serializable {
|
public class Bloc extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|||||||
@@ -20,8 +20,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.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@@ -40,12 +38,11 @@ public class Personne extends BaseEntity implements Serializable {
|
|||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
private String ifu;
|
private String ifu;
|
||||||
private String nom;
|
private String nomOuSigle;
|
||||||
private String prenom;
|
private String prenomOuRaisonSociale;
|
||||||
private String raisonSociale;
|
|
||||||
private String numRavip;
|
private String numRavip;
|
||||||
private String npi;
|
private String npi;
|
||||||
private LocalDate dateNaissanceOuConsti;
|
private String dateNaissanceOuConsti;
|
||||||
private String lieuNaissance;
|
private String lieuNaissance;
|
||||||
private String tel1;
|
private String tel1;
|
||||||
private String tel2;
|
private String tel2;
|
||||||
@@ -78,12 +75,10 @@ public class Personne extends BaseEntity implements Serializable {
|
|||||||
@ColumnDefault("0")
|
@ColumnDefault("0")
|
||||||
private int mustHaveRepresentant;
|
private int mustHaveRepresentant;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|
||||||
private String observation;
|
private String observation;
|
||||||
@ColumnDefault("false")
|
@ColumnDefault("false")
|
||||||
private boolean synchronise;
|
private boolean synchronise;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "personne")
|
@OneToMany(mappedBy = "personne")
|
||||||
private List<Upload> uploads;
|
private List<Upload> uploads;
|
||||||
|
|
||||||
@@ -92,11 +87,10 @@ public class Personne extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
public List<Upload> getUploads() {
|
public List<Upload> getUploads() {
|
||||||
|
return uploads.stream().filter(upload -> upload.getPiece() == null && upload.getMembreGroupe() == null).toList();
|
||||||
return uploads==null ? new ArrayList<>():uploads.stream().filter(upload -> upload.getPiece() == null && upload.getMembreGroupe() == null).toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Piece> getPieces() {
|
public List<Piece> getPieces() {
|
||||||
return pieces==null ? new ArrayList<>():pieces.stream().filter(piece -> piece.getPersonne() != null).toList();
|
return pieces.stream().filter(piece -> piece.getActeurConcerne() == null).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package io.gmss.fiscad.entities.infocad.parametre;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||||
import io.gmss.fiscad.entities.user.Fonction;
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
@@ -30,12 +28,12 @@ import java.util.Set;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
//@SQLDelete(sql =
|
@SQLDelete(sql =
|
||||||
// "UPDATE structure " +
|
"UPDATE structure " +
|
||||||
// "SET deleted = true " +
|
"SET deleted = true " +
|
||||||
// "WHERE id = ?")
|
"WHERE id = ?")
|
||||||
//@Where(clause = " deleted = false")
|
@Where(clause = " deleted = false")
|
||||||
//@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||||
public class Structure extends BaseEntity implements Serializable {
|
public class Structure extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -49,29 +47,21 @@ public class Structure extends BaseEntity implements Serializable {
|
|||||||
private String tel;
|
private String tel;
|
||||||
private String email;
|
private String email;
|
||||||
private String adresse;
|
private String adresse;
|
||||||
//@NotNull(message = "Veuillez préciser la commune du centre d'impôts")
|
@NotNull
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Commune commune;
|
private Commune commune;
|
||||||
|
//@JsonIgnore
|
||||||
@JsonIgnore
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name = "arrondissements_structures",
|
@JoinTable(name = "arrondissements_structures",
|
||||||
joinColumns = @JoinColumn(name = "structure_id"),
|
joinColumns = @JoinColumn(name = "structure_id"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "arrondissement_id")
|
inverseJoinColumns = @JoinColumn(name = "arrondissement_id")
|
||||||
)
|
)
|
||||||
private Set<Arrondissement> arrondissements;
|
private Set<Arrondissement> arrondissements;
|
||||||
|
// @JsonIgnore
|
||||||
|
// @OneToMany(mappedBy = "structure")
|
||||||
|
// private List<User> agents;
|
||||||
|
// @JsonIgnore
|
||||||
|
// @OneToMany(mappedBy = "structure")
|
||||||
|
// private List<Bloc> blocs;
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Structure{" +
|
|
||||||
"id=" + id +
|
|
||||||
", code='" + code + '\'' +
|
|
||||||
", nom='" + nom + '\'' +
|
|
||||||
", ifu='" + ifu + '\'' +
|
|
||||||
", rccm='" + rccm + '\'' +
|
|
||||||
", tel='" + tel + '\'' +
|
|
||||||
", email='" + email + '\'' +
|
|
||||||
", adresse='" + adresse + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.infocad.parametre;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
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;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Un bloc représente un secteur de découpage admin dans le cadre d'une enquete fiscale
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class TypeRue extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
private String code;
|
|
||||||
private String nom;
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.ActeurConcernePayLoad;
|
import io.gmss.fiscad.paylaods.request.ActeurConcernePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.BatimentPaylaod;
|
import io.gmss.fiscad.paylaods.request.BatimentPaylaod;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.CaracteristiqueBatimentPayload;
|
import io.gmss.fiscad.paylaods.request.CaracteristiqueBatimentPaylod;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -26,7 +26,7 @@ public class MobileDataCaracteristiqueBatiment extends BaseEntity implements Ser
|
|||||||
private Long externalKey;
|
private Long externalKey;
|
||||||
@Type(JsonBinaryType.class)
|
@Type(JsonBinaryType.class)
|
||||||
@Column(columnDefinition = "jsonb")
|
@Column(columnDefinition = "jsonb")
|
||||||
private CaracteristiqueBatimentPayload CaracteristiqueBatimentPayload ;
|
private CaracteristiqueBatimentPaylod caracteristiqueBatimentPaylod ;
|
||||||
@Column(columnDefinition = "boolean default false")
|
@Column(columnDefinition = "boolean default false")
|
||||||
private boolean traiter;
|
private boolean traiter;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.CaracteristiqueParcellePayload;
|
import io.gmss.fiscad.paylaods.request.CaracteristiqueParcellePaylod;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -26,7 +26,7 @@ public class MobileDataCaracteristiqueParcelle extends BaseEntity implements Ser
|
|||||||
private Long externalKey;
|
private Long externalKey;
|
||||||
@Type(JsonBinaryType.class)
|
@Type(JsonBinaryType.class)
|
||||||
@Column(columnDefinition = "jsonb")
|
@Column(columnDefinition = "jsonb")
|
||||||
private CaracteristiqueParcellePayload CaracteristiqueParcellePayload ;
|
private CaracteristiqueParcellePaylod caracteristiqueParcellePaylod ;
|
||||||
@Column(columnDefinition = "boolean default false")
|
@Column(columnDefinition = "boolean default false")
|
||||||
private boolean traiter;
|
private boolean traiter;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.CaracteristiqueUniteLogementPayload;
|
import io.gmss.fiscad.paylaods.request.CaracteristiqueUniteLogementPaylod;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -26,7 +26,7 @@ public class MobileDataCaracteristiqueUniteLogement extends BaseEntity implement
|
|||||||
private Long externalKey;
|
private Long externalKey;
|
||||||
@Type(JsonBinaryType.class)
|
@Type(JsonBinaryType.class)
|
||||||
@Column(columnDefinition = "jsonb")
|
@Column(columnDefinition = "jsonb")
|
||||||
private CaracteristiqueUniteLogementPayload CaracteristiqueUniteLogementPayload ;
|
private CaracteristiqueUniteLogementPaylod caracteristiqueUniteLogementPaylod ;
|
||||||
@Column(columnDefinition = "boolean default false")
|
@Column(columnDefinition = "boolean default false")
|
||||||
private boolean traiter;
|
private boolean traiter;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.DeclarationNcPayload;
|
import io.gmss.fiscad.paylaods.request.DeclarationNcPayload;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -15,7 +15,7 @@ import java.io.Serializable;
|
|||||||
@Setter
|
@Setter
|
||||||
@Table(
|
@Table(
|
||||||
indexes = {
|
indexes = {
|
||||||
@Index(name = "idx_terminal_external_dnc", columnList = "terminalId, externalKey")
|
@Index(name = "idx_terminal_external_bat", columnList = "terminalId, externalKey")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public class MobileDataDeclarationNc extends BaseEntity implements Serializable {
|
public class MobileDataDeclarationNc extends BaseEntity implements Serializable {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EnquetePayLoad;
|
import io.gmss.fiscad.paylaods.request.EnquetePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.BatimentPaylaod;
|
import io.gmss.fiscad.paylaods.request.BatimentPaylaod;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EnqueteActivitePayload;
|
import io.gmss.fiscad.paylaods.request.EnqueteActivitePayload;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EnqueteBatimentPayload;
|
import io.gmss.fiscad.paylaods.request.EnqueteBatimentPayload;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.EnqueteUniteLogementPayload;
|
import io.gmss.fiscad.paylaods.request.EnqueteUniteLogementPayload;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.MembreGroupePayLoad;
|
import io.gmss.fiscad.paylaods.request.MembreGroupePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.ParcellePayLoad;
|
import io.gmss.fiscad.paylaods.request.ParcellePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.ParcellePayLoad;
|
import io.gmss.fiscad.paylaods.request.ParcellePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.PersonnePayLoad;
|
import io.gmss.fiscad.paylaods.request.PersonnePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.PiecePayLoad;
|
import io.gmss.fiscad.paylaods.request.PiecePayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.ParcellePayLoad;
|
import io.gmss.fiscad.paylaods.request.ParcellePayLoad;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.UniteLogementPaylaod;
|
import io.gmss.fiscad.paylaods.request.UniteLogementPaylaod;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.gmss.fiscad.entities.metadata;
|
|||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.UploadPayLoad;
|
import io.gmss.fiscad.paylaods.request.UploadPayLoad;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Where(clause = " deleted = false")
|
@Where(clause = " deleted = false")
|
||||||
public class Batiment extends BaseEntity implements Serializable {
|
public class Batiment extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@@ -34,13 +35,10 @@ public class Batiment extends BaseEntity implements Serializable {
|
|||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateConstruction;
|
private LocalDate dateConstruction;
|
||||||
private Long idDerniereEnquete;
|
private Long idDerniereEnquete;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Parcelle parcelle;
|
private Parcelle parcelle;
|
||||||
|
|
||||||
private Long parcelleExternalKey;
|
private Long parcelleExternalKey;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Tpe terminal;
|
private Tpe terminal;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ public class CaracteristiqueBatiment extends BaseEntity implements Serializable
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Caracteristique caracteristique;
|
private Caracteristique caracteristique;
|
||||||
private String valeur;
|
private String valeur;
|
||||||
private String observation ;
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Tpe terminal ;
|
private Tpe terminal ;
|
||||||
|
|||||||
@@ -30,17 +30,13 @@ public class CaracteristiqueUniteLogement extends BaseEntity implements Serializ
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ManyToOne
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JsonBackReference
|
@JsonBackReference
|
||||||
private EnqueteUniteLogement enqueteUniteLogement;
|
private EnqueteUniteLogement enqueteUniteLogement;
|
||||||
|
|
||||||
private Long enqueteUniteLogementExternalKey;
|
private Long enqueteUniteLogementExternalKey;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Caracteristique caracteristique;
|
private Caracteristique caracteristique;
|
||||||
private String valeur;
|
private String valeur;
|
||||||
private String observation;
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Tpe terminal;
|
private Tpe terminal;
|
||||||
|
|||||||
@@ -49,15 +49,13 @@ public class EnqueteActivite extends BaseEntity implements Serializable {
|
|||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateEnquete;
|
private LocalDate dateEnquete;
|
||||||
|
|
||||||
@Column(columnDefinition = "boolean default false", nullable = false)
|
@Column(columnDefinition = "false")
|
||||||
private boolean estDeclarer;
|
private boolean estDeclarer;
|
||||||
|
|
||||||
private String nc;
|
private String nc;
|
||||||
private Long ChiffreAffaire;
|
private Long ChiffreAffaire;
|
||||||
private String NumeroRccm;
|
private String NumeroRccm;
|
||||||
@OneToOne
|
@OneToOne
|
||||||
private Personne personne;
|
private Personne personne;
|
||||||
|
|
||||||
private Long personneExternalKey;
|
private Long personneExternalKey;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import io.gmss.fiscad.entities.infocad.metier.Enquete;
|
|||||||
import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
||||||
import io.gmss.fiscad.entities.infocad.metier.Upload;
|
import io.gmss.fiscad.entities.infocad.metier.Upload;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
import io.gmss.fiscad.entities.infocad.parametre.Personne;
|
||||||
import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.enums.StatutEnregistrement;
|
import io.gmss.fiscad.enums.StatutEnregistrement;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -54,10 +53,7 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
|
|||||||
private float surfaceLouee;
|
private float surfaceLouee;
|
||||||
private int nbreMenage;
|
private int nbreMenage;
|
||||||
private int nbreHabitant;
|
private int nbreHabitant;
|
||||||
private Long montantMensuelLocation;
|
private float valeurMensuelleLocation;
|
||||||
private Long montantLocatifAnnuelDeclare;
|
|
||||||
private Long valeurBatimentEstime;
|
|
||||||
private Long valeurBatimentReel;
|
|
||||||
private int nbreMoisLocation;
|
private int nbreMoisLocation;
|
||||||
private String autreCaracteristiquePhysique;
|
private String autreCaracteristiquePhysique;
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
@@ -66,34 +62,20 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
|
|||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateFinExcemption;
|
private LocalDate dateFinExcemption;
|
||||||
|
@OneToOne
|
||||||
//@JsonIgnore
|
|
||||||
@ManyToOne
|
|
||||||
private Personne personne;
|
private Personne personne;
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "categorie_caracteristique_id")
|
|
||||||
private Caracteristique caracteristique;
|
|
||||||
|
|
||||||
private Long personneExternalKey;
|
private Long personneExternalKey;
|
||||||
|
@ManyToOne
|
||||||
|
private Batiment batiment;
|
||||||
|
private Long batimentExternalKey;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne
|
||||||
@JsonBackReference
|
|
||||||
private Batiment batiment;
|
|
||||||
|
|
||||||
private Long batimentExternalKey;
|
|
||||||
private Long nbreEtage;
|
|
||||||
|
|
||||||
// @JsonIgnore
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JsonBackReference
|
|
||||||
private Enquete enquete;
|
private Enquete enquete;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "enqueteBatiment")
|
|
||||||
@JsonManagedReference ///pour couper la récurcivité
|
@JsonManagedReference ///pour couper la récurcivité
|
||||||
|
@OneToMany(mappedBy = "enqueteBatiment")
|
||||||
private List<CaracteristiqueBatiment> caracteristiqueBatiments;
|
private List<CaracteristiqueBatiment> caracteristiqueBatiments;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -107,7 +89,7 @@ public class EnqueteBatiment extends BaseEntity implements Serializable {
|
|||||||
@OneToMany(mappedBy = "enqueteBatiment")
|
@OneToMany(mappedBy = "enqueteBatiment")
|
||||||
private List<Upload> uploads;
|
private List<Upload> uploads;
|
||||||
|
|
||||||
//@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
//@JsonIgnore
|
@JsonIgnore
|
||||||
//private StatutEnregistrement statutEnregistrement;
|
private StatutEnregistrement statutEnregistrement;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.gmss.fiscad.entities.rfu.metier;
|
package io.gmss.fiscad.entities.rfu.metier;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||||
@@ -41,17 +40,15 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
private float surface;
|
||||||
private int nbrePiece;
|
private int nbrePiece;
|
||||||
private int nbreHabitant;
|
private int nbreHabitant;
|
||||||
private int nbreMenage;
|
private int nbreMenage;
|
||||||
private boolean enLocation;
|
private boolean enLocation;
|
||||||
private float montantMensuelLoyer;
|
private float montantMensuelLoyer;
|
||||||
private int nbreMoisLocation;
|
private int nbreMoisEnLocation;
|
||||||
private float montantLocatifAnnuelDeclare;
|
private float montantLocatifAnnuelDeclare;
|
||||||
private Long valeurUniteLogementEstime;
|
|
||||||
private Long valeurUniteLogementReel;
|
|
||||||
private float surfaceLouee;
|
private float surfaceLouee;
|
||||||
private float SurfaceAuSol;
|
|
||||||
private boolean sbee;
|
private boolean sbee;
|
||||||
private boolean soneb;
|
private boolean soneb;
|
||||||
private String numCompteurSbee;
|
private String numCompteurSbee;
|
||||||
@@ -62,25 +59,16 @@ public class EnqueteUniteLogement extends BaseEntity implements Serializable {
|
|||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
@JsonFormat(pattern = "dd-MM-yyyy")
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||||
private LocalDate dateFinExcemption;
|
private LocalDate dateFinExcemption;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne
|
||||||
@JsonBackReference
|
|
||||||
private Enquete enquete;
|
private Enquete enquete;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private UniteLogement uniteLogement;
|
private UniteLogement uniteLogement;
|
||||||
|
|
||||||
|
|
||||||
private Long uniteLogementExternalKey;
|
private Long uniteLogementExternalKey;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
private Personne personne;
|
private Personne personne;
|
||||||
|
|
||||||
private Long personneExternalKey;
|
private Long personneExternalKey;
|
||||||
private Long mobileDataId;
|
private Long mobileDataId;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "enqueteUniteLogement")
|
@OneToMany(mappedBy = "enqueteUniteLogement")
|
||||||
@JsonManagedReference
|
@JsonManagedReference
|
||||||
private List<CaracteristiqueUniteLogement> caracteristiqueUniteLogements;
|
private List<CaracteristiqueUniteLogement> caracteristiqueUniteLogements;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package io.gmss.fiscad.entities.rfu.metier;
|
package io.gmss.fiscad.entities.rfu.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.infocad.metier.Tpe;
|
import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -14,7 +11,6 @@ import lombok.NoArgsConstructor;
|
|||||||
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,9 +27,6 @@ public class UniteLogement extends BaseEntity implements Serializable {
|
|||||||
private String nul;
|
private String nul;
|
||||||
private String numeroEtage;
|
private String numeroEtage;
|
||||||
private String code;
|
private String code;
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
|
||||||
private LocalDate dateConstruction;
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@OneToMany(mappedBy = "uniteLogement")
|
@OneToMany(mappedBy = "uniteLogement")
|
||||||
private List<EnqueteUniteLogement> enqueteUniteLogements;
|
private List<EnqueteUniteLogement> enqueteUniteLogements;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public class Caracteristique extends BaseEntity implements Serializable {
|
|||||||
private Tpe terminal;
|
private Tpe terminal;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private CategorieBatiment categorieBatiment;
|
private CategorieBatiment categorieBatiment;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Arrondissement arrondissement;
|
private Arrondissement arrondissement;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.user;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
||||||
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Section;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
|
||||||
import io.gmss.fiscad.enums.Titre;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
//@SQLDelete(sql =
|
|
||||||
// "UPDATE parcelle " +
|
|
||||||
// "SET deleted = true " +
|
|
||||||
// "WHERE id = ?")
|
|
||||||
//@Where(clause = " deleted = false")
|
|
||||||
public class AvoirFonction extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
|
||||||
private LocalDate dateDebut;
|
|
||||||
@JsonFormat(pattern = "dd-MM-yyyy")
|
|
||||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
|
||||||
private LocalDate dateFin;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
@ManyToOne //(fetch = FetchType.LAZY, optional = false)
|
|
||||||
@JoinColumn(name = "user_id", nullable = false)
|
|
||||||
@NotNull
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
@ManyToOne //(fetch = FetchType.LAZY, optional = false)
|
|
||||||
@JoinColumn(name = "fonction_id", nullable = false)
|
|
||||||
@NotNull
|
|
||||||
private Fonction fonction;
|
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private Titre titre;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getExternalKey() {
|
|
||||||
return super.getExternalKey();
|
|
||||||
}
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getEnqueteExternalKey() {
|
|
||||||
return super.getEnqueteExternalKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.user;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
||||||
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Section;
|
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Entity
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
//@SQLDelete(sql =
|
|
||||||
// "UPDATE parcelle " +
|
|
||||||
// "SET deleted = true " +
|
|
||||||
// "WHERE id = ?")
|
|
||||||
//@Where(clause = " deleted = false")
|
|
||||||
public class Fonction extends BaseEntity implements Serializable {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
private String code ;
|
|
||||||
private String nom ;
|
|
||||||
|
|
||||||
@JsonBackReference
|
|
||||||
@ManyToOne
|
|
||||||
private Secteur secteur;
|
|
||||||
|
|
||||||
//@JsonBackReference
|
|
||||||
@ManyToOne
|
|
||||||
private Section section;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "structure_id")
|
|
||||||
private Structure structure;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
private Departement departement;
|
|
||||||
|
|
||||||
//@JsonIgnore
|
|
||||||
@ManyToOne //(fetch = FetchType.LAZY, optional = false)
|
|
||||||
@JoinColumn(name = "profile_id", nullable = false)
|
|
||||||
@NotNull
|
|
||||||
private Profile profile;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getExternalKey() {
|
|
||||||
return super.getExternalKey();
|
|
||||||
}
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getEnqueteExternalKey() {
|
|
||||||
return super.getEnqueteExternalKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package io.gmss.fiscad.entities.user;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
|
||||||
import io.gmss.fiscad.enums.UserProfile;
|
|
||||||
import io.gmss.fiscad.enums.UserRole;
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
//@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Entity
|
|
||||||
public class Profile extends BaseEntity implements Serializable {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
private UserProfile nom;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public Profile(UserProfile name, String description) {
|
|
||||||
this.nom = name;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
|
||||||
@JoinTable(name = "profile_role",
|
|
||||||
joinColumns = @JoinColumn(name = "profile_id"),
|
|
||||||
inverseJoinColumns = @JoinColumn(name = "role_id")
|
|
||||||
)
|
|
||||||
private Set<Role> roles = new HashSet<>();
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
|
|
||||||
// If the object is compared with itself then return true
|
|
||||||
if (o == this) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if o is an instance of Complex or not
|
|
||||||
"null instanceof [type]" also returns false */
|
|
||||||
if (!(o instanceof Profile)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// typecast o to Complex so that we can compare data members
|
|
||||||
Profile r = (Profile) o;
|
|
||||||
|
|
||||||
// Compare the data members and return accordingly
|
|
||||||
return r.getNom().equals(this.getNom());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, nom, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getExternalKey() {
|
|
||||||
return super.getExternalKey();
|
|
||||||
}
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getEnqueteExternalKey() {
|
|
||||||
return super.getEnqueteExternalKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.gmss.fiscad.entities.user;
|
package io.gmss.fiscad.entities.user;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import io.gmss.fiscad.entities.BaseEntity;
|
import io.gmss.fiscad.entities.BaseEntity;
|
||||||
import io.gmss.fiscad.enums.UserRole;
|
import io.gmss.fiscad.enums.UserRole;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -55,13 +54,4 @@ public class Role extends BaseEntity implements Serializable {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, nom, description);
|
return Objects.hash(id, nom, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getExternalKey() {
|
|
||||||
return super.getExternalKey();
|
|
||||||
}
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getEnqueteExternalKey() {
|
|
||||||
return super.getEnqueteExternalKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,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.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -40,12 +39,6 @@ public class User extends BaseEntity implements Serializable {
|
|||||||
private String prenom;
|
private String prenom;
|
||||||
private String tel;
|
private String tel;
|
||||||
private String email;
|
private String email;
|
||||||
@Column(
|
|
||||||
name = "username",
|
|
||||||
nullable = false,
|
|
||||||
unique = true,
|
|
||||||
length = 200
|
|
||||||
)
|
|
||||||
private String username;
|
private String username;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String password;
|
private String password;
|
||||||
@@ -53,31 +46,41 @@ public class User extends BaseEntity implements Serializable {
|
|||||||
private boolean active;
|
private boolean active;
|
||||||
@Column(columnDefinition = "boolean default false")
|
@Column(columnDefinition = "boolean default false")
|
||||||
private boolean resetPassword;
|
private boolean resetPassword;
|
||||||
|
@ManyToMany
|
||||||
@OneToMany(mappedBy = "user")
|
@JoinTable(name = "users_roles",
|
||||||
private Set<AvoirFonction> avoirFonctions= new HashSet<>();
|
joinColumns = @JoinColumn(name = "user_id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(name = "roles_id")
|
||||||
|
)
|
||||||
|
private Set<Role> roles;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Structure structure;
|
private Structure structure;
|
||||||
|
// @JsonIgnore
|
||||||
|
// @OneToMany(mappedBy = "user")
|
||||||
|
// private List<Enquete> enquetes;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@OneToMany(mappedBy = "user")
|
@OneToMany(mappedBy = "user")
|
||||||
private List<Participer> participers;
|
private List<Participer> participers;
|
||||||
|
|
||||||
|
// @JsonIgnore
|
||||||
|
// @OneToMany(mappedBy = "chefSecteur")
|
||||||
|
// private List<Secteur> secteurs;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private Long idCampagneCourant;
|
private Long idCampagneCourant;
|
||||||
@Transient
|
@Transient
|
||||||
private Long idSecteurCourant;
|
private Long idSecteurCourant;
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = this.email;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAdmin() {
|
public boolean isAdmin() {
|
||||||
// for (Role r : this.roles) {
|
for (Role r : this.roles) {
|
||||||
// if (r.getNom().equals(UserRole.ROLE_ADMIN)) {
|
if (r.getNom().equals(UserRole.ROLE_ADMIN)) {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package io.gmss.fiscad.enums;
|
package io.gmss.fiscad.enums;
|
||||||
|
|
||||||
public enum StatutEnquete {
|
public enum StatusEnquete {
|
||||||
EN_COURS,
|
EN_COURS,
|
||||||
FINALISE,
|
FINALISE,
|
||||||
REJETE,
|
REJETE,
|
||||||
VALIDE,
|
VALIDE,
|
||||||
|
//SYNCHRONISE
|
||||||
ECHEC
|
ECHEC
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package io.gmss.fiscad.enums;
|
package io.gmss.fiscad.enums;
|
||||||
|
|
||||||
public enum StatutEnregistrement {
|
public enum StatutEnregistrement {
|
||||||
SAISIE_EN_COURS,
|
NOUVELLE_INSERTION,
|
||||||
SAISIE,
|
MISE_A_JOUR
|
||||||
VALIDATION_EN_COURS,
|
|
||||||
VALIDE,
|
|
||||||
REJETE
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package io.gmss.fiscad.enums;
|
|
||||||
|
|
||||||
public enum Titre {
|
|
||||||
TITULAIRE,
|
|
||||||
INTERIMAIRE
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package io.gmss.fiscad.enums;
|
|
||||||
|
|
||||||
public enum UserProfile {
|
|
||||||
INSPECTEUR_GESTIONNAIRE,
|
|
||||||
ADMIN_FONCTIONNEL,
|
|
||||||
INSPECTEUR_GESTIONNAIRE_CHEF_SECTEUR,
|
|
||||||
INSPECTEUR_GESTIONNAIRE_CHEF_SECTION,
|
|
||||||
INSPECTEUR_GESTIONNAIRE_CHEF_CENTRE
|
|
||||||
}
|
|
||||||
@@ -2,23 +2,11 @@ package io.gmss.fiscad.enums;
|
|||||||
|
|
||||||
public enum UserRole {
|
public enum UserRole {
|
||||||
|
|
||||||
ADMIN,
|
ROLE_ADMIN,
|
||||||
CREATE_USER,
|
ROLE_USER,
|
||||||
UPDATE_USER,
|
ROLE_DIRECTEUR,
|
||||||
READ_USER,
|
ROLE_SUPERVISEUR,
|
||||||
DELETE_USER,
|
ROLE_ENQUETEUR,
|
||||||
CREATE_PARCELLE,
|
ROLE_ANONYMOUS,
|
||||||
UPDATE_PARCELLE,
|
ROLE_RESPONSABLE
|
||||||
READ_PARCELLE,
|
|
||||||
DELETE_PARCELLE,
|
|
||||||
CREATE_ENQUETE,
|
|
||||||
UPDATE_ENQUETE,
|
|
||||||
READ_ENQUETE,
|
|
||||||
DELETE_ENQUETE,
|
|
||||||
CREATE_BATIMENT,
|
|
||||||
UPDATE_BATIMENT,
|
|
||||||
READ_BATIMENT,
|
|
||||||
DELETE_BATIMENT
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package io.gmss.fiscad.exceptions;
|
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
|
|
||||||
@ResponseStatus(HttpStatus.NOT_ACCEPTABLE)
|
|
||||||
public class ApplicationException extends RuntimeException {
|
|
||||||
public ApplicationException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
|
import io.gmss.fiscad.repositories.decoupage.ArrondissementRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -56,28 +55,27 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ArrondissementPaylaodWeb> getArrondissementList(Pageable pageable) {
|
public Page<Arrondissement> getArrondissementList(Pageable pageable) {
|
||||||
return arrondissementRepository.findAllArrondissementToDtoPageable(pageable);
|
return arrondissementRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArrondissementPaylaodWeb> getArrondissementList() {
|
public List<Arrondissement> getArrondissementList() {
|
||||||
return arrondissementRepository.findAllArrondissementToDto();
|
return arrondissementRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId) {
|
public Optional<Arrondissement> getArrondissementById(Long id) {
|
||||||
return arrondissementRepository.findAllArrondissementByCommuneToDto(communeId);
|
return arrondissementRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ArrondissementPaylaodWeb> getArrondissementListByCommuneId(Long communeId, Pageable pageable) {
|
public List<Arrondissement> getArrondissementByComune(Long communeId) {
|
||||||
return arrondissementRepository.findAllArrondissementByCommuneToDtoPageable(communeId,pageable);
|
Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
|
||||||
|
if (communeOptional.isEmpty()) {
|
||||||
|
throw new NotFoundException("Impossible de trouver la commune spécifiée.");
|
||||||
}
|
}
|
||||||
|
return arrondissementRepository.findAllByCommune(communeOptional.get());
|
||||||
@Override
|
|
||||||
public Optional<ArrondissementPaylaodWeb> getArrondissementById(Long id) {
|
|
||||||
return arrondissementRepository.findArrondissementToDtoById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.CommunePaylaodWeb;
|
import io.gmss.fiscad.repositories.decoupage.CommuneRepository;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.CommuneRepository;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -57,28 +55,27 @@ public class CommuneServiceImpl implements CommuneService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CommunePaylaodWeb> getCommuneList(Pageable pageable) {
|
public Page<Commune> getCommuneList(Pageable pageable) {
|
||||||
return communeRepository.findAllCommuneToDtoPageable(pageable);
|
return communeRepository.findAll(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Commune> getCommuneList() {
|
||||||
|
return communeRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CommunePaylaodWeb> getCommuneList() {
|
public List<Commune> getCommunesByDepartement(Long departementId) {
|
||||||
return communeRepository.findAllCommuneToDto();
|
Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
|
||||||
|
if (departementOptional.isEmpty()) {
|
||||||
|
throw new NotFoundException("Impossible de trouver le département spécifié.");
|
||||||
|
}
|
||||||
|
return communeRepository.findAllByDepartement(departementOptional.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId) {
|
public Optional<Commune> getCommuneById(Long id) {
|
||||||
return communeRepository.findAllCommuneByDepartementToDto(departementId);
|
return communeRepository.findById(id);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<CommunePaylaodWeb> getCommunesByDepartementId(Long departementId, Pageable pageable) {
|
|
||||||
return communeRepository.findAllCommuneByDepartementToDtoPageable(departementId,pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<CommunePaylaodWeb> getCommuneById(Long id) {
|
|
||||||
return communeRepository.findCommuneToDtoById(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import io.gmss.fiscad.entities.decoupage.Departement;
|
|||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.DepartementPaylaodWeb;
|
import io.gmss.fiscad.repositories.decoupage.DepartementRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.DepartementRepository;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -52,20 +51,20 @@ public class DepartementServiceImpl implements DepartementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DepartementPaylaodWeb> getDepartementList(Pageable pageable) {
|
public Page<Departement> getDepartementList(Pageable pageable) {
|
||||||
return departementRepository.findAllDepartementToDtoPageable(pageable);
|
return departementRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DepartementPaylaodWeb> getDepartementList() {
|
public List<Departement> getDepartementList() {
|
||||||
return departementRepository.findAllDepartementToDto();
|
return departementRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DepartementPaylaodWeb> getDepartementById(Long id) {
|
public Optional<Departement> getDepartementById(Long id) {
|
||||||
if (departementRepository.existsById(id)) {
|
if (departementRepository.existsById(id)) {
|
||||||
return departementRepository.findDepartementToDtoById(id);
|
return departementRepository.findById(id);
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
|
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.gmss.fiscad.entities.decoupage.Nationalite;
|
|||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.NationaliteService;
|
import io.gmss.fiscad.interfaces.decoupage.NationaliteService;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.NationaliteRepository;
|
import io.gmss.fiscad.repositories.decoupage.NationaliteRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
|||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
|
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.QuartierPaylaodWeb;
|
import io.gmss.fiscad.repositories.decoupage.QuartierRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -56,28 +55,31 @@ public class QuartierServiceImpl implements QuartierService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<QuartierPaylaodWeb> getQuartierList(Pageable pageable) {
|
public Page<Quartier> getQuartierList(Pageable pageable) {
|
||||||
return quartierRepository.findAllQuartierToDtoPageable(pageable);
|
return quartierRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<QuartierPaylaodWeb> getQuartierList() {
|
public List<Quartier> getQuartierList() {
|
||||||
return quartierRepository.findAllQuartierToDto();
|
return quartierRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId) {
|
public Optional<Quartier> getQuartierById(Long id) {
|
||||||
return quartierRepository.findAllQuartierByArrondissementToDto(arrondissementId);
|
if (quartierRepository.existsById(id)) {
|
||||||
|
return quartierRepository.findById(id);
|
||||||
|
} else {
|
||||||
|
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<QuartierPaylaodWeb> getQuartierListByArrondissementId(Long arrondissementId, Pageable pageable) {
|
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
|
||||||
return quartierRepository.findAllQuartierByArrondissementToDtoPageable(arrondissementId,pageable);
|
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
|
||||||
|
if (arrondissementOptional.isEmpty()) {
|
||||||
|
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
|
||||||
}
|
}
|
||||||
|
return quartierRepository.getAllByArrondissement(arrondissementOptional.get());
|
||||||
@Override
|
|
||||||
public Optional<QuartierPaylaodWeb> getQuartierById(Long id) {
|
|
||||||
return quartierRepository.findQuartierToDtoById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +1,42 @@
|
|||||||
package io.gmss.fiscad.implementations.decoupage;
|
package io.gmss.fiscad.implementations.decoupage;
|
||||||
|
|
||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
import io.gmss.fiscad.repositories.decoupage.SecteurDecoupageRepository;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.SecteurDecoupagePaylaodWeb;
|
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
|
||||||
import io.gmss.fiscad.paylaods.response.restoration.ParcelleStatsProjectionUnSecteur;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurDecoupageRepository;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@AllArgsConstructor
|
|
||||||
@Service
|
@Service
|
||||||
public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||||
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
private final SecteurDecoupageRepository secteurDecoupageRepository;
|
||||||
private final SecteurService secteurService;
|
|
||||||
private final ParcelleRepository parcelleRepository;
|
|
||||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
|
||||||
|
|
||||||
|
|
||||||
|
public SecteurDecoupageServiceImpl(SecteurDecoupageRepository secteurDecoupageRepository) {
|
||||||
|
this.secteurDecoupageRepository = secteurDecoupageRepository;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecteurDecoupagePaylaodWeb createSecteurDecoupage(SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws BadRequestException {
|
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
|
||||||
if (secteurDecoupagePaylaodWeb.getId() != null) {
|
if (secteurDecoupage.getId() != null) {
|
||||||
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
|
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
|
||||||
}
|
}
|
||||||
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||||
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
|
||||||
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecteurDecoupagePaylaodWeb updateSecteurDecoupage(Long id, SecteurDecoupagePaylaodWeb secteurDecoupagePaylaodWeb) throws NotFoundException {
|
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
|
||||||
if (secteurDecoupagePaylaodWeb.getId() == null) {
|
if (secteurDecoupage.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
|
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
|
||||||
}
|
}
|
||||||
if (!secteurDecoupageRepository.existsById(secteurDecoupagePaylaodWeb.getId())) {
|
if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) {
|
||||||
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
||||||
}
|
}
|
||||||
|
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||||
SecteurDecoupage secteurDecoupage = entityFromPayLoadService.getSecteurDecoupageFromPayLoadWeb(secteurDecoupagePaylaodWeb);
|
|
||||||
secteurDecoupage = secteurDecoupageRepository.save(secteurDecoupage);
|
|
||||||
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(secteurDecoupage.getId()).orElse(null);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,28 +50,13 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList(Pageable pageable) {
|
public Page<SecteurDecoupage> getSecteurDecoupageList(Pageable pageable) {
|
||||||
return secteurDecoupageRepository.findAllSecteurDecoupageToDtoPageable(pageable);
|
return secteurDecoupageRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageList() {
|
public List<SecteurDecoupage> getSecteurDecoupageList() {
|
||||||
return secteurDecoupageRepository.findAllSecteurDecoupageToDto();
|
return secteurDecoupageRepository.findAll();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long secteurId, Pageable pageable) {
|
|
||||||
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDtoPageable(secteurId,pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SecteurDecoupagePaylaodWeb> getSecteurDecoupageListBySecteurId(Long sectionId) {
|
|
||||||
return secteurDecoupageRepository.findAllSecteurDecoupageBySecteurToDto(sectionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SecteurDecoupagePaylaodWeb> getSecteurDecoupageByIdToDto(Long id) {
|
|
||||||
return secteurDecoupageRepository.findSecteurDecoupageToDtoById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -95,21 +64,4 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
|||||||
public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) {
|
public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) {
|
||||||
return secteurDecoupageRepository.findById(id);
|
return secteurDecoupageRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ParcelleStatsProjectionUnSecteur> getStatParcelleDecoupageUnSecteur(Long secteurId) {
|
|
||||||
return parcelleRepository.findStatsBySecteurs(List.of(secteurId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ParcelleStatsProjectionUnSecteur> getStatParcelleDecoupageByUserId(Long userId) {
|
|
||||||
List<ParcelleStatsProjectionUnSecteur> parcelleStatsProjectionUnSecteurs = new ArrayList<>();
|
|
||||||
List<Secteur> secteurs= secteurService.getListSecteurUserId(userId);
|
|
||||||
List<Long> secteurIds = secteurs.stream()
|
|
||||||
.map(Secteur::getId)
|
|
||||||
.toList();
|
|
||||||
parcelleStatsProjectionUnSecteurs = parcelleRepository.findStatsBySecteurs(secteurIds);
|
|
||||||
|
|
||||||
return parcelleStatsProjectionUnSecteurs ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,103 +3,105 @@ package io.gmss.fiscad.implementations.decoupage;
|
|||||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||||
import io.gmss.fiscad.entities.user.AvoirFonction;
|
|
||||||
import io.gmss.fiscad.entities.user.User;
|
import io.gmss.fiscad.entities.user.User;
|
||||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||||
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||||
import io.gmss.fiscad.paylaods.request.crudweb.SecteurPaylaodWeb;
|
import io.gmss.fiscad.paylaods.request.SecteurDecoupagePayload;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurDecoupagePayload;
|
import io.gmss.fiscad.paylaods.request.SecteurPayload;
|
||||||
import io.gmss.fiscad.paylaods.request.synchronisation.SecteurPayload;
|
import io.gmss.fiscad.repositories.decoupage.ArrondissementRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.ArrondissementRepository;
|
import io.gmss.fiscad.repositories.decoupage.QuartierRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.QuartierRepository;
|
import io.gmss.fiscad.repositories.decoupage.SecteurRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.decoupage.SecteurRepository;
|
import io.gmss.fiscad.repositories.infocad.parametre.StructureRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
import io.gmss.fiscad.repositories.user.UserRepository;
|
||||||
import io.gmss.fiscad.persistence.repositories.infocad.parametre.StructureRepository;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.user.AvoirFonctionRepository;
|
|
||||||
import io.gmss.fiscad.persistence.repositories.user.UserRepository;
|
|
||||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Service
|
@Service
|
||||||
public class SecteurServiceImpl implements SecteurService {
|
public class SecteurServiceImpl implements SecteurService {
|
||||||
private final SecteurRepository secteurRepository;
|
private final SecteurRepository secteurRepository;
|
||||||
private final ParcelleRepository parcelleRepository;
|
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final ArrondissementRepository arrondissementRepository;
|
private final ArrondissementRepository arrondissementRepository;
|
||||||
private final QuartierRepository quartierRepository;
|
private final QuartierRepository quartierRepository;
|
||||||
private final StructureRepository structureRepository;
|
private final StructureRepository structureRepository;
|
||||||
private final AvoirFonctionRepository avoirFonctionRepository;
|
|
||||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
|
||||||
|
|
||||||
|
|
||||||
|
public SecteurServiceImpl(SecteurRepository secteurRepository, UserRepository userRepository, ArrondissementRepository arrondissementRepository, QuartierRepository quartierRepository, StructureRepository structureRepository) {
|
||||||
|
this.secteurRepository = secteurRepository;
|
||||||
|
this.userRepository = userRepository;
|
||||||
|
this.arrondissementRepository = arrondissementRepository;
|
||||||
|
this.quartierRepository = quartierRepository;
|
||||||
|
this.structureRepository = structureRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecteurPaylaodWeb createSecteur(SecteurPaylaodWeb secteurPaylaodWeb) throws BadRequestException {
|
public Secteur createSecteur(SecteurPayload secteurPayload) throws BadRequestException {
|
||||||
if (secteurPaylaodWeb.getId() != null) {
|
if (secteurPayload.getId() != null) {
|
||||||
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
|
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
|
||||||
}
|
}
|
||||||
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
|
|
||||||
secteur = secteurRepository.save(secteur);
|
if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
|
||||||
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
Secteur secteur = getSecteurFromPayload(secteurPayload);
|
||||||
|
return secteurRepository.save(secteur);
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) {
|
private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) {
|
||||||
// Secteur secteur = new Secteur();
|
Secteur secteur = new Secteur();
|
||||||
//// Optional<User> optionalUser = userRepository.findById(secteurPayload.getChefSecteurId());
|
Optional<User> optionalUser = userRepository.findById(secteurPayload.getChefSecteurId());
|
||||||
// //secteur.setChefSecteur(optionalUser.orElse(null));
|
secteur.setChefSecteur(optionalUser.orElse(null));
|
||||||
//// Optional<Structure> optionalStructure = structureRepository.findById(secteurPayload.getStructureId());
|
Optional<Structure> optionalStructure = structureRepository.findById(secteurPayload.getStructureId());
|
||||||
//// secteur.setStructure(optionalStructure.orElse(null));
|
secteur.setStructure(optionalStructure.orElse(null));
|
||||||
//// List<SecteurDecoupage> secteurDecoupageList = new ArrayList<>();
|
List<SecteurDecoupage> secteurDecoupageList = new ArrayList<>();
|
||||||
//
|
|
||||||
//// for (SecteurDecoupagePayload sdp : secteurPayload.getSecteurDecoupages()) {
|
for (SecteurDecoupagePayload sdp : secteurPayload.getSecteurDecoupages()) {
|
||||||
//// SecteurDecoupage sd = new SecteurDecoupage();
|
SecteurDecoupage sd = new SecteurDecoupage();
|
||||||
//// if (sdp.getSecteurId() != null && secteurRepository.existsById(sdp.getSecteurId())) {
|
if (sdp.getSecteurId() != null && secteurRepository.existsById(sdp.getSecteurId())) {
|
||||||
//// sd.setSecteur(secteurRepository.findById(sdp.getSecteurId()).orElse(null));
|
sd.setSecteur(secteurRepository.findById(sdp.getSecteurId()).orElse(null));
|
||||||
//// }
|
}
|
||||||
////
|
|
||||||
//// if (sdp.getArrondissementId() != null && arrondissementRepository.existsById(sdp.getArrondissementId())) {
|
if (sdp.getArrondissementId() != null && arrondissementRepository.existsById(sdp.getArrondissementId())) {
|
||||||
//// sd.setArrondissement(arrondissementRepository.findById(sdp.getArrondissementId()).orElse(null));
|
sd.setArrondissement(arrondissementRepository.findById(sdp.getArrondissementId()).orElse(null));
|
||||||
//// }
|
}
|
||||||
////
|
|
||||||
//// if (sdp.getQuartierId() != null && quartierRepository.existsById(sdp.getQuartierId())) {
|
if (sdp.getQuartierId() != null && quartierRepository.existsById(sdp.getQuartierId())) {
|
||||||
//// sd.setQuartier(quartierRepository.findById(sdp.getQuartierId()).orElse(null));
|
sd.setQuartier(quartierRepository.findById(sdp.getQuartierId()).orElse(null));
|
||||||
//// }
|
}
|
||||||
//// sd.setDateDebut(sdp.getDateDebut());
|
sd.setDateDebut(sdp.getDateDebut());
|
||||||
//// sd.setDateFin(sdp.getDateFin());
|
sd.setDateFin(sdp.getDateFin());
|
||||||
//// sd.setId(sdp.getId());
|
sd.setId(sdp.getId());
|
||||||
//// secteurDecoupageList.add(sd);
|
secteurDecoupageList.add(sd);
|
||||||
//// }
|
}
|
||||||
// //secteur.setSecteurDecoupages(secteurDecoupageList);
|
secteur.setSecteurDecoupages(secteurDecoupageList);
|
||||||
// //TODO
|
//TODO
|
||||||
// secteur.setId(secteurPayload.getId());
|
secteur.setId(secteurPayload.getId());
|
||||||
// secteur.setCode(secteurPayload.getCode());
|
secteur.setCode(secteurPayload.getCode());
|
||||||
// secteur.setNom(secteurPayload.getNom());
|
secteur.setNom(secteurPayload.getNom());
|
||||||
// return secteur;
|
return secteur;
|
||||||
// }
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecteurPaylaodWeb updateSecteur(Long id, SecteurPaylaodWeb secteurPaylaodWeb) throws NotFoundException {
|
public Secteur updateSecteur(Long id, SecteurPayload secteurPayload) throws NotFoundException {
|
||||||
if (secteurPaylaodWeb.getId() == null) {
|
if (secteurPayload.getId() == null) {
|
||||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null.");
|
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!secteurRepository.existsById(secteurPaylaodWeb.getId())) {
|
if (!secteurRepository.existsById(secteurPayload.getId())) {
|
||||||
throw new NotFoundException("Impossible de trouver le secteur spécifié.");
|
throw new NotFoundException("Impossible de trouver le secteur spécifié.");
|
||||||
}
|
}
|
||||||
Secteur secteur = entityFromPayLoadService.getSecteurFromPayLoadWeb(secteurPaylaodWeb);
|
if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
|
||||||
secteur = secteurRepository.save(secteur);
|
Secteur secteur = getSecteurFromPayload(secteurPayload);
|
||||||
return secteurRepository.findSecteurToDtoById(secteur.getId()).orElse(null);
|
return secteurRepository.save(secteur);
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,58 +115,23 @@ public class SecteurServiceImpl implements SecteurService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SecteurPaylaodWeb> getSecteurList(Pageable pageable) {
|
public Page<Secteur> getSecteurList(Pageable pageable) {
|
||||||
return secteurRepository.findAllSecteurToDtoPageable(pageable);
|
return secteurRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SecteurPaylaodWeb> getSecteurList() {
|
public List<Secteur> getSecteurList() {
|
||||||
return secteurRepository.findAllSecteurToDto();
|
return secteurRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SecteurPaylaodWeb> getSecteurListBySectionId(Long sectionId, Pageable pageable) {
|
public List<Secteur> getSecteurListUneStruture(Long structureId) {
|
||||||
return secteurRepository.findAllSecteurBySectionIdToDtoPageable(sectionId,pageable);
|
return secteurRepository.findAllByStructure_Id(structureId);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SecteurPaylaodWeb> getSecteurListBySectionId(Long sectionId) {
|
|
||||||
return secteurRepository.findAllSecteurBySectionIdToDto(sectionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SecteurPaylaodWeb> getSecteurListByStructureId(Long structureId) {
|
|
||||||
return secteurRepository.findAllSecteurByStructureIdToDto(structureId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SecteurPaylaodWeb> getSecteurListByStructureId(Long structureId, Pageable pageable) {
|
|
||||||
return secteurRepository.findAllSecteurByStructureIdToDtoPageable(structureId,pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SecteurPaylaodWeb> getSecteurById(Long id) {
|
public Optional<Secteur> getSecteurById(Long id) {
|
||||||
return secteurRepository.findSecteurToDtoById(id);
|
return secteurRepository.findById(id);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Secteur> getListSecteurUserId(Long userId) {
|
|
||||||
List<AvoirFonction> avoirFonctions= avoirFonctionRepository.findAvoirFonctionByUser_Id(userId);
|
|
||||||
List<Secteur> secteurs = new ArrayList<>();
|
|
||||||
avoirFonctions.stream()
|
|
||||||
.filter(af -> af.getDateFin() == null || af.getDateFin().isAfter(LocalDate.now()))
|
|
||||||
.forEach(avoirFonction -> {
|
|
||||||
if(avoirFonction.getFonction().getSecteur()!=null){
|
|
||||||
secteurs.addAll(List.of(avoirFonction.getFonction().getSecteur()));
|
|
||||||
}else
|
|
||||||
if (avoirFonction.getFonction().getSection()!=null){
|
|
||||||
secteurs.addAll(secteurRepository.findDistinctBySection_Id(avoirFonction.getFonction().getSection().getId()));
|
|
||||||
}else if(avoirFonction.getFonction().getStructure()!=null){
|
|
||||||
secteurs.addAll(secteurRepository.findDistinctBySection_Structure_Id(avoirFonction.getFonction().getStructure().getId()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return secteurs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user