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

import com.prolog.eis.dao.shelves.AllotmentCfgMapper;
import com.prolog.eis.dto.page.AllotmentTaskRecordReqDto;
import com.prolog.eis.dto.page.AllotmentTaskRecordResultDto;
import com.prolog.eis.model.shelves.AllotmentCfg;
import com.prolog.eis.service.shelves.AllotmentCfgService;
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-08-28 11:41
 */
@Service
public class AllotmentCfgServiceImpl implements AllotmentCfgService {

    @Autowired
    private AllotmentCfgMapper allotmentCfgMapper;

    /**
     * 新增数据
     *
     * @param allotmentCfg 分拨站配置表
     */
    @Override
    public long save(AllotmentCfg allotmentCfg) {
        return allotmentCfgMapper.save(allotmentCfg);
    }

    /**
     * 新增批量数据
     *
     * @param allotmentCfgList 分拨站配置表
     */
    @Override
    public long saveBatch(List<AllotmentCfg> allotmentCfgList) {
        return allotmentCfgMapper.saveBatch(allotmentCfgList);
    }

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

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

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

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

    /**
     * 修改数据
     *
     * @param allotmentCfg 实例对象
     */
    @Override
    public long update(AllotmentCfg allotmentCfg) {
        return allotmentCfgMapper.update(allotmentCfg);
    }

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

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

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

    @Override
    public List<AllotmentTaskRecordResultDto> allotmentTaskRecordList(AllotmentTaskRecordReqDto req) {
        return allotmentCfgMapper.allotmentTaskRecordList(req);
    }
}
