package com.yuchen.saas.park.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yuchen.saas.park.api.entity.park.PmgBatRfidInfo;
import com.yuchen.saas.park.service.service.PmgBatRfidInfoService;
import com.yuchen.saas.park.service.mapper.PmgBatRfidInfoMapper;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * RFID标签管理表 业务层
 */
@Service
public class PmgBatRfidInfoServiceImpl extends BaseServiceImpl<PmgBatRfidInfoMapper, PmgBatRfidInfo> implements PmgBatRfidInfoService {

    @Override
    public List<String> getEpc() {
        return baseMapper.getEpc();
    }

    @Override
    public boolean existEpc(String epc) {
        return baseMapper.selectCount(new LambdaQueryWrapper<PmgBatRfidInfo>().eq(PmgBatRfidInfo::getEpc, epc)
                .eq(PmgBatRfidInfo::getIsDeleted, 0).last("limit 1")
        ) > 0;
    }

    @Override
    public PmgBatRfidInfo getByEpc(String epc) {
        PmgBatRfidInfo pmgBatRfidInfo = getOne(Wrappers.<PmgBatRfidInfo>query().lambda()
                .eq(PmgBatRfidInfo::getEpc,epc).eq(PmgBatRfidInfo::getEpc, 0));
        return pmgBatRfidInfo;
    }
}
