package com.ensign.crm.module.crm.service;

import com.ensign.crm.framework.excel.core.util.ExcelUtils;
import com.ensign.crm.module.crm.model.DealerRegistrationModel;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description: TODO
 * @Date: 29/11/2024 2:29 pm
 * @Created: by ZZSLL
 */

@Service
public class ExcelTemplateService {

    /**
     * 经销商登记
     *
     * @param response
     */
    public void generateDealerRegistration(HttpServletResponse response) throws IOException {

        List<DealerRegistrationModel> emptyData = new ArrayList<>();
        ExcelUtils.write(response, "经销商登记引出模板.xlsx", "Sheet1", DealerRegistrationModel.class, emptyData);
    }

    public List<DealerRegistrationModel> parsingExcel(MultipartFile file) throws IOException {
        return ExcelUtils.read(file, DealerRegistrationModel.class);
    }
}
