-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-format the project using eclipse code formatter
- Loading branch information
EMEA\VEA3SF
committed
Jan 22, 2024
1 parent
3e7e275
commit 644a62c
Showing
79 changed files
with
2,011 additions
and
1,529 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
53 changes: 27 additions & 26 deletions
53
src/main/java/com/springpageable/controller/CriteriaBuilderExampleController.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 |
---|---|---|
@@ -1,62 +1,63 @@ | ||
package com.springpageable.controller; | ||
|
||
import static com.springpageable.configuration.WebPath.API_VERSION_1; | ||
import static com.springpageable.configuration.WebPath.PATH_USERS; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.springpageable.dto.GetUserResponseDTO; | ||
import com.springpageable.enums.LdapGroup; | ||
import com.springpageable.service.CriteriaBuilderExampleService; | ||
import com.springpageable.swagger.SwaggerErrorResponses; | ||
import com.springpageable.swagger.SwaggerPageable; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
import static com.springpageable.configuration.WebPath.API_VERSION_1; | ||
import static com.springpageable.configuration.WebPath.PATH_USERS; | ||
|
||
@RestController | ||
@RequestMapping(API_VERSION_1) | ||
@Validated | ||
@Tag(name = "Criteria Builder Example", description = "Pageing result from criteria builder") | ||
@Tag(name = "Criteria Builder Example", description = "Paging result from criteria builder") | ||
public class CriteriaBuilderExampleController { | ||
|
||
private final CriteriaBuilderExampleService criteriaBuilderExampleService; | ||
|
||
public CriteriaBuilderExampleController(CriteriaBuilderExampleService criteriaBuilderExampleService) { | ||
this.criteriaBuilderExampleService = criteriaBuilderExampleService; | ||
} | ||
@Autowired | ||
private final CriteriaBuilderExampleService criteriaBuilderExampleService; | ||
|
||
@GetMapping(PATH_USERS) | ||
@SwaggerPageable | ||
@SwaggerErrorResponses | ||
@Operation( | ||
summary = "Retrieves users by username. Can be used for retrieving or excluding " + | ||
"users with concrete usernames, but not in the same time") | ||
@Parameter(name = "exclude-usernames", description = "User names which to be excluded from the result set", | ||
array = @ArraySchema(schema = @Schema(example = "testUser"))) | ||
@Parameter(name = "usernames", array = @ArraySchema(schema = @Schema(example = "testUser")), | ||
description = "Search by list of usernames") | ||
@Operation(summary = "Retrieves users by username. Can be used for retrieving or excluding " + | ||
"users with concrete usernames, but not in the same time") | ||
@Parameter(name = "exclude-usernames", description = "User names which to be excluded from the result set", array = @ArraySchema(schema = @Schema(example = "testUser"))) | ||
@Parameter(name = "usernames", array = @ArraySchema(schema = @Schema(example = "testUser")), description = "Search by list of usernames") | ||
@Parameter(name = "searchParameter", example = "testUser", description = "Search by username, first name or last name") | ||
@ApiResponse(responseCode = "200", | ||
content = @Content(array = @ArraySchema(schema = @Schema(implementation = GetUserResponseDTO.class)))) | ||
@ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GetUserResponseDTO.class)))) | ||
public Page<GetUserResponseDTO> getUsers( | ||
@RequestHeader(name = "exclude-usernames", required = false, defaultValue = "") List<String> excludeUsernames, | ||
@RequestHeader(required = false, defaultValue = "") List<String> usernames, | ||
@RequestHeader(name = "ldap-groups", required = false, defaultValue = "") List<LdapGroup> ldapGroups, | ||
@RequestParam(required = false, defaultValue = "") String searchParameter, | ||
@PageableDefault(direction = Sort.Direction.ASC, sort = {"firstName", "lastName", "username"}) | ||
Pageable p) { | ||
@PageableDefault(direction = Sort.Direction.ASC, sort = { "firstName", "lastName", | ||
"username" }) Pageable p) { | ||
return criteriaBuilderExampleService.getUsers(usernames, excludeUsernames, ldapGroups, searchParameter, p); | ||
} | ||
} |
46 changes: 25 additions & 21 deletions
46
src/main/java/com/springpageable/controller/DateController.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 |
---|---|---|
@@ -1,39 +1,43 @@ | ||
package com.springpageable.controller; | ||
|
||
import static com.springpageable.configuration.WebPath.API_VERSION_1; | ||
import static com.springpageable.configuration.WebPath.PATH_DATE; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.springpageable.dto.DateRequestDTO; | ||
import com.springpageable.service.DateService; | ||
import com.springpageable.swagger.SwaggerErrorResponses; | ||
|
||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import jakarta.validation.Valid; | ||
|
||
import static com.springpageable.configuration.WebPath.API_VERSION_1; | ||
import static com.springpageable.configuration.WebPath.PATH_DATE; | ||
|
||
@RestController | ||
@RequestMapping(API_VERSION_1) | ||
@Validated | ||
@Tag(name = "Date validator", description = "Show custom date validator in spring") | ||
public class DateController { | ||
|
||
private final DateService dateService; | ||
private final DateService dateService; | ||
|
||
@Autowired | ||
public DateController(DateService dateService) { | ||
this.dateService = dateService; | ||
} | ||
@Autowired | ||
public DateController(DateService dateService) { | ||
this.dateService = dateService; | ||
} | ||
|
||
@PostMapping(PATH_DATE) | ||
@SwaggerErrorResponses | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@ApiResponse(responseCode = "201") | ||
public void dateValidator(@Valid @RequestBody DateRequestDTO dateRequestDto) { | ||
this.dateService.demo(dateRequestDto); | ||
} | ||
@PostMapping(PATH_DATE) | ||
@SwaggerErrorResponses | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@ApiResponse(responseCode = "201") | ||
public void dateValidator(@Valid @RequestBody DateRequestDTO dateRequestDto) { | ||
this.dateService.demo(dateRequestDto); | ||
} | ||
} |
Oops, something went wrong.