package com.prolog.eis.service.pick.impl;

import com.prolog.eis.dao.pick.PickingOrderMapper;
import com.prolog.eis.model.pick.PickingOrder;
import com.prolog.eis.service.pick.PickingOrderService;
import com.prolog.framework.core.restriction.Criteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author zmr
 * @description: 任务包表-服务实现类
 * @date 2023-07-06 12:59
 */
@Service
public class PickingOrderServiceImpl implements PickingOrderService {

    @Autowired
    private PickingOrderMapper pickingOrderMapper;

    /**
     * 新增数据
     *
     * @param pickingOrder 任务包表
     */
    @Override
    public long save(PickingOrder pickingOrder) {
        return pickingOrderMapper.save(pickingOrder);
    }

    /**
     * 新增批量数据
     *
     * @param pickingOrderList 任务包表
     */
    @Override
    public long saveBatch(List<PickingOrder> pickingOrderList) {
        return pickingOrderMapper.saveBatch(pickingOrderList);
    }

    /**
     * 查询多条数据
     *
     * @param paramMap 查询起始位置
     * @return 对象列表
     */
    @Override
    public List<PickingOrder> findByMap(Map<String, Object> paramMap) {
        return pickingOrderMapper.findByMap(paramMap, PickingOrder.class);
    }

    /**
     * 查询单条数据
     *
     * @param paramMap 查询起始位置
     * @return 对象
     */
    @Override
    public PickingOrder findOneByMap(Map<String, Object> paramMap) {
        List<PickingOrder> dataList = findByMap(paramMap);
        if(dataList.isEmpty()) {
            return null;
        }
        return dataList.get(0);
    }

    /**
     * 查询多条数据
     *
     * @param criteria 查询起始位置
     * @return 对象列表
     */
    @Override
    public List<PickingOrder> findByCriteria(Criteria criteria) {
        return pickingOrderMapper.findByCriteria(criteria);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PickingOrder findById(int id) {
        return pickingOrderMapper.findById(id, PickingOrder.class);
    }

    /**
     * 修改数据
     *
     * @param pickingOrder 实例对象
     */
    @Override
    public long update(PickingOrder pickingOrder) {
        return pickingOrderMapper.update(pickingOrder);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     */
    @Override
    public long deleteById(int id) {
        return pickingOrderMapper.deleteById(id, PickingOrder.class);
    }

    /**
     * 通过参数删除数据
     *
     * @param paramMap 参数
     */
    @Override
    public long deleteByMap(Map<String, Object> paramMap) {
        return pickingOrderMapper.deleteByMap(paramMap, PickingOrder.class);
    }

    /**
     * 通过参数查询总条数
     *
     * @param paramMap 参数
     */
    @Override
    public long findCountByMap(Map<String, Object> paramMap) {
        return pickingOrderMapper.findCountByMap(paramMap, PickingOrder.class);
    }
}
