package com.huyi.service.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huyi.service.base.entity.SysCompanySpare;
import com.huyi.service.base.mapper.SysCompanySpareMapper;
import com.huyi.service.base.service.ISysCompanySpareService;
import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ClassName: SysCompanySpareServiceImpl<br>
 * Description: ISysCompanySpareService实现 <br>
 * Company: keao
 *
 * @author songqg
 * @version v1.0.0    2021-08-17  songqg    由Generator自动创建
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class SysCompanySpareServiceImpl extends ServiceImpl<SysCompanySpareMapper, SysCompanySpare> implements ISysCompanySpareService {

    @Autowired
    private SysCompanySpareMapper sysCompanySpareMapper;

    @Override
    public IPage<SysCompanySpare> findSysCompanySpares(QueryRequest request, LambdaQueryWrapper<SysCompanySpare> wrapper) {
        Page<SysCompanySpare> page = new Page<>(request.getPageNum(), request.getPageSize());
        return this.page(page, wrapper);
    }

    @Override
    public List<SysCompanySpare> findSysCompanySpares(LambdaQueryWrapper<SysCompanySpare> wrapper) {
		return this.list(wrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void createSysCompanySpare(SysCompanySpare sysCompanySpare) {
        this.save(sysCompanySpare);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateSysCompanySpare(SysCompanySpare sysCompanySpare) {
        this.saveOrUpdate(sysCompanySpare);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteSysCompanySpare(LambdaQueryWrapper<SysCompanySpare> wrapper) {
	    this.remove(wrapper);
	}
}
