-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
took create page logic to ApiUtil class, change return type to Page i…
…n get methods
- Loading branch information
Showing
17 changed files
with
164 additions
and
125 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* InvestBook | ||
* Copyright (C) 2024 Spacious Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package ru.investbook.api; | ||
|
||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
|
||
public class ApiUtil { | ||
|
||
private ApiUtil(){} | ||
|
||
public static final String DEFAULT_PAGE = "1"; | ||
|
||
public static final String DEFAULT_PAGE_SIZE = "10"; | ||
public static final String DEFAULT_EVENT_CASH_FLOW_SORT_BY = "portfolio"; | ||
public static final String DEFAULT_FOREIGN_EXCHANGE_RATE_SORT_BY = "rate"; | ||
public static final String DEFAULT_ISSUER_SORT_BY = "taxpayerId"; | ||
public static final String DEFAULT_PORTFOLIO_PROPERTY_SORT_BY = "portfolio"; | ||
public static final String DEFAULT_PORTFOLIO_CASH_SORT_BY = "portfolio"; | ||
public static final String DEFAULT_SECURITY_DESCRIPTION_SORT_BY= "sector"; | ||
public static final String DEFAULT_SECURITY_EVENT_CASH_FLOW_SORT_BY = "value"; | ||
public static final String DEFAULT_SECURITY_QUOTE_SORT_BY = "quote"; | ||
public static final String DEFAULT_SECURITY_SORT_BY = "name"; | ||
public static final String DEFAULT_TRANSACTION_CASH_FLOW_SORT_BY = "transactionId"; | ||
public static final String DEFAULT_TRANSACTION_SORT_BY = "tradeId"; | ||
public static final String DEFAULT_PORTFOLIO_SORT_BY = "id"; | ||
|
||
public static final String DEFAULT_SORT_DIRECTION = "desc"; | ||
|
||
public static Pageable getPage(int pageNo, int pageSize, String sortBy, String sortDir){ | ||
Sort sort = sortDir.equalsIgnoreCase(Sort.Direction.ASC.name()) ? Sort.by(sortBy).ascending() | ||
: Sort.by(sortBy).descending(); | ||
return PageRequest.of(pageNo, pageSize, sort); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.