package com.nantian.cloud.jljc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nantian.cloud.jljc.entity.DeleteDataRecord;
import com.nantian.cloud.jljc.mapper.DeleteDataRecordMapper;
import com.nantian.cloud.jljc.service.DeleteDataRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("DeleteDataRecordService")
public class DeleteDataRecordServiceImpl extends ServiceImpl<DeleteDataRecordMapper, DeleteDataRecord> implements DeleteDataRecordService {
    private static final String EXTENSION_XLS = "xls";
    private static final String EXTENSION_XLSX = "xlsx";

    @Autowired
    private DeleteDataRecordMapper deleteDataRecordMapper;

    @Override
    public IPage<DeleteDataRecord> pageInfo(Page page, DeleteDataRecord deleteDataRecord) {
        IPage<DeleteDataRecord> deleteDataRecords = deleteDataRecordMapper.getPage(page,deleteDataRecord);
        List<DeleteDataRecord> newDtoList = deleteDataRecords.getRecords();
        Integer total = baseMapper.getTotal(deleteDataRecord);
        List<DeleteDataRecord> list = new ArrayList<>();
        for (DeleteDataRecord deleteDataRecordItem : newDtoList) {
            list.add(deleteDataRecordItem);
        }
        IPage<DeleteDataRecord> page1 = new Page<>();
        page1.setCurrent(deleteDataRecords.getCurrent());
        page1.setTotal(total);
        page1.setSize(deleteDataRecords.getSize());
        page1.setRecords(list);
        return page1;
    }
}
