package com.liang.service.impl;

import com.liang.entity.StaTravelexpenses;
import com.liang.dao.StaTravelexpensesDao;
import com.liang.service.StaTravelexpensesService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 差旅费(StaTravelexpenses)表服务实现类
 *
 * @author makejava
 * @since 2023-04-26 09:50:01
 */
@Service("staTravelexpensesService")
public class StaTravelexpensesServiceImpl implements StaTravelexpensesService {
    @Resource
    private StaTravelexpensesDao staTravelexpensesDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public StaTravelexpenses queryById(Integer id) {
        return this.staTravelexpensesDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param staTravelexpenses 筛选条件
     * @param pageRequest       分页对象
     * @return 查询结果
     */
    @Override
    public Page<StaTravelexpenses> queryByPage(StaTravelexpenses staTravelexpenses, PageRequest pageRequest) {
        long total = this.staTravelexpensesDao.count(staTravelexpenses);
        return new PageImpl<>(this.staTravelexpensesDao.queryAllByLimit(staTravelexpenses, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param staTravelexpenses 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(StaTravelexpenses staTravelexpenses) {
        return this.staTravelexpensesDao.insert(staTravelexpenses);
    }

    /**
     * 修改数据
     *
     * @param staTravelexpenses 实例对象
     * @return 实例对象
     */
    @Override
    public int update(StaTravelexpenses staTravelexpenses) {
        return this.staTravelexpensesDao.update(staTravelexpenses);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.staTravelexpensesDao.deleteById(id) > 0;
    }

    @Override
    public int deleteByZb(Integer zb) {
        return this.staTravelexpensesDao.deleteByZb(zb);
    }

    @Override
    public int batchDeleteByZb(List<Integer> zbList) {
        return this.staTravelexpensesDao.batchDeleteByZb(zbList);
    }

    @Override
    public int insertBatch(List<StaTravelexpenses> expenseList) {
        return this.staTravelexpensesDao.insertBatch(expenseList);
    }

    @Override
    public List<StaTravelexpenses> getClfList(Integer zb) {
        return this.staTravelexpensesDao.getClfList(zb);
    }

    @Override
    public List<StaTravelexpenses> queryByKyfh(String kyfh) {
        return this.staTravelexpensesDao.queryByKyfh(kyfh);
    }

    @Override
    public List<HashMap<String, Object>> searchTravelexpensesCost(Map map) {
        return this.staTravelexpensesDao.searchTravelexpensesCost(map);
    }
}
