package com.sptg.device.biz.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sptg.common.core.constant.OperationConstant;
import com.sptg.device.api.entity.FlowCardDevice;
import com.sptg.device.biz.mapper.FlowCardDeviceMapper;
import com.sptg.device.biz.service.FlowCardDeviceServiceInterface;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;



@Service
@AllArgsConstructor
public class FlowCardDeviceServiceImpl extends ServiceImpl<FlowCardDeviceMapper, FlowCardDevice> implements FlowCardDeviceServiceInterface {

    @Override
    public List<FlowCardDevice> getList(FlowCardDevice flowCardDevice) {
        Wrapper<FlowCardDevice> wrapper = new EntityWrapper<>();
        wrapper.eq("i_status", OperationConstant.ZERO);
        return this.selectList(wrapper);
    }

    @Override
    public FlowCardDevice getOne(FlowCardDevice flowCardDevice) {
        Wrapper<FlowCardDevice> wrapper = new EntityWrapper<>();
        wrapper.eq("i_status",OperationConstant.ZERO);
        if (flowCardDevice.getFlowCardId() != null){
            wrapper.eq("l_id",flowCardDevice.getFlowCardId());
        }
        return this.selectOne(wrapper);
    }
}
