package com.liang.service.impl;

import com.liang.dao.StaIndirectCostsDao;
import com.liang.entity.StaIndirectCosts;
import com.liang.service.StaIndirectCostsService;
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;

/**
 * 间接费(StaIndirectCosts)表服务实现类
 */
@Service("staIndirectCostsService")
public class StaIndirectCostsServiceImpl implements StaIndirectCostsService {
    @Resource
    private StaIndirectCostsDao staIndirectCostsDao;

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

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

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

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

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

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

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

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

    @Override
    public List<StaIndirectCosts> getJjfList(Integer zb) {
        return this.staIndirectCostsDao.getJjfList(zb);
    }

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