This file contains hidden or 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
$(function () { | |
const url = location.protocol + '//' + location.host + location.pathname; | |
$('.sortable>th').on('click', function () { | |
const sort = $(this).data('sort'); | |
if (!location.search) { | |
if ($(this).hasClass('sortedASC')) { | |
window.location.href = url + '?sort=' + sort + ',' + 'DESC'; |
This file contains hidden or 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
.sortedASC:after { | |
cursor: pointer; | |
opacity: 0.8; | |
content: '\25B2'; | |
} | |
.sortedDESC:after { | |
cursor: pointer; | |
opacity: 0.8; | |
content: '\25BC'; | |
} |
This file contains hidden or 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
@Service | |
public class PagingAndSortingService { | |
public String[] setSortInfoArray(Page<?> page) { | |
final String [] sortInfoArray = page.getSort().toString().split(":"); | |
return Arrays.stream(sortInfoArray).map(String::trim).toArray(String[]::new); | |
} | |
public String getSortClassName(final String [] sortInfoArray, | |
final String propertyName) { |
This file contains hidden or 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
<thead> | |
<!-- sortInfoArray[0] = sorting property (e.g: project.customer), | |
sortInfoArray[1] = sorting direction (asc/desc) --> | |
<tr class="sortable" | |
th:with="sortInfoArray = ${@pagingAndSortingService.setSortInfoArray(workLogs)}"> | |
<th data-sort="id" | |
th:classappend="${@pagingAndSortingService.getSortClassName(sortInfoArray, 'id')}"> | |
Id | |
</th> | |
<th data-sort="employee" |
This file contains hidden or 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
@Repository | |
public interface WorkLogRepository extends PagingAndSortingRepository<WorkLog, Long> { | |
@Override | |
Page<WorkLog> findAll(Pageable pageable); | |
} |
This file contains hidden or 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
@Controller | |
@AllArgsConstructor | |
@RequestMapping("/work-logs") | |
public class WorkLogController { | |
private final WorkLogService workLogService; | |
@GetMapping | |
public String index(Model model, Pageable pageable){ | |
model.addAttribute("workLogs", workLogService.getWorkLogs(pageable)); |
This file contains hidden or 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
/** | |
* | |
*/ | |
package service.defaultValue; | |
import javax.ws.rs.DefaultValue; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.QueryParam; |
This file contains hidden or 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
/** | |
* | |
*/ | |
package service.beanParam; | |
import javax.ws.rs.BeanParam; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
/** |
This file contains hidden or 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
/** | |
* | |
*/ | |
package service.beanParam; | |
import javax.ws.rs.MatrixParam; | |
import javax.ws.rs.PathParam; | |
import javax.ws.rs.QueryParam; | |
/** |
NewerOlder