generated from bcgov/quickstart-openshift
-
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.
* feat: reviewing changes from pull request 22 * feat: mapped only existing props from jwt decoded token * feat: remove autoimport maven files * ci: autogenerated JaCoCo coverage badge * feat: fix review comments * feat: validations, activity enum serialization, logs * fix: test passing now * ci: autogenerated JaCoCo coverage badge * feat: remove props from activity enum * ci: autogenerated JaCoCo coverage badge * test: improve and clean test cases * ci: autogenerated JaCoCo coverage badge --------- Co-authored-by: Ci Bot <cibot@users.noreply.github.com>
- Loading branch information
1 parent
e5fe55e
commit 9da8c8a
Showing
42 changed files
with
1,244 additions
and
1,386 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -107,7 +107,7 @@ local.properties | |
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
*.iml | ||
# *.ipr | ||
|
||
# CMake | ||
|
12 changes: 0 additions & 12 deletions
12
backend/src/main/java/ca/bc/gov/backendstartapi/dto/FavoriteActivityCreateDto.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
backend/src/main/java/ca/bc/gov/backendstartapi/dto/FavoriteActivityUpdateDto.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/ca/bc/gov/backendstartapi/dto/FavouriteActivityCreateDto.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,12 @@ | ||
package ca.bc.gov.backendstartapi.dto; | ||
|
||
import ca.bc.gov.backendstartapi.entity.FavouriteActivityEntity; | ||
import ca.bc.gov.backendstartapi.enums.ActivityEnum; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* This record represents a dto when creating a {@link FavouriteActivityEntity}. | ||
* | ||
* @param activity The activity from {@link ca.bc.gov.backendstartapi.enums.ActivityEnum} | ||
*/ | ||
public record FavouriteActivityCreateDto(@NotNull ActivityEnum activity) {} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/ca/bc/gov/backendstartapi/dto/FavouriteActivityUpdateDto.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,12 @@ | ||
package ca.bc.gov.backendstartapi.dto; | ||
|
||
import ca.bc.gov.backendstartapi.entity.FavouriteActivityEntity; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
/** | ||
* This record represents a dto when updating a {@link FavouriteActivityEntity}. | ||
* | ||
* @param highlighted A boolean representing if the activity is highlighted | ||
* @param enabled a boolean representing if the activity is enabled | ||
*/ | ||
public record FavouriteActivityUpdateDto(@NotNull Boolean highlighted, @NotNull Boolean enabled) {} |
90 changes: 0 additions & 90 deletions
90
backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/FavoriteActivityEndpoint.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/FavouriteActivityEndpoint.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,85 @@ | ||
package ca.bc.gov.backendstartapi.endpoint; | ||
|
||
import ca.bc.gov.backendstartapi.dto.FavouriteActivityCreateDto; | ||
import ca.bc.gov.backendstartapi.dto.FavouriteActivityUpdateDto; | ||
import ca.bc.gov.backendstartapi.entity.FavouriteActivityEntity; | ||
import ca.bc.gov.backendstartapi.service.FavouriteActivityService; | ||
import jakarta.validation.Valid; | ||
import java.util.List; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** This class contains all {@link FavouriteActivityEntity} resources that a user needs. */ | ||
@Setter | ||
@NoArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/favourite-activities") | ||
public class FavouriteActivityEndpoint { | ||
|
||
private FavouriteActivityService favouriteActivityService; | ||
|
||
@Autowired | ||
FavouriteActivityEndpoint(FavouriteActivityService favouriteActivityService) { | ||
this.favouriteActivityService = favouriteActivityService; | ||
} | ||
|
||
/** | ||
* Creates to the logged user a {@link FavouriteActivityEntity} based on the activity title, that | ||
* comes from {@link ca.bc.gov.backendstartapi.enums.ActivityEnum}. | ||
* | ||
* @param createDto a {@link FavouriteActivityCreateDto} with the activity title | ||
* @return a {@link FavouriteActivityEntity} created | ||
*/ | ||
@PostMapping(consumes = "application/json", produces = "application/json") | ||
@PreAuthorize("hasRole('user_write')") | ||
public FavouriteActivityEntity createUserActivity( | ||
@Valid @RequestBody FavouriteActivityCreateDto createDto) { | ||
return favouriteActivityService.createUserActivity(createDto); | ||
} | ||
|
||
/** | ||
* Retrieve all {@link FavouriteActivityEntity} bound to the user that made the request. | ||
* | ||
* @return a list of {@link FavouriteActivityEntity} | ||
*/ | ||
@GetMapping(produces = "application/json") | ||
@PreAuthorize("hasRole('user_read')") | ||
public List<FavouriteActivityEntity> getUserActivities() { | ||
return favouriteActivityService.getAllUserFavoriteActivities(); | ||
} | ||
|
||
/** | ||
* Update a {@link FavouriteActivityEntity} of the logged user. | ||
* | ||
* @param id The id of the {@link FavouriteActivityEntity} | ||
* @param updateDto a {@link FavouriteActivityUpdateDto} containing highlighted and enabled states | ||
* @return the {@link FavouriteActivityEntity} updated | ||
*/ | ||
@PutMapping(value = "/{id}", consumes = "application/json", produces = "application/json") | ||
@PreAuthorize("hasRole('user_write')") | ||
public FavouriteActivityEntity updateFavoriteActivity( | ||
@PathVariable Long id, @Valid @RequestBody FavouriteActivityUpdateDto updateDto) { | ||
return favouriteActivityService.updateUserActivity(id, updateDto); | ||
} | ||
|
||
/** | ||
* Delete a user's {@link FavouriteActivityEntity}. | ||
* | ||
* @param id The id of the {@link FavouriteActivityEntity} | ||
*/ | ||
@DeleteMapping(value = "/{id}", produces = "application/json") | ||
@PreAuthorize("hasRole('user_write')") | ||
public void deleteFavoriteActivity(@PathVariable Long id) { | ||
favouriteActivityService.deleteUserActivity(id); | ||
} | ||
} |
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
37 changes: 0 additions & 37 deletions
37
backend/src/main/java/ca/bc/gov/backendstartapi/entity/UserEntity.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/ca/bc/gov/backendstartapi/entity/UserProfileEntity.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,27 @@ | ||
package ca.bc.gov.backendstartapi.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
/** This class represents a system User in the database. */ | ||
@Entity | ||
@Getter | ||
@Setter | ||
@Table(name = "user_profile") | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class UserProfileEntity { | ||
|
||
@Id | ||
@Column(name = "user_id") | ||
private String userId; | ||
|
||
@Column(name = "dark_theme") | ||
private Boolean darkTheme; | ||
} |
Oops, something went wrong.