package com.liang.service.impl;

import com.liang.entity.PrjPayplan;
import com.liang.dao.PrjPayplanDao;
import com.liang.service.PrjPayplanService;
import com.liang.service.PrjPayplannameService;
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.List;

/**
 * 付款计划(PrjPayplan)表服务实现类
 *
 * @author makejava
 * @since 2023-06-06 13:16:05
 */
@Service("prjPayplanService")
public class PrjPayplanServiceImpl implements PrjPayplanService {
    @Resource
    private PrjPayplanDao prjPayplanDao;
    @Resource
    private PrjPayplannameService prjPayplannameService;


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

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

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

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

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

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

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

    @Override
    public int insertBatch(List<PrjPayplan> prjPayplanList) {
        return this.prjPayplanDao.insertBatch(prjPayplanList);
    }

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