package cn.gov.customs.wxjy.task;

import cn.gov.customs.wxjy.base.dao.GoodsCatalogMapper;
import cn.gov.customs.wxjy.base.pojo.GoodsCatalog;
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 GoodsCatalogTask extends BaseBusinessTask<GoodsCatalog> {
    @Autowired
    private GoodsCatalogMapper goodsCatalogMapper;

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

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

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

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

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

    @Override
    public List<GoodsCatalog> queryData(Date lastSyncTime) {
        GoodsCatalogQuery query = new GoodsCatalogQuery();
        query.setUpdateTime(lastSyncTime);
        return goodsCatalogMapper.selectList(query);
    }

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