Create pageBy api for log.

pull/146/head
ruibaby 2019-05-05 23:31:30 +08:00
parent b2415d33ce
commit 574ae54208
1 changed files with 12 additions and 0 deletions

View File

@ -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.
*
@ -38,6 +44,12 @@ public class LogController {
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.
*/