package cn.gov.customs.wxjy.task;

import cn.gov.customs.wxjy.base.dao.ChemicalsCatalogMapper;
import cn.gov.customs.wxjy.base.dao.GoodsCatalogMapper;
import cn.gov.customs.wxjy.base.pojo.ChemicalsCatalog;
import cn.gov.customs.wxjy.base.pojo.ChemicalsCatalogQuery;
import cn.gov.customs.wxjy.base.pojo.GoodsCatalogQuery;
import cn.gov.customs.wxjy.ibmmq.enums.BillTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 危化品目录推送任务
 */
@Component
@Slf4j
public class ChemicalsCatalogTask extends BaseBusinessTask<ChemicalsCatalog> {

    @Autowired
    private ChemicalsCatalogMapper chemicalsCatalogMapper;

    @Override
    public String getTaskCode() {
        return BillTypeEnum.BUS_TYPE_CHEMICALS_CATALOG.getCode();
    }

    @Override
    public String getTaskName() {
        return BillTypeEnum.getNameByCode(getTaskCode());
    }

    @Override
    public String getBusinessType() {
        return getTaskCode();
    }

    @Override
    public String getMapperClassName() {
        // 返回对应的Mapper类名
        return ChemicalsCatalogMapper.class.getName();
    }

    @Override
    public Class<ChemicalsCatalog> getEntityClass() {
        return ChemicalsCatalog.class;
    }

    @Override
    public List<ChemicalsCatalog> queryData(Date lastSyncTime) {
        ChemicalsCatalogQuery query = new ChemicalsCatalogQuery();
        query.setUpdateTime(lastSyncTime);
        return chemicalsCatalogMapper.selectList(query);
    }

    @Override
    public String getDataId(ChemicalsCatalog data) {
        return data.getId();
    }
}