package com.liang.service.impl;

import com.liang.entity.StaDeviceexpenses;
import com.liang.dao.StaDeviceexpensesDao;
import com.liang.service.StaDeviceexpensesService;
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;

/**
 * 仪器设备使用费(StaDeviceexpenses)表服务实现类
 *
 * @author makejava
 * @since 2023-07-18 21:51:46
 */
@Service("staDeviceexpensesService")
public class StaDeviceexpensesServiceImpl implements StaDeviceexpensesService {
    @Resource
    private StaDeviceexpensesDao staDeviceexpensesDao;

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

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

    /**
     * 新增数据
     *
     * @param staDeviceexpenses 实例对象
     * @return 实例对象
     */
    @Override
    public StaDeviceexpenses insert(StaDeviceexpenses staDeviceexpenses) {
        this.staDeviceexpensesDao.insert(staDeviceexpenses);
        return staDeviceexpenses;
    }

    /**
     * 修改数据
     *
     * @param staDeviceexpenses 实例对象
     * @return 实例对象
     */
    @Override
    public StaDeviceexpenses update(StaDeviceexpenses staDeviceexpenses) {
        this.staDeviceexpensesDao.update(staDeviceexpenses);
        return this.queryById(staDeviceexpenses.getId());
    }

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

    @Override
    public List<StaDeviceexpenses> getSbsyfList(Integer zb) {
        return this.staDeviceexpensesDao.getSbsyfList(zb);
    }

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

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

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