package com.liang.service.impl;

import com.liang.dao.StaSourceFeeDao;
import com.liang.entity.StaSourceFee;
import com.liang.service.StaSourceFeeService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

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

/**
 * 资料费(StaSourceFee)表服务实现类
 */
@Service("staSourceFeeService")
public class StaSourceFeeServiceImpl implements StaSourceFeeService {
    @Resource
    private StaSourceFeeDao staSourceFeeDao;

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

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

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

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

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

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

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

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

    @Override
    public List<StaSourceFee> getZlfList(Integer zb) {
        return this.staSourceFeeDao.getZlfList(zb);
    }

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

    @Override
    public List<StaSourceFee> searchSourceTsmcByDeptName(String deptName) {
        return this.staSourceFeeDao.searchSourceTsmcByDeptName(deptName);
    }


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

}
