mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 22:50:51 +08:00
Add DAU statistics module
This commit is contained in:
26
src/main/java/com/openisle/controller/StatController.java
Normal file
26
src/main/java/com/openisle/controller/StatController.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.openisle.controller;
|
||||
|
||||
import com.openisle.service.UserVisitService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
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 java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/stats")
|
||||
@RequiredArgsConstructor
|
||||
public class StatController {
|
||||
private final UserVisitService userVisitService;
|
||||
|
||||
@GetMapping("/dau")
|
||||
public Map<String, Long> dau(@RequestParam(value = "date", required = false)
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
|
||||
long count = userVisitService.countDau(date);
|
||||
return Map.of("dau", count);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user