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

import com.prolog.eis.dao.out.PrintSchemeMapper;
import com.prolog.eis.model.outbound.PrintScheme;
import com.prolog.eis.service.out.PrintSchemeService;
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-30 12:24
 */
@Service
public class PrintSchemeServiceImpl implements PrintSchemeService {

    @Autowired
    private PrintSchemeMapper printSchemeMapper;

    /**
     * 新增数据
     *
     * @param printScheme 打印机模块
     */
    @Override
    public long save(PrintScheme printScheme) {
        return printSchemeMapper.save(printScheme);
    }

    /**
     * 新增批量数据
     *
     * @param printSchemeList 打印机模块
     */
    @Override
    public long saveBatch(List<PrintScheme> printSchemeList) {
        return printSchemeMapper.saveBatch(printSchemeList);
    }

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

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

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

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

    /**
     * 修改数据
     *
     * @param printScheme 实例对象
     */
    @Override
    public long update(PrintScheme printScheme) {
        return printSchemeMapper.update(printScheme);
    }

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

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

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