Skip to content

Commit

Permalink
fixed the orgUnit for the multiSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzgrewal committed Nov 7, 2024
1 parent 30c836e commit 4905fec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public OpeningSearchFiltersDto(
// Create a constructor with only the List<String> openingIds
public OpeningSearchFiltersDto(
List<String> openingIds) {
this.orgUnit = null;
this.category = null;
this.orgUnit = new ArrayList<>();
this.category = new ArrayList<>();
this.statusList = new ArrayList<>();
this.openingIds = openingIds;
this.myOpenings = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,50 @@

import ca.bc.gov.restapi.results.common.pagination.PaginatedResult;
import ca.bc.gov.restapi.results.oracle.dto.OpeningSearchResponseDto;
import ca.bc.gov.restapi.results.postgres.dto.UserRecentOpeningDto;
import ca.bc.gov.restapi.results.postgres.service.UserRecentOpeningService;
import lombok.RequiredArgsConstructor;

import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/openings/recent")
public class UserRecentOpeningEndpoint {

private final UserRecentOpeningService userRecentOpeningService;
private final UserRecentOpeningService userRecentOpeningService;

/**
* Retrieves a list of recent openings viewed by the user, limited by the number of results.
*
* @param limit The maximum number of results to return.
* @return A list of opening IDs viewed by the user.
*/
@GetMapping
public ResponseEntity<PaginatedResult<OpeningSearchResponseDto>> getUserRecentOpenings(
@RequestParam(defaultValue = "10") int limit) {
// Fetch recent openings for the logged-in user with the specified limit
return ResponseEntity.ok(userRecentOpeningService.getAllRecentOpeningsForUser(limit));
}

/**
* Records the opening viewed by the user based on the provided opening ID.
*
* @param openingId The ID of the opening viewed by the user.
* @return A simple confirmation message or the HTTP code 204-No Content.
*/
@PostMapping("api/users/recent/{openingId}")
public ResponseEntity<UserRecentOpeningDto> recordUserViewedOpening(@PathVariable String openingId) {
// Store the opening and return the DTO
UserRecentOpeningDto recentOpeningDto = userRecentOpeningService.storeViewedOpening(openingId);
return ResponseEntity.ok(recentOpeningDto);
}
/**
* Records the opening viewed by the user based on the provided opening ID.
*
* @param openingId The ID of the opening viewed by the user.
* @return A simple confirmation message or the HTTP code 204-No Content.
*/
@PutMapping("/{openingId}")
@ResponseStatus(HttpStatus.ACCEPTED)
public void recordUserViewedOpening(
@PathVariable String openingId) {
// Store the opening and return the DTO
userRecentOpeningService.storeViewedOpening(openingId);
}

/**
* Retrieves a list of recent openings viewed by the user, limited by the number of results.
*
* @param limit The maximum number of results to return.
* @return A list of opening IDs viewed by the user.
*/
@GetMapping("api/user/recent-openings")
public ResponseEntity<PaginatedResult<OpeningSearchResponseDto>> getUserRecentOpenings(@RequestParam(defaultValue = "10") int limit) {
// Fetch recent openings for the logged-in user with the specified limit
PaginatedResult<OpeningSearchResponseDto> recentOpenings = userRecentOpeningService.getAllRecentOpeningsForUser(limit);
return ResponseEntity.ok(recentOpenings);
}
}

0 comments on commit 4905fec

Please sign in to comment.