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 CollaborationExpenditureServiceImpl
    extends ServiceImpl<CollaborationExpenditureMapper, CollaborationExpenditureEntity>
    implements CollaborationExpenditureService {

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

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

}
