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.AEquipmentLedger;
import com.zksy.property.service.AEquipmentLedgerService;
import com.zksy.property.mapper.AEquipmentLedgerMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【e_equipment_ledger(设备台账表)】的数据库操作Service实现
* @createDate 2025-07-02 10:56:46
*/
@Service
public class AEquipmentLedgerServiceImpl extends ServiceImpl<AEquipmentLedgerMapper, AEquipmentLedger>
    implements AEquipmentLedgerService {

    @Override
    public Page<AEquipmentLedger> findByPage(long pageNum, long pageSize, String equipmentId, String equipmentName, String equipmentType, String activeState) {
        Page<AEquipmentLedger> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<AEquipmentLedger> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(equipmentId != null,AEquipmentLedger::getEquipmentId,equipmentId);
        queryWrapper.like(equipmentName != null,AEquipmentLedger::getEquipmentName,equipmentName);
        queryWrapper.like(equipmentType != null,AEquipmentLedger::getEquipmentType,equipmentType);
        queryWrapper.like(activeState != null,AEquipmentLedger::getActiveState,activeState);
        queryWrapper.orderByDesc(AEquipmentLedger::getUpdateTime);
        Page<AEquipmentLedger> page1 = this.page(page, queryWrapper);
        return page1;
    }

    @Override
    public List<AEquipmentLedger> getAEquipmentLedgerList(String equipmentId, String equipmentName, String equipmentType, String activeState) {
        LambdaQueryWrapper<AEquipmentLedger> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(equipmentId != null,AEquipmentLedger::getEquipmentId,equipmentId);
        queryWrapper.like(equipmentName != null,AEquipmentLedger::getEquipmentName,equipmentName);
        queryWrapper.like(equipmentType != null,AEquipmentLedger::getEquipmentType,equipmentType);
        queryWrapper.like(activeState != null,AEquipmentLedger::getActiveState,activeState);
        queryWrapper.orderByDesc(AEquipmentLedger::getUpdateTime);
        List<AEquipmentLedger> list = this.list(queryWrapper);
        return list;
    }
}




