1
0
This commit is contained in:
2024-03-28 04:24:35 +08:00
commit 28ae65b3d2
110 changed files with 45386 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package xyz.fortern.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import xyz.fortern.pojo.News;
import xyz.fortern.service.NewsService;
import xyz.fortern.util.PageInfo;
@Slf4j
@Controller
@RequestMapping("/news")
public class NewsController {
private final NewsService newsService;
public NewsController(NewsService newsService) {
this.newsService = newsService;
}
@GetMapping("/{page}")
public ResponseEntity<PageInfo<News>> getByPage(@PathVariable int page) {
if(page < 1)
return ResponseEntity.badRequest().build();
return ResponseEntity.ok(newsService.getNewsByPage(page));
}
}