package com.njcn.gather.dip.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
import com.njcn.gather.dip.mapper.PqDipDataMapper;
import com.njcn.gather.dip.pojo.po.PqDipData;
import com.njcn.gather.dip.service.IPqDipDataService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author caozehui
 * @date 2026-04-09
 */
@Service
public class PqDipDataServiceImpl extends ServiceImpl<PqDipDataMapper, PqDipData> implements IPqDipDataService {
    @Override
    public List<PqDipData> listDipData(Integer suffix) {
        DynamicTableNameHandler.setTableName("pq_dip_data_" + suffix);
        LambdaQueryChainWrapper<PqDipData> wrapper = this.lambdaQuery().orderByAsc(PqDipData::getStartTime);
        List<PqDipData> result = wrapper.list();
        DynamicTableNameHandler.remove();
        return result;
    }

    @Override
    public void clearAllData(Integer suffix) {
        DynamicTableNameHandler.setTableName("pq_dip_data_" + suffix);
        this.remove(null);
        DynamicTableNameHandler.remove();
    }
}
