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.RepairRefundRecordMapper;
import com.repair.model.pojo.RepairRefundRecord;
import com.repair.model.result.PageUtils;
import com.repair.services.RepairRefundRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2023-07-20
 */
@Service
public class RepairRefundRecordServiceImpl extends ServiceImpl<RepairRefundRecordMapper, RepairRefundRecord> implements RepairRefundRecordService {

    @Autowired
    private RepairRefundRecordMapper repairRefundRecordMapper;

    @Override
    public int insertRepairRefundRecord(RepairRefundRecord rc) {
        int result = repairRefundRecordMapper.insert(rc);
        return result;
    }

    @Override
    public int updateRepairRefundRecord(RepairRefundRecord rc) {
        int result = repairRefundRecordMapper.updateById(rc);
        return result;
    }

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

    @Override
    public int deleteRepairRefundRecordById(int id) {
        int result = repairRefundRecordMapper.deleteById(id);
        return result;
    }

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

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

    @Override
    public List<RepairRefundRecord> getRepairsByStatu() {
        QueryWrapper<RepairRefundRecord> queryWrapper = new QueryWrapper<>();
        List<RepairRefundRecord> result = repairRefundRecordMapper.selectList(queryWrapper);
        return result;
    }
}
