package com.liang.service.impl;

import com.liang.dao.PrjPayplanXgDao;
import com.liang.entity.PrjPayplan;
import com.liang.entity.PrjPayplanXg;
import com.liang.service.PrjPayplanXgService;
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;

@Service("prjPayplanXgService")
public class PrjPayplanXgServiceImpl implements PrjPayplanXgService {
    @Resource
    private PrjPayplanXgDao prjPayplanXgDao;

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

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

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

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

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

    @Override
    public int batchDelete(List<Integer> idList) {
        return this.prjPayplanXgDao.batchDelete(idList);
    }

    @Override
    public List<PrjPayplanXg> getPayPlanList(Integer ht) {
        return this.prjPayplanXgDao.getPayPlanList(ht);
    }

    @Override
    public int insertBatch(List<PrjPayplanXg> prjPayplanAddList) {
        return prjPayplanXgDao.insertBatch(prjPayplanAddList);
    }

    @Override
    public void deleteByHtId(Integer ht) {
        prjPayplanXgDao.deleteBtHtId(ht);
    }
}
