package com.dji.sample.wayline.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dji.sample.wayline.dao.IWaylineBreakPointMapper;
import com.dji.sample.wayline.model.entity.WaylineBreakPointEntity;
import com.dji.sample.wayline.service.IWaylineBreakPointService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author huiqing.jiang
 * @version 1.1
 * @date 2024/9/30
 */
@Service
@Transactional
@Slf4j
public class WaylineBreakPointServiceImpl implements IWaylineBreakPointService {

    @Autowired
    private IWaylineBreakPointMapper mapper;

    @Override
    public void insert(WaylineBreakPointEntity entity) {
        mapper.insert(entity);
    }

    @Override
    public WaylineBreakPointEntity selByJobId(String jobId) {
        LambdaQueryWrapper<WaylineBreakPointEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(WaylineBreakPointEntity::getFlightId,jobId)
                .orderByDesc(WaylineBreakPointEntity::getCreateTime);
        List<WaylineBreakPointEntity> list = mapper.selectList(wrapper);
        if(list.size() > 0) {
            return list.get(0);
        }
        return null;
    }



}
