package com.corewing.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corewing.app.entity.SiriusFirmware;
import com.corewing.app.mapper.SiriusFirmwareMapper;
import com.corewing.app.service.SiriusFirmwareService;
import org.springframework.stereotype.Service;

/**
 * Sirius固件信息 Service 实现类
 */
@Service
public class SiriusFirmwareServiceImpl extends ServiceImpl<SiriusFirmwareMapper, SiriusFirmware> implements SiriusFirmwareService {

    @Override
    public SiriusFirmware getLatestByTypeAndProtocol(Integer firmwareType, Integer protocolType) {
        LambdaQueryWrapper<SiriusFirmware> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SiriusFirmware::getFirmwareType, firmwareType);
        wrapper.eq(SiriusFirmware::getProtocolType, protocolType);
        wrapper.orderByDesc(SiriusFirmware::getCreateTime);
        wrapper.last("LIMIT 1");
        return getOne(wrapper);
    }
}
