package org.jeecg.modules.under.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.under.entity.Under;
import org.jeecg.modules.under.mapper.UnderMapper;
import org.jeecg.modules.under.service.IUnderService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: under
 * @Author: jeecg-boot
 * @Date:   2025-02-05
 * @Version: V1.0
 */
@Service
public class UnderServiceImpl extends ServiceImpl<UnderMapper, Under> implements IUnderService {
    @Override
    public IPage<Under> queryHistoryDataByMonth(Page<Under> page, String month) {
        // 构造历史表名
        String tableName = "under_history_" + month;
        // 查询历史数据
        return baseMapper.queryHistoryDataByMonth(page, tableName);
    }

    @Override
    public IPage<Under> queryHistoryDataByTimeRange(Page<Under> page, String startTime, String endTime) {
        // 根据开始时间确定表名（这里假设按月分表）
        String month = startTime.substring(0, 7).replace("-", "");
        String tableName = "under_history_" + month;
        // 查询历史数据
        return baseMapper.queryHistoryDataByTimeRange(page, tableName, startTime, endTime);
    }
}
