Skip to content

Commit

Permalink
Create pageBy api for log.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed May 5, 2019
1 parent b2415d3 commit 574ae54
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/run/halo/app/controller/admin/api/LogController.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package run.halo.app.controller.admin.api;

import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.model.entity.Log;
import run.halo.app.service.LogService;

import java.util.List;

import static org.springframework.data.domain.Sort.Direction.DESC;

/**
* Log controller.
*
Expand Down Expand Up @@ -38,6 +44,12 @@ public List<LogDTO> pageLatest(@RequestParam(name = "top", defaultValue = "10")
return logService.pageLatest(top).getContent();
}

@GetMapping
public Page<LogDTO> pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable){
Page<Log> logPage = logService.listAll(pageable);
return logPage.map(log -> new LogDTO().convertFrom(log));
}

/**
* Clear all logs.
*/
Expand Down

0 comments on commit 574ae54

Please sign in to comment.