From 789be4f72c8ea58c2698eae2b540ed908670fc77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Thu, 16 May 2024 23:06:24 +0100 Subject: [PATCH 1/7] fix: Fix security config --- .../ControllerLayer/ReceitaDTOResponse.java | 20 +++++++++++++++++++ .../ReceitaDTOServiceResponse.java | 20 +++++++++++++++++++ .../ipp/pt/api/desofs/SecurityConfig.java | 1 + 3 files changed, 41 insertions(+) diff --git a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ControllerLayer/ReceitaDTOResponse.java b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ControllerLayer/ReceitaDTOResponse.java index 1c53c950..90e1d52c 100644 --- a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ControllerLayer/ReceitaDTOResponse.java +++ b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ControllerLayer/ReceitaDTOResponse.java @@ -61,4 +61,24 @@ public Pacote getPacote() { public TipoReceita getTipoReceita() { return tipoReceita; } + + public void setReceitaId(Long receitaId) { + this.receitaId = receitaId; + } + + public void setPath(String path) { + this.path = path; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public void setPacote(Pacote pacote) { + this.pacote = pacote; + } + + public void setTipoReceita(TipoReceita tipoReceita) { + this.tipoReceita = tipoReceita; + } } diff --git a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServiceResponse.java b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServiceResponse.java index a3d35f81..ebb184a3 100644 --- a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServiceResponse.java +++ b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServiceResponse.java @@ -61,4 +61,24 @@ public Pacote getPacote() { public TipoReceita getTipoReceita() { return tipoReceita; } + + public void setReceitaId(Long receitaId) { + this.receitaId = receitaId; + } + + public void setPath(String path) { + this.path = path; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public void setPacote(Pacote pacote) { + this.pacote = pacote; + } + + public void setTipoReceita(TipoReceita tipoReceita) { + this.tipoReceita = tipoReceita; + } } diff --git a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/SecurityConfig.java b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/SecurityConfig.java index 5e041b8c..4a7a18fb 100644 --- a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/SecurityConfig.java +++ b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/SecurityConfig.java @@ -114,6 +114,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .requestMatchers("/user/info/**").authenticated() .requestMatchers("/encomenda/**").authenticated() .requestMatchers("/tipoReceita/**").authenticated() + .requestMatchers("/receita/**").authenticated() .requestMatchers("/api-docs/**").permitAll() .requestMatchers("/swagger-ui/**").permitAll() From a540435d56ec04e07cb7a515a1301cbeceebec84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Fri, 17 May 2024 03:59:25 +0100 Subject: [PATCH 2/7] fix: Fix tipoReceita endpoint --- .../ControllerLayer/TipoReceitaDTOResponse.java | 7 +++++++ .../ServiceLayer/TipoReceitaDTOServiceResponse.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ControllerLayer/TipoReceitaDTOResponse.java b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ControllerLayer/TipoReceitaDTOResponse.java index 8a9a4399..624e5c7e 100644 --- a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ControllerLayer/TipoReceitaDTOResponse.java +++ b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ControllerLayer/TipoReceitaDTOResponse.java @@ -37,4 +37,11 @@ public String getNome() { return nome; } + public void setTipoReceitaId(Long tipoReceitaId) { + this.tipoReceitaId = tipoReceitaId; + } + + public void setNome(String nome) { + this.nome = nome; + } } diff --git a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ServiceLayer/TipoReceitaDTOServiceResponse.java b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ServiceLayer/TipoReceitaDTOServiceResponse.java index 8ad76096..3a21bba2 100644 --- a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ServiceLayer/TipoReceitaDTOServiceResponse.java +++ b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/TipoReceitaDTO/ServiceLayer/TipoReceitaDTOServiceResponse.java @@ -40,4 +40,8 @@ public String getNome() { public void setNome(String nome) { this.nome = nome; } + + public void setTipoReceitaId(Long tipoReceitaId) { + this.tipoReceitaId = tipoReceitaId; + } } From 1fed4594f6373a921fb0c49d5e3069a1e3744f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Fri, 17 May 2024 05:22:18 +0100 Subject: [PATCH 3/7] fix: Fix tipoReceita endpoint --- .../ReceitaDTOServicePatchRequest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServicePatchRequest.java b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServicePatchRequest.java index 39ce27bf..b2533f80 100644 --- a/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServicePatchRequest.java +++ b/desofsApi/src/main/java/isep/ipp/pt/api/desofs/Dto/ReceitaDTO/ServiceLayer/ReceitaDTOServicePatchRequest.java @@ -64,5 +64,23 @@ public Long getTipoReceita() { return tipoReceita; } + public void setReceitaId(Long receitaId) { + this.receitaId = receitaId; + } + public void setPath(String path) { + this.path = path; + } + + public void setNome(String nome) { + this.nome = nome; + } + + public void setPacote(Long pacote) { + this.pacote = pacote; + } + + public void setTipoReceita(Long tipoReceita) { + this.tipoReceita = tipoReceita; + } } From 7ef01b5970853786c13502368c4f75b031bb3a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Fri, 17 May 2024 05:23:30 +0100 Subject: [PATCH 4/7] feat : Add Receita functionalities --- .../src/lib/Types/types.ts | 36 +++++- .../default_components/Header/Header.svelte | 6 + .../src/routes/recipe/+page.server.ts | 15 +++ .../src/routes/recipe/+page.svelte | 73 ++++++++++++ .../recipe/create-recipe/+page.server.ts | 13 +++ .../routes/recipe/create-recipe/+page.svelte | 105 ++++++++++++++++++ .../edit-recipe/[recipeId]/+page.server.ts | 24 ++++ .../edit-recipe/[recipeId]/+page.svelte | 105 ++++++++++++++++++ 8 files changed, 376 insertions(+), 1 deletion(-) create mode 100644 desofs_svelte_front_end/src/routes/recipe/+page.server.ts create mode 100644 desofs_svelte_front_end/src/routes/recipe/+page.svelte create mode 100644 desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts create mode 100644 desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte create mode 100644 desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts create mode 100644 desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte diff --git a/desofs_svelte_front_end/src/lib/Types/types.ts b/desofs_svelte_front_end/src/lib/Types/types.ts index 37c7b259..a0eebe44 100644 --- a/desofs_svelte_front_end/src/lib/Types/types.ts +++ b/desofs_svelte_front_end/src/lib/Types/types.ts @@ -1,4 +1,5 @@ import { EstadoEncomenda } from '$lib/Enum/enums'; +import type { R } from 'vitest/dist/reporters-yx5ZTtEV.js'; // Type type Package = { @@ -101,6 +102,35 @@ type Delivery = { user: User; }; +//Recipes +type RecipeDTOSend = { + path: string; + nome: string; + pacote: number; + tipoReceita: number; +}; + +type RecipePatchSend = { + receitaId: number; + path: string; + nome: string; + pacote: number; + tipoReceita: number; +}; + +type Recipe = { + receitaId: number; + path: string; + nome: string; + pacote: Package; + tipoReceita: RecipeType; +}; + +type RecipeType = { + tipoReceitaId: number; + nome: string; +}; + enum StateDelivery { REGISTADO, ENTREGUE, @@ -121,5 +151,9 @@ export type { DeliveryDTOSend, Delivery, DeliveryDTOPatch, - StateDelivery + StateDelivery, + RecipeDTOSend, + RecipePatchSend, + RecipeType, + Recipe }; diff --git a/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte b/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte index a746d90d..2ff27c0e 100644 --- a/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte +++ b/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte @@ -26,6 +26,12 @@ text="Gestão de pacotes" gotoName="/package-management" /> + + + + + + + + + + + + + + + + {#each data.recipes as item} + + + + + + + + {/each} + +
PackageRecipe TypePathNameActions
{item.pacote.pacoteId}{item.tipoReceita.tipoReceitaId}{item.path}{item.nome} + + +
+ + diff --git a/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts new file mode 100644 index 00000000..e316b513 --- /dev/null +++ b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts @@ -0,0 +1,13 @@ +import type { PageServerLoad } from './$types'; +import type { Package,RecipeType } from '$lib/Types/types'; +import { sendRequest } from '$lib/scripts'; + +export const load: PageServerLoad = async ({locals}) => { + const responsePacotes = await sendRequest('pacote/all', 'GET', '', ''); + const pacotes: Package[] = await responsePacotes.json(); + + const responseTipoReceitas = await sendRequest('tipoReceita/list', 'GET', '', locals.user.token); + const tipoReceitas: RecipeType[] = await responseTipoReceitas.json(); + + return { pacotes, tipoReceitas }; +}; diff --git a/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte new file mode 100644 index 00000000..b0cabf9c --- /dev/null +++ b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte @@ -0,0 +1,105 @@ + + +
+

Create Recipe

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
diff --git a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts new file mode 100644 index 00000000..9e140e01 --- /dev/null +++ b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts @@ -0,0 +1,24 @@ +import type { PageServerLoad } from './$types'; +import type { Package, Recipe,RecipeType } from '$lib/Types/types'; +import { sendRequest } from '$lib/scripts'; + +export const load: PageServerLoad = async ({ params, locals }) => { + const recipeIdId = params.recipeId; + + const responsePacotes = await sendRequest('pacote/all', 'GET', '', ''); + const pacotes: Package[] = await responsePacotes.json(); + + const responseTipoReceitas = await sendRequest('tipoReceita/list', 'GET', '', locals.user.token); + const tipoReceitas: RecipeType[] = await responseTipoReceitas.json(); + + const responseEncomenda = await sendRequest( + `receita/get/${recipeIdId}`, + 'GET', + '', + locals.user.token + ); + const recipe: Recipe = await responseEncomenda.json(); + + console.log(pacotes, tipoReceitas, recipe); + return { pacotes, recipe, tipoReceitas }; +}; diff --git a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte new file mode 100644 index 00000000..8d1ae3bc --- /dev/null +++ b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte @@ -0,0 +1,105 @@ + + +
+

Edit Recipe

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
From 824bc9786495d6b21fdaf7185b77f96ec41f101e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Fri, 17 May 2024 05:25:16 +0100 Subject: [PATCH 5/7] fix: fix console.log --- .../src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts index 9e140e01..954aa6fd 100644 --- a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts +++ b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts @@ -19,6 +19,5 @@ export const load: PageServerLoad = async ({ params, locals }) => { ); const recipe: Recipe = await responseEncomenda.json(); - console.log(pacotes, tipoReceitas, recipe); return { pacotes, recipe, tipoReceitas }; }; From 7088732d106ad68e3e24c69358aff5e0b8b27dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Fri, 17 May 2024 05:28:29 +0100 Subject: [PATCH 6/7] style: chang style --- .../default_components/Header/Header.svelte | 6 +----- .../src/routes/recipe/+page.server.ts | 11 +++------- .../src/routes/recipe/+page.svelte | 10 ++-------- .../recipe/create-recipe/+page.server.ts | 12 +++++------ .../routes/recipe/create-recipe/+page.svelte | 14 ++++++------- .../edit-recipe/[recipeId]/+page.server.ts | 8 ++++---- .../edit-recipe/[recipeId]/+page.svelte | 20 +++++++++---------- 7 files changed, 33 insertions(+), 48 deletions(-) diff --git a/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte b/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte index 2ff27c0e..4f0c67f9 100644 --- a/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte +++ b/desofs_svelte_front_end/src/lib/components/default_components/Header/Header.svelte @@ -27,11 +27,7 @@ gotoName="/package-management" /> - goto('/recipe/create-recipe')}> diff --git a/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts index e316b513..51b314d0 100644 --- a/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts +++ b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.server.ts @@ -1,13 +1,13 @@ import type { PageServerLoad } from './$types'; -import type { Package,RecipeType } from '$lib/Types/types'; +import type { Package, RecipeType } from '$lib/Types/types'; import { sendRequest } from '$lib/scripts'; -export const load: PageServerLoad = async ({locals}) => { +export const load: PageServerLoad = async ({ locals }) => { const responsePacotes = await sendRequest('pacote/all', 'GET', '', ''); const pacotes: Package[] = await responsePacotes.json(); - - const responseTipoReceitas = await sendRequest('tipoReceita/list', 'GET', '', locals.user.token); - const tipoReceitas: RecipeType[] = await responseTipoReceitas.json(); - + + const responseTipoReceitas = await sendRequest('tipoReceita/list', 'GET', '', locals.user.token); + const tipoReceitas: RecipeType[] = await responseTipoReceitas.json(); + return { pacotes, tipoReceitas }; }; diff --git a/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte index b0cabf9c..f33704a1 100644 --- a/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte +++ b/desofs_svelte_front_end/src/routes/recipe/create-recipe/+page.svelte @@ -7,16 +7,16 @@ export let data: PageData; let packageId = 0; - let path = ""; - let name = ""; + let path = ''; + let name = ''; let recipeTypeId = 0; async function handleSubmit() { const recipe: RecipeDTOSend = { path: path, - nome: name, - tipoReceita: recipeTypeId, - pacote: packageId + nome: name, + tipoReceita: recipeTypeId, + pacote: packageId }; const response = await sendRequest( @@ -70,10 +70,10 @@ id="tipoReceita" class="rounded border border-current p-2 bg-white min-w-80" > - {#each data.tipoReceitas as type} + {#each data.tipoReceitas as type} {/each} - +
diff --git a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts index 954aa6fd..ad100950 100644 --- a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts +++ b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.server.ts @@ -1,5 +1,5 @@ import type { PageServerLoad } from './$types'; -import type { Package, Recipe,RecipeType } from '$lib/Types/types'; +import type { Package, Recipe, RecipeType } from '$lib/Types/types'; import { sendRequest } from '$lib/scripts'; export const load: PageServerLoad = async ({ params, locals }) => { @@ -7,9 +7,9 @@ export const load: PageServerLoad = async ({ params, locals }) => { const responsePacotes = await sendRequest('pacote/all', 'GET', '', ''); const pacotes: Package[] = await responsePacotes.json(); - - const responseTipoReceitas = await sendRequest('tipoReceita/list', 'GET', '', locals.user.token); - const tipoReceitas: RecipeType[] = await responseTipoReceitas.json(); + + const responseTipoReceitas = await sendRequest('tipoReceita/list', 'GET', '', locals.user.token); + const tipoReceitas: RecipeType[] = await responseTipoReceitas.json(); const responseEncomenda = await sendRequest( `receita/get/${recipeIdId}`, diff --git a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte index 8d1ae3bc..24da8ff4 100644 --- a/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte +++ b/desofs_svelte_front_end/src/routes/recipe/edit-recipe/[recipeId]/+page.svelte @@ -14,9 +14,9 @@ const encData: RecipePatchSend = { receitaId: data.recipe.receitaId, nome: name, - path: path, - pacote: pacoteId, - tipoReceita: recipeTypeId + path: path, + pacote: pacoteId, + tipoReceita: recipeTypeId }; const response = await sendRequest( @@ -45,11 +45,11 @@
@@ -70,10 +70,10 @@ id="tipoReceita" class="rounded border border-current p-2 bg-white min-w-80" > - {#each data.tipoReceitas as type} + {#each data.tipoReceitas as type} {/each} - +
From 86a7a4b7ce939eea7250e80002737dfef0a4412f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mendes?= Date: Fri, 17 May 2024 05:32:27 +0100 Subject: [PATCH 7/7] fix: fix unused import --- desofs_svelte_front_end/src/lib/Types/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/desofs_svelte_front_end/src/lib/Types/types.ts b/desofs_svelte_front_end/src/lib/Types/types.ts index a0eebe44..38b1ab00 100644 --- a/desofs_svelte_front_end/src/lib/Types/types.ts +++ b/desofs_svelte_front_end/src/lib/Types/types.ts @@ -1,5 +1,4 @@ import { EstadoEncomenda } from '$lib/Enum/enums'; -import type { R } from 'vitest/dist/reporters-yx5ZTtEV.js'; // Type type Package = {