package com.liang.service.impl;

import com.liang.dao.StaProjectExpensesDao;
import com.liang.entity.StaProjectExpenses;
import com.liang.service.StaProjectExpensesService;
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.List;

/**
 * 项目费用支出（StaProjectExpensesServiceImpl）表服务接口
 */
@Service("staProjectExpensesService")
public class StaProjectExpensesServiceImpl implements StaProjectExpensesService {
    @Resource
    private StaProjectExpensesDao staProjectExpensesDao;

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

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

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

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

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

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

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

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

    @Override
    public List<StaProjectExpenses> getXmfyList(Integer zb) {
        return this.staProjectExpensesDao.getXmfyList(zb);
    }
}
