package com.liang.service.impl;

import com.liang.entity.BaseProjectbudget;
import com.liang.dao.BaseProjectbudgetDao;
import com.liang.service.BaseProjectbudgetService;
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;

/**
 * 项目预算(BaseProjectbudget)表服务实现类
 *
 * @author makejava
 * @since 2023-03-13 16:47:30
 */
@Service("baseProjectbudgetService")
public class BaseProjectbudgetServiceImpl implements BaseProjectbudgetService {
    @Resource
    private BaseProjectbudgetDao baseProjectbudgetDao;

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

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

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

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

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

    @Override
    public int delete(BaseProjectbudget baseProjectbudget) {
        return this.baseProjectbudgetDao.delete(baseProjectbudget);
    }

    /**
     * 获取项目模板
     *
     * @return
     */
    @Override
    public List<BaseProjectbudget> getBudgetList(Integer xm) {
        return this.baseProjectbudgetDao.getBudgetList(xm);
    }

    @Override
    public List<BaseProjectbudget> getPrjBudgetList(Integer xm) {
        return this.baseProjectbudgetDao.getPrjBudgetList(xm);
    }
}
