package com.fdkankan.modeling.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fdkankan.modeling.entity.SceneFileBuild;
import com.fdkankan.modeling.mapper.ISceneFileBuildMapper;
import com.fdkankan.modeling.service.ISceneFileBuildService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 场景文件建模表 服务实现类
 * </p>
 *
 * @author dengsixing
 * @since 2021-12-23
 */
@Service
public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper, SceneFileBuild> implements ISceneFileBuildService {

    @Override
    public SceneFileBuild findByFileId(String fileId) {
        QueryWrapper<SceneFileBuild> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SceneFileBuild::getFileId,fileId);
        queryWrapper.lambda().eq(SceneFileBuild::getRecStatus,"A");
        queryWrapper.lambda().orderByDesc(SceneFileBuild::getCreateTime);
        queryWrapper.last("LIMIT 1");
        List<SceneFileBuild> list = this.list(queryWrapper);
        if(list == null || list.size() <=0){
            return null;
        }
        return list.get(0);
    }

}
