HistoryController.java 713 B

1234567891011121314151617181920212223242526
  1. package com.hwmonitor.controller;
  2. import com.hwmonitor.model.entity.MetricRecord;
  3. import com.hwmonitor.service.HistoryService;
  4. import org.springframework.web.bind.annotation.*;
  5. import java.util.List;
  6. @RestController
  7. @RequestMapping("/api/v1")
  8. public class HistoryController {
  9. private final HistoryService historyService;
  10. public HistoryController(HistoryService historyService) {
  11. this.historyService = historyService;
  12. }
  13. @GetMapping("/history")
  14. public List<MetricRecord> getHistory(
  15. @RequestParam(required = false) String type,
  16. @RequestParam Long from,
  17. @RequestParam Long to) {
  18. return historyService.queryHistory(type, from, to);
  19. }
  20. }