package org.dromara.rfid.service.impl;

import lombok.RequiredArgsConstructor;
import org.dromara.rfid.domain.vo.HomeStatsVO;
import org.dromara.rfid.mapper.StatisticsMapper;
import org.dromara.rfid.service.IStatisticsService;
import org.springframework.stereotype.Service;

/**
 * 首页统计 Service 实现（轻量级，仅查询位置表）
 */
@RequiredArgsConstructor
@Service
public class StatisticsServiceImpl implements IStatisticsService {

    private final StatisticsMapper statisticsMapper;

    @Override
    public HomeStatsVO getHomeStats() {
        HomeStatsVO vo = new HomeStatsVO();
        // 仅查询 rfid_location 表，避免分表查询带来的性能问题
        vo.setLocationStats(statisticsMapper.selectLocationStats());
        vo.setLocations(statisticsMapper.selectTopLocations());
        return vo;
    }
}
