package com.chaozhanggui.system.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.chaozhanggui.system.entity.Promotion;
import lombok.extern.slf4j.Slf4j;

/**
 * @author lyf
 */

@Slf4j
public class MyReadListener implements ReadListener<Promotion> {
    /**
     * 这个每一条数据解析都会来调用
     *
     * @param data    one row value. Is is same as {@link AnalysisContext#readRowHolder()}
     * @param context
     */
    @Override
    public void invoke(Promotion data, AnalysisContext context) {
        //log.info("解析到一条数据:{}", JSON.toJSONString(data));
        System.out.println(data.getMerchantCode() + " - " + data.getAmount() + " - " + data.getRemake());
    }

    /**
     * 所有数据解析完成了 都会来调用
     *
     * @param context
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        log.info("所有数据解析完成！");
    }

}
