package com.liang.service.impl;

import com.liang.entity.StaSoftwareexpenses;
import com.liang.dao.StaSoftwareexpensesDao;
import com.liang.service.StaSoftwareexpensesService;
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;

/**
 * 软件使用费(StaSoftwareexpenses)表服务实现类
 *
 * @author makejava
 * @since 2023-07-18 21:52:44
 */
@Service("staSoftwareexpensesService")
public class StaSoftwareexpensesServiceImpl implements StaSoftwareexpensesService {
    @Resource
    private StaSoftwareexpensesDao staSoftwareexpensesDao;

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

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

    /**
     * 新增数据
     *
     * @param staSoftwareexpenses 实例对象
     * @return 实例对象
     */
    @Override
    public StaSoftwareexpenses insert(StaSoftwareexpenses staSoftwareexpenses) {
        this.staSoftwareexpensesDao.insert(staSoftwareexpenses);
        return staSoftwareexpenses;
    }

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

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

    @Override
    public List<StaSoftwareexpenses> getRjsyfList(Integer zb) {
        return this.staSoftwareexpensesDao.getRjsyfList(zb);
    }

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

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

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