package com.cool.store.dao;

import com.cool.store.entity.plan.ShopDeliveryPlanDO;
import com.cool.store.mapper.ShopDeliveryPlanMapper;
import com.cool.store.vo.desk.DeliveryPendingVO;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Repository
public class ShopDeliveryPlanDAO {

    @Resource
    private ShopDeliveryPlanMapper shopDeliveryPlanMapper;

    /**
     * 根据ID查询
     */
    public ShopDeliveryPlanDO getById(Long id) {
        if (id == null) {
            return null;
        }
        return shopDeliveryPlanMapper.getById(id);
    }

    /**
     * 根据门店ID查询
     */
    public ShopDeliveryPlanDO getByShopId(Long shopId) {
        if (shopId == null) {
            return null;
        }
        return shopDeliveryPlanMapper.getByShopId(shopId);
    }

    /**
     * 插入
     */
    public int insert(ShopDeliveryPlanDO record) {
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        return shopDeliveryPlanMapper.insert(record);
    }

    /**
     * 更新
     */
    public int update(ShopDeliveryPlanDO record) {
        record.setUpdateTime(new Date());
        return shopDeliveryPlanMapper.update(record);
    }

    /**
     * 删除
     */
    public int deleteById(Long id) {
        if (id == null) {
            return 0;
        }
        return shopDeliveryPlanMapper.deleteById(id);
    }

    public List<DeliveryPendingVO> getPendingList(String keyword, Integer type) {
        return shopDeliveryPlanMapper.getPendingList(keyword,type);
    }



    /**
     * 查询所有
     */
    public List<ShopDeliveryPlanDO> listAll() {
        return shopDeliveryPlanMapper.listAll();
    }
}