package com.liang.service.impl;

import com.liang.entity.PrjApproval;
import com.liang.dao.PrjApprovalDao;
import com.liang.service.PrjApprovalService;
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;

/**
 * (PrjApproval)表服务实现类
 *
 * @author makejava
 * @since 2023-04-29 22:05:41
 */
@Service("prjApprovalService")
public class PrjApprovalServiceImpl implements PrjApprovalService {
    @Resource
    private PrjApprovalDao prjApprovalDao;

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

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

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

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

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