Merge branch 'ch-evo-17-03-2025' into 'main'
Fix :: Erreur 401 sur toutes les ressources à la levée d'une exception quelconque. See merge request christianakpona/fiscad!6
This commit is contained in:
9
.mvn/wrapper/MavenWrapperDownloader.java
vendored
9
.mvn/wrapper/MavenWrapperDownloader.java
vendored
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
@@ -54,7 +55,7 @@ public class MavenWrapperDownloader {
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if(mavenWrapperPropertyFile.exists()) {
|
||||
if (mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
@@ -65,7 +66,7 @@ public class MavenWrapperDownloader {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if(mavenWrapperPropertyFileInputStream != null) {
|
||||
if (mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -76,8 +77,8 @@ public class MavenWrapperDownloader {
|
||||
System.out.println("- Downloading from: " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if(!outputFile.getParentFile().exists()) {
|
||||
if(!outputFile.getParentFile().mkdirs()) {
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
|
||||
1
HELP.md
1
HELP.md
@@ -1,6 +1,7 @@
|
||||
# Getting Started
|
||||
|
||||
### Reference Documentation
|
||||
|
||||
For further reference, please consider the following sections:
|
||||
|
||||
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf -->
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
|
||||
uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
|
||||
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
|
||||
<property name="com.jaspersoft.studio.unit." value="pixel"/>
|
||||
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
|
||||
@@ -41,7 +46,7 @@
|
||||
</textElement>
|
||||
<text><![CDATA[Structure :]]></text>
|
||||
</staticText>
|
||||
<textField >
|
||||
<textField>
|
||||
<reportElement x="90" y="112" width="590" height="20" uuid="890f9a0d-98c7-4acd-becc-ea41d147c44d"/>
|
||||
<textElement>
|
||||
<font size="12"/>
|
||||
@@ -64,8 +69,10 @@
|
||||
<columnHeader>
|
||||
<band height="20" splitType="Stretch">
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3" uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3"
|
||||
uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -80,8 +87,10 @@
|
||||
<text><![CDATA[Code]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="110" y="0" width="220" height="20" backcolor="#E6E3E3" uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="110" y="0" width="220" height="20" backcolor="#E6E3E3"
|
||||
uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -96,8 +105,10 @@
|
||||
<text><![CDATA[Nom]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="330" y="0" width="185" height="20" backcolor="#E6E3E3" uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="330" y="0" width="185" height="20" backcolor="#E6E3E3"
|
||||
uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -113,8 +124,10 @@
|
||||
<text><![CDATA[Arrondissement]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="515" y="0" width="145" height="20" backcolor="#E6E3E3" uuid="86774042-75a8-480b-8cee-b051aaf448f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="515" y="0" width="145" height="20" backcolor="#E6E3E3"
|
||||
uuid="86774042-75a8-480b-8cee-b051aaf448f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -130,8 +143,10 @@
|
||||
<text><![CDATA[Commune]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="660" y="0" width="140" height="20" backcolor="#E6E3E3" uuid="c083896b-34f1-4034-8422-171bac20fa8b">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="660" y="0" width="140" height="20" backcolor="#E6E3E3"
|
||||
uuid="c083896b-34f1-4034-8422-171bac20fa8b">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -150,9 +165,11 @@
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20" splitType="Stretch">
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20" uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20"
|
||||
uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -166,9 +183,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ContainerHeight" x="110" y="0" width="220" height="20" uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ContainerHeight" x="110" y="0" width="220" height="20"
|
||||
uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
<property name="com.jaspersoft.studio.unit.width" value="px"/>
|
||||
</reportElement>
|
||||
@@ -183,9 +202,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{nom}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="330" y="0" width="185" height="20" uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="330" y="0" width="185" height="20"
|
||||
uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -199,9 +220,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{arrondissement}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="515" y="0" width="145" height="20" uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="515" y="0" width="145" height="20"
|
||||
uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -215,9 +238,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{commune}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="660" y="0" width="140" height="20" uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="660" y="0" width="140" height="20"
|
||||
uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf -->
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
|
||||
uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
|
||||
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
|
||||
<property name="com.jaspersoft.studio.unit." value="pixel"/>
|
||||
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
|
||||
@@ -48,7 +53,7 @@
|
||||
</textElement>
|
||||
<text><![CDATA[Structure :]]></text>
|
||||
</staticText>
|
||||
<textField >
|
||||
<textField>
|
||||
<reportElement x="120" y="112" width="260" height="20" uuid="890f9a0d-98c7-4acd-becc-ea41d147c44d"/>
|
||||
<textElement>
|
||||
<font size="12"/>
|
||||
@@ -59,7 +64,7 @@
|
||||
<reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/>
|
||||
<imageExpression><![CDATA[$P{logoGauche}]]></imageExpression>
|
||||
</image>
|
||||
<textField >
|
||||
<textField>
|
||||
<reportElement x="470" y="112" width="330" height="20" uuid="e89fe5e8-8c95-465a-963a-38c89fe7b45c"/>
|
||||
<textElement>
|
||||
<font size="14"/>
|
||||
@@ -80,7 +85,7 @@
|
||||
</textElement>
|
||||
<text><![CDATA[Commune :]]></text>
|
||||
</staticText>
|
||||
<textField >
|
||||
<textField>
|
||||
<reportElement x="470" y="150" width="330" height="20" uuid="7944bfcb-94e3-4fc3-b717-a65820dd64de"/>
|
||||
<textElement>
|
||||
<font size="14"/>
|
||||
@@ -98,7 +103,7 @@
|
||||
</textElement>
|
||||
<text><![CDATA[Arrondissement :]]></text>
|
||||
</staticText>
|
||||
<textField >
|
||||
<textField>
|
||||
<reportElement x="140" y="-18" width="240" height="20" uuid="f187b92d-cabc-4fbf-afae-7ac6d04d0dd6"/>
|
||||
<textElement>
|
||||
<font size="14"/>
|
||||
@@ -110,8 +115,10 @@
|
||||
<columnHeader>
|
||||
<band height="20" splitType="Stretch">
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3" uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3"
|
||||
uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -126,8 +133,10 @@
|
||||
<text><![CDATA[NUP Provisoire]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="110" y="0" width="120" height="20" backcolor="#E6E3E3" uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="110" y="0" width="120" height="20" backcolor="#E6E3E3"
|
||||
uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -142,8 +151,10 @@
|
||||
<text><![CDATA[Quartier]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="230" y="0" width="50" height="20" backcolor="#E6E3E3" uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="230" y="0" width="50" height="20" backcolor="#E6E3E3"
|
||||
uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -159,8 +170,10 @@
|
||||
<text><![CDATA[Q]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="280" y="0" width="40" height="20" backcolor="#E6E3E3" uuid="86774042-75a8-480b-8cee-b051aaf448f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="280" y="0" width="40" height="20" backcolor="#E6E3E3"
|
||||
uuid="86774042-75a8-480b-8cee-b051aaf448f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -176,8 +189,10 @@
|
||||
<text><![CDATA[I]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="320" y="0" width="50" height="20" backcolor="#E6E3E3" uuid="c083896b-34f1-4034-8422-171bac20fa8b">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="320" y="0" width="50" height="20" backcolor="#E6E3E3"
|
||||
uuid="c083896b-34f1-4034-8422-171bac20fa8b">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -193,8 +208,10 @@
|
||||
<text><![CDATA[P]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="370" y="0" width="60" height="20" backcolor="#E6E3E3" uuid="43fae784-98c5-4c75-bb0a-11f364bce22f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="370" y="0" width="60" height="20" backcolor="#E6E3E3"
|
||||
uuid="43fae784-98c5-4c75-bb0a-11f364bce22f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -209,8 +226,10 @@
|
||||
<text><![CDATA[Litige]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="430" y="0" width="114" height="20" backcolor="#E6E3E3" uuid="6fb97069-4150-4b4d-a7e4-110f7275e530">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="430" y="0" width="114" height="20" backcolor="#E6E3E3"
|
||||
uuid="6fb97069-4150-4b4d-a7e4-110f7275e530">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -225,8 +244,10 @@
|
||||
<text><![CDATA[Nature Domaine]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="544" y="0" width="156" height="20" backcolor="#E6E3E3" uuid="b609f024-82e7-491d-8558-ad6010c18cb6">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="544" y="0" width="156" height="20" backcolor="#E6E3E3"
|
||||
uuid="b609f024-82e7-491d-8558-ad6010c18cb6">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -241,8 +262,10 @@
|
||||
<text><![CDATA[Nom Propriétaire]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3" uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3"
|
||||
uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -260,9 +283,11 @@
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20" splitType="Stretch">
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20" uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20"
|
||||
uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -276,9 +301,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{nupProvisoire}==null ? "" : $F{nupProvisoire}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ContainerHeight" x="110" y="0" width="120" height="20" uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ContainerHeight" x="110" y="0" width="120" height="20"
|
||||
uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
<property name="com.jaspersoft.studio.unit.width" value="px"/>
|
||||
</reportElement>
|
||||
@@ -293,9 +320,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{quartier}==null ? "": $F{quartier}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="230" y="0" width="50" height="20" uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="230" y="0" width="50" height="20"
|
||||
uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -309,9 +338,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{q}==null ? "" : $F{q}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="280" y="0" width="40" height="20" uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="280" y="0" width="40" height="20"
|
||||
uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -325,9 +356,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{i} == null ? "" : $F{i}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="320" y="0" width="50" height="20" uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="320" y="0" width="50" height="20"
|
||||
uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -341,9 +374,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{p} == null ? "" : $F{p}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="370" y="0" width="60" height="20" uuid="5d6015a1-12af-4979-9b77-576cb6c99c05">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="370" y="0" width="60" height="20"
|
||||
uuid="5d6015a1-12af-4979-9b77-576cb6c99c05">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -357,9 +392,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{litige}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="430" y="0" width="114" height="20" uuid="5880e9de-e658-4cda-b737-0d1e791fff8c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="430" y="0" width="114" height="20"
|
||||
uuid="5880e9de-e658-4cda-b737-0d1e791fff8c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -373,9 +410,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{nature}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="544" y="0" width="156" height="20" uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="544" y="0" width="156" height="20"
|
||||
uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -387,11 +426,14 @@
|
||||
<font size="12"/>
|
||||
<paragraph leftIndent="10"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{nomProprietaire} == null ? "" : $F{nomProprietaire}]]></textFieldExpression>
|
||||
<textFieldExpression>
|
||||
<![CDATA[$F{nomProprietaire} == null ? "" : $F{nomProprietaire}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20" uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20"
|
||||
uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf -->
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
|
||||
name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802"
|
||||
leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
|
||||
uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
|
||||
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
|
||||
<property name="com.jaspersoft.studio.unit." value="pixel"/>
|
||||
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
|
||||
@@ -55,8 +60,10 @@
|
||||
<columnHeader>
|
||||
<band height="20" splitType="Stretch">
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<reportElement mode="Opaque" x="0" y="0" width="70" height="20" backcolor="#E6E3E3"
|
||||
uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -71,8 +78,10 @@
|
||||
<text><![CDATA[NUP Provisoire]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="200" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="200" y="0" width="70" height="20" backcolor="#E6E3E3"
|
||||
uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -87,8 +96,10 @@
|
||||
<text><![CDATA[Commune]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="270" y="0" width="80" height="20" backcolor="#E6E3E3" uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="270" y="0" width="80" height="20" backcolor="#E6E3E3"
|
||||
uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -104,8 +115,10 @@
|
||||
<text><![CDATA[Arrondissement]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="350" y="0" width="80" height="20" backcolor="#E6E3E3" uuid="86774042-75a8-480b-8cee-b051aaf448f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="350" y="0" width="80" height="20" backcolor="#E6E3E3"
|
||||
uuid="86774042-75a8-480b-8cee-b051aaf448f3">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -121,8 +134,10 @@
|
||||
<text><![CDATA[Bloc]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="430" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="c083896b-34f1-4034-8422-171bac20fa8b">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<reportElement mode="Opaque" x="430" y="0" width="70" height="20" backcolor="#E6E3E3"
|
||||
uuid="c083896b-34f1-4034-8422-171bac20fa8b">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -138,8 +153,10 @@
|
||||
<text><![CDATA[Structure]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="140" y="0" width="60" height="20" backcolor="#E6E3E3" uuid="43fae784-98c5-4c75-bb0a-11f364bce22f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="140" y="0" width="60" height="20" backcolor="#E6E3E3"
|
||||
uuid="43fae784-98c5-4c75-bb0a-11f364bce22f">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -154,8 +171,10 @@
|
||||
<text><![CDATA[Litige]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="70" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="6fb97069-4150-4b4d-a7e4-110f7275e530">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="70" y="0" width="70" height="20" backcolor="#E6E3E3"
|
||||
uuid="6fb97069-4150-4b4d-a7e4-110f7275e530">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -170,8 +189,10 @@
|
||||
<text><![CDATA[Nature Domaine]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="590" y="0" width="110" height="20" backcolor="#E6E3E3" uuid="b609f024-82e7-491d-8558-ad6010c18cb6">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="590" y="0" width="110" height="20" backcolor="#E6E3E3"
|
||||
uuid="b609f024-82e7-491d-8558-ad6010c18cb6">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -186,8 +207,10 @@
|
||||
<text><![CDATA[Nom Propriétaire]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3" uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3"
|
||||
uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -202,8 +225,10 @@
|
||||
<text><![CDATA[Statut]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="500" y="0" width="90" height="20" backcolor="#E6E3E3" uuid="3a10eece-e81b-408b-b680-d7f31c9931a1">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<reportElement mode="Opaque" x="500" y="0" width="90" height="20" backcolor="#E6E3E3"
|
||||
uuid="3a10eece-e81b-408b-b680-d7f31c9931a1">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -221,9 +246,11 @@
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="20" splitType="Stretch">
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="70" height="20" uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="70" height="20"
|
||||
uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -237,9 +264,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{nupprovisoire}==null ? "" : $F{nupprovisoire}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ContainerHeight" x="200" y="0" width="70" height="20" uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ContainerHeight" x="200" y="0" width="70" height="20"
|
||||
uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
<property name="com.jaspersoft.studio.unit.width" value="px"/>
|
||||
</reportElement>
|
||||
@@ -254,9 +283,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{communenom}==null ? "": $F{communenom}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="270" y="0" width="80" height="20" uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="270" y="0" width="80" height="20"
|
||||
uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -268,11 +299,14 @@
|
||||
<font size="8"/>
|
||||
<paragraph leftIndent="10"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{arrondissementnom}==null ? "" : $F{arrondissementnom}]]></textFieldExpression>
|
||||
<textFieldExpression>
|
||||
<![CDATA[$F{arrondissementnom}==null ? "" : $F{arrondissementnom}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="350" y="0" width="80" height="20" uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="350" y="0" width="80" height="20"
|
||||
uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -286,9 +320,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{blocnom} == null ? "" : $F{blocnom}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="430" y="0" width="70" height="20" uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="430" y="0" width="70" height="20"
|
||||
uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -302,9 +338,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{structurenom}== null ? "" : $F{structurenom}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="140" y="0" width="60" height="20" uuid="5d6015a1-12af-4979-9b77-576cb6c99c05">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="140" y="0" width="60" height="20"
|
||||
uuid="5d6015a1-12af-4979-9b77-576cb6c99c05">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -318,9 +356,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{litige}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="70" y="0" width="70" height="20" uuid="5880e9de-e658-4cda-b737-0d1e791fff8c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="70" y="0" width="70" height="20"
|
||||
uuid="5880e9de-e658-4cda-b737-0d1e791fff8c">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -334,9 +374,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{naturedomaine}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="590" y="0" width="110" height="20" uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="590" y="0" width="110" height="20"
|
||||
uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -350,9 +392,11 @@
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{prenomraisonsociale} +" "+ $F{nomsigle}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20" uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20"
|
||||
uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
@@ -364,11 +408,14 @@
|
||||
<font size="8"/>
|
||||
<paragraph leftIndent="10"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{statusenquete} == null ? "" : $F{statusenquete}]]></textFieldExpression>
|
||||
<textFieldExpression>
|
||||
<![CDATA[$F{statusenquete} == null ? "" : $F{statusenquete}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField >
|
||||
<reportElement stretchType="ElementGroupHeight" x="500" y="0" width="90" height="20" uuid="28eac03c-0024-4451-9e95-b755a6cb6cb7">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<textField>
|
||||
<reportElement stretchType="ElementGroupHeight" x="500" y="0" width="90" height="20"
|
||||
uuid="28eac03c-0024-4451-9e95-b755a6cb6cb7">
|
||||
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
|
||||
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
|
||||
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
|
||||
</reportElement>
|
||||
<box>
|
||||
|
||||
1
pom.xml
1
pom.xml
@@ -98,7 +98,6 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.locationtech.jts</groupId>
|
||||
<artifactId>jts-core</artifactId>
|
||||
|
||||
@@ -31,16 +31,15 @@ public class DataLoadConfig {
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void loadData(){
|
||||
public void loadData() {
|
||||
loadRoles();
|
||||
loadUsers();
|
||||
}
|
||||
|
||||
|
||||
public void loadRoles() {
|
||||
|
||||
public void loadRoles(){
|
||||
|
||||
if(roleRepository.count() > 0) return;
|
||||
if (roleRepository.count() > 0) return;
|
||||
Set<Role> roles = new HashSet<>();
|
||||
roles.add(new Role(UserRole.ROLE_USER, "Role attribué aux utilisateurs simples."));
|
||||
roles.add(new Role(UserRole.ROLE_ADMIN, "Role attribué aux administrateurs du système."));
|
||||
@@ -52,8 +51,8 @@ public class DataLoadConfig {
|
||||
|
||||
}
|
||||
|
||||
public void loadUsers(){
|
||||
if(userRepository.countAllByUsernameIsNotNull() == 0) {
|
||||
public void loadUsers() {
|
||||
if (userRepository.countAllByUsernameIsNotNull() == 0) {
|
||||
User admin = new User();
|
||||
admin.setUsername("administrateur@infocad.bj");
|
||||
admin.setEmail("administrateur@infocad.bj");
|
||||
|
||||
@@ -9,7 +9,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@@ -18,6 +21,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
public class ApplicationConfig {
|
||||
|
||||
private final CustomUserDetailsService customUserDetailsService;
|
||||
private final UserDetailsService userDetailsService;
|
||||
|
||||
@Bean
|
||||
public AuthenticationProvider authenticationProvider() {
|
||||
@@ -37,13 +41,27 @@ public class ApplicationConfig {
|
||||
return new JwtAuthenticationFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {
|
||||
return config.getAuthenticationManager();
|
||||
}
|
||||
// @Bean
|
||||
// public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {
|
||||
// return config.getAuthenticationManager();
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public ModelMapper modelMapper() {
|
||||
return new ModelMapper();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(HttpSecurity http) throws Exception {
|
||||
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
|
||||
daoAuthenticationProvider.setUserDetailsService(customUserDetailsService);
|
||||
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
|
||||
|
||||
AuthenticationManagerBuilder authenticationManagerBuilder =
|
||||
http.getSharedObject(AuthenticationManagerBuilder.class);
|
||||
|
||||
authenticationManagerBuilder.authenticationProvider(daoAuthenticationProvider);
|
||||
|
||||
return authenticationManagerBuilder.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class AuditorAwareImpl implements AuditorAware<Long> {
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
if(authentication == null || !authentication.isAuthenticated() || authentication instanceof AnonymousAuthenticationToken){
|
||||
if (authentication == null || !authentication.isAuthenticated() || authentication instanceof AnonymousAuthenticationToken) {
|
||||
return Optional.empty();
|
||||
}
|
||||
UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
|
||||
|
||||
@@ -9,8 +9,7 @@ import javax.sql.DataSource;
|
||||
@Configuration
|
||||
public class JdbcConfig {
|
||||
@Bean
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource)
|
||||
{
|
||||
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
|
||||
return new JdbcTemplate(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class SpringSecurityConfig {
|
||||
// .csrf(csrf -> {
|
||||
// csrf.ignoringRequestMatchers("/api/**");
|
||||
// })
|
||||
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
|
||||
.authorizeHttpRequests(req ->
|
||||
req
|
||||
//.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
@@ -65,10 +66,11 @@ public class SpringSecurityConfig {
|
||||
.authenticationProvider(authenticationProvider)
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
|
||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
|
||||
|
||||
;
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -23,18 +23,18 @@ public class SwaggerOAS3Config {
|
||||
|
||||
private static final String[] DECOUPAGE = {
|
||||
"/api/arrondissement/**", "/api/commune/**", "/api/departement/**", "/api/nationalite/**", "/api/quartier/**",
|
||||
"/api/secteur/**","/api/secteur-decoupage/**"
|
||||
"/api/secteur/**", "/api/secteur-decoupage/**"
|
||||
};
|
||||
|
||||
private static final String[] INFOCAD_METIER = {
|
||||
//metier
|
||||
"/api/acteur-concerne/**","/api/commentaire/**","/api/enquete/**","/api/tpe/**","/api/upload/**",
|
||||
"/api/acteur-concerne/**", "/api/commentaire/**", "/api/enquete/**", "/api/tpe/**", "/api/upload/**",
|
||||
};
|
||||
|
||||
private static final String[] INFOCAD_PARAMETERS = {
|
||||
"/api/bloc/**","/api/mode-acquisition/**","/api/nature-domaine/**","/api/position-representation/**",
|
||||
"/api/profession/**","/api/situation-geographique/**","/api/situation-matrimoniale/**","/api/source-droit/**",
|
||||
"/api/structure/**","/api/type-contestation/**","/api/type-domaine/**","/api/type-personne/**","/api/type-piece/**",
|
||||
"/api/bloc/**", "/api/mode-acquisition/**", "/api/nature-domaine/**", "/api/position-representation/**",
|
||||
"/api/profession/**", "/api/situation-geographique/**", "/api/situation-matrimoniale/**", "/api/source-droit/**",
|
||||
"/api/structure/**", "/api/type-contestation/**", "/api/type-domaine/**", "/api/type-personne/**", "/api/type-piece/**",
|
||||
"/api/type-representation/**"
|
||||
};
|
||||
|
||||
@@ -84,7 +84,6 @@ public class SwaggerOAS3Config {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi infocadMetierApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
|
||||
@@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import net.sf.jasperreports.engine.JasperCompileManager;
|
||||
import net.sf.jasperreports.engine.JasperReport;
|
||||
import net.sf.jasperreports.engine.util.JRSaver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -23,14 +25,16 @@ public class OpenController {
|
||||
@Value("${file.jasper-reports}")
|
||||
private String jaspersDir;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OpenController.class);
|
||||
|
||||
@GetMapping("/compile-report")
|
||||
public ResponseEntity<?> compile(@RequestParam String jrxmlFileName) {
|
||||
try{
|
||||
try {
|
||||
InputStream quitusReportStream = getStream(jaspersDir + "/" + jrxmlFileName + ".jrxml");
|
||||
JasperReport jasperReport = JasperCompileManager.compileReport(quitusReportStream);
|
||||
JRSaver.saveObject(jasperReport, jaspersDir + "/" + jrxmlFileName + ".jasper");
|
||||
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
@@ -43,5 +47,4 @@ public class OpenController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@ package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Arrondissement;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -16,7 +18,7 @@ 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
|
||||
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class ArrondissementController {
|
||||
|
||||
private final ArrondissementService arrondissementService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(ArrondissementController.class);
|
||||
|
||||
public ArrondissementController(ArrondissementService arrondissementService) {
|
||||
this.arrondissementService = arrondissementService;
|
||||
@@ -41,17 +44,25 @@ public class ArrondissementController {
|
||||
)
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createArrondissement(@RequestBody @Valid @Validated Arrondissement arrondissement) {
|
||||
try{
|
||||
try {
|
||||
arrondissement = arrondissementService.createArrondissement(arrondissement);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissement, "Arrondissement créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,73 +75,144 @@ public class ArrondissementController {
|
||||
)
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateArrondissement(@PathVariable Long id, @RequestBody Arrondissement arrondissement) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissementService.updateArrondissement(id, arrondissement), "Arrondissement mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteArrondissement(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
arrondissementService.deleteArrondissement(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Arrondissement supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Arrondissement 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<?> getAllArrondissementList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementList(), "Liste des arrondissements 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<?> getAllArrondissementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementList(pageable), "Liste des arrondissements 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<?> getArrondissementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement 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("/commune/{communeId}")
|
||||
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
|
||||
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (NotFoundException e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Commune;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.CommuneService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -15,7 +17,7 @@ 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
|
||||
@@ -27,95 +29,176 @@ public class CommuneController {
|
||||
|
||||
private final CommuneService communeService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CommuneController.class);
|
||||
|
||||
public CommuneController(CommuneService communeService) {
|
||||
this.communeService = communeService;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createCommune(@RequestBody @Valid @Validated Commune commune) {
|
||||
try{
|
||||
try {
|
||||
commune = communeService.createCommune(commune);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commune, "Commune créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateCommune(@PathVariable Long id, @RequestBody Commune commune) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, communeService.updateCommune(id, commune), "Commune mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteCommuner(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
communeService.deleteCommune(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Commune supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Commune 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<?> getAllCommuneList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, communeService.getCommuneList(), "Liste des communes 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<?> getAllCommunePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, communeService.getCommuneList(pageable), "Liste des communes 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<?> getCommuneById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, communeService.getCommuneById(id), "Commune 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("/departement/{departementId}")
|
||||
public ResponseEntity<?> getCommuneByDepartement(@PathVariable Long departementId) {
|
||||
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (NotFoundException e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Departement;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.DepartementService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class DepartementController {
|
||||
|
||||
private final DepartementService departementService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(DepartementController.class);
|
||||
|
||||
public DepartementController(DepartementService departementService) {
|
||||
this.departementService = departementService;
|
||||
@@ -32,73 +36,144 @@ public class DepartementController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createDepartement(@RequestBody @Valid @Validated Departement departement) {
|
||||
try{
|
||||
try {
|
||||
departement = departementService.createDepartement(departement);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, departement, "Departement créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateDepartement(@PathVariable Long id, @RequestBody Departement departement) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, departementService.updateDepartement(id, departement), "Département mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteDepartementr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
departementService.deleteDepartement(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Département supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Département supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllDepartementList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, departementService.getDepartementList(), "Liste des 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("/all-paged")
|
||||
public ResponseEntity<?> getAllDepartementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, departementService.getDepartementList(pageable), "Liste des 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("/id/{id}")
|
||||
public ResponseEntity<?> getDepartementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, departementService.getDepartementById(id), "Département 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Nationalite;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.NationaliteService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class NationaliteController {
|
||||
|
||||
private final NationaliteService nationaliteService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(NationaliteController.class);
|
||||
|
||||
public NationaliteController(NationaliteService nationaliteService) {
|
||||
this.nationaliteService = nationaliteService;
|
||||
@@ -32,73 +36,143 @@ public class NationaliteController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createNationalite(@RequestBody @Valid @Validated Nationalite nationalite) {
|
||||
try{
|
||||
try {
|
||||
nationalite = nationaliteService.createNationalite(nationalite);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, nationalite, "Nationalite créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateNationalite(@PathVariable Long id, @RequestBody Nationalite nationalite) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, nationaliteService.updateNationalite(id, nationalite), "Nationalités mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteNationaliter(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
nationaliteService.deleteNationalite(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Nationalités supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Nationalités supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllNationaliteList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, nationaliteService.getNationaliteList(), "Liste des nationalités 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<?> getAllNationalitePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, nationaliteService.getNationaliteList(pageable), "Liste des nationalités 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<?> getNationaliteById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, nationaliteService.getNationaliteById(id), "Nationalités 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.QuartierService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -15,6 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class QuartierController {
|
||||
|
||||
private final QuartierService quartierService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(QuartierController.class);
|
||||
|
||||
public QuartierController(QuartierService quartierService) {
|
||||
this.quartierService = quartierService;
|
||||
@@ -32,89 +36,166 @@ public class QuartierController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createQuartier(@RequestBody @Valid @Validated Quartier quartier) {
|
||||
try{
|
||||
try {
|
||||
quartier = quartierService.createQuartier(quartier);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartier, "Quartier créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateQuartier(@PathVariable Long id, @RequestBody Quartier quartier) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartierService.updateQuartier(id, quartier), "Quartier mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteQuartier(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
quartierService.deleteQuartier(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Quartier supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Quartier supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllQuartierList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartierService.getQuartierList(), "Liste des quartiers 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<?> getAllQuartierPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartierService.getQuartierList(pageable), "Liste des quartiers 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<?> getQuartierById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier 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("/arrondissement/{arrondissementId}")
|
||||
public ResponseEntity<?> getQuartierByArrondissement(@PathVariable Long arrondissementId) {
|
||||
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (NotFoundException e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.Secteur;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.SecteurService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.SecteurPayload;
|
||||
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;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -23,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SecteurController {
|
||||
|
||||
private final SecteurService secteurService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SecteurController.class);
|
||||
|
||||
public SecteurController(SecteurService secteurService) {
|
||||
this.secteurService = secteurService;
|
||||
@@ -31,86 +36,169 @@ public class SecteurController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) {
|
||||
try{
|
||||
try {
|
||||
// Secteur secteur=getSecteurFromPayload(secteurPayload);
|
||||
Secteur secteur = secteurService.createSecteur(secteurPayload);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteur, "Secteur créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPayload secteurPayload) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayload), "Secteur mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
secteurService.deleteSecteur(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Secteur supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Secteur 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<?> getAllSecteurList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurService.getSecteurList(), "Liste des secteurs 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<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurService.getSecteurList(pageable), "Liste des secteurs 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<?> getSecteurById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurService.getSecteurById(id), "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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/by-structure-id/{structureId}")
|
||||
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurService.getSecteurById(structureId), "Secteur trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package io.gmss.fiscad.controllers.decoupage;
|
||||
|
||||
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -13,6 +16,7 @@ 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
|
||||
@@ -22,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SecteurDecoupageController {
|
||||
|
||||
private final SecteurDecoupageService secteurDecoupageService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SecteurDecoupageController.class);
|
||||
|
||||
public SecteurDecoupageController(SecteurDecoupageService secteurDecoupageService) {
|
||||
this.secteurDecoupageService = secteurDecoupageService;
|
||||
@@ -30,74 +35,143 @@ public class SecteurDecoupageController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
|
||||
try{
|
||||
try {
|
||||
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteSecteurDecoupager(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
secteurDecoupageService.deleteSecteurDecoupage(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Secteur découpage supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Secteur découpage 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<?> getAllSecteurDecoupageList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageList(), "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("/all-paged")
|
||||
public ResponseEntity<?> getAllSecteurDecoupagePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageList(pageable), "Liste des secteurDecoupages chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, secteurDecoupageService.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package io.gmss.fiscad.controllers.infocad.metier;
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.metier.ActeurConcerneService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "api/acteur-concerne", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -18,6 +22,8 @@ public class ActeurConcerneController {
|
||||
|
||||
private final ActeurConcerneService acteurConcerneService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActeurConcerneController.class);
|
||||
|
||||
public ActeurConcerneController(ActeurConcerneService acteurConcerneService) {
|
||||
this.acteurConcerneService = acteurConcerneService;
|
||||
}
|
||||
@@ -25,10 +31,25 @@ public class ActeurConcerneController {
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, acteurConcerneService.getActeurConcerneById(id).get(), "Arrondissement 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.gmss.fiscad.controllers.infocad.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.metier.Commentaire;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.CommentaireRequest;
|
||||
@@ -9,11 +10,14 @@ import io.gmss.fiscad.paylaods.request.SyncCommentaireRequest;
|
||||
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.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.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -27,6 +31,8 @@ public class CommentaireController {
|
||||
|
||||
private final CommentaireService commentaireService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CommentaireController.class);
|
||||
|
||||
public CommentaireController(CommentaireService commentaireService) {
|
||||
this.commentaireService = commentaireService;
|
||||
}
|
||||
@@ -34,127 +40,286 @@ public class CommentaireController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createcommentaire(@RequestBody @Valid @Validated Commentaire commentaire) {
|
||||
try{
|
||||
try {
|
||||
commentaire.setDateCommentaire(LocalDateTime.now());
|
||||
commentaire = commentaireService.createCommentaire(commentaire);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaire, "Commentaire créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updatecommentaire(@PathVariable Long id, @RequestBody Commentaire commentaire) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.updateCommentaire(id, commentaire), "commentaire mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deletecommentaire(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
commentaireService.deleteCommentaire(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Commentaire supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Commentaire supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllcommentaireList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentaireList(), "Liste des commentaires 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<?> getcommentaireById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentaireById(id), "commentaire 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("/nup/{nup}")
|
||||
public ResponseEntity<?> getcommentaireByNup(@PathVariable String nup) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentaireByNup(nup), "commentaire 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/enquete")
|
||||
public ResponseEntity<?> getcommentaireByEnquete(@RequestBody Commentaire commentaire) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentairesByEnqueteAndTerminal(commentaire.getIdEnquete(), commentaire.getTerminalId()), "Liste des commentaires chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/enquete-and-state")
|
||||
//@ApiOperation(value = "Cette ressource permet d'avoir la liste de tous les commentaires d'une enquête avec le statut (lu ou non lu). Les champs a renseigner pour le payload sont idEnquete et lu")
|
||||
public ResponseEntity<?> getcommentaireByEnqueteAndStatut(@RequestBody Commentaire commentaire) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentairesByEnqueteAndLu(commentaire.getIdEnquete(), commentaire.isLu()), "Liste des commentaires chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/all-by-params")
|
||||
//@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) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentairesByOrigineAndStateReadAndTerminalId(commentaireRequest.getOrigine(), commentaireRequest.isLu(), commentaireRequest.getTerminalId()), "Liste des commentaires chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("synchronise/from-mobile")
|
||||
//@ApiOperation(value = "Cette ressource permet de synchroniser tous les commentaires effectués sur le mobile vers le backend.")
|
||||
public ResponseEntity<?> synchroniseCommentairesFromMobile(@RequestBody List<Commentaire> commentaires) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.saveAllCommentairesFromMobile(commentaires), "Liste des commentaires synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("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 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) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.getCommentairesByOrigineAndStateSynchronizedAndTerminalId(commentaireRequest.getOrigine(), commentaireRequest.isSynchronise(), commentaireRequest.getTerminalId()), "Liste des commentaires chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("synchronise/notify-done-from-mobile")
|
||||
//@ApiOperation(value = "Cette ressource permet matérialiser coté backend les commentaires du WEB déjà synchronisé avec le MOBILE pour que les prochaines extractions ne prennent pas en compte cela. ")
|
||||
public ResponseEntity<?> notifyDoneSynchronizedFromMobile(@RequestBody List<SyncCommentaireRequest> syncCommentaireRequests) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, commentaireService.notifySynchronizedDoneFromMobile(syncCommentaireRequests), "Synchronisation terminé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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.gmss.fiscad.controllers.infocad.metier;
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.EnquetePayLoad;
|
||||
@@ -8,6 +9,8 @@ import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
|
||||
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;
|
||||
@@ -15,6 +18,7 @@ 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;
|
||||
|
||||
@@ -25,7 +29,9 @@ import java.util.List;
|
||||
@CrossOrigin(origins = "*")
|
||||
public class EnqueteController {
|
||||
|
||||
private final EnqueteService enqueteService ;
|
||||
private final EnqueteService enqueteService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(EnqueteController.class);
|
||||
|
||||
public EnqueteController(EnqueteService enqueteService) {
|
||||
this.enqueteService = enqueteService;
|
||||
@@ -51,144 +57,304 @@ public class EnqueteController {
|
||||
|
||||
@PutMapping("/validation")
|
||||
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false,"Impossible de valider l'enquête : "+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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/rejet")
|
||||
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false,"Impossible de valider l'enquête : "+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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/validation-lot")
|
||||
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false,"Impossible de valider l'enquête : " + 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/rejet-lot")
|
||||
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectuée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false,"Impossible de valider l'enquête : "+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/decoupage-admin-for-enquete")
|
||||
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.getDecoupageAdminUserConnecterAndStat(), "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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
enqueteService.deleteEnquete(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"enquete supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "enquete 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<?> getAllStructureList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.getEnqueteList(), "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/com-arrond-bloc")
|
||||
public ResponseEntity<?> getAllByCommuneArrondBloc() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/all/com-arrond-bloc/filtre")
|
||||
public ResponseEntity<?> getAllByCommuneArrondBlocFiltre(@RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBlocFiltre(filtreEnquetePayLoad), "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, enqueteService.getEnqueteList(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("/fiche/id/{id}")
|
||||
public ResponseEntity<?> getFicheEnqueteById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.getFicheEnquete(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("/id/{id}")
|
||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.getEnqueteById(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("/traiter-non-synch-to-mobile/{terminalId}")
|
||||
public ResponseEntity<?> getEnqueteValideNonSynch(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteService.getEnqueteValideNonSynch(terminalId), "Liste des enquetes traitées non synchronisées sur le termianl."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.metier.Tpe;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.metier.TpeService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TpeController {
|
||||
|
||||
private final TpeService tpeService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TpeController.class);
|
||||
|
||||
public TpeController(TpeService tpeService) {
|
||||
this.tpeService = tpeService;
|
||||
@@ -31,98 +36,212 @@ public class TpeController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTpe(@RequestBody @Valid @Validated Tpe tpe) {
|
||||
try{
|
||||
try {
|
||||
tpe = tpeService.createTpe(tpe);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpe, "Tpe créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTpe(@PathVariable Long id, @RequestBody Tpe tpe) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.updateTpe(id, tpe), "Tpe mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTper(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
tpeService.deleteTpe(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Tpe supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Tpe supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTpeList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.getTpeList(), "Liste des tpe 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-model/{model}")
|
||||
public ResponseEntity<?> getAllTpeListByModel(@PathVariable String model) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.getTpeListByModel(model), "Liste des tpe 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-userId/{userId}")
|
||||
public ResponseEntity<?> getAllTpeListByUserId(@PathVariable Long userId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.getTpeListByUserId(userId), "Liste des tpe de l'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<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.getTpeList(pageable), "Liste des tpe 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<?> getTpeById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.getTpeById(id), "Tpe 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("/identifier/{identifier}")
|
||||
public ResponseEntity<?> getTpeByIdentifier(@PathVariable String identifier) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, tpeService.getTepByIdentifier(identifier), "Tpe 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.time.format.DateTimeFormatter;
|
||||
@CrossOrigin(origins = "*")
|
||||
public class UploadController {
|
||||
|
||||
boolean headIsValid=false;
|
||||
boolean headIsValid = false;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
|
||||
|
||||
@@ -44,7 +44,6 @@ public class UploadController {
|
||||
private UploadRepository uploadRepository;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private FileStorageService fileStorageService;
|
||||
|
||||
@@ -55,9 +54,6 @@ public class UploadController {
|
||||
// private ActeurRepository proprietaireRepository;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private int firstLineColumnNumber = 0;
|
||||
private String fileHeader;
|
||||
private String fileHeaderType;
|
||||
@@ -65,14 +61,10 @@ public class UploadController {
|
||||
private int indiceOfFile = 0;
|
||||
|
||||
|
||||
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMDD");
|
||||
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYYMMDD");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<?> all() {
|
||||
try {
|
||||
@@ -82,13 +74,13 @@ public class UploadController {
|
||||
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findAll(), "All uploads files founded."), HttpStatus.OK);
|
||||
}
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
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);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +106,6 @@ public class UploadController {
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> one(@PathVariable Long id) {
|
||||
|
||||
@@ -123,21 +113,20 @@ public class UploadController {
|
||||
if (uploadRepository.findById(id).isPresent()) {
|
||||
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<>(new ApiResponse(true, null,"The upload with id {" + id + "} you request for is not found."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK);
|
||||
}
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
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);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param fileName
|
||||
* @param request
|
||||
@@ -168,7 +157,7 @@ public class UploadController {
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file , @RequestParam String reference,@RequestParam String description /*, @RequestParam Long idTypeUpload*/) {
|
||||
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file, @RequestParam String reference, @RequestParam String description /*, @RequestParam Long idTypeUpload*/) {
|
||||
|
||||
try {
|
||||
Upload upload = new Upload();
|
||||
@@ -187,22 +176,20 @@ public class UploadController {
|
||||
upload.setMimeType(file.getContentType());
|
||||
upload.setSize(file.getSize());
|
||||
upload.setOriginalFileName(file.getOriginalFilename());
|
||||
return new ResponseEntity<>(new ApiResponse(true,uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
return new ResponseEntity<>(new ApiResponse(false,null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@DeleteMapping("/delete/id/{id}")
|
||||
public ResponseEntity<?> delete(@PathVariable Long id) {
|
||||
try {
|
||||
@@ -210,18 +197,18 @@ public class UploadController {
|
||||
String name = uploadRepository.getOne(id).getFileName();
|
||||
fileStorageService.deleteFile(name);
|
||||
uploadRepository.deleteById(id);
|
||||
return new ResponseEntity<>(new ApiResponse(true,null, "File with name {" + name + "} has been deleted successfully."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(true, null, "File with name {" + name + "} has been deleted successfully."), HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<>(new ApiResponse(true,null, "The upload specified in your request body is not found."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(true, null, "The upload specified in your request body is not found."), HttpStatus.OK);
|
||||
}
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
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);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.Bloc;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.BlocService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.security.CurrentUser;
|
||||
import io.gmss.fiscad.security.UserPrincipal;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -16,7 +18,7 @@ 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
|
||||
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class BlocController {
|
||||
|
||||
private final BlocService blocService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(BlocController.class);
|
||||
|
||||
public BlocController(BlocService blocService) {
|
||||
this.blocService = blocService;
|
||||
@@ -34,99 +37,218 @@ public class BlocController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createBloc(@RequestBody @Valid @Validated Bloc bloc, @CurrentUser UserPrincipal userPrincipal) {
|
||||
try{
|
||||
try {
|
||||
bloc = blocService.createBloc(bloc);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, bloc, "Bloc créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateBloc(@PathVariable Long id, @RequestBody Bloc bloc) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.updateBloc(id, bloc), "Bloc mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteBlocr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
blocService.deleteBloc(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Bloc supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Bloc supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllBlocList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.getBlocList(), "Liste des blocs 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("/list-by-arrondissement")
|
||||
public ResponseEntity<?> getAllBlocListByArrondissement(@RequestParam Long idArrondissement) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.getBlocsByArrondissement(idArrondissement), "Liste des blocs 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("/list-by-structure")
|
||||
public ResponseEntity<?> getAllBlocListByStructure(@RequestParam Long idStructure) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.getBlocsByStructure(idStructure), "Liste des blocs 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("/list-by-secteur")
|
||||
@Tag(name = "Liste blocs",description = "Liste des blocs d'un secteur")
|
||||
@Tag(name = "Liste blocs", description = "Liste des blocs d'un secteur")
|
||||
public ResponseEntity<?> getAllBlocListBySecteur(@RequestParam Long idSecteur) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.getBlocsBySecteur(idSecteur), "Liste des blocs 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<?> getAllBlocPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.getBlocList(pageable), "Liste des blocs 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<?> getBlocById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, blocService.getBlocById(id), "Bloc 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.ModeAcquisitionService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -26,79 +29,150 @@ public class ModeAcquisitionController {
|
||||
|
||||
private final ModeAcquisitionService modeAcquisitionService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ModeAcquisitionController.class);
|
||||
|
||||
public ModeAcquisitionController(ModeAcquisitionService modeAcquisitionService) {
|
||||
this.modeAcquisitionService = modeAcquisitionService;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createModeAcquisition(@RequestBody @Valid @Validated ModeAcquisition modeAcquisition) {
|
||||
try{
|
||||
try {
|
||||
modeAcquisition = modeAcquisitionService.createModeAcquisition(modeAcquisition);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modeAcquisition, "Mode acquisition créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateModeAcquisition(@PathVariable Long id, @RequestBody ModeAcquisition modeAcquisition) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modeAcquisitionService.updateModeAcquisition(id, modeAcquisition), "Mode d'acquisition mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteModeAcquisitionr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
modeAcquisitionService.deleteModeAcquisition(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Mode d'acquisition supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Mode d'acquisition supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllModeAcquisitionList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionList(), "Liste des modes d'acquisitions 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<?> getAllModeAcquisitionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionList(pageable), "Liste des modes d'acquisitions 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<?> getModeAcquisitionById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionById(id), "Mode d'acquisition 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.NatureDomaineService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class NatureDomaineController {
|
||||
|
||||
private final NatureDomaineService natureDomaineService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(NatureDomaineController.class);
|
||||
|
||||
public NatureDomaineController(NatureDomaineService natureDomaineService) {
|
||||
this.natureDomaineService = natureDomaineService;
|
||||
@@ -32,73 +36,142 @@ public class NatureDomaineController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createNatureDomaine(@RequestBody @Valid @Validated NatureDomaine natureDomaine) {
|
||||
try{
|
||||
try {
|
||||
natureDomaine = natureDomaineService.createNatureDomaine(natureDomaine);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, natureDomaine, "Nature Domaine créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateNatureDomaine(@PathVariable Long id, @RequestBody NatureDomaine natureDomaine) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, natureDomaineService.updateNatureDomaine(id, natureDomaine), "Nature Domaine mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteNatureDomainer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
natureDomaineService.deleteNatureDomaine(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Nature Domaine supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Nature Domaine 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<?> getAllNatureDomaineList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, natureDomaineService.getNatureDomaineList(), "Liste des natures de domaine 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<?> getAllNatureDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, natureDomaineService.getNatureDomaineList(pageable), "Liste des natures de domaine 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<?> getNatureDomaineById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, natureDomaineService.getNatureDomaineById(id), "Nature Domaine 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.PositionRepresentation;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.PositionRepresentationService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class PositionRepresentationController {
|
||||
|
||||
private final PositionRepresentationService positionRepresentationService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(PositionRepresentationController.class);
|
||||
|
||||
public PositionRepresentationController(PositionRepresentationService positionRepresentationService) {
|
||||
this.positionRepresentationService = positionRepresentationService;
|
||||
@@ -31,73 +36,144 @@ public class PositionRepresentationController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createPositionRepresentation(@RequestBody @Valid @Validated PositionRepresentation positionRepresentation) {
|
||||
try{
|
||||
try {
|
||||
positionRepresentation = positionRepresentationService.createPositionRepresentation(positionRepresentation);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, positionRepresentation, "Position de representation créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updatePositionRepresentation(@PathVariable Long id, @RequestBody PositionRepresentation positionRepresentation) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, positionRepresentationService.updatePositionRepresentation(id, positionRepresentation), "Position de representation mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deletePositionRepresentation(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
positionRepresentationService.deletePositionRepresentation(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Position de representation supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Position de representation 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<?> getAllPositionRepresentationList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationList(), "Liste des positions de representation 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<?> getAllPositionRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationList(pageable), "Liste des positions de representation 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<?> getPositionRepresentationById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationById(id), "Position de representation trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.Profession;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.ProfessionService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -25,79 +29,152 @@ public class ProfessionController {
|
||||
|
||||
private final ProfessionService professionService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProfessionController.class);
|
||||
|
||||
public ProfessionController(ProfessionService professionService) {
|
||||
this.professionService = professionService;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createProfession(@RequestBody @Valid @Validated Profession profession) {
|
||||
try{
|
||||
try {
|
||||
profession = professionService.createProfession(profession);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, profession, "Profession créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateProfession(@PathVariable Long id, @RequestBody Profession profession) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, professionService.updateProfession(id, profession), "Profession mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteProfessionr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
professionService.deleteProfession(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Profession supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Profession 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<?> getAllProfessionList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, professionService.getProfessionList(), "Liste des professions 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<?> getAllProfessionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, professionService.getProfessionList(pageable), "Liste des professions 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<?> getProfessionById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, professionService.getProfessionById(id), "Profession trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.SituationGeographique;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.SituationGeographiqueService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SituationGeographiqueController {
|
||||
|
||||
private final SituationGeographiqueService situationGeographiqueService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SituationGeographiqueController.class);
|
||||
|
||||
public SituationGeographiqueController(SituationGeographiqueService situationGeographiqueService) {
|
||||
this.situationGeographiqueService = situationGeographiqueService;
|
||||
@@ -31,73 +36,142 @@ public class SituationGeographiqueController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSituationGeographique(@RequestBody @Valid @Validated SituationGeographique situationGeographique) {
|
||||
try{
|
||||
try {
|
||||
situationGeographique = situationGeographiqueService.createSituationGeographique(situationGeographique);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationGeographique, "Situation géographique créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSituationGeographique(@PathVariable Long id, @RequestBody SituationGeographique situationGeographique) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationGeographiqueService.updateSituationGeographique(id, situationGeographique), "Situation géographique mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteSituationGeographiquer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
situationGeographiqueService.deleteSituationGeographique(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Situation géographique supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Situation géographique 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<?> getAllSituationGeographiqueList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueList(), "Liste des situations géographiques 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<?> getAllSituationGeographiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueList(pageable), "Liste des situations géographiques 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<?> getSituationGeographiqueById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueById(id), "Situation géographique trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.SituationMatrimoniale;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.SituationMatrimonialeService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SituationMatrimonialeController {
|
||||
|
||||
private final SituationMatrimonialeService situationMatrimonialeService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SituationMatrimonialeController.class);
|
||||
|
||||
public SituationMatrimonialeController(SituationMatrimonialeService situationMatrimonialeService) {
|
||||
this.situationMatrimonialeService = situationMatrimonialeService;
|
||||
@@ -31,73 +36,142 @@ public class SituationMatrimonialeController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSituationMatrimoniale(@RequestBody @Valid @Validated SituationMatrimoniale situationMatrimoniale) {
|
||||
try{
|
||||
try {
|
||||
situationMatrimoniale = situationMatrimonialeService.createSituationMatrimoniale(situationMatrimoniale);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationMatrimoniale, "Situation matrimoniale créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSituationMatrimoniale(@PathVariable Long id, @RequestBody SituationMatrimoniale situationMatrimoniale) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationMatrimonialeService.updateSituationMatrimoniale(id, situationMatrimoniale), "Situation matrimoniale mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteSituationMatrimonialer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
situationMatrimonialeService.deleteSituationMatrimoniale(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Situation matrimoniale supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Situation matrimoniale supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllSituationMatrimonialeList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeList(), "Liste des situations matrimoniales 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<?> getAllSituationMatrimonialePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeList(pageable), "Liste des situations matrimoniales 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<?> getSituationMatrimonialeById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeById(id), "Situation matrimoniale 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.SourceDroit;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.SourceDroitService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SourceDroitController {
|
||||
|
||||
private final SourceDroitService sourceDroitService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SourceDroitController.class);
|
||||
|
||||
public SourceDroitController(SourceDroitService sourceDroitService) {
|
||||
this.sourceDroitService = sourceDroitService;
|
||||
@@ -31,73 +36,142 @@ public class SourceDroitController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createSourceDroit(@RequestBody @Valid @Validated SourceDroit sourceDroit) {
|
||||
try{
|
||||
try {
|
||||
sourceDroit = sourceDroitService.createSourceDroit(sourceDroit);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, sourceDroit, "Source de droit créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateSourceDroit(@PathVariable Long id, @RequestBody SourceDroit sourceDroit) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, sourceDroitService.updateSourceDroit(id, sourceDroit), "Source de droit mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteSourceDroitr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
sourceDroitService.deleteSourceDroit(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Source de droit supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Source de droit 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<?> getAllSourceDroitList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, sourceDroitService.getSourceDroitList(), "Liste des sources de droit 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<?> getAllSourceDroitPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, sourceDroitService.getSourceDroitList(pageable), "Liste des sources de droit 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<?> getSourceDroitById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, sourceDroitService.getSourceDroitById(id), "Source de droit 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.Structure;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.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;
|
||||
@@ -15,6 +18,7 @@ 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
|
||||
@@ -26,6 +30,7 @@ public class StructureController {
|
||||
|
||||
private final StructureService structureService;
|
||||
private final ArrondissementService arrondissementService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(StructureController.class);
|
||||
|
||||
public StructureController(StructureService structureService, ArrondissementService arrondissementService) {
|
||||
this.structureService = structureService;
|
||||
@@ -34,90 +39,174 @@ public class StructureController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) {
|
||||
try{
|
||||
try {
|
||||
structure = structureService.createStructure(structure);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, structure, "Structure créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
structureService.deleteStructure(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Structure supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Structure 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<?> getAllStructureList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, structureService.getStructureList(), "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("/all-by-arrondissement")
|
||||
public ResponseEntity<?> getAllStructureListByArrondissement(@RequestParam Long arrondissementId) {
|
||||
|
||||
if(arrondissementService.getArrondissementById(arrondissementId).isPresent()){
|
||||
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{
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false,"Impossible de trouver l'arrondissement spécifiée."),
|
||||
new ApiResponse<>(false, "Impossible de trouver l'arrondissement spécifiée."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, structureService.getStructureList(pageable), "Liste des structures chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getStructureById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, structureService.getStructureById(id), "Structure 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.TypeContestation;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.TypeContestationService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TypeContestationController {
|
||||
|
||||
private final TypeContestationService typeContestationService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypeContestationController.class);
|
||||
|
||||
public TypeContestationController(TypeContestationService typeContestationService) {
|
||||
this.typeContestationService = typeContestationService;
|
||||
@@ -31,73 +36,142 @@ public class TypeContestationController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTypeContestation(@RequestBody @Valid @Validated TypeContestation typeContestation) {
|
||||
try{
|
||||
try {
|
||||
typeContestation = typeContestationService.createTypeContestation(typeContestation);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeContestation, "Type de contestation créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTypeContestation(@PathVariable Long id, @RequestBody TypeContestation typeContestation) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeContestationService.updateTypeContestation(id, typeContestation), "Type de contestation mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTypeContestationr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
typeContestationService.deleteTypeContestation(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Type de contestation supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Type de contestation supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTypeContestationList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeContestationService.getTypeContestationList(), "Liste des types de contestation 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<?> getAllTypeContestationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeContestationService.getTypeContestationList(pageable), "Liste des types de contestation 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<?> getTypeContestationById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeContestationService.getTypeContestationById(id), "Type de contestation 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.TypeDomaineService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TypeDomaineController {
|
||||
|
||||
private final TypeDomaineService typeDomaineService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypeDomaineController.class);
|
||||
|
||||
public TypeDomaineController(TypeDomaineService typeDomaineService) {
|
||||
this.typeDomaineService = typeDomaineService;
|
||||
@@ -31,73 +36,142 @@ public class TypeDomaineController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTypeDomaine(@RequestBody @Valid @Validated TypeDomaine typeDomaine) {
|
||||
try{
|
||||
try {
|
||||
typeDomaine = typeDomaineService.createTypeDomaine(typeDomaine);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeDomaine, "Type de domaine créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTypeDomaine(@PathVariable Long id, @RequestBody TypeDomaine typeDomaine) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeDomaineService.updateTypeDomaine(id, typeDomaine), "Type de domaine mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTypeDomainer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
typeDomaineService.deleteTypeDomaine(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Type de domaine supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Type de domaine supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTypeDomaineList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeDomaineService.getTypeDomaineList(), "Liste des types de domaine 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<?> getAllTypeDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeDomaineService.getTypeDomaineList(pageable), "Liste des types de domaine 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<?> getTypeDomaineById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeDomaineService.getTypeDomaineById(id), "Type de domaine 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.TypePersonne;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.TypePersonneService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TypePersonneController {
|
||||
|
||||
private final TypePersonneService typePersonneService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypePersonneController.class);
|
||||
|
||||
public TypePersonneController(TypePersonneService typePersonneService) {
|
||||
this.typePersonneService = typePersonneService;
|
||||
@@ -32,73 +36,142 @@ public class TypePersonneController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTypePersonne(@RequestBody @Valid @Validated TypePersonne typePersonne) {
|
||||
try{
|
||||
try {
|
||||
typePersonne = typePersonneService.createTypePersonne(typePersonne);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePersonne, "Type de personne créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTypePersonne(@PathVariable Long id, @RequestBody TypePersonne typePersonne) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePersonneService.updateTypePersonne(id, typePersonne), "Type de personne mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTypePersonner(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
typePersonneService.deleteTypePersonne(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Type de personne supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Type de personne supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTypePersonneList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePersonneService.getTypePersonneList(), "Liste des types de personne 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<?> getAllTypePersonnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePersonneService.getTypePersonneList(pageable), "Liste des types de personne 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<?> getTypePersonneById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePersonneService.getTypePersonneById(id), "Type de personne 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.TypePiece;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.TypePieceService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TypePieceController {
|
||||
|
||||
private final TypePieceService typePieceService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypePieceController.class);
|
||||
|
||||
public TypePieceController(TypePieceService typePieceService) {
|
||||
this.typePieceService = typePieceService;
|
||||
@@ -32,73 +36,142 @@ public class TypePieceController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTypePiece(@RequestBody @Valid @Validated TypePiece typePiece) {
|
||||
try{
|
||||
try {
|
||||
typePiece = typePieceService.createTypePiece(typePiece);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePiece, "Type de piece créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTypePiece(@PathVariable Long id, @RequestBody TypePiece typePiece) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePieceService.updateTypePiece(id, typePiece), "Type de piece mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTypePiecer(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
typePieceService.deleteTypePiece(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Type de piece supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Type de piece supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTypePieceList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePieceService.getTypePieceList(), "Liste des types de piece 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<?> getAllTypePiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePieceService.getTypePieceList(pageable), "Liste des types de piece 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<?> getTypePieceById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typePieceService.getTypePieceById(id), "Type de piece 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.parametre.TypeRepresentation;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.TypeRepresentationService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TypeRepresentationController {
|
||||
|
||||
private final TypeRepresentationService typeRepresentationService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypeRepresentationController.class);
|
||||
|
||||
public TypeRepresentationController(TypeRepresentationService typeRepresentationService) {
|
||||
this.typeRepresentationService = typeRepresentationService;
|
||||
@@ -32,73 +36,142 @@ public class TypeRepresentationController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTypeRepresentation(@RequestBody @Valid @Validated TypeRepresentation typeRepresentation) {
|
||||
try{
|
||||
try {
|
||||
typeRepresentation = typeRepresentationService.createTypeRepresentation(typeRepresentation);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeRepresentation, "Type de representation créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTypeRepresentation(@PathVariable Long id, @RequestBody TypeRepresentation typeRepresentation) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeRepresentationService.updateTypeRepresentation(id, typeRepresentation), "Type de representation mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTypeRepresentationr(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
typeRepresentationService.deleteTypeRepresentation(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Type de representation supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Type de representation supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTypeRepresentationList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationList(), "Liste des types de representation 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<?> getAllTypeRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationList(pageable), "Liste des types de representation 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<?> getTypeRepresentationById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationById(id), "Type de representation 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import io.gmss.fiscad.interfaces.notification.EmailService;
|
||||
import io.gmss.fiscad.paylaods.EmailDetails;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class EmailController {
|
||||
|
||||
private final EmailService emailService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmailController.class);
|
||||
|
||||
public EmailController(EmailService emailService) {
|
||||
this.emailService = emailService;
|
||||
@@ -22,16 +25,14 @@ public class EmailController {
|
||||
|
||||
// Sending a simple Email
|
||||
@PostMapping("/sendMail")
|
||||
public String sendMail(@RequestBody EmailDetails details)
|
||||
{
|
||||
public String sendMail(@RequestBody EmailDetails details) {
|
||||
return emailService.sendSimpleMail(details);
|
||||
}
|
||||
|
||||
// Sending email with attachment
|
||||
@PostMapping("/sendMailWithAttachment")
|
||||
public String sendMailWithAttachment(
|
||||
@RequestBody EmailDetails details)
|
||||
{
|
||||
@RequestBody EmailDetails details) {
|
||||
String status
|
||||
= emailService.sendMailWithAttachment(details);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
@CrossOrigin(origins = "*")
|
||||
public class ReportingController {
|
||||
private final ReportService reportService;
|
||||
|
||||
private final BlocRepository blocRepository;
|
||||
private final StructureRepository structureRepository;
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReportingController.class);
|
||||
@@ -43,7 +44,7 @@ public class ReportingController {
|
||||
@GetMapping("/structure/blocs/{formatRapport}/{structureId}")
|
||||
public void imprimerBlocsParStructure(HttpServletResponse response, @PathVariable FormatRapport formatRapport, @PathVariable Long structureId) {
|
||||
try {
|
||||
reportService.imprimerBlocsStructure(response,formatRapport,structureId);
|
||||
reportService.imprimerBlocsStructure(response, formatRapport, structureId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -52,7 +53,7 @@ public class ReportingController {
|
||||
@GetMapping("/bloc/enquetes/{formatRapport}/{blocId}")
|
||||
public void imprimerEnqueteParBloc(HttpServletResponse response, @PathVariable FormatRapport formatRapport, @PathVariable Long blocId) {
|
||||
try {
|
||||
reportService.imprimerEnqueteParBloc(response,formatRapport,blocId);
|
||||
reportService.imprimerEnqueteParBloc(response, formatRapport, blocId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public class ReportingController {
|
||||
@PostMapping("/filtre/enquetes/{formatRapport}")
|
||||
public void imprimerEnqueteParFiltre(HttpServletResponse response, @RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad, @PathVariable FormatRapport formatRapport) {
|
||||
try {
|
||||
reportService.imprimerEnqueteParFiltre(response,filtreEnquetePayLoad,formatRapport);
|
||||
reportService.imprimerEnqueteParFiltre(response, filtreEnquetePayLoad, formatRapport);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -26,79 +29,150 @@ public class BatimentController {
|
||||
|
||||
private final BatimentService batimentService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BatimentController.class);
|
||||
|
||||
public BatimentController(BatimentService batimentService) {
|
||||
this.batimentService = batimentService;
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated Batiment batiment) {
|
||||
try{
|
||||
try {
|
||||
batiment = batimentService.createBatiment(batiment);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, batiment, "Batiment créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody Batiment batiment) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, batimentService.updateBatiment(id, batiment), "Batiment mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteBatiment(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
batimentService.deleteBatiment(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Batiment supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Batiment 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<?> getAllBatimentList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, batimentService.getBatimentList(), "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<?> getAllBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, batimentService.getBatimentList(pageable), "Liste des caractéristiques chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, batimentService.getBatimentById(id), "Batiment trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.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;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class CaracteristiqueBatimentController {
|
||||
|
||||
private final CaracteristiqueBatimentService caracteristiqueBatimentService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueBatimentController.class);
|
||||
|
||||
public CaracteristiqueBatimentController(CaracteristiqueBatimentService caracteristiqueBatimentService) {
|
||||
this.caracteristiqueBatimentService = caracteristiqueBatimentService;
|
||||
@@ -32,73 +36,142 @@ public class CaracteristiqueBatimentController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatiment caracteristiqueBatiment) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueBatiment = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueBatiment, "Caracteristique du batiment créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatiment caracteristiqueBatiment) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteCaracteristiqueBatiment(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueBatimentService.deleteCaracteristiqueBatiment(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"CaracteristiqueBatiment supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "CaracteristiqueBatiment 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<?> getAllCaracteristiqueBatimentList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentList(), "Liste des Caracteristiques du batiment 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<?> getAllCaracteristiqueBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentList(pageable), "Liste des Caracteristiques du batiment 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<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.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;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class CaracteristiqueParcelleController {
|
||||
|
||||
private final CaracteristiqueParcelleService caracteristiqueParcelleService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueParcelleController.class);
|
||||
|
||||
public CaracteristiqueParcelleController(CaracteristiqueParcelleService caracteristiqueParcelleService) {
|
||||
this.caracteristiqueParcelleService = caracteristiqueParcelleService;
|
||||
@@ -32,73 +36,142 @@ public class CaracteristiqueParcelleController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcelle caracteristiqueParcelle) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteCaracteristiqueParcelle(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueParcelleService.deleteCaracteristiqueParcelle(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Caracteristique parcelle supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Caracteristique 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<?> getAllCaracteristiqueParcelleList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleList(), "Liste des Caracteristiques parcelles chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleList(pageable), "Liste des Caracteristiques parcelles chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getCaracteristiqueParcelleById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleById(id), "Caracteristiques parcelles trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.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;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class CaracteristiqueUniteLogementController {
|
||||
|
||||
private final CaracteristiqueUniteLogementService caracteristiqueUniteLogementService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueUniteLogementController.class);
|
||||
|
||||
public CaracteristiqueUniteLogementController(CaracteristiqueUniteLogementService caracteristiqueUniteLogementService) {
|
||||
this.caracteristiqueUniteLogementService = caracteristiqueUniteLogementService;
|
||||
@@ -32,73 +36,142 @@ public class CaracteristiqueUniteLogementController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteCaracteristiqueUniteLogement(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueUniteLogementService.deleteCaracteristiqueUniteLogement(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"CaracteristiqueUniteLogement supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "CaracteristiqueUniteLogement 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<?> getAllCaracteristiqueUniteLogementList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementList(), "Liste des Caracteristiques Unite Logement chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllCaracteristiqueUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementList(pageable), "Liste des Caracteristiques Unite Logement chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getCaracteristiqueUniteLogementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementById(id), "Caracteristique Unite Logement trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class EnqueteBatimentController {
|
||||
|
||||
private final EnqueteBatimentService enqueteBatimentService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(EnqueteBatimentController.class);
|
||||
|
||||
public EnqueteBatimentController(EnqueteBatimentService enqueteBatimentService) {
|
||||
this.enqueteBatimentService = enqueteBatimentService;
|
||||
@@ -32,73 +36,143 @@ public class EnqueteBatimentController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatiment enqueteBatiment) {
|
||||
try{
|
||||
try {
|
||||
enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatiment);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatiment enqueteBatiment) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteBatimentService.updateEnqueteBatiment(id, enqueteBatiment), "Enquete batiment mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
enqueteBatimentService.deleteEnqueteBatiment(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"EnqueteBatiment supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "EnqueteBatiment supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<?> getAllEnqueteBatimentList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentList(), "Liste des Enquetes batiments chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentList(pageable), "Liste des Enquetes batiments chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentById(id), "Enquete batiment trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class EnqueteUniteLogementController {
|
||||
|
||||
private final EnqueteUniteLogementService enqueteUniteLogementService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(EnqueteUniteLogementController.class);
|
||||
|
||||
public EnqueteUniteLogementController(EnqueteUniteLogementService enqueteUniteLogementService) {
|
||||
this.enqueteUniteLogementService = enqueteUniteLogementService;
|
||||
@@ -32,73 +36,143 @@ public class EnqueteUniteLogementController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogement enqueteUniteLogement) {
|
||||
try{
|
||||
try {
|
||||
enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogement);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogement enqueteUniteLogement) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.updateEnqueteUniteLogement(id, enqueteUniteLogement), "Enquete unite logement mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteEnqueteUniteLogement(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
enqueteUniteLogementService.deleteEnqueteUniteLogement(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Enquete Unite Logement supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Enquete Unite Logement 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<?> getAllEnqueteUniteLogementList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementList(), "Liste des Enquetes des unites Logements chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllEnqueteUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementList(pageable), "Liste des enquetes des unites de logements chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getEnqueteUniteLogementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementById(id), "Enquete unite de logement trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.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;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class UniteLogementController {
|
||||
|
||||
private final UniteLogementService enqueteUniteLogementService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UniteLogementController.class);
|
||||
|
||||
public UniteLogementController(UniteLogementService enqueteUniteLogementService) {
|
||||
this.enqueteUniteLogementService = enqueteUniteLogementService;
|
||||
@@ -32,73 +36,143 @@ public class UniteLogementController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) {
|
||||
try{
|
||||
try {
|
||||
enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogement enqueteUniteLogement) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteUniteLogement(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
enqueteUniteLogementService.deleteUniteLogement(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Unite Logement supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Unite Logement 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<?> getAllUniteLogementList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementList(), "Liste des Enquetes des unites Logements chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-paged")
|
||||
public ResponseEntity<?> getAllUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementList(pageable), "Liste des enquetes des unites de logements chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementById(id), "Unite de de logement trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package io.gmss.fiscad.controllers.rfu.parametre;
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.parametre.Campagne;
|
||||
import io.gmss.fiscad.enums.TypeCampagne;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.parametre.CampagneService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -15,7 +17,7 @@ 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
|
||||
@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class CampagneController {
|
||||
|
||||
private final CampagneService campagneService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(CampagneController.class);
|
||||
|
||||
public CampagneController(CampagneService campagneService) {
|
||||
this.campagneService = campagneService;
|
||||
@@ -33,89 +36,167 @@ public class CampagneController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createCampagne(@RequestBody @Valid @Validated Campagne campagne) {
|
||||
try{
|
||||
try {
|
||||
campagne = campagneService.createCampagne(campagne);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, campagne, "Campagne créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateCampagne(@PathVariable Long id, @RequestBody Campagne campagne) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, campagneService.updateCampagne(id, campagne), "Campagne mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteCampagner(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
campagneService.deleteCampagne(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Campagne supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Campagne 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<?> getAllCampagneList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, campagneService.getCampagneList(), "Liste des campagnes 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<?> getAllCampagnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, campagneService.getCampagneList(pageable), "Liste des campagnes 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<?> getCampagneById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, campagneService.getCampagneById(id), "Campagne 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("/type-campagne/{typeCampagne}")
|
||||
public ResponseEntity<?> getCampagneByType(@PathVariable TypeCampagne typeCampagne) {
|
||||
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, campagneService.getCampagnesByType(typeCampagne), "Liste des campagne par type chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (NotFoundException e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.parametre.CaracteristiqueService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class CaracteristiqueController {
|
||||
|
||||
private final CaracteristiqueService caracteristiqueService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueController.class);
|
||||
|
||||
public CaracteristiqueController(CaracteristiqueService caracteristiqueService) {
|
||||
this.caracteristiqueService = caracteristiqueService;
|
||||
@@ -31,73 +35,144 @@ public class CaracteristiqueController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createCaracteristique(@RequestBody @Valid @Validated Caracteristique caracteristique) {
|
||||
try{
|
||||
try {
|
||||
caracteristique = caracteristiqueService.createCaracteristique(caracteristique);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristique, "Caracteristique créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateCaracteristique(@PathVariable Long id, @RequestBody Caracteristique caracteristique) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueService.updateCaracteristique(id, caracteristique), "Caracteristique mise à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteCaracteristique(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
caracteristiqueService.deleteCaracteristique(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Caracteristique supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Caracteristique 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<?> getAllCaracteristiqueList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueList(), "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<?> getAllCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueList(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<?> getCaracteristiqueById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueById(id), "Caracteristique 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,12 +1,15 @@
|
||||
package io.gmss.fiscad.controllers.rfu.parametre;
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.parametre.Equipe;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.EquipePayload;
|
||||
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;
|
||||
@@ -14,7 +17,7 @@ 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
|
||||
@@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class EquipeController {
|
||||
|
||||
private final EquipeService equipeService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(EquipeController.class);
|
||||
|
||||
public EquipeController(EquipeService equipeService) {
|
||||
this.equipeService = equipeService;
|
||||
@@ -32,74 +36,144 @@ public class EquipeController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createEquipe(@RequestBody @Valid @Validated EquipePayload equipePayload) {
|
||||
try{
|
||||
try {
|
||||
Equipe equipe = equipeService.createEquipe(equipePayload);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, equipe, "Equipe créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateEquipe(@PathVariable Long id, @RequestBody EquipePayload equipePayload) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, equipeService.updateEquipe(id, equipePayload), "Equipe mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteEquiper(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
equipeService.deleteEquipe(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Equipe supprimée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Equipe 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<?> getAllEquipeList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, equipeService.getEquipeList(), "Liste des equipes 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<?> getAllEquipePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, equipeService.getEquipeList(pageable), "Liste des equipes 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<?> getEquipeById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, equipeService.getEquipeById(id), "Equipe trouvée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.parametre;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.rfu.parametre.TypeCaracteristique;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.rfu.parametre.TypeCaracteristiqueService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -23,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TypeCaracteristiqueController {
|
||||
|
||||
private final TypeCaracteristiqueService typeCaracteristiqueService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypeCaracteristiqueController.class);
|
||||
|
||||
public TypeCaracteristiqueController(TypeCaracteristiqueService typeCaracteristiqueService) {
|
||||
this.typeCaracteristiqueService = typeCaracteristiqueService;
|
||||
@@ -30,73 +35,143 @@ public class TypeCaracteristiqueController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createTypeCaracteristique(@RequestBody @Valid @Validated TypeCaracteristique typeCaracteristique) {
|
||||
try{
|
||||
try {
|
||||
typeCaracteristique = typeCaracteristiqueService.createTypeCaracteristique(typeCaracteristique);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeCaracteristique, "Type de caracteristique créé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTypeCaracteristique(@PathVariable Long id, @RequestBody TypeCaracteristique typeCaracteristique) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeCaracteristiqueService.updateTypeCaracteristique(id, typeCaracteristique), "Type caracteristique mis à jour avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteTypeCaracteristique(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
typeCaracteristiqueService.deleteTypeCaracteristique(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Type caracteristique supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Type caracteristique supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> getAllTypeCaracteristiqueList() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueList(), "Liste des types caracteristiques 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<?> getAllTypeCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueList(pageable), "Liste des types caracteristiques 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<?> getTypeCaracteristiqueById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueById(id), "Type caracteristique 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,13 +1,17 @@
|
||||
package io.gmss.fiscad.controllers.statistique;
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "api/statistique", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -15,40 +19,103 @@ import org.springframework.web.bind.annotation.*;
|
||||
@Tag(name = "Statistique")
|
||||
@CrossOrigin(origins = "*")
|
||||
public class StatistiqueController {
|
||||
private final StatistiquesService statistiquesService ;
|
||||
private final StatistiquesService statistiquesService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StatistiqueController.class);
|
||||
|
||||
public StatistiqueController(StatistiquesService statistiquesService) {
|
||||
this.statistiquesService = statistiquesService;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/user/enquete-par-statut")
|
||||
public ResponseEntity<?> getStatistiquesParStatut() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, statistiquesService.getStatEnqueteParStatut(), "Statistique des enquêtes par statut."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/enquete-par-arrondissement/{commune_id}")
|
||||
public ResponseEntity<?> getStatistiquesParArrondissement(@PathVariable Long commune_id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, statistiquesService.getStatEnqueteAdminDecoupage(commune_id), "Statistique des enquêtes par arrondissement."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/user/enquete-par-structure")
|
||||
public ResponseEntity<?> getStatistiquesParStructure() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, statistiquesService.getStatEnqueteAdminStructure(), "Statistique des enquêtes par structure."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/user/enquete-par-bloc")
|
||||
public ResponseEntity<?> getStatistiquesParBloc() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, statistiquesService.getStatBloc(), "Statistique des enquêtes par bloc."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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,13 +1,17 @@
|
||||
package io.gmss.fiscad.controllers.synchronisation;
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.synchronisation.RestaurationService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "api/restauration", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -17,107 +21,289 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class RestaurationController {
|
||||
public final RestaurationService restaurationService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RestaurationController.class);
|
||||
|
||||
public RestaurationController(RestaurationService restaurationService) {
|
||||
this.restaurationService = restaurationService;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/enquete/{terminalId}")
|
||||
public ResponseEntity<?> getEnquetes(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getEnquete(terminalId), "liste des enquetes avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/acteur-concerne/{terminalId}")
|
||||
public ResponseEntity<?> getActeurConcerne(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getActeurConcernes(terminalId), "liste des acteurs concerné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(path = "/personne/{terminalId}") // ok
|
||||
public ResponseEntity<?> getPersonnes(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getPersonne(terminalId), "liste des personnes avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/membre-groupe/{terminalId}")
|
||||
public ResponseEntity<?> getMembrePersonnes(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getMembreGroupe(terminalId), "liste des membres groupe avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/parcelle/{terminalId}")
|
||||
public ResponseEntity<?> getParcelle(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getParcelle(terminalId), "liste des parcelle avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/piece/{terminalId}")
|
||||
public ResponseEntity<?> getPieces(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getPieces(terminalId), "liste des enquetes avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/upload/{terminalId}")
|
||||
public ResponseEntity<?> getUpload(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getUpload(terminalId), "liste des enquetes avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/current-user-tpes")
|
||||
public ResponseEntity<?> getCurrentUserTpe() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getTpeListByCurrentUser(), "liste des enquetes avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/batiment/{terminalId}")
|
||||
public ResponseEntity<?> getBatiments(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getBatiment(terminalId), "liste des batiments avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/enquete-batiment/{terminalId}")
|
||||
public ResponseEntity<?> getEnqueteBatiment(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getEnqueteBatiment(terminalId), "liste des enquetes batiments avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/caracteristique-batiment/{terminalId}")
|
||||
public ResponseEntity<?> getCaracteristiqueBatiment(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getCaracateristiqueBatiment(terminalId), "liste des caractéristiques batiments avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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(path = "/caracteristique-unite-logement/{terminalId}")
|
||||
public ResponseEntity<?> getCaracteristiqueUniteLogement(@PathVariable Long terminalId) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, restaurationService.getCaracateristiqueUniteLogement(terminalId), "liste des caractéristiques des unités de logement avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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,14 +1,18 @@
|
||||
package io.gmss.fiscad.controllers.synchronisation;
|
||||
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.request.*;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
@@ -20,6 +24,7 @@ import java.util.List;
|
||||
@CrossOrigin(origins = "*")
|
||||
public class SynchronisationController {
|
||||
private final SynchronisationService synchronisationService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(SynchronisationController.class);
|
||||
|
||||
public SynchronisationController(SynchronisationService synchronisationService) {
|
||||
this.synchronisationService = synchronisationService;
|
||||
@@ -27,80 +32,206 @@ public class SynchronisationController {
|
||||
|
||||
@GetMapping("/user-decoupage-territorial")
|
||||
public ResponseEntity<?> getUserDecoupageTerritorial() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.getDecoupageAdminUserConnecter(), "Liste des découpages territoriaux chargé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("/references")
|
||||
public ResponseEntity<?> getAllReferences() {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.getReferencesSyncResponses(), "Liste des données de référence chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/personnes")
|
||||
public ResponseEntity<?> syncPersonne(@RequestBody List<PersonnePayLoad> personnePayLoads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncPersonnes(personnePayLoads), "Liste des personnes synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/membre-groupe")
|
||||
public ResponseEntity<?> syncMembreGroupe(@RequestBody List<MembreGroupePayLoad> membreGroupePayLoads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncMembreGroupe(membreGroupePayLoads), "Liste des membres de groupes de personnes synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/enquete")
|
||||
public ResponseEntity<?> syncEnquete(@RequestBody List<EnquetePayLoad> enquetePayLoads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncEnquete(enquetePayLoads), "Liste des enquêtes synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/parcelle")
|
||||
public ResponseEntity<?> syncParcelle(@RequestBody List<ParcellePayLoad> parcellePayLoads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncParcelle(parcellePayLoads), "Liste des parceclles synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/piece")
|
||||
public ResponseEntity<?> syncPiece(@RequestBody List<PiecePayLoad> piecePayLoads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncPiece(piecePayLoads), "Liste des pièces synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/acteur-concerne")
|
||||
public ResponseEntity<?> syncActeurConcerne(@RequestBody List<ActeurConcernePayLoad> piecePayLoads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncActeurConcerne(piecePayLoads), "Liste des acteurs concernes synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
//@PostMapping("/files")
|
||||
@PostMapping(path = "/files")
|
||||
public ResponseEntity<?> syncFiles(@RequestPart(required = true) MultipartFile file,
|
||||
@RequestParam(required=false) Long idBackend,
|
||||
@RequestParam(required = false) Long idBackend,
|
||||
@RequestParam Long externalKey,
|
||||
@RequestParam(required=false) Long pieceId,
|
||||
@RequestParam(required=false) Long membreGroupeId,
|
||||
@RequestParam(required=false) Long terminalId,
|
||||
@RequestParam(required=false) String name,
|
||||
@RequestParam(required=false) String filePath,
|
||||
@RequestParam(required=false) Long max_numero_piece_id,
|
||||
@RequestParam(required=false) Long max_numero_upload_id,
|
||||
@RequestParam(required=false) Long max_numero_acteur_concerne_id,
|
||||
@RequestParam(required=false) Long enqueteId,
|
||||
@RequestParam(required=false) Long enqueteBatimentId,
|
||||
@RequestParam(required=false) Long enqueteUniteLogementId
|
||||
@RequestParam(required = false) Long pieceId,
|
||||
@RequestParam(required = false) Long membreGroupeId,
|
||||
@RequestParam(required = false) Long terminalId,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String filePath,
|
||||
@RequestParam(required = false) Long max_numero_piece_id,
|
||||
@RequestParam(required = false) Long max_numero_upload_id,
|
||||
@RequestParam(required = false) Long max_numero_acteur_concerne_id,
|
||||
@RequestParam(required = false) Long enqueteId,
|
||||
@RequestParam(required = false) Long enqueteBatimentId,
|
||||
@RequestParam(required = false) Long enqueteUniteLogementId
|
||||
) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncFiles(file,
|
||||
idBackend,
|
||||
@@ -116,22 +247,66 @@ public class SynchronisationController {
|
||||
enqueteId, enqueteBatimentId, enqueteUniteLogementId), "Liste des fichiers synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(path = "/synchronise/all-enquete-data")
|
||||
public ResponseEntity<?> syncAllEnqueteData(@ModelAttribute EnqueteAllDataPayload enqueteAllDataPayload) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncEnqueteAllData(enqueteAllDataPayload), "Les enquetes sont synchronisé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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(path = "/synchronise/enquete/confirme-from-mobile")
|
||||
public ResponseEntity<?> syncAllEnqueteData(@RequestBody List<BatimentPaylaod> batimentPaylaods) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncBatiment(batimentPaylaods), "Synchronisation confirmée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,58 +318,163 @@ public class SynchronisationController {
|
||||
|
||||
@PostMapping(path = "/batiment")
|
||||
public ResponseEntity<?> syncBatiment(@RequestBody List<BatimentPaylaod> batimentPaylaods) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncBatiment(batimentPaylaods), "Liste des batiments synchronisé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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(path = "/unite-logement")
|
||||
public ResponseEntity<?> syncUniteLogement(@RequestBody List<UniteLogementPaylaod> uniteLogementPaylaods) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncUniteLogement(uniteLogementPaylaods), "Liste des unités de logement synchronisé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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(path = "/caracteristique-batiment")
|
||||
public ResponseEntity<?> syncCaracteristiqueBatiment(@RequestBody List<CaracteristiqueBatimentPaylod> caracteristiqueBatimentPaylods) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueBatiment(caracteristiqueBatimentPaylods), "Liste des caractéristiques des bâtiments synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(path = "/caracteristique-parcelle")
|
||||
public ResponseEntity<?> syncCaracteristiqueParcelle(@RequestBody List<CaracteristiqueParcellePaylod> caracteristiqueParcellePaylods) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueParcelle(caracteristiqueParcellePaylods), "Liste des caractéristiques des parcelles synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(path = "/caracteristique-unite-logement")
|
||||
public ResponseEntity<?> syncCaracteristiqueUniteLogement(@RequestBody List<CaracteristiqueUniteLogementPaylod> caracteristiqueUniteLogementPaylods) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueUniteLogement(caracteristiqueUniteLogementPaylods), "Liste des caractéristiques des unités de logement synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/enquete-batiment")
|
||||
public ResponseEntity<?> syncEnqueteBatiment(@RequestBody List<EnqueteBatimentPayload> enqueteBatimentPayloads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncEnqueteBatiment(enqueteBatimentPayloads), "Liste des enquêtes des batiments synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/enquete-unite-logement")
|
||||
public ResponseEntity<?> syncEnqueteUniteLogement(@RequestBody List<EnqueteUniteLogementPayload> enqueteUniteLogementPayloads) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, synchronisationService.syncEnqueteUniteLogement(enqueteUniteLogementPayloads), "Liste des enquêtes des unités de logement synchronisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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,6 +3,7 @@ package io.gmss.fiscad.controllers.user;
|
||||
import io.gmss.fiscad.entities.user.Role;
|
||||
import io.gmss.fiscad.entities.user.User;
|
||||
import io.gmss.fiscad.enums.UserRole;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
|
||||
import io.gmss.fiscad.interfaces.user.RoleService;
|
||||
import io.gmss.fiscad.interfaces.user.UserService;
|
||||
@@ -13,11 +14,14 @@ import io.gmss.fiscad.paylaods.UserRequest;
|
||||
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.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.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -32,6 +36,7 @@ public class AuthController {
|
||||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
private final StructureService structureService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
public AuthController(UserService userService, RoleService roleService, StructureService structureService) {
|
||||
this.userService = userService;
|
||||
@@ -41,40 +46,47 @@ public class AuthController {
|
||||
|
||||
@PostMapping(value = "/login")
|
||||
public ResponseEntity<?> login(@RequestBody @Validated @Valid Login login) {
|
||||
try{
|
||||
try {
|
||||
JwtAuthenticationResponse jwtAuthenticationResponse = userService.loginUser(login);
|
||||
|
||||
if(!jwtAuthenticationResponse.getToken().isEmpty()){
|
||||
if (!jwtAuthenticationResponse.getToken().isEmpty()) {
|
||||
User user = userService.getUserByUsername(login.getUsername());
|
||||
if(user.isResetPassword()){
|
||||
if (user.isResetPassword()) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, jwtAuthenticationResponse, "Vous devez impérativement changer son mot de passe avant de pouvoir continuer toute action dans le logiciel infocad."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, jwtAuthenticationResponse, "Authentification réussie avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, "Authentification échouée."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<User>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/signup")
|
||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) {
|
||||
try{
|
||||
try {
|
||||
User user = getUser(userRequest);
|
||||
user.setUsername(userRequest.getEmail());
|
||||
user = userService.createUser(user, false);
|
||||
@@ -82,11 +94,19 @@ public class AuthController {
|
||||
new ApiResponse<>(true, user, "User created successully."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ package io.gmss.fiscad.controllers.user;
|
||||
import io.gmss.fiscad.entities.user.DemandeReinitialisationMP;
|
||||
import io.gmss.fiscad.entities.user.User;
|
||||
import io.gmss.fiscad.enums.UserRole;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.user.DemandeReinitialisationMPService;
|
||||
import io.gmss.fiscad.interfaces.user.RoleService;
|
||||
import io.gmss.fiscad.interfaces.user.UserService;
|
||||
@@ -13,12 +14,15 @@ import io.gmss.fiscad.security.CurrentUser;
|
||||
import io.gmss.fiscad.security.UserPrincipal;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import 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.web.bind.annotation.*;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "api/demande-reinitialisation-mp", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -28,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class DemandeReinitialisationMPController {
|
||||
|
||||
private final DemandeReinitialisationMPService demandeReinitialisationMPService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(DemandeReinitialisationMPController.class);
|
||||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
|
||||
@@ -45,11 +50,19 @@ public class DemandeReinitialisationMPController {
|
||||
new ApiResponse<>(true, "DemandeReinitialisation MP 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) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
HttpStatus.OK
|
||||
);
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +73,19 @@ public class DemandeReinitialisationMPController {
|
||||
new ApiResponse<>(true, demandeReinitialisationMPService.updateDemandeReinitialisationMP(id, demandeReinitialisationMP), "DemandeReinitialisationMP 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) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
HttpStatus.OK
|
||||
);
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,11 +97,19 @@ public class DemandeReinitialisationMPController {
|
||||
new ApiResponse<>(true, "Demande de Reinitialisation de mot de passe supprimé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
HttpStatus.OK
|
||||
);
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +119,12 @@ public class DemandeReinitialisationMPController {
|
||||
|
||||
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<>(
|
||||
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
if (user.getStructure() == null) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
|
||||
@@ -121,35 +150,76 @@ public class DemandeReinitialisationMPController {
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
HttpStatus.OK
|
||||
);
|
||||
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<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
|
||||
try {
|
||||
Pageable pageable = PageRequest.of(pageNo, pageSize);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(pageable), "Liste des demandeReinitialisationMP 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<?> getDemandeReinitialisationMPById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPById(id), "DemandeReinitialisationMP 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("/reset")
|
||||
public ResponseEntity<?> traiterDemande(@RequestParam Long id, @RequestParam String password) {
|
||||
try {
|
||||
DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPService.traiterDemandeReinitialisation(id, password);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,
|
||||
new DemandeReinitialisationMPResponse(
|
||||
@@ -159,5 +229,19 @@ public class DemandeReinitialisationMPController {
|
||||
"Traitement effectué avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.user;
|
||||
|
||||
|
||||
import io.gmss.fiscad.entities.user.Role;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.user.RoleService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,6 +17,7 @@ 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
|
||||
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class RoleController {
|
||||
|
||||
private final RoleService roleService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(RoleController.class);
|
||||
|
||||
public RoleController(RoleService roleService) {
|
||||
this.roleService = roleService;
|
||||
@@ -32,67 +37,122 @@ public class RoleController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createRole(@RequestBody @Valid @Validated Role role) {
|
||||
try{
|
||||
try {
|
||||
role = roleService.createRole(role);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, role, "Role created successully."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateRole(@PathVariable Long id, @RequestBody Role role) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, roleService.updateRole(id, role), "Role updated successully."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<?> deleteRole(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
roleService.deleteRole(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"Role deleted successully"),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "Role 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, roleService.getRoleList(), "Liste des roles."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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, roleService.getRoleList(pageable), "Liste des roles."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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,6 +3,7 @@ package io.gmss.fiscad.controllers.user;
|
||||
|
||||
import io.gmss.fiscad.entities.user.User;
|
||||
import io.gmss.fiscad.enums.UserRole;
|
||||
import io.gmss.fiscad.exceptions.*;
|
||||
import io.gmss.fiscad.interfaces.user.UserService;
|
||||
import io.gmss.fiscad.paylaods.ApiResponse;
|
||||
import io.gmss.fiscad.paylaods.Login;
|
||||
@@ -11,12 +12,14 @@ import io.gmss.fiscad.security.UserPrincipal;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.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
|
||||
@@ -27,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
|
||||
public UserController(UserService userService) {
|
||||
@@ -35,155 +39,241 @@ public class UserController {
|
||||
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) {
|
||||
try{
|
||||
try {
|
||||
user.setUsername(user.getEmail());
|
||||
user = userService.createUser(user, true);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, user, "Utilisateur créé avec succès"),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/change-password")
|
||||
public ResponseEntity<?> changeUserPassword(@RequestBody @Valid @Validated Login login) {
|
||||
try{
|
||||
try {
|
||||
userService.updatePassword(login.getUsername(), login.getPassword());
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, "Votre mot de passe à été modifiée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/reset-password")
|
||||
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
|
||||
try{
|
||||
try {
|
||||
User user = userService.resetPassword(login.getUsername(), login.getPassword());
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, user, "Votre mot de passe à été réinitialisée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/validate-user-account")
|
||||
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
|
||||
try{
|
||||
try {
|
||||
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, user, "Cet utilisateur à été activé avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody User user) {
|
||||
try{
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.updateUser(id, user), "User updated successully."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, 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 ("/activate-or-not")
|
||||
@GetMapping("/activate-or-not")
|
||||
public ResponseEntity<?> acitvateOrNotUser(@RequestParam Long id) {
|
||||
try{
|
||||
try {
|
||||
|
||||
User user = userService.activateOrNotUser(id);
|
||||
String message = "Utilisateur activé avec succès";
|
||||
if(!user.isActive()) {
|
||||
if (!user.isActive()) {
|
||||
message = "Utilisateur désactivé avec succès";
|
||||
}
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, user , message),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, user, message),
|
||||
HttpStatus.OK
|
||||
);
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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<?> deleteUser(@PathVariable Long id) {
|
||||
try{
|
||||
try {
|
||||
userService.deleteUser(id);
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true,"User deleted successully"),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}catch (Exception e){
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, e.getMessage()),
|
||||
new ApiResponse<>(true, "User 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(@CurrentUser UserPrincipal userPrincipal) {
|
||||
try {
|
||||
|
||||
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<>(
|
||||
new ApiResponse<>(true, userService.getAllUserListResponse(), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/all-by-structure")
|
||||
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
|
||||
|
||||
if(userPrincipal.getUser().getStructure() != null) {
|
||||
try {
|
||||
if (userPrincipal.getUser().getStructure() != null) {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}else{
|
||||
} else {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."),
|
||||
HttpStatus.OK
|
||||
);
|
||||
}
|
||||
} catch (HttpClientErrorException.MethodNotAllowed e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
|
||||
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
|
||||
FileStorageException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
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")
|
||||
@@ -197,26 +287,71 @@ public class UserController {
|
||||
|
||||
@GetMapping("/id/{id}")
|
||||
public ResponseEntity<?> getUserById(@PathVariable Long id) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getUserById(id), "User 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);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/username/{username}")
|
||||
public ResponseEntity<?> getUserByUsername(@PathVariable String username) {
|
||||
try {
|
||||
return new ResponseEntity<>(
|
||||
new ApiResponse<>(true, userService.getUserByUsername(username), "User 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);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Secteur extends BaseEntity implements Serializable {
|
||||
private Structure structure;
|
||||
//@JsonIgnore
|
||||
//@OneToMany(mappedBy = "secteur")
|
||||
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "secteur_id")
|
||||
private List<SecteurDecoupage> secteurDecoupages;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class ActeurConcerne extends BaseEntity implements Serializable {
|
||||
//////////////////////////////
|
||||
private Long blocId;
|
||||
@ColumnDefault("0")
|
||||
private int haveDeclarant ;
|
||||
private int haveDeclarant;
|
||||
private Long max_numero_acteur_concerne_id;
|
||||
|
||||
|
||||
|
||||
@@ -156,74 +156,77 @@ public class Enquete extends BaseEntity implements Serializable {
|
||||
private StatutEnregistrement statutEnregistrement;
|
||||
|
||||
|
||||
public Long getTerminalId(){
|
||||
if(this.terminal!=null){
|
||||
public Long getTerminalId() {
|
||||
if (this.terminal != null) {
|
||||
return this.terminal.getId();
|
||||
}else return null;
|
||||
} else return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getNomPrenomEnqueteur(){
|
||||
if(this.user!=null){
|
||||
return this.user.getNom()+" "+this.user.getPrenom();
|
||||
}else return "";
|
||||
public String getNomPrenomEnqueteur() {
|
||||
if (this.user != null) {
|
||||
return this.user.getNom() + " " + this.user.getPrenom();
|
||||
} else return "";
|
||||
}
|
||||
public String getNomBloc(){
|
||||
if(this.bloc!=null){
|
||||
|
||||
public String getNomBloc() {
|
||||
if (this.bloc != null) {
|
||||
return this.bloc.getNom();
|
||||
}else return "";
|
||||
} else return "";
|
||||
}
|
||||
|
||||
public String getCodeBloc(){
|
||||
if(this.bloc!=null){
|
||||
public String getCodeBloc() {
|
||||
if (this.bloc != null) {
|
||||
return this.bloc.getCote();
|
||||
}else return "";
|
||||
} else return "";
|
||||
}
|
||||
public String getDepartement(){
|
||||
if(this.bloc!=null){
|
||||
Arrondissement arrondissement= this.bloc.getArrondissement();
|
||||
if(arrondissement!=null){
|
||||
|
||||
public String getDepartement() {
|
||||
if (this.bloc != null) {
|
||||
Arrondissement arrondissement = this.bloc.getArrondissement();
|
||||
if (arrondissement != null) {
|
||||
return arrondissement.getCommune().getDepartement().getNom();
|
||||
}else return "";
|
||||
}else return "";
|
||||
} else return "";
|
||||
} else return "";
|
||||
}
|
||||
public String getCommune(){
|
||||
if(this.bloc!=null){
|
||||
Arrondissement arrondissement= this.bloc.getArrondissement();
|
||||
if(arrondissement!=null){
|
||||
|
||||
public String getCommune() {
|
||||
if (this.bloc != null) {
|
||||
Arrondissement arrondissement = this.bloc.getArrondissement();
|
||||
if (arrondissement != null) {
|
||||
return arrondissement.getCommune().getNom();
|
||||
}else return "";
|
||||
}else return "";
|
||||
} else return "";
|
||||
} else return "";
|
||||
}
|
||||
|
||||
public String getArrondissement(){
|
||||
if(this.bloc!=null) {
|
||||
Arrondissement arrondissement= this.bloc.getArrondissement();
|
||||
if(arrondissement!=null){
|
||||
public String getArrondissement() {
|
||||
if (this.bloc != null) {
|
||||
Arrondissement arrondissement = this.bloc.getArrondissement();
|
||||
if (arrondissement != null) {
|
||||
return arrondissement.getNom();
|
||||
}else return "";
|
||||
}else return "";
|
||||
} else return "";
|
||||
} else return "";
|
||||
}
|
||||
public String getTypeDomaine(){
|
||||
if(this.parcelle!=null){
|
||||
NatureDomaine natureDomaine= this.parcelle.getNatureDomaine();
|
||||
if(natureDomaine!=null){
|
||||
|
||||
public String getTypeDomaine() {
|
||||
if (this.parcelle != null) {
|
||||
NatureDomaine natureDomaine = this.parcelle.getNatureDomaine();
|
||||
if (natureDomaine != null) {
|
||||
return natureDomaine.getTypeDomaine().getLibelle();
|
||||
}else return "";
|
||||
}else return "";
|
||||
} else return "";
|
||||
} else return "";
|
||||
}
|
||||
|
||||
public String getTelEnqueteur(){
|
||||
if(this.user !=null){
|
||||
public String getTelEnqueteur() {
|
||||
if (this.user != null) {
|
||||
return this.user.getTel();
|
||||
}else return "";
|
||||
} else return "";
|
||||
}
|
||||
|
||||
public String getStructureEnqueteur(){
|
||||
if(this.user !=null){
|
||||
public String getStructureEnqueteur() {
|
||||
if (this.user != null) {
|
||||
return this.user.getStructure().getNom();
|
||||
}else return "";
|
||||
} else return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@ import jakarta.persistence.Id;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class EnqueteFiltreResponse{
|
||||
public class EnqueteFiltreResponse {
|
||||
@Id
|
||||
private Long id;
|
||||
private String parcelleid;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Parcelle extends BaseEntity implements Serializable {
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "parcelle")
|
||||
private List<Enquete> enquetes;
|
||||
// @ManyToOne
|
||||
// @ManyToOne
|
||||
// private SituationGeographique situationGeographique;
|
||||
@ManyToOne
|
||||
//private TypeDomaine typeDomaine;
|
||||
@@ -87,6 +87,4 @@ public class Parcelle extends BaseEntity implements Serializable {
|
||||
// private Point geometry32631;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package io.gmss.fiscad.entities.infocad.metier;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.gmss.fiscad.entities.BaseEntity;
|
||||
import io.gmss.fiscad.entities.decoupage.Quartier;
|
||||
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
|
||||
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -16,12 +12,10 @@ import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.locationtech.jts.geom.MultiPolygon;
|
||||
import org.locationtech.jts.geom.Point;
|
||||
import org.n52.jackson.datatype.jts.GeometryDeserializer;
|
||||
import org.n52.jackson.datatype.jts.GeometrySerializer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Entity
|
||||
@@ -42,9 +36,9 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
|
||||
private String ilot;
|
||||
private String zone;
|
||||
private String p;
|
||||
@Column(unique = true,nullable = true)
|
||||
@Column(unique = true, nullable = true)
|
||||
private String nup;
|
||||
@Column(unique = true,nullable = true)
|
||||
@Column(unique = true, nullable = true)
|
||||
private String nupProvisoire;
|
||||
private String longitude;
|
||||
private String latitude;
|
||||
@@ -55,11 +49,11 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
|
||||
|
||||
@JsonSerialize(using = GeometrySerializer.class)
|
||||
@JsonDeserialize(contentUsing = GeometryDeserializer.class)
|
||||
@Column(name = "geom",columnDefinition = "geometry(MultiPolygon,4326)")
|
||||
private MultiPolygon geometry ;
|
||||
@Column(name = "geom", columnDefinition = "geometry(MultiPolygon,4326)")
|
||||
private MultiPolygon geometry;
|
||||
|
||||
@JsonSerialize(using = GeometrySerializer.class)
|
||||
@JsonDeserialize(contentUsing = GeometryDeserializer.class)
|
||||
@Column(name = "geom_32631",columnDefinition = "geometry(MultiPolygon,32631)")
|
||||
private MultiPolygon geometry32631 ;
|
||||
@Column(name = "geom_32631", columnDefinition = "geometry(MultiPolygon,32631)")
|
||||
private MultiPolygon geometry32631;
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ public class Piece extends BaseEntity implements Serializable {
|
||||
private Personne personne;
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
private ActeurConcerne acteurConcerne ;
|
||||
private ActeurConcerne acteurConcerne;
|
||||
@ManyToOne
|
||||
private SourceDroit sourceDroit ;
|
||||
private SourceDroit sourceDroit;
|
||||
@ManyToOne
|
||||
private ModeAcquisition modeAcquisition ;
|
||||
private ModeAcquisition modeAcquisition;
|
||||
@OneToMany(mappedBy = "piece")
|
||||
private List<Upload> uploads ;
|
||||
private List<Upload> uploads;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Upload extends BaseEntity implements Serializable {
|
||||
return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null;
|
||||
}
|
||||
|
||||
private String serverContext(){
|
||||
private String serverContext() {
|
||||
return ServletUriComponentsBuilder.fromCurrentContextPath()
|
||||
.path("/api/upload/downloadFile/")
|
||||
.toUriString();
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ModeAcquisition extends BaseEntity implements Serializable {
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "modeAcquisition")
|
||||
//private List<SourceDroitExerce> sourceDroitExerces;
|
||||
private List<Piece> pieces ;
|
||||
private List<Piece> pieces;
|
||||
@ManyToMany
|
||||
@JoinTable(name = "modeAcquisition_typePersonne",
|
||||
joinColumns = @JoinColumn(name = "mode_acquisition_id"),
|
||||
|
||||
@@ -84,6 +84,4 @@ public class Personne extends BaseEntity implements Serializable {
|
||||
private boolean synchronise;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SourceDroit extends BaseEntity implements Serializable {
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "sourceDroit")
|
||||
//private List<SourceDroitExerce> sourceDroitExerces;
|
||||
private List<Piece> pieces ;
|
||||
private List<Piece> pieces;
|
||||
@Column(columnDefinition = "boolean default false")
|
||||
private boolean titreFoncier;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TypeDomaine extends BaseEntity implements Serializable {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String libelle;
|
||||
// @JsonIgnore
|
||||
// @JsonIgnore
|
||||
// @OneToMany(mappedBy = "typeDomaine")
|
||||
// private List<Parcelle> parcelles;
|
||||
@JsonIgnore
|
||||
|
||||
@@ -31,10 +31,10 @@ public class Equipe extends BaseEntity implements Serializable {
|
||||
@ManyToOne
|
||||
private Bloc bloc;
|
||||
@ManyToOne
|
||||
private Secteur secteur ;
|
||||
private Secteur secteur;
|
||||
@ManyToOne
|
||||
private Campagne campagne;
|
||||
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "equipe_id")
|
||||
private List<Participer> participers;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class User extends BaseEntity implements Serializable {
|
||||
private List<Participer> participers;
|
||||
@JsonIgnore
|
||||
@OneToMany(mappedBy = "chefSecteur")
|
||||
private List<Secteur> secteurs ;
|
||||
private List<Secteur> secteurs;
|
||||
|
||||
@Transient
|
||||
private Long idCampagneCourant;
|
||||
@@ -73,9 +73,9 @@ public class User extends BaseEntity implements Serializable {
|
||||
this.username = this.email;
|
||||
}
|
||||
|
||||
public boolean isAdmin(){
|
||||
for(Role r:this.roles ){
|
||||
if(r.getNom().equals(UserRole.ROLE_ADMIN)){
|
||||
public boolean isAdmin() {
|
||||
for (Role r : this.roles) {
|
||||
if (r.getNom().equals(UserRole.ROLE_ADMIN)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -83,18 +83,18 @@ public class User extends BaseEntity implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
public Long getIdCampagneCourant(){
|
||||
for (Participer p:participers){
|
||||
if(p.getDateFin()==null){
|
||||
public Long getIdCampagneCourant() {
|
||||
for (Participer p : participers) {
|
||||
if (p.getDateFin() == null) {
|
||||
return p.getEquipe().getCampagne().getId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Long getIdSecteurCourant(){
|
||||
for (Participer p:participers){
|
||||
if(p.getDateFin()==null){
|
||||
public Long getIdSecteurCourant() {
|
||||
for (Participer p : participers) {
|
||||
if (p.getDateFin() == null) {
|
||||
return p.getEquipe().getSecteur().getId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public class BadRequestException extends RuntimeException{
|
||||
public BadRequestException(String message){
|
||||
public class BadRequestException extends RuntimeException {
|
||||
public BadRequestException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package io.gmss.fiscad.exceptions;
|
||||
|
||||
public class FileStorageException extends RuntimeException {
|
||||
public FileStorageException(String message) {
|
||||
super(message);
|
||||
|
||||
@@ -4,8 +4,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public class NotFoundException extends RuntimeException{
|
||||
public NotFoundException(String message){
|
||||
public class NotFoundException extends RuntimeException {
|
||||
public NotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
||||
|
||||
@Override
|
||||
public Arrondissement createArrondissement(Arrondissement arrondissement) throws BadRequestException {
|
||||
if(arrondissement.getId() != null ){
|
||||
if (arrondissement.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouvel arrondissement ayant un id non null.");
|
||||
}
|
||||
return arrondissementRepository.save(arrondissement);
|
||||
@@ -35,10 +35,10 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
||||
|
||||
@Override
|
||||
public Arrondissement updateArrondissement(Long id, Arrondissement arrondissement) throws NotFoundException {
|
||||
if(arrondissement.getId() == null ){
|
||||
if (arrondissement.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouvel arrondissement ayant un id null.");
|
||||
}
|
||||
if(!arrondissementRepository.existsById(arrondissement.getId())){
|
||||
if (!arrondissementRepository.existsById(arrondissement.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié dans notre base de données.");
|
||||
}
|
||||
return arrondissementRepository.save(arrondissement);
|
||||
@@ -47,9 +47,9 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
||||
@Override
|
||||
public void deleteArrondissement(Long id) throws NotFoundException {
|
||||
Optional<Arrondissement> arrondissementOptional = arrondissementRepository.findById(id);
|
||||
if(arrondissementOptional.isPresent()){
|
||||
if (arrondissementOptional.isPresent()) {
|
||||
arrondissementRepository.deleteById(arrondissementOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class ArrondissementServiceImpl implements ArrondissementService {
|
||||
@Override
|
||||
public List<Arrondissement> getArrondissementByComune(Long communeId) {
|
||||
Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
|
||||
if(communeOptional.isEmpty()){
|
||||
if (communeOptional.isEmpty()) {
|
||||
throw new NotFoundException("Impossible de trouver la commune spécifiée.");
|
||||
}
|
||||
return arrondissementRepository.findAllByCommune(communeOptional.get());
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CommuneServiceImpl implements CommuneService {
|
||||
|
||||
@Override
|
||||
public Commune createCommune(Commune commune) throws BadRequestException {
|
||||
if(commune.getId() != null ){
|
||||
if (commune.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle commune ayant un id non null.");
|
||||
}
|
||||
return communeRepository.save(commune);
|
||||
@@ -35,10 +35,10 @@ public class CommuneServiceImpl implements CommuneService {
|
||||
|
||||
@Override
|
||||
public Commune updateCommune(Long id, Commune commune) throws NotFoundException {
|
||||
if(commune.getId() == null ){
|
||||
if (commune.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle commune ayant un id null.");
|
||||
}
|
||||
if(!communeRepository.existsById(commune.getId())){
|
||||
if (!communeRepository.existsById(commune.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la commune spécifiée dans notre base de données.");
|
||||
}
|
||||
return communeRepository.save(commune);
|
||||
@@ -47,9 +47,9 @@ public class CommuneServiceImpl implements CommuneService {
|
||||
@Override
|
||||
public void deleteCommune(Long id) throws NotFoundException {
|
||||
Optional<Commune> communeOptional = communeRepository.findById(id);
|
||||
if(communeOptional.isPresent()){
|
||||
if (communeOptional.isPresent()) {
|
||||
communeRepository.deleteById(communeOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la commune spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CommuneServiceImpl implements CommuneService {
|
||||
@Override
|
||||
public List<Commune> getCommunesByDepartement(Long departementId) {
|
||||
Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
|
||||
if(departementOptional.isEmpty()){
|
||||
if (departementOptional.isEmpty()) {
|
||||
throw new NotFoundException("Impossible de trouver le département spécifié.");
|
||||
}
|
||||
return communeRepository.findAllByDepartement(departementOptional.get());
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DepartementServiceImpl implements DepartementService {
|
||||
|
||||
@Override
|
||||
public Departement createDepartement(Departement departement) throws BadRequestException {
|
||||
if(departement.getId() != null ){
|
||||
if (departement.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau département ayant un id non null.");
|
||||
}
|
||||
return departementRepository.save(departement);
|
||||
@@ -31,10 +31,10 @@ public class DepartementServiceImpl implements DepartementService {
|
||||
|
||||
@Override
|
||||
public Departement updateDepartement(Long id, Departement departement) throws NotFoundException {
|
||||
if(departement.getId() == null ){
|
||||
if (departement.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau département ayant un id null.");
|
||||
}
|
||||
if(!departementRepository.existsById(departement.getId())){
|
||||
if (!departementRepository.existsById(departement.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le département spécifié dans notre base de données.");
|
||||
}
|
||||
return departementRepository.save(departement);
|
||||
@@ -43,9 +43,9 @@ public class DepartementServiceImpl implements DepartementService {
|
||||
@Override
|
||||
public void deleteDepartement(Long id) throws NotFoundException {
|
||||
Optional<Departement> departementOptional = departementRepository.findById(id);
|
||||
if(departementOptional.isPresent()){
|
||||
if (departementOptional.isPresent()) {
|
||||
departementRepository.deleteById(departementOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le département spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -63,9 +63,9 @@ public class DepartementServiceImpl implements DepartementService {
|
||||
|
||||
@Override
|
||||
public Optional<Departement> getDepartementById(Long id) {
|
||||
if(departementRepository.existsById(id)){
|
||||
if (departementRepository.existsById(id)) {
|
||||
return departementRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class NationaliteServiceImpl implements NationaliteService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class NationaliteServiceImpl implements NationaliteService {
|
||||
|
||||
@Override
|
||||
public Nationalite createNationalite(Nationalite nationalite) throws BadRequestException {
|
||||
if(nationalite.getId() != null ){
|
||||
if (nationalite.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle nationalité ayant un id non null.");
|
||||
}
|
||||
return nationaliteRepository.save(nationalite);
|
||||
@@ -30,10 +31,10 @@ public class NationaliteServiceImpl implements NationaliteService {
|
||||
|
||||
@Override
|
||||
public Nationalite updateNationalite(Long id, Nationalite nationalite) throws NotFoundException {
|
||||
if(nationalite.getId() == null ){
|
||||
if (nationalite.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle nationalité ayant un id null.");
|
||||
}
|
||||
if(!nationaliteRepository.existsById(nationalite.getId())){
|
||||
if (!nationaliteRepository.existsById(nationalite.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans notre base de données.");
|
||||
}
|
||||
return nationaliteRepository.save(nationalite);
|
||||
@@ -42,9 +43,9 @@ public class NationaliteServiceImpl implements NationaliteService {
|
||||
@Override
|
||||
public void deleteNationalite(Long id) throws NotFoundException {
|
||||
Optional<Nationalite> nationaliteOptional = nationaliteRepository.findById(id);
|
||||
if(nationaliteOptional.isPresent()){
|
||||
if (nationaliteOptional.isPresent()) {
|
||||
nationaliteRepository.deleteById(nationaliteOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -62,9 +63,9 @@ public class NationaliteServiceImpl implements NationaliteService {
|
||||
|
||||
@Override
|
||||
public Optional<Nationalite> getNationaliteById(Long id) {
|
||||
if(nationaliteRepository.existsById(id)){
|
||||
if (nationaliteRepository.existsById(id)) {
|
||||
return nationaliteRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class QuartierServiceImpl implements QuartierService {
|
||||
|
||||
@Override
|
||||
public Quartier createQuartier(Quartier quartier) throws BadRequestException {
|
||||
if(quartier.getId() != null ){
|
||||
if (quartier.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau quartier ayant un id non null.");
|
||||
}
|
||||
return quartierRepository.save(quartier);
|
||||
@@ -35,10 +35,10 @@ public class QuartierServiceImpl implements QuartierService {
|
||||
|
||||
@Override
|
||||
public Quartier updateQuartier(Long id, Quartier quartier) throws NotFoundException {
|
||||
if(quartier.getId() == null ){
|
||||
if (quartier.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau quartier ayant un id null.");
|
||||
}
|
||||
if(!quartierRepository.existsById(quartier.getId())){
|
||||
if (!quartierRepository.existsById(quartier.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le quartier spécifié dans notre base de données.");
|
||||
}
|
||||
return quartierRepository.save(quartier);
|
||||
@@ -47,9 +47,9 @@ public class QuartierServiceImpl implements QuartierService {
|
||||
@Override
|
||||
public void deleteQuartier(Long id) throws NotFoundException {
|
||||
Optional<Quartier> quartierOptional = quartierRepository.findById(id);
|
||||
if(quartierOptional.isPresent()){
|
||||
if (quartierOptional.isPresent()) {
|
||||
quartierRepository.deleteById(quartierOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le quartier spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -66,9 +66,9 @@ public class QuartierServiceImpl implements QuartierService {
|
||||
|
||||
@Override
|
||||
public Optional<Quartier> getQuartierById(Long id) {
|
||||
if(quartierRepository.existsById(id)){
|
||||
if (quartierRepository.existsById(id)) {
|
||||
return quartierRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class QuartierServiceImpl implements QuartierService {
|
||||
@Override
|
||||
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
|
||||
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
|
||||
if(arrondissementOptional.isEmpty()){
|
||||
if (arrondissementOptional.isEmpty()) {
|
||||
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
|
||||
}
|
||||
return quartierRepository.getAllByArrondissement(arrondissementOptional.get());
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
|
||||
@Override
|
||||
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
|
||||
if(secteurDecoupage.getId() != null ){
|
||||
if (secteurDecoupage.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
|
||||
}
|
||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||
@@ -30,10 +30,10 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
|
||||
@Override
|
||||
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
|
||||
if(secteurDecoupage.getId() == null ){
|
||||
if (secteurDecoupage.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
|
||||
}
|
||||
if(!secteurDecoupageRepository.existsById(secteurDecoupage.getId())){
|
||||
if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
||||
}
|
||||
return secteurDecoupageRepository.save(secteurDecoupage);
|
||||
@@ -42,9 +42,9 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
@Override
|
||||
public void deleteSecteurDecoupage(Long id) throws NotFoundException {
|
||||
Optional<SecteurDecoupage> secteurDecoupageOptional = secteurDecoupageRepository.findById(id);
|
||||
if(secteurDecoupageOptional.isPresent()){
|
||||
if (secteurDecoupageOptional.isPresent()) {
|
||||
secteurDecoupageRepository.deleteById(secteurDecoupageOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) {
|
||||
return secteurDecoupageRepository.findById(id);
|
||||
|
||||
@@ -41,37 +41,37 @@ public class SecteurServiceImpl implements SecteurService {
|
||||
|
||||
@Override
|
||||
public Secteur createSecteur(SecteurPayload secteurPayload) throws BadRequestException {
|
||||
if(secteurPayload.getId() != null ){
|
||||
if (secteurPayload.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
|
||||
}
|
||||
|
||||
if(secteurPayload.getChefSecteurId()!=null && userRepository.existsById(secteurPayload.getChefSecteurId()) ) {
|
||||
if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
|
||||
Secteur secteur = getSecteurFromPayload(secteurPayload);
|
||||
return secteurRepository.save(secteur);
|
||||
}else{
|
||||
} else {
|
||||
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
|
||||
}
|
||||
}
|
||||
|
||||
private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) {
|
||||
Secteur secteur=new Secteur();
|
||||
Optional<User> optionalUser=userRepository.findById(secteurPayload.getChefSecteurId());
|
||||
Secteur secteur = new Secteur();
|
||||
Optional<User> optionalUser = userRepository.findById(secteurPayload.getChefSecteurId());
|
||||
secteur.setChefSecteur(optionalUser.orElse(null));
|
||||
Optional<Structure> optionalStructure=structureRepository.findById(secteurPayload.getStructureId());
|
||||
Optional<Structure> optionalStructure = structureRepository.findById(secteurPayload.getStructureId());
|
||||
secteur.setStructure(optionalStructure.orElse(null));
|
||||
List<SecteurDecoupage> secteurDecoupageList=new ArrayList<>();
|
||||
List<SecteurDecoupage> secteurDecoupageList = new ArrayList<>();
|
||||
|
||||
for (SecteurDecoupagePayload sdp: secteurPayload.getSecteurDecoupages()){
|
||||
SecteurDecoupage sd=new SecteurDecoupage();
|
||||
if(sdp.getSecteurId()!=null && secteurRepository.existsById(sdp.getSecteurId()) ){
|
||||
for (SecteurDecoupagePayload sdp : secteurPayload.getSecteurDecoupages()) {
|
||||
SecteurDecoupage sd = new SecteurDecoupage();
|
||||
if (sdp.getSecteurId() != null && secteurRepository.existsById(sdp.getSecteurId())) {
|
||||
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));
|
||||
}
|
||||
|
||||
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.setDateDebut(sdp.getDateDebut());
|
||||
@@ -88,17 +88,17 @@ public class SecteurServiceImpl implements SecteurService {
|
||||
|
||||
@Override
|
||||
public Secteur updateSecteur(Long id, SecteurPayload secteurPayload) throws NotFoundException {
|
||||
if(secteurPayload.getId() == null ){
|
||||
if (secteurPayload.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null.");
|
||||
}
|
||||
|
||||
if(!secteurRepository.existsById(secteurPayload.getId())){
|
||||
if (!secteurRepository.existsById(secteurPayload.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le secteur spécifié.");
|
||||
}
|
||||
if(secteurPayload.getChefSecteurId()!=null && userRepository.existsById(secteurPayload.getChefSecteurId()) ) {
|
||||
if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
|
||||
Secteur secteur = getSecteurFromPayload(secteurPayload);
|
||||
return secteurRepository.save(secteur);
|
||||
}else{
|
||||
} else {
|
||||
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
|
||||
}
|
||||
}
|
||||
@@ -106,9 +106,9 @@ public class SecteurServiceImpl implements SecteurService {
|
||||
@Override
|
||||
public void deleteSecteur(Long id) throws NotFoundException {
|
||||
Optional<Secteur> secteurOptional = secteurRepository.findById(id);
|
||||
if(secteurOptional.isPresent()){
|
||||
if (secteurOptional.isPresent()) {
|
||||
secteurRepository.deleteById(secteurOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le secteur spécifié.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ActeurConcerneServiceImpl implements ActeurConcerneService {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CommentaireServiceImpl implements CommentaireService {
|
||||
|
||||
@Override
|
||||
public Commentaire createCommentaire(Commentaire commentaire) throws BadRequestException {
|
||||
if(commentaire.getId() != null ){
|
||||
if (commentaire.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau commentaire ayant un id non null.");
|
||||
}
|
||||
return commentaireRepository.save(commentaire);
|
||||
@@ -33,10 +33,10 @@ public class CommentaireServiceImpl implements CommentaireService {
|
||||
|
||||
@Override
|
||||
public Commentaire updateCommentaire(Long id, Commentaire commentaire) throws NotFoundException {
|
||||
if(commentaire.getId() == null ){
|
||||
if (commentaire.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau commentaire ayant un id null.");
|
||||
}
|
||||
if(!commentaireRepository.existsById(commentaire.getId())){
|
||||
if (!commentaireRepository.existsById(commentaire.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le commentaire spécifié dans notre base de données.");
|
||||
}
|
||||
return commentaireRepository.save(commentaire);
|
||||
@@ -45,15 +45,15 @@ public class CommentaireServiceImpl implements CommentaireService {
|
||||
@Override
|
||||
public void deleteCommentaire(Long id) throws NotFoundException {
|
||||
Optional<Commentaire> commentaireOptional = commentaireRepository.findById(id);
|
||||
if(commentaireOptional.isPresent()){
|
||||
if (commentaireOptional.isPresent()) {
|
||||
commentaireRepository.deleteById(commentaireOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le commentaire spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Commentaire> getCommentairesByEnqueteAndTerminal(Long idEnquete , Long terminalId) {
|
||||
public List<Commentaire> getCommentairesByEnqueteAndTerminal(Long idEnquete, Long terminalId) {
|
||||
return commentaireRepository.findAllByIdEnqueteAndTerminalId(idEnquete, terminalId);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class CommentaireServiceImpl implements CommentaireService {
|
||||
|
||||
@Override
|
||||
public boolean setCommentaireRead(Long id) {
|
||||
if(commentaireRepository.existsById(id)){
|
||||
if (commentaireRepository.existsById(id)) {
|
||||
Commentaire commentaire = commentaireRepository.getById(id);
|
||||
commentaire.setLu(true);
|
||||
updateCommentaire(id, commentaire);
|
||||
@@ -113,11 +113,11 @@ public class CommentaireServiceImpl implements CommentaireService {
|
||||
@Override
|
||||
public List<CommentaireResponse> notifySynchronizedDoneFromMobile(List<SyncCommentaireRequest> syncCommentaireRequests) {
|
||||
|
||||
if(syncCommentaireRequests != null || !syncCommentaireRequests.isEmpty()){
|
||||
if (syncCommentaireRequests != null || !syncCommentaireRequests.isEmpty()) {
|
||||
List<CommentaireResponse> commentaireResponses = new ArrayList<>();
|
||||
syncCommentaireRequests.forEach(syncCommentaireRequest -> {
|
||||
Optional<Commentaire> commentaireOptional = commentaireRepository.findById(syncCommentaireRequest.getIdBackend());
|
||||
if(commentaireOptional.isPresent()){
|
||||
if (commentaireOptional.isPresent()) {
|
||||
Commentaire commentaire = commentaireOptional.get();
|
||||
commentaire.setExternalKey(syncCommentaireRequest.getExternalKey());
|
||||
commentaire.setSynchronise(true);
|
||||
|
||||
@@ -68,19 +68,19 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public Enquete createEnquete(EnquetePayLoad enquetePayLoad) throws BadRequestException {
|
||||
Optional<User> optionalUser =userRepository.findById(enquetePayLoad.getUserId());
|
||||
if(!optionalUser.isPresent()){
|
||||
Optional<User> optionalUser = userRepository.findById(enquetePayLoad.getUserId());
|
||||
if (!optionalUser.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une enquête avec un enquêteur inexistant");
|
||||
}
|
||||
Optional<Bloc> optionalBloc =blocRepository.findById(enquetePayLoad.getBlocId());
|
||||
if(!optionalBloc.isPresent()){
|
||||
Optional<Bloc> optionalBloc = blocRepository.findById(enquetePayLoad.getBlocId());
|
||||
if (!optionalBloc.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une enquête avec un bloc inexistant");
|
||||
}
|
||||
Optional<Parcelle> optionalParcelle =parcelleRepository.findById(enquetePayLoad.getParcelleId());
|
||||
if(!optionalParcelle.isPresent()){
|
||||
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoad.getParcelleId());
|
||||
if (!optionalParcelle.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
|
||||
}
|
||||
Enquete enquete=new Enquete();
|
||||
Enquete enquete = new Enquete();
|
||||
enquete.setDateEnquete(LocalDate.now());
|
||||
enquete.setBloc(optionalBloc.get());
|
||||
enquete.setUser(optionalUser.get());
|
||||
@@ -98,9 +98,9 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public List<EnqueteFiltreResponse> getEnqueteCommuneArrondBlocFiltre(FiltreEnquetePayLoad filtreEnquetePayLoad) {
|
||||
String condition="";
|
||||
Query query ;
|
||||
String sql ="select distinct " +
|
||||
String condition = "";
|
||||
Query query;
|
||||
String sql = "select distinct " +
|
||||
" e.id," +
|
||||
" e.parcelle_id as parcelleId," +
|
||||
" c.id as communeId, " +
|
||||
@@ -138,80 +138,79 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
" left join type_personne tp on tp.id=per.type_personne_id " +
|
||||
" where ac.role_acteur='PROPRIETAIRE' ";
|
||||
|
||||
if(filtreEnquetePayLoad.getCommuneId()!=null){
|
||||
condition+= " AND c.id = "+filtreEnquetePayLoad.getCommuneId();
|
||||
if (filtreEnquetePayLoad.getCommuneId() != null) {
|
||||
condition += " AND c.id = " + filtreEnquetePayLoad.getCommuneId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getArrondissementId()!=null){
|
||||
condition+= " AND a.id = "+filtreEnquetePayLoad.getArrondissementId() ;
|
||||
if (filtreEnquetePayLoad.getArrondissementId() != null) {
|
||||
condition += " AND a.id = " + filtreEnquetePayLoad.getArrondissementId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getStructureId()!=null){
|
||||
condition+= " AND s.id = "+filtreEnquetePayLoad.getStructureId() ;
|
||||
if (filtreEnquetePayLoad.getStructureId() != null) {
|
||||
condition += " AND s.id = " + filtreEnquetePayLoad.getStructureId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getParcelleId()!=null){
|
||||
condition+= " AND p.id = "+filtreEnquetePayLoad.getParcelleId();
|
||||
if (filtreEnquetePayLoad.getParcelleId() != null) {
|
||||
condition += " AND p.id = " + filtreEnquetePayLoad.getParcelleId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getBlocId()!=null){
|
||||
condition+= " AND b.id = "+filtreEnquetePayLoad.getBlocId() ;
|
||||
if (filtreEnquetePayLoad.getBlocId() != null) {
|
||||
condition += " AND b.id = " + filtreEnquetePayLoad.getBlocId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getNomPersonne()!=null){
|
||||
condition+= " AND per.nom_ou_sigle like '%"+filtreEnquetePayLoad.getNomPersonne() +"%'";
|
||||
if (filtreEnquetePayLoad.getNomPersonne() != null) {
|
||||
condition += " AND per.nom_ou_sigle like '%" + filtreEnquetePayLoad.getNomPersonne() + "%'";
|
||||
}
|
||||
if(filtreEnquetePayLoad.getPrenomPersonne()!=null){
|
||||
condition+= " AND per.prenom_ou_raison_sociale like '%"+filtreEnquetePayLoad.getPrenomPersonne() +"%'";
|
||||
if (filtreEnquetePayLoad.getPrenomPersonne() != null) {
|
||||
condition += " AND per.prenom_ou_raison_sociale like '%" + filtreEnquetePayLoad.getPrenomPersonne() + "%'";
|
||||
}
|
||||
if(filtreEnquetePayLoad.getNatureDomaneId()!=null){
|
||||
condition+= " AND nd.id = "+filtreEnquetePayLoad.getNatureDomaneId() ;
|
||||
if (filtreEnquetePayLoad.getNatureDomaneId() != null) {
|
||||
condition += " AND nd.id = " + filtreEnquetePayLoad.getNatureDomaneId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getTypeDomaineId()!=null){
|
||||
condition+= " AND td.id = "+filtreEnquetePayLoad.getTypeDomaineId() ;
|
||||
if (filtreEnquetePayLoad.getTypeDomaineId() != null) {
|
||||
condition += " AND td.id = " + filtreEnquetePayLoad.getTypeDomaineId();
|
||||
}
|
||||
if(filtreEnquetePayLoad.getTypePersonneId()!=null){
|
||||
condition+= " AND tp.id = "+filtreEnquetePayLoad.getTypePersonneId() ;
|
||||
if (filtreEnquetePayLoad.getTypePersonneId() != null) {
|
||||
condition += " AND tp.id = " + filtreEnquetePayLoad.getTypePersonneId();
|
||||
}
|
||||
/////////////////
|
||||
if(filtreEnquetePayLoad.getEnqueteurId()!=null){
|
||||
condition+= " AND e.user_id = "+filtreEnquetePayLoad.getEnqueteurId() ;
|
||||
if (filtreEnquetePayLoad.getEnqueteurId() != null) {
|
||||
condition += " AND e.user_id = " + filtreEnquetePayLoad.getEnqueteurId();
|
||||
}
|
||||
|
||||
if(filtreEnquetePayLoad.getStatutEnquete()!=null){
|
||||
condition+= " AND e.status_enquete = "+filtreEnquetePayLoad.getStatutEnquete() ;
|
||||
if (filtreEnquetePayLoad.getStatutEnquete() != null) {
|
||||
condition += " AND e.status_enquete = " + filtreEnquetePayLoad.getStatutEnquete();
|
||||
}
|
||||
|
||||
if(filtreEnquetePayLoad.getLitige()!=null){
|
||||
condition+= " AND e.litige is "+filtreEnquetePayLoad.getLitige() ;
|
||||
if (filtreEnquetePayLoad.getLitige() != null) {
|
||||
condition += " AND e.litige is " + filtreEnquetePayLoad.getLitige();
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.out.println(condition);
|
||||
StringBuilder sb = new StringBuilder(sql).append(condition);
|
||||
query = em.createNativeQuery(sb.toString(), EnqueteFiltreResponse.class);
|
||||
List<EnqueteFiltreResponse> enqueteFiltreResponses = query.getResultList();
|
||||
|
||||
return enqueteFiltreResponses ;
|
||||
return enqueteFiltreResponses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enquete updateEnquete(EnquetePayLoad enquetePayLoad) throws NotFoundException {
|
||||
if(enquetePayLoad.getIdBackend() == null ){
|
||||
if (enquetePayLoad.getIdBackend() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
|
||||
}
|
||||
if(!enqueteRepository.existsById(enquetePayLoad.getIdBackend())){
|
||||
if (!enqueteRepository.existsById(enquetePayLoad.getIdBackend())) {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier.");
|
||||
}
|
||||
Optional<User> optionalUser =userRepository.findById(enquetePayLoad.getUserId());
|
||||
if(!optionalUser.isPresent()){
|
||||
Optional<User> optionalUser = userRepository.findById(enquetePayLoad.getUserId());
|
||||
if (!optionalUser.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une enquête avec un enquêteur inexistant");
|
||||
}
|
||||
Optional<Bloc> optionalBloc =blocRepository.findById(enquetePayLoad.getBlocId());
|
||||
if(!optionalBloc.isPresent()){
|
||||
Optional<Bloc> optionalBloc = blocRepository.findById(enquetePayLoad.getBlocId());
|
||||
if (!optionalBloc.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une enquête avec un bloc inexistant");
|
||||
}
|
||||
Optional<Parcelle> optionalParcelle =parcelleRepository.findById(enquetePayLoad.getParcelleId());
|
||||
if(!optionalParcelle.isPresent()){
|
||||
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoad.getParcelleId());
|
||||
if (!optionalParcelle.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
|
||||
}
|
||||
Enquete enquete=enqueteRepository.findById(enquetePayLoad.getParcelleId()).get();
|
||||
Enquete enquete = enqueteRepository.findById(enquetePayLoad.getParcelleId()).get();
|
||||
enquete.setBloc(optionalBloc.get());
|
||||
enquete.setUser(optionalUser.get());
|
||||
enquete.setParcelle(optionalParcelle.get());
|
||||
@@ -225,9 +224,9 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
@Override
|
||||
public void deleteEnquete(Long id) throws NotFoundException {
|
||||
Optional<Enquete> optionalEnquete = enqueteRepository.findById(id);
|
||||
if(optionalEnquete.isPresent()){
|
||||
if (optionalEnquete.isPresent()) {
|
||||
enqueteRepository.deleteById(optionalEnquete.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez supprimer.");
|
||||
}
|
||||
}
|
||||
@@ -244,20 +243,20 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public Optional<Enquete> getEnqueteById(Long id) {
|
||||
if(enqueteRepository.existsById(id)){
|
||||
if (enqueteRepository.existsById(id)) {
|
||||
return enqueteRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enquete validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
||||
if(enqueteTraitementPayLoad == null ){
|
||||
if (enqueteTraitementPayLoad == null) {
|
||||
throw new BadRequestException("Impossible de valider une enquête ayant un id null.");
|
||||
}
|
||||
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend());
|
||||
if(!optionalEnquete.isPresent()){
|
||||
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend());
|
||||
if (!optionalEnquete.isPresent()) {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider.");
|
||||
}
|
||||
optionalEnquete.get().setDateValidation(LocalDate.now());
|
||||
@@ -268,11 +267,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public Enquete rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
|
||||
if(enqueteTraitementPayLoad.getIdBackend() == null ){
|
||||
if (enqueteTraitementPayLoad.getIdBackend() == null) {
|
||||
throw new BadRequestException("Impossible de rejeter une enquête ayant un id null.");
|
||||
}
|
||||
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend());
|
||||
if(!optionalEnquete.isPresent()){
|
||||
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend());
|
||||
if (!optionalEnquete.isPresent()) {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter.");
|
||||
}
|
||||
optionalEnquete.get().setDateRejet(LocalDate.now());
|
||||
@@ -286,11 +285,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
@Override
|
||||
public List<Enquete> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
||||
List<Enquete> enquetes = new ArrayList<>();
|
||||
try{
|
||||
try {
|
||||
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
|
||||
enquetes.add(validerEnquete(enqueteTraitementPayLoad));
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
enquetes.add(null);
|
||||
}
|
||||
return enquetes;
|
||||
@@ -299,11 +298,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
@Override
|
||||
public List<Enquete> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
|
||||
List<Enquete> enquetes = new ArrayList<>();
|
||||
try{
|
||||
try {
|
||||
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
|
||||
enquetes.add(rejeterEnquete(enqueteTraitementPayLoad));
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
enquetes.add(null);
|
||||
}
|
||||
return enquetes;
|
||||
@@ -311,11 +310,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public Enquete finaliserEnquete(Long enqueteId) {
|
||||
if(enqueteId == null ){
|
||||
if (enqueteId == null) {
|
||||
throw new BadRequestException("Impossible de finaliser une enquête ayant un id null.");
|
||||
}
|
||||
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteId);
|
||||
if(!optionalEnquete.isPresent()){
|
||||
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteId);
|
||||
if (!optionalEnquete.isPresent()) {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez finaliser.");
|
||||
}
|
||||
optionalEnquete.get().setDateFinalisation(LocalDate.now());
|
||||
@@ -325,11 +324,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public Enquete reglerLitigeEnquete(Long enqueteId) {
|
||||
if(enqueteId == null ){
|
||||
if (enqueteId == null) {
|
||||
throw new BadRequestException("Impossible de régler le litige d'une enquête ayant un id null.");
|
||||
}
|
||||
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteId);
|
||||
if(!optionalEnquete.isPresent()){
|
||||
Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteId);
|
||||
if (!optionalEnquete.isPresent()) {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête dont vous désirez régler le litige.");
|
||||
}
|
||||
optionalEnquete.get().setDateLitigeResolu(LocalDate.now());
|
||||
@@ -341,11 +340,11 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
@Override
|
||||
public UserDecoupageEnqResponses getDecoupageAdminUserConnecterAndStat() {
|
||||
String userName="";
|
||||
String userName = "";
|
||||
try {
|
||||
authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
userName = authentication.getName();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -357,14 +356,14 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
System.out.println(user.isAdmin());
|
||||
|
||||
List<CommuneEnqResponse> communeEnqResponses =
|
||||
user.isAdmin() ? communeRepository.getAdminCommuneEnqResponse():communeRepository.getCommuneEnqResponse(user.getStructure().getId());
|
||||
user.isAdmin() ? communeRepository.getAdminCommuneEnqResponse() : communeRepository.getCommuneEnqResponse(user.getStructure().getId());
|
||||
|
||||
|
||||
List<ArrondissementEnqResponse> arrondissementEnqResponses =
|
||||
user.isAdmin()? arrondissementRepository.getAdminArrondissementEnqResponse() : arrondissementRepository.getArrondissementEnqResponse(user.getStructure().getId());
|
||||
user.isAdmin() ? arrondissementRepository.getAdminArrondissementEnqResponse() : arrondissementRepository.getArrondissementEnqResponse(user.getStructure().getId());
|
||||
|
||||
List<BlocEnqResponse> blocEnqResponses =
|
||||
user.isAdmin() ? blocRepository.getAdminBlocEnqResponse(): blocRepository.getBlocEnqResponse(user.getStructure().getId());
|
||||
user.isAdmin() ? blocRepository.getAdminBlocEnqResponse() : blocRepository.getBlocEnqResponse(user.getStructure().getId());
|
||||
|
||||
UserDecoupageEnqResponses userDecoupageEnqResponses = new UserDecoupageEnqResponses();
|
||||
userDecoupageEnqResponses.setCommunes(communeEnqResponses);
|
||||
@@ -383,33 +382,33 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
|
||||
FicheEnquetesResponse ficheEnquetesResponse = new FicheEnquetesResponse(); // classe payload de Enquete
|
||||
|
||||
if(optionalEnquete.isPresent()){
|
||||
if (optionalEnquete.isPresent()) {
|
||||
ficheEnquetesResponse = modelMapper.map(optionalEnquete.get(), FicheEnquetesResponse.class);
|
||||
}
|
||||
|
||||
List<FicheActeurConcerneResponse> ficheActeurConcerneResponses = new ArrayList<>();
|
||||
if(!acteurConcernes.isEmpty()){
|
||||
if (!acteurConcernes.isEmpty()) {
|
||||
acteurConcernes.stream().forEach(acteurConcerne -> ficheActeurConcerneResponses.add(modelMapper.map(acteurConcerne, FicheActeurConcerneResponse.class)));
|
||||
}
|
||||
|
||||
List<CaracteristiqueParcelle> caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId);
|
||||
|
||||
List<FicheCaracteristiqueParcelleResponse> caracteristiqueParcelleResponses = new ArrayList<>();
|
||||
if(!caracteristiqueParcelles.isEmpty()){
|
||||
if (!caracteristiqueParcelles.isEmpty()) {
|
||||
caracteristiqueParcelles.stream().forEach(caracteristiqueParcelle -> caracteristiqueParcelleResponses.add(modelMapper.map(caracteristiqueParcelle, FicheCaracteristiqueParcelleResponse.class)));
|
||||
}
|
||||
|
||||
List<FicheEnqueteBatimentResponse> enqueteBatimentResponses = new ArrayList<>();
|
||||
|
||||
List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId);
|
||||
if(!enqueteBatiments.isEmpty()){
|
||||
if (!enqueteBatiments.isEmpty()) {
|
||||
enqueteBatiments.stream().forEach(enqueteBatiment -> enqueteBatimentResponses.add(modelMapper.map(enqueteBatiment, FicheEnqueteBatimentResponse.class)));
|
||||
}
|
||||
|
||||
List<FicheEnqueteUniteLogementResponse> enqueteUniteLogementResponses = new ArrayList<>();
|
||||
|
||||
List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId);
|
||||
if(!enqueteUniteLogements.isEmpty()){
|
||||
if (!enqueteUniteLogements.isEmpty()) {
|
||||
enqueteUniteLogements.stream().forEach(enqueteUniteLogement -> enqueteUniteLogementResponses.add(modelMapper.map(enqueteUniteLogement, FicheEnqueteUniteLogementResponse.class)));
|
||||
}
|
||||
|
||||
@@ -420,7 +419,7 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
ficheEnqueteResponse.setEnquete(ficheEnquetesResponse);
|
||||
ficheEnqueteResponse.setActeurConcernes(ficheActeurConcerneResponses);
|
||||
|
||||
return ficheEnqueteResponse ;
|
||||
return ficheEnqueteResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,51 +44,51 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
@Override
|
||||
public Parcelle createParcelle(ParcellePayLoad parcellePayLoad) throws BadRequestException {
|
||||
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoad.getNatureDomaineId());
|
||||
if(!optionalNatureDomaine.isPresent()){
|
||||
if (!optionalNatureDomaine.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant");
|
||||
}
|
||||
Optional<Quartier> optionalQuartier =quartierRepository.findById(parcellePayLoad.getQuartierId());
|
||||
if(!optionalQuartier.isPresent()){
|
||||
Optional<Quartier> optionalQuartier = quartierRepository.findById(parcellePayLoad.getQuartierId());
|
||||
if (!optionalQuartier.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant");
|
||||
}
|
||||
Optional<SituationGeographique> optionalSituationGeographique =situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId());
|
||||
if(!optionalSituationGeographique.isPresent()){
|
||||
Optional<SituationGeographique> optionalSituationGeographique = situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId());
|
||||
if (!optionalSituationGeographique.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant");
|
||||
}
|
||||
|
||||
Parcelle parcelle=getParcelle(parcellePayLoad, optionalSituationGeographique, optionalNatureDomaine);
|
||||
Parcelle parcelle = getParcelle(parcellePayLoad, optionalSituationGeographique, optionalNatureDomaine);
|
||||
return parcelleRepository.save(parcelle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelle updateParcelle(ParcellePayLoad parcellePayLoad) throws NotFoundException {
|
||||
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoad.getIdBackend());
|
||||
if(!optionalParcelle.isPresent()){
|
||||
if (!optionalParcelle.isPresent()) {
|
||||
throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier");
|
||||
}
|
||||
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoad.getNatureDomaineId());
|
||||
if(!optionalNatureDomaine.isPresent()){
|
||||
if (!optionalNatureDomaine.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistante");
|
||||
}
|
||||
Optional<Quartier> optionalQuartier =quartierRepository.findById(parcellePayLoad.getQuartierId());
|
||||
if(!optionalQuartier.isPresent()){
|
||||
Optional<Quartier> optionalQuartier = quartierRepository.findById(parcellePayLoad.getQuartierId());
|
||||
if (!optionalQuartier.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant");
|
||||
}
|
||||
Optional<SituationGeographique> optionalSituationGeographique =situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId());
|
||||
if(!optionalSituationGeographique.isPresent()){
|
||||
Optional<SituationGeographique> optionalSituationGeographique = situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId());
|
||||
if (!optionalSituationGeographique.isPresent()) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant");
|
||||
}
|
||||
|
||||
Parcelle parcelle=getParcelle(optionalParcelle.get(),parcellePayLoad,optionalSituationGeographique, optionalNatureDomaine);
|
||||
Parcelle parcelle = getParcelle(optionalParcelle.get(), parcellePayLoad, optionalSituationGeographique, optionalNatureDomaine);
|
||||
return parcelleRepository.save(parcelle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteParcelle(Long id) throws NotFoundException {
|
||||
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(id);
|
||||
if(optionalParcelle.isPresent()){
|
||||
if (optionalParcelle.isPresent()) {
|
||||
parcelleRepository.deleteById(optionalParcelle.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la parcelle que vous désirez supprimer.");
|
||||
}
|
||||
}
|
||||
@@ -105,15 +105,16 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
|
||||
@Override
|
||||
public Optional<Parcelle> getParcelleById(Long id) {
|
||||
if(parcelleRepository.existsById(id)){
|
||||
if (parcelleRepository.existsById(id)) {
|
||||
return parcelleRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver l'enquête.");
|
||||
}
|
||||
}
|
||||
|
||||
private Parcelle getParcelle(ParcellePayLoad parcellePayLoad, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
|
||||
StringBuilder coordonnees =new StringBuilder();
|
||||
Parcelle parcelle=new Parcelle();
|
||||
StringBuilder coordonnees = new StringBuilder();
|
||||
Parcelle parcelle = new Parcelle();
|
||||
parcelle.setP(parcellePayLoad.getP());
|
||||
parcelle.setI(parcellePayLoad.getI());
|
||||
parcelle.setQ(parcellePayLoad.getQ());
|
||||
@@ -145,8 +146,9 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
// }
|
||||
return parcelle;
|
||||
}
|
||||
|
||||
private Parcelle getParcelle(Parcelle parcelle, ParcellePayLoad parcellePayLoad, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
|
||||
StringBuilder coordonnees =new StringBuilder();
|
||||
StringBuilder coordonnees = new StringBuilder();
|
||||
parcelle.setP(parcellePayLoad.getP());
|
||||
parcelle.setI(parcellePayLoad.getI());
|
||||
parcelle.setQ(parcellePayLoad.getQ());
|
||||
@@ -180,6 +182,4 @@ public class ParcelleServiceImpl implements ParcelleService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class TpeServiceImpl implements TpeService {
|
||||
|
||||
@@ -27,29 +28,29 @@ public class TpeServiceImpl implements TpeService {
|
||||
@Override
|
||||
public Tpe createTpe(Tpe tpe) throws BadRequestException {
|
||||
String codeEquipe;
|
||||
do{
|
||||
do {
|
||||
codeEquipe = StringService.getCodeEquipe();
|
||||
}while (tpeRepository.existsDistinctByCodeEquipe(codeEquipe));
|
||||
} while (tpeRepository.existsDistinctByCodeEquipe(codeEquipe));
|
||||
|
||||
tpe.setCodeEquipe(codeEquipe);
|
||||
|
||||
if(tpe.getId() != null ){
|
||||
if (tpe.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau tpe ayant un id non null.");
|
||||
}
|
||||
|
||||
if(tpeRepository.existsDistinctByIdentifier(tpe.getIdentifier())){
|
||||
if (tpeRepository.existsDistinctByIdentifier(tpe.getIdentifier())) {
|
||||
return tpeRepository.findDistinctByIdentifier(tpe.getIdentifier()).get();
|
||||
}else{
|
||||
} else {
|
||||
return tpeRepository.save(tpe);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tpe updateTpe(Long id, Tpe tpe) throws NotFoundException {
|
||||
if(tpe.getId() == null ){
|
||||
if (tpe.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau tpe ayant un id null.");
|
||||
}
|
||||
if(!tpeRepository.existsById(tpe.getId())){
|
||||
if (!tpeRepository.existsById(tpe.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le tpe spécifié dans notre base de données.");
|
||||
}
|
||||
return tpeRepository.save(tpe);
|
||||
@@ -58,9 +59,9 @@ public class TpeServiceImpl implements TpeService {
|
||||
@Override
|
||||
public void deleteTpe(Long id) throws NotFoundException {
|
||||
Optional<Tpe> tpeOptional = tpeRepository.findById(id);
|
||||
if(tpeOptional.isPresent()){
|
||||
if (tpeOptional.isPresent()) {
|
||||
tpeRepository.deleteById(tpeOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le tpe spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -77,9 +78,9 @@ public class TpeServiceImpl implements TpeService {
|
||||
|
||||
@Override
|
||||
public Optional<Tpe> getTpeById(Long id) {
|
||||
if(tpeRepository.existsById(id)){
|
||||
if (tpeRepository.existsById(id)) {
|
||||
return tpeRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le tpe spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
@@ -87,18 +88,18 @@ public class TpeServiceImpl implements TpeService {
|
||||
|
||||
@Override
|
||||
public Optional<Tpe> getTepByIdentifier(String identifier) {
|
||||
if(tpeRepository.existsDistinctByIdentifier(identifier)){
|
||||
if (tpeRepository.existsDistinctByIdentifier(identifier)) {
|
||||
return tpeRepository.findDistinctByIdentifier(identifier);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le tpe lié à cette clé dans la base de données.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tpe> getTpeListByModel(String model) {
|
||||
if(model != null){
|
||||
if (model != null) {
|
||||
return tpeRepository.findAllByModel(model);
|
||||
}else{
|
||||
} else {
|
||||
throw new BadRequestException("Vous devez spécifier le model du tpe.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,52 +35,52 @@ public class BlocServiceImpl implements BlocService {
|
||||
|
||||
@Override
|
||||
public Bloc createBloc(Bloc bloc) throws BadRequestException {
|
||||
if(bloc.getId() != null ){
|
||||
if (bloc.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau bloc ayant un id non null.");
|
||||
}
|
||||
String idBlocParArrondissement = getIdBlocParArrondissementValue(bloc);
|
||||
bloc.setIdBlocParArrondissement(idBlocParArrondissement);
|
||||
|
||||
if(bloc.getStructure() == null){
|
||||
if (bloc.getStructure() == null) {
|
||||
bloc.setCote(getCoteValue(bloc, idBlocParArrondissement, null));
|
||||
}else{
|
||||
} else {
|
||||
bloc.setCote(getCoteValue(bloc, idBlocParArrondissement, bloc.getStructure().getId()));
|
||||
}
|
||||
|
||||
if(bloc.getQuartier() != null){
|
||||
if (bloc.getQuartier() != null) {
|
||||
bloc.setCoteq(getCoteQuartierByCoteBloc(bloc.getCote(), bloc.getQuartier()));
|
||||
}
|
||||
if(bloc.getSecteurDecoupage()!=null) {
|
||||
if (bloc.getSecteurDecoupage() != null) {
|
||||
bloc.setSecteur(bloc.getSecteurDecoupage().getSecteur());
|
||||
}
|
||||
return blocRepository.save(bloc);
|
||||
}
|
||||
|
||||
private String getCoteQuartierByCoteBloc(String cote, Quartier quartier) {
|
||||
if(cote == null) {
|
||||
if (cote == null) {
|
||||
throw new BadRequestException("Le bloc spécifié ne dispose pas encore de code.");
|
||||
}else{
|
||||
return new StringBuilder().append(cote.substring(0,3)).append(quartier.getCode()).toString();
|
||||
} else {
|
||||
return new StringBuilder().append(cote.substring(0, 3)).append(quartier.getCode()).toString();
|
||||
}
|
||||
}
|
||||
|
||||
private String getCoteValue(Bloc bloc, String idBlocParArrondissement, Long structure_id) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if(structure_id == null){
|
||||
if (structure_id == null) {
|
||||
structure_id = blocRepository.getStructureId(bloc.getArrondissement().getId());
|
||||
if(structure_id == null){
|
||||
if (structure_id == null) {
|
||||
throw new NotFoundException("Aucune structure n'est associé à ce bloc. Il n'est donc pas possible d'enregistrer ce bloc. Vous devez donc attribué ce bloc à une structure.");
|
||||
}
|
||||
}
|
||||
|
||||
Optional<Structure> structureOptional = structureService.getStructureById(structure_id);
|
||||
if(structureOptional.isPresent()){
|
||||
if (structureOptional.isPresent()) {
|
||||
builder.append(structureOptional.get().getCode());
|
||||
builder.append(bloc.getArrondissement().getCode());
|
||||
builder.append(idBlocParArrondissement);
|
||||
return builder.toString();
|
||||
}else {
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la structure associée à ce bloc");
|
||||
}
|
||||
}
|
||||
@@ -92,10 +92,10 @@ public class BlocServiceImpl implements BlocService {
|
||||
|
||||
@Override
|
||||
public Bloc updateBloc(Long id, Bloc bloc) throws NotFoundException {
|
||||
if(bloc.getId() == null ){
|
||||
if (bloc.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau bloc ayant un id null.");
|
||||
}
|
||||
if(!blocRepository.existsById(bloc.getId())){
|
||||
if (!blocRepository.existsById(bloc.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le bloc spécifié dans notre base de données.");
|
||||
}
|
||||
return blocRepository.save(bloc);
|
||||
@@ -104,9 +104,9 @@ public class BlocServiceImpl implements BlocService {
|
||||
@Override
|
||||
public void deleteBloc(Long id) throws NotFoundException {
|
||||
Optional<Bloc> blocOptional = blocRepository.findById(id);
|
||||
if(blocOptional.isPresent()){
|
||||
if (blocOptional.isPresent()) {
|
||||
blocRepository.deleteById(blocOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le bloc spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -126,9 +126,9 @@ public class BlocServiceImpl implements BlocService {
|
||||
|
||||
@Override
|
||||
public List<Bloc> getBlocsByStructure(Long idStructure) {
|
||||
if(structureService.getStructureById(idStructure).isPresent()){
|
||||
if (structureService.getStructureById(idStructure).isPresent()) {
|
||||
return blocRepository.getBlocsByStructure(idStructure);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la structure spécifiée.");
|
||||
}
|
||||
}
|
||||
@@ -145,18 +145,18 @@ public class BlocServiceImpl implements BlocService {
|
||||
|
||||
@Override
|
||||
public Optional<Bloc> getBlocById(Long id) {
|
||||
if(blocRepository.existsById(id)){
|
||||
if (blocRepository.existsById(id)) {
|
||||
return blocRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le bloc spécifié dans la base de données.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countAllBlocByArrondissement(Long idArrondissement) {
|
||||
if(arrondissementService.getArrondissementById(idArrondissement).isPresent()){
|
||||
if (arrondissementService.getArrondissementById(idArrondissement).isPresent()) {
|
||||
return blocRepository.countAllBlocByArrondissement(idArrondissement);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver l'arrondissement' spécifié dans la base de données.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
|
||||
|
||||
@Override
|
||||
public ModeAcquisition createModeAcquisition(ModeAcquisition modeAcquisition) throws BadRequestException {
|
||||
if(modeAcquisition.getId() != null ){
|
||||
if (modeAcquisition.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau mode d'acquisition ayant un id non null.");
|
||||
}
|
||||
return modeAcquisitionRepository.save(modeAcquisition);
|
||||
@@ -30,10 +31,10 @@ public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
|
||||
|
||||
@Override
|
||||
public ModeAcquisition updateModeAcquisition(Long id, ModeAcquisition modeAcquisition) throws NotFoundException {
|
||||
if(modeAcquisition.getId() == null ){
|
||||
if (modeAcquisition.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau mode d'acquisition ayant un id null.");
|
||||
}
|
||||
if(!modeAcquisitionRepository.existsById(modeAcquisition.getId())){
|
||||
if (!modeAcquisitionRepository.existsById(modeAcquisition.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans notre base de données.");
|
||||
}
|
||||
return modeAcquisitionRepository.save(modeAcquisition);
|
||||
@@ -42,9 +43,9 @@ public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
|
||||
@Override
|
||||
public void deleteModeAcquisition(Long id) throws NotFoundException {
|
||||
Optional<ModeAcquisition> modeAcquisitionOptional = modeAcquisitionRepository.findById(id);
|
||||
if(modeAcquisitionOptional.isPresent()){
|
||||
if (modeAcquisitionOptional.isPresent()) {
|
||||
modeAcquisitionRepository.deleteById(modeAcquisitionOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
|
||||
|
||||
@Override
|
||||
public Optional<ModeAcquisition> getModeAcquisitionById(Long id) {
|
||||
if(modeAcquisitionRepository.existsById(id)){
|
||||
if (modeAcquisitionRepository.existsById(id)) {
|
||||
return modeAcquisitionRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class NatureDomaineServiceImpl implements NatureDomaineService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class NatureDomaineServiceImpl implements NatureDomaineService {
|
||||
|
||||
@Override
|
||||
public NatureDomaine createNatureDomaine(NatureDomaine natureDomaine) throws BadRequestException {
|
||||
if(natureDomaine.getId() != null ){
|
||||
if (natureDomaine.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle nature domaine ayant un id non null.");
|
||||
}
|
||||
return natureDomaineRepository.save(natureDomaine);
|
||||
@@ -30,10 +31,10 @@ public class NatureDomaineServiceImpl implements NatureDomaineService {
|
||||
|
||||
@Override
|
||||
public NatureDomaine updateNatureDomaine(Long id, NatureDomaine natureDomaine) throws NotFoundException {
|
||||
if(natureDomaine.getId() == null ){
|
||||
if (natureDomaine.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle nature domaine ayant un id null.");
|
||||
}
|
||||
if(!natureDomaineRepository.existsById(natureDomaine.getId())){
|
||||
if (!natureDomaineRepository.existsById(natureDomaine.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans notre base de données.");
|
||||
}
|
||||
return natureDomaineRepository.save(natureDomaine);
|
||||
@@ -42,9 +43,9 @@ public class NatureDomaineServiceImpl implements NatureDomaineService {
|
||||
@Override
|
||||
public void deleteNatureDomaine(Long id) throws NotFoundException {
|
||||
Optional<NatureDomaine> natureDomaineOptional = natureDomaineRepository.findById(id);
|
||||
if(natureDomaineOptional.isPresent()){
|
||||
if (natureDomaineOptional.isPresent()) {
|
||||
natureDomaineRepository.deleteById(natureDomaineOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class NatureDomaineServiceImpl implements NatureDomaineService {
|
||||
|
||||
@Override
|
||||
public Optional<NatureDomaine> getNatureDomaineById(Long id) {
|
||||
if(natureDomaineRepository.existsById(id)){
|
||||
if (natureDomaineRepository.existsById(id)) {
|
||||
return natureDomaineRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class PositionRepresentationServiceImpl implements PositionRepresentationService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class PositionRepresentationServiceImpl implements PositionRepresentation
|
||||
|
||||
@Override
|
||||
public PositionRepresentation createPositionRepresentation(PositionRepresentation positionRepresentation) throws BadRequestException {
|
||||
if(positionRepresentation.getId() != null ){
|
||||
if (positionRepresentation.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle position de représentation ayant un id non null.");
|
||||
}
|
||||
return positionRepresentationRepository.save(positionRepresentation);
|
||||
@@ -30,10 +31,10 @@ public class PositionRepresentationServiceImpl implements PositionRepresentation
|
||||
|
||||
@Override
|
||||
public PositionRepresentation updatePositionRepresentation(Long id, PositionRepresentation positionRepresentation) throws NotFoundException {
|
||||
if(positionRepresentation.getId() == null ){
|
||||
if (positionRepresentation.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle position de représentation ayant un id null.");
|
||||
}
|
||||
if(!positionRepresentationRepository.existsById(positionRepresentation.getId())){
|
||||
if (!positionRepresentationRepository.existsById(positionRepresentation.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans notre base de données.");
|
||||
}
|
||||
return positionRepresentationRepository.save(positionRepresentation);
|
||||
@@ -42,9 +43,9 @@ public class PositionRepresentationServiceImpl implements PositionRepresentation
|
||||
@Override
|
||||
public void deletePositionRepresentation(Long id) throws NotFoundException {
|
||||
Optional<PositionRepresentation> positionRepresentationOptional = positionRepresentationRepository.findById(id);
|
||||
if(positionRepresentationOptional.isPresent()){
|
||||
if (positionRepresentationOptional.isPresent()) {
|
||||
positionRepresentationRepository.deleteById(positionRepresentationOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class PositionRepresentationServiceImpl implements PositionRepresentation
|
||||
|
||||
@Override
|
||||
public Optional<PositionRepresentation> getPositionRepresentationById(Long id) {
|
||||
if(positionRepresentationRepository.existsById(id)){
|
||||
if (positionRepresentationRepository.existsById(id)) {
|
||||
return positionRepresentationRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ProfessionServiceImpl implements ProfessionService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class ProfessionServiceImpl implements ProfessionService {
|
||||
|
||||
@Override
|
||||
public Profession createProfession(Profession profession) throws BadRequestException {
|
||||
if(profession.getId() != null ){
|
||||
if (profession.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle profession ayant un id non null.");
|
||||
}
|
||||
return professionRepository.save(profession);
|
||||
@@ -30,10 +31,10 @@ public class ProfessionServiceImpl implements ProfessionService {
|
||||
|
||||
@Override
|
||||
public Profession updateProfession(Long id, Profession profession) throws NotFoundException {
|
||||
if(profession.getId() == null ){
|
||||
if (profession.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle profession ayant un id null.");
|
||||
}
|
||||
if(!professionRepository.existsById(profession.getId())){
|
||||
if (!professionRepository.existsById(profession.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la profession spécifiée dans notre base de données.");
|
||||
}
|
||||
return professionRepository.save(profession);
|
||||
@@ -42,9 +43,9 @@ public class ProfessionServiceImpl implements ProfessionService {
|
||||
@Override
|
||||
public void deleteProfession(Long id) throws NotFoundException {
|
||||
Optional<Profession> professionOptional = professionRepository.findById(id);
|
||||
if(professionOptional.isPresent()){
|
||||
if (professionOptional.isPresent()) {
|
||||
professionRepository.deleteById(professionOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la profession spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class ProfessionServiceImpl implements ProfessionService {
|
||||
|
||||
@Override
|
||||
public Optional<Profession> getProfessionById(Long id) {
|
||||
if(professionRepository.existsById(id)){
|
||||
if (professionRepository.existsById(id)) {
|
||||
return professionRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la profession spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class SituationGeographiqueServiceImpl implements SituationGeographiqueService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class SituationGeographiqueServiceImpl implements SituationGeographiqueSe
|
||||
|
||||
@Override
|
||||
public SituationGeographique createSituationGeographique(SituationGeographique situationGeographique) throws BadRequestException {
|
||||
if(situationGeographique.getId() != null ){
|
||||
if (situationGeographique.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle situation géographique ayant un id non null.");
|
||||
}
|
||||
return situationGeographiqueRepository.save(situationGeographique);
|
||||
@@ -30,10 +31,10 @@ public class SituationGeographiqueServiceImpl implements SituationGeographiqueSe
|
||||
|
||||
@Override
|
||||
public SituationGeographique updateSituationGeographique(Long id, SituationGeographique situationGeographique) throws NotFoundException {
|
||||
if(situationGeographique.getId() == null ){
|
||||
if (situationGeographique.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle situation géographique ayant un id null.");
|
||||
}
|
||||
if(!situationGeographiqueRepository.existsById(situationGeographique.getId())){
|
||||
if (!situationGeographiqueRepository.existsById(situationGeographique.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans notre base de données.");
|
||||
}
|
||||
return situationGeographiqueRepository.save(situationGeographique);
|
||||
@@ -42,9 +43,9 @@ public class SituationGeographiqueServiceImpl implements SituationGeographiqueSe
|
||||
@Override
|
||||
public void deleteSituationGeographique(Long id) throws NotFoundException {
|
||||
Optional<SituationGeographique> situationGeographiqueOptional = situationGeographiqueRepository.findById(id);
|
||||
if(situationGeographiqueOptional.isPresent()){
|
||||
if (situationGeographiqueOptional.isPresent()) {
|
||||
situationGeographiqueRepository.deleteById(situationGeographiqueOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class SituationGeographiqueServiceImpl implements SituationGeographiqueSe
|
||||
|
||||
@Override
|
||||
public Optional<SituationGeographique> getSituationGeographiqueById(Long id) {
|
||||
if(situationGeographiqueRepository.existsById(id)){
|
||||
if (situationGeographiqueRepository.existsById(id)) {
|
||||
return situationGeographiqueRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeSe
|
||||
|
||||
@Override
|
||||
public SituationMatrimoniale createSituationMatrimoniale(SituationMatrimoniale situationMatrimoniale) throws BadRequestException {
|
||||
if(situationMatrimoniale.getId() != null ){
|
||||
if (situationMatrimoniale.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle situation matrimoniale ayant un id non null.");
|
||||
}
|
||||
return situationMatrimonialeRepository.save(situationMatrimoniale);
|
||||
@@ -30,10 +31,10 @@ public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeSe
|
||||
|
||||
@Override
|
||||
public SituationMatrimoniale updateSituationMatrimoniale(Long id, SituationMatrimoniale situationMatrimoniale) throws NotFoundException {
|
||||
if(situationMatrimoniale.getId() == null ){
|
||||
if (situationMatrimoniale.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle situation matrimoniale ayant un id null.");
|
||||
}
|
||||
if(!situationMatrimonialeRepository.existsById(situationMatrimoniale.getId())){
|
||||
if (!situationMatrimonialeRepository.existsById(situationMatrimoniale.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans notre base de données.");
|
||||
}
|
||||
return situationMatrimonialeRepository.save(situationMatrimoniale);
|
||||
@@ -42,9 +43,9 @@ public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeSe
|
||||
@Override
|
||||
public void deleteSituationMatrimoniale(Long id) throws NotFoundException {
|
||||
Optional<SituationMatrimoniale> situationMatrimonialeOptional = situationMatrimonialeRepository.findById(id);
|
||||
if(situationMatrimonialeOptional.isPresent()){
|
||||
if (situationMatrimonialeOptional.isPresent()) {
|
||||
situationMatrimonialeRepository.deleteById(situationMatrimonialeOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeSe
|
||||
|
||||
@Override
|
||||
public Optional<SituationMatrimoniale> getSituationMatrimonialeById(Long id) {
|
||||
if(situationMatrimonialeRepository.existsById(id)){
|
||||
if (situationMatrimonialeRepository.existsById(id)) {
|
||||
return situationMatrimonialeRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class SourceDroitServiceImpl implements SourceDroitService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class SourceDroitServiceImpl implements SourceDroitService {
|
||||
|
||||
@Override
|
||||
public SourceDroit createSourceDroit(SourceDroit sourceDroit) throws BadRequestException {
|
||||
if(sourceDroit.getId() != null ){
|
||||
if (sourceDroit.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle source de droit ayant un id non null.");
|
||||
}
|
||||
return sourceDroitRepository.save(sourceDroit);
|
||||
@@ -30,10 +31,10 @@ public class SourceDroitServiceImpl implements SourceDroitService {
|
||||
|
||||
@Override
|
||||
public SourceDroit updateSourceDroit(Long id, SourceDroit sourceDroit) throws NotFoundException {
|
||||
if(sourceDroit.getId() == null ){
|
||||
if (sourceDroit.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une nouvelle source de droit ayant un id null.");
|
||||
}
|
||||
if(!sourceDroitRepository.existsById(sourceDroit.getId())){
|
||||
if (!sourceDroitRepository.existsById(sourceDroit.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans notre base de données.");
|
||||
}
|
||||
return sourceDroitRepository.save(sourceDroit);
|
||||
@@ -42,9 +43,9 @@ public class SourceDroitServiceImpl implements SourceDroitService {
|
||||
@Override
|
||||
public void deleteSourceDroit(Long id) throws NotFoundException {
|
||||
Optional<SourceDroit> sourceDroitOptional = sourceDroitRepository.findById(id);
|
||||
if(sourceDroitOptional.isPresent()){
|
||||
if (sourceDroitOptional.isPresent()) {
|
||||
sourceDroitRepository.deleteById(sourceDroitOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -62,9 +63,9 @@ public class SourceDroitServiceImpl implements SourceDroitService {
|
||||
|
||||
@Override
|
||||
public Optional<SourceDroit> getSourceDroitById(Long id) {
|
||||
if(sourceDroitRepository.existsById(id)){
|
||||
if (sourceDroitRepository.existsById(id)) {
|
||||
return sourceDroitRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class StructureServiceImpl implements StructureService {
|
||||
|
||||
@@ -23,12 +24,12 @@ public class StructureServiceImpl implements StructureService {
|
||||
|
||||
@Override
|
||||
public Structure createStructure(Structure structure) throws BadRequestException {
|
||||
if(structure.getId() != null ){
|
||||
if (structure.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une structure ayant un id non null.");
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("C");
|
||||
builder.append(structureRepository.getLastRecordId()+1);
|
||||
builder.append(structureRepository.getLastRecordId() + 1);
|
||||
structure.setCode(builder.toString());
|
||||
return structureRepository.save(structure);
|
||||
}
|
||||
@@ -38,10 +39,10 @@ public class StructureServiceImpl implements StructureService {
|
||||
|
||||
System.out.println("structure = " + structure);
|
||||
|
||||
if(structure.getId() == null ){
|
||||
if (structure.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour une structure ayant un id null.");
|
||||
}
|
||||
if(!structureRepository.existsById(structure.getId())){
|
||||
if (!structureRepository.existsById(structure.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données.");
|
||||
}
|
||||
structureRepository.save(structure);
|
||||
@@ -54,9 +55,9 @@ public class StructureServiceImpl implements StructureService {
|
||||
@Override
|
||||
public void deleteStructure(Long id) throws NotFoundException {
|
||||
Optional<Structure> structureOptional = structureRepository.findById(id);
|
||||
if(structureOptional.isPresent()){
|
||||
if (structureOptional.isPresent()) {
|
||||
structureRepository.deleteById(structureOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -78,9 +79,9 @@ public class StructureServiceImpl implements StructureService {
|
||||
|
||||
@Override
|
||||
public Optional<Structure> getStructureById(Long id) {
|
||||
if(structureRepository.existsById(id)){
|
||||
if (structureRepository.existsById(id)) {
|
||||
return structureRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver la structure spécifiée dans la base de données.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class TypeContestationServiceImpl implements TypeContestationService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class TypeContestationServiceImpl implements TypeContestationService {
|
||||
|
||||
@Override
|
||||
public TypeContestation createTypeContestation(TypeContestation typeContestation) throws BadRequestException {
|
||||
if(typeContestation.getId() != null ){
|
||||
if (typeContestation.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau type de contestation ayant un id non null.");
|
||||
}
|
||||
return typeContestationRepository.save(typeContestation);
|
||||
@@ -30,10 +31,10 @@ public class TypeContestationServiceImpl implements TypeContestationService {
|
||||
|
||||
@Override
|
||||
public TypeContestation updateTypeContestation(Long id, TypeContestation typeContestation) throws NotFoundException {
|
||||
if(typeContestation.getId() == null ){
|
||||
if (typeContestation.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau type de contestation ayant un id null.");
|
||||
}
|
||||
if(!typeContestationRepository.existsById(typeContestation.getId())){
|
||||
if (!typeContestationRepository.existsById(typeContestation.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans notre base de données.");
|
||||
}
|
||||
return typeContestationRepository.save(typeContestation);
|
||||
@@ -42,9 +43,9 @@ public class TypeContestationServiceImpl implements TypeContestationService {
|
||||
@Override
|
||||
public void deleteTypeContestation(Long id) throws NotFoundException {
|
||||
Optional<TypeContestation> typeContestationOptional = typeContestationRepository.findById(id);
|
||||
if(typeContestationOptional.isPresent()){
|
||||
if (typeContestationOptional.isPresent()) {
|
||||
typeContestationRepository.deleteById(typeContestationOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class TypeContestationServiceImpl implements TypeContestationService {
|
||||
|
||||
@Override
|
||||
public Optional<TypeContestation> getTypeContestationById(Long id) {
|
||||
if(typeContestationRepository.existsById(id)){
|
||||
if (typeContestationRepository.existsById(id)) {
|
||||
return typeContestationRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class TypeDomaineServiceImpl implements TypeDomaineService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class TypeDomaineServiceImpl implements TypeDomaineService {
|
||||
|
||||
@Override
|
||||
public TypeDomaine createTypeDomaine(TypeDomaine typeDomaine) throws BadRequestException {
|
||||
if(typeDomaine.getId() != null ){
|
||||
if (typeDomaine.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau type de domaine ayant un id non null.");
|
||||
}
|
||||
return typeDomaineRepository.save(typeDomaine);
|
||||
@@ -30,10 +31,10 @@ public class TypeDomaineServiceImpl implements TypeDomaineService {
|
||||
|
||||
@Override
|
||||
public TypeDomaine updateTypeDomaine(Long id, TypeDomaine typeDomaine) throws NotFoundException {
|
||||
if(typeDomaine.getId() == null ){
|
||||
if (typeDomaine.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau type de domaine ayant un id null.");
|
||||
}
|
||||
if(!typeDomaineRepository.existsById(typeDomaine.getId())){
|
||||
if (!typeDomaineRepository.existsById(typeDomaine.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans notre base de données.");
|
||||
}
|
||||
return typeDomaineRepository.save(typeDomaine);
|
||||
@@ -42,9 +43,9 @@ public class TypeDomaineServiceImpl implements TypeDomaineService {
|
||||
@Override
|
||||
public void deleteTypeDomaine(Long id) throws NotFoundException {
|
||||
Optional<TypeDomaine> typeDomaineOptional = typeDomaineRepository.findById(id);
|
||||
if(typeDomaineOptional.isPresent()){
|
||||
if (typeDomaineOptional.isPresent()) {
|
||||
typeDomaineRepository.deleteById(typeDomaineOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class TypeDomaineServiceImpl implements TypeDomaineService {
|
||||
|
||||
@Override
|
||||
public Optional<TypeDomaine> getTypeDomaineById(Long id) {
|
||||
if(typeDomaineRepository.existsById(id)){
|
||||
if (typeDomaineRepository.existsById(id)) {
|
||||
return typeDomaineRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class TypePersonneServiceImpl implements TypePersonneService {
|
||||
|
||||
@@ -22,7 +23,7 @@ public class TypePersonneServiceImpl implements TypePersonneService {
|
||||
|
||||
@Override
|
||||
public TypePersonne createTypePersonne(TypePersonne typePersonne) throws BadRequestException {
|
||||
if(typePersonne.getId() != null ){
|
||||
if (typePersonne.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau type de personne ayant un id non null.");
|
||||
}
|
||||
return typePersonneRepository.save(typePersonne);
|
||||
@@ -30,10 +31,10 @@ public class TypePersonneServiceImpl implements TypePersonneService {
|
||||
|
||||
@Override
|
||||
public TypePersonne updateTypePersonne(Long id, TypePersonne typePersonne) throws NotFoundException {
|
||||
if(typePersonne.getId() == null ){
|
||||
if (typePersonne.getId() == null) {
|
||||
throw new BadRequestException("Impossible de mettre à jour un nouveau type de personne ayant un id null.");
|
||||
}
|
||||
if(!typePersonneRepository.existsById(typePersonne.getId())){
|
||||
if (!typePersonneRepository.existsById(typePersonne.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le type de personne spécifié dans notre base de données.");
|
||||
}
|
||||
return typePersonneRepository.save(typePersonne);
|
||||
@@ -42,9 +43,9 @@ public class TypePersonneServiceImpl implements TypePersonneService {
|
||||
@Override
|
||||
public void deleteTypePersonne(Long id) throws NotFoundException {
|
||||
Optional<TypePersonne> typePersonneOptional = typePersonneRepository.findById(id);
|
||||
if(typePersonneOptional.isPresent()){
|
||||
if (typePersonneOptional.isPresent()) {
|
||||
typePersonneRepository.deleteById(typePersonneOptional.get().getId());
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le type de personne spécifié dans notre base de données.");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +62,9 @@ public class TypePersonneServiceImpl implements TypePersonneService {
|
||||
|
||||
@Override
|
||||
public Optional<TypePersonne> getTypePersonneById(Long id) {
|
||||
if(typePersonneRepository.existsById(id)){
|
||||
if (typePersonneRepository.existsById(id)) {
|
||||
return typePersonneRepository.findById(id);
|
||||
}else{
|
||||
} else {
|
||||
throw new NotFoundException("Impossible de trouver le type de personne spécifié dans la base de données.");
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user