-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into asvs-new-feats
- Loading branch information
Showing
45 changed files
with
1,861 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
name: release-please | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v4 | ||
with: | ||
# You will want to configure a GitHub Actions secret with a | ||
# Personal Access Token if you want GitHub Actions CI | ||
# checks to run on Release Please PRs. | ||
# The folowing assumes that you have created a personal access token | ||
# (PAT) and configured it as a GitHub action secret named | ||
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important). | ||
#token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }} | ||
|
||
# if you dont need to trigger new workflow runs on a release please PR | ||
# its fine to use GITHUB_TOKEN as folows | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# this is a built-in strategy in release-please, see "Action Inputs" | ||
# for more options | ||
release-type: simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Changelog | ||
|
||
## 1.0.0 (2024-05-14) | ||
|
||
|
||
### ⚠ BREAKING CHANGES | ||
|
||
* fix pipeline | ||
|
||
### Features | ||
|
||
* base authentication definition ([7de00d0](https://github.com/MiguelFerreira18/desofs2024_m1b_2/commit/7de00d0c295a58fad13d704c929a25357a26ccc4)) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* fix pipeline ([1b3c5aa](https://github.com/MiguelFerreira18/desofs2024_m1b_2/commit/1b3c5aabe1dffac4411194d242e664bc0eb92c5b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
desofsApi/src/main/java/isep/ipp/pt/api/desofs/Controllers/ReceitaController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package isep.ipp.pt.api.desofs.Controllers; | ||
|
||
import isep.ipp.pt.api.desofs.Dto.ReceitaDTO.ControllerLayer.ReceitaDTOPatchRequest; | ||
import isep.ipp.pt.api.desofs.Dto.ReceitaDTO.ControllerLayer.ReceitaDTOResponse; | ||
import isep.ipp.pt.api.desofs.Dto.ReceitaDTO.ControllerLayer.ReceitaDTOSaveRequest; | ||
import isep.ipp.pt.api.desofs.Dto.ReceitaDTO.ServiceLayer.ReceitaDTOServicePatchRequest; | ||
import isep.ipp.pt.api.desofs.Dto.ReceitaDTO.ServiceLayer.ReceitaDTOServiceRequest; | ||
import isep.ipp.pt.api.desofs.Dto.ReceitaDTO.ServiceLayer.ReceitaDTOServiceResponse; | ||
import isep.ipp.pt.api.desofs.Mapper.ReceitaMapper.ReceitaMapper; | ||
import isep.ipp.pt.api.desofs.Service.ReceitaService.ReceitaService; | ||
import isep.ipp.pt.api.desofs.Utils.PersonalValidation; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@Controller | ||
@RequestMapping("/receita") | ||
public class ReceitaController { | ||
@Autowired | ||
private ReceitaService receitaService; | ||
@Autowired | ||
private ReceitaMapper receitaMapper; | ||
@Autowired | ||
private PersonalValidation validation; | ||
|
||
|
||
@PostMapping("/save") | ||
public ResponseEntity<ReceitaDTOResponse> saveReceita(@RequestBody ReceitaDTOSaveRequest receita) { | ||
if (!validation.validate(receita)) { | ||
return ResponseEntity.badRequest().build(); | ||
} | ||
|
||
try { | ||
ReceitaDTOServiceRequest receitaRequestService = receitaMapper.toReceitaDtoServiceRequestFromReceitaDtoSaveRequest(receita); | ||
if (!validation.validate(receitaRequestService)) { | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
ReceitaDTOServiceResponse receitaServiceResponse = receitaService.save(receitaRequestService); | ||
return ResponseEntity.ok( receitaMapper.fromReceitaToDto(receitaServiceResponse)); | ||
|
||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
|
||
@GetMapping("/get/{receitaId}") | ||
public ResponseEntity<ReceitaDTOResponse> getReceita(@PathVariable Long receitaId) { | ||
if (receitaId < 0) return ResponseEntity.badRequest().build(); | ||
try { | ||
|
||
ReceitaDTOServiceResponse receitaServiceResponse = receitaService.findbyId(receitaId); | ||
return ResponseEntity.ok( receitaMapper.fromReceitaToDto(receitaServiceResponse)); | ||
|
||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
|
||
@PatchMapping("/update") | ||
public ResponseEntity<ReceitaDTOResponse> updateReceita(@RequestBody ReceitaDTOPatchRequest receita) { | ||
if (!validation.validate(receita)) { | ||
return ResponseEntity.badRequest().build(); | ||
} | ||
try { | ||
ReceitaDTOServicePatchRequest receitaRequestService = receitaMapper.toReceitaDTOServicePAtchRequestFromReceitaDTOPatchRequest(receita); | ||
if (!validation.validate(receitaRequestService)) { | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
ReceitaDTOServiceResponse receitaServiceResponse = receitaService.update(receitaRequestService); | ||
return ResponseEntity.ok( receitaMapper.fromReceitaToDto(receitaServiceResponse)); | ||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
|
||
@DeleteMapping("/delete/{receitaId}") | ||
public ResponseEntity deleteReceita(@PathVariable Long receitaId) { | ||
if (receitaId < 0) return ResponseEntity.badRequest().build(); | ||
receitaService.deleteById(receitaId); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@GetMapping("/all") | ||
public ResponseEntity<List<ReceitaDTOResponse>> getAllReceitas() { | ||
try { | ||
List<ReceitaDTOResponse> receitas = receitaMapper.fromReceitaDtoServiceResponseListToReceitaDToResponseList(receitaService.findAll()); | ||
return ResponseEntity.ok(receitas); | ||
} catch (Exception e) { | ||
System.out.println(e.getMessage()); | ||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
} |
Oops, something went wrong.