package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import com.example.demo.service.UserService;

@Controller
public class HomeController {

    @Autowired
    private UserService userService;

    @GetMapping("/")
    public String home(Model model) {
        // 统计在线用户数（最近10分钟内活跃的用户）
        long onlineUserCount = userService.countOnlineUsers();
        model.addAttribute("onlineUserCount", onlineUserCount);
        
        return "home";
    }
}



