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

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuchen.saas.park.api.entity.park.PmgBatHandlerWarning;
import com.yuchen.saas.park.service.mapper.PmgBatHandlerWarningMapper;
import com.yuchen.saas.park.service.service.IHandlerWarningService;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 吕海泉
 * @ClassName HandlerWarningServiceImpl
 * @Description
 * @Date 2021/4/7 15:48
 * @Version 1.0
 **/
@Service
public class HandlerWarningServiceImpl extends BaseServiceImpl<PmgBatHandlerWarningMapper, PmgBatHandlerWarning> implements IHandlerWarningService {
    @Override
    public List<PmgBatHandlerWarning> getByPkAndPn(String productKey, String productName) {
        return baseMapper.getByPkAndPnV(productKey, productName);
    }

    @Override
    public PmgBatHandlerWarning getHandlerResult(String productKey, String productName) {
        LambdaQueryWrapper<PmgBatHandlerWarning> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PmgBatHandlerWarning::getProductKey, productKey)
                .eq(PmgBatHandlerWarning::getProductName, productName)
                .orderByDesc(PmgBatHandlerWarning::getCreateTime)
                .last("LIMIT 1");
        return getOne(queryWrapper);
    }
}


