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

import com.prolog.eis.dao.out.shelves.GridInfoGroupMapper;
import com.prolog.eis.model.shelves.GridInfoGroup;
import com.prolog.eis.service.shelves.GridInfoGroupService;
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 GridInfoGroupServiceImpl implements GridInfoGroupService {

    @Autowired
    private GridInfoGroupMapper gridInfoGroupMapper;

    /**
     * 新增数据
     *
     * @param gridInfoGroup 格口组表
     */
    @Override
    public long save(GridInfoGroup gridInfoGroup) {
        return gridInfoGroupMapper.save(gridInfoGroup);
    }

    /**
     * 新增批量数据
     *
     * @param gridInfoGroupList 格口组表
     */
    @Override
    public long saveBatch(List<GridInfoGroup> gridInfoGroupList) {
        return gridInfoGroupMapper.saveBatch(gridInfoGroupList);
    }

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

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

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

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

    /**
     * 修改数据
     *
     * @param gridInfoGroup 实例对象
     */
    @Override
    public long update(GridInfoGroup gridInfoGroup) {
        return gridInfoGroupMapper.update(gridInfoGroup);
    }

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

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

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