package com.agileboot.domain.collaboration.record.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * @author codex
 */
@Service
public class CollaborationFileServiceImpl
    extends ServiceImpl<CollaborationFileMapper, CollaborationFileEntity>
    implements CollaborationFileService {

    @Override
    public List<CollaborationFileEntity> listByRecordId(Long recordId) {
        if (recordId == null) {
            return Collections.emptyList();
        }
        return list(new QueryWrapper<CollaborationFileEntity>()
            .eq("record_id", recordId)
            .orderByAsc("file_type", "sort_order"));
    }

    @Override
    public void removeByRecordIds(Collection<Long> recordIds) {
        if (recordIds == null || recordIds.isEmpty()) {
            return;
        }
        remove(new QueryWrapper<CollaborationFileEntity>().in("record_id", recordIds));
    }

}
