package cn.gov.customs.wxjy.task;

import cn.gov.customs.wxjy.base.dao.PackCatalogMapper;
import cn.gov.customs.wxjy.base.pojo.PackCatalog;
import cn.gov.customs.wxjy.base.pojo.PackCatalogQuery;
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 PackCatalogTask extends BaseBusinessTask<PackCatalog> {

    @Autowired
    private PackCatalogMapper packCatalogMapper;

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

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

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

    @Override
    public String getMapperClassName() {
        return PackCatalogMapper.class.getName();
    }

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

    @Override
    public List<PackCatalog> queryData(Date lastSyncTime) {
        PackCatalogQuery query = new PackCatalogQuery();
        query.setUpdateTime(lastSyncTime);
        return packCatalogMapper.selectList(query);
    }

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