package com.zksy.property.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.property.domain.AMaintenanceRecords;
import com.zksy.property.mapper.AMaintenanceRecordsMapper;
import com.zksy.property.service.AMaintenanceRecordsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【a_maintenance_records(维护记录表)】的数据库操作Service实现
* @createDate 2025-07-14 11:59:44
*/
@Service
public class AMaintenanceRecordsServiceImpl extends ServiceImpl<AMaintenanceRecordsMapper, AMaintenanceRecords>
    implements AMaintenanceRecordsService{

    @Override
    public Page<AMaintenanceRecords> findByPage(long pageNum, long pageSize, String maintenanceDate, String maintenanceContent, String maintenanceType) {
        Page<AMaintenanceRecords> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<AMaintenanceRecords> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(maintenanceDate != null,AMaintenanceRecords::getMaintenanceDate,maintenanceDate);
        queryWrapper.like(maintenanceContent != null,AMaintenanceRecords::getMaintenanceContent,maintenanceContent);
        queryWrapper.like(maintenanceType != null,AMaintenanceRecords::getMaintenanceType,maintenanceType);
        return this.page(page, queryWrapper);
    }

    @Override
    public List<AMaintenanceRecords> getAMaintenanceRecordsList(String maintenanceDate, String maintenanceContent, String maintenanceType) {
        LambdaQueryWrapper<AMaintenanceRecords> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(maintenanceDate != null,AMaintenanceRecords::getMaintenanceDate,maintenanceDate);
        queryWrapper.like(maintenanceContent != null,AMaintenanceRecords::getMaintenanceContent,maintenanceContent);
        queryWrapper.like(maintenanceType != null,AMaintenanceRecords::getMaintenanceType,maintenanceType);
        return this.list(queryWrapper);
    }

    @Override
    public List<AMaintenanceRecords> getByDeviceId(String deviceId) {
        LambdaQueryWrapper<AMaintenanceRecords> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AMaintenanceRecords::getDeviceId,deviceId);
        return this.list(queryWrapper);
    }
}




