package com.yueqian.xingyun.sc.excel.stock;

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.ProductStock;
import com.yueqian.xingyun.sc.service.stock.ProductStockService;
import com.yueqian.xingyun.sc.vo.stock.QueryProductStockVo;

public class ProductStockExportTaskWorker implements
    ExportTaskWorker<QueryProductStockVo, ProductStock, ProductStockExportModel> {

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

  @Override
  public PageResult<ProductStock> getDataList(int pageIndex, int pageSize,
      QueryProductStockVo params) {

    ProductStockService productStockService = ApplicationUtil.getBean(ProductStockService.class);

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

  @Override
  public ProductStockExportModel exportData(ProductStock data) {
    return new ProductStockExportModel(data);
  }

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