package com.repair.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.repair.mapper.RepairSystemSettingMapper;
import com.repair.model.pojo.RepairSystemSetting;
import com.repair.services.RepairSystemSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ceshi
 * @since 2023-07-11
 */
@Service
public class RepairSystemSettingServiceImpl extends ServiceImpl<RepairSystemSettingMapper, RepairSystemSetting> implements RepairSystemSettingService {

    @Autowired
    private RepairSystemSettingMapper repairSystemSettingMapper;

    @Override
    public RepairSystemSetting queryRepairSystemSetting() {
        QueryWrapper<RepairSystemSetting> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("create_time");

        List<RepairSystemSetting> datas = repairSystemSettingMapper.selectList(wrapper);

        return datas.size() > 0 ? datas.get(0) : new RepairSystemSetting();
    }

    @Override
    public int insertRepairSystemSetting(RepairSystemSetting rss) {
        int result = repairSystemSettingMapper.insert(rss);
        return result;
    }

    @Override
    public int updateRepaiSystemSetting(RepairSystemSetting rss) {
        int result = repairSystemSettingMapper.updateById(rss);
        return result;
    }
}
