package com.repair.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.repair.mapper.RepairCloseMapper;
import com.repair.model.pojo.RepairClose;
import com.repair.model.result.PageUtils;
import com.repair.services.RepairCloseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2023-08-04
 */
@Service
public class RepairCloseServiceImpl extends ServiceImpl<RepairCloseMapper, RepairClose> implements RepairCloseService {

    @Autowired
    private RepairCloseMapper repairCloseMapper;

    @Override
    public int insertRepairClose(RepairClose rc) {
        int result = repairCloseMapper.insert(rc);
        return result;
    }

    @Override
    public int updateRepairClose(RepairClose rc) {
        int result = repairCloseMapper.updateById(rc);
        return result;
    }

    @Override
    public PageUtils<RepairClose> queryPageRepairCloses(int currentPage, int pageCount, String name) {
        Page<RepairClose> page = new Page<>(currentPage, pageCount);
        QueryWrapper<RepairClose> queryWrapper = new QueryWrapper<>();
        IPage<RepairClose> result = repairCloseMapper.selectPage(page, queryWrapper);
        return new PageUtils(result);
    }

    @Override
    public int deleteRepairCloseById(int id) {
        int result = repairCloseMapper.deleteById(id);
        return result;
    }

    @Override
    public RepairClose getRepairById(int id) {
        RepairClose result = repairCloseMapper.selectById(id);
        return result;
    }

    @Override
    public List<RepairClose> getRepairs() {
        List<RepairClose> result = repairCloseMapper.selectList(null);
        return result;
    }
}
