package com.yueqian.xingyun.sc.excel.sale.out;

import com.lframework.starter.web.core.components.resp.PageResult;
import com.lframework.starter.web.core.utils.ApplicationUtil;
import com.lframework.starter.web.core.utils.JsonUtil;
import com.lframework.starter.mq.core.components.export.ExportTaskWorker;
import com.yueqian.xingyun.sc.entity.SaleOutSheet;
import com.yueqian.xingyun.sc.service.sale.SaleOutSheetService;
import com.yueqian.xingyun.sc.vo.sale.out.QuerySaleOutSheetVo;

public class SaleOutSheetExportTaskWorker implements
    ExportTaskWorker<QuerySaleOutSheetVo, SaleOutSheet, SaleOutSheetExportModel> {

  @Override
  public QuerySaleOutSheetVo parseParams(String json) {
    return JsonUtil.parseObject(json, QuerySaleOutSheetVo.class);
  }

  @Override
  public PageResult<SaleOutSheet> getDataList(int pageIndex, int pageSize,
      QuerySaleOutSheetVo params) {

    SaleOutSheetService saleOutSheetService = ApplicationUtil.getBean(
        SaleOutSheetService.class);

    return saleOutSheetService.query(pageIndex, pageSize, params);
  }

  @Override
  public SaleOutSheetExportModel exportData(SaleOutSheet data) {
    return new SaleOutSheetExportModel(data);
  }

  @Override
  public Class<SaleOutSheetExportModel> getModelClass() {
    return SaleOutSheetExportModel.class;
  }
}
