feat(dto): Add toString methods for PageQueryReq and PageResult classes - Add toString methods in PageQueryReq class to print the object's property information

- Add toString method to the PageResult class to print attribute information of paging results
- The addition of toString method is easy to debug and log, improving the maintainability of the code
This commit is contained in:
gewuyou 2025-06-05 16:08:02 +08:00
parent 0e74483168
commit 37309f5b15
2 changed files with 8 additions and 0 deletions

View File

@ -109,4 +109,7 @@ open class PageResult<T> {
*/ */
fun <T> empty(): PageResult<T> = PageResult() fun <T> empty(): PageResult<T> = PageResult()
} }
override fun toString(): String {
return "PageResult(records=$records, totalRecords=$totalRecords, totalPages=$totalPages, currentPage=$currentPage, pageSize=$pageSize, hasPrevious=$hasPrevious, hasNext=$hasNext)"
}
} }

View File

@ -85,4 +85,9 @@ open class PageQueryReq<T> {
fun isDateRangeValid(): Boolean { fun isDateRangeValid(): Boolean {
return startDate == null || endDate == null || !startDate!!.isAfter(endDate) return startDate == null || endDate == null || !startDate!!.isAfter(endDate)
} }
override fun toString(): String {
return "PageQueryReq(currentPage=$currentPage, pageSize=$pageSize, sortBy='$sortBy', sortDirection=$sortDirection, sortConditions=$sortConditions, keyword=$keyword, filter=$filter, startDate=$startDate, endDate=$endDate, enabled=$enabled, deleted=$deleted)"
}
} }