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 CollaborationSettlementServiceImpl
    extends ServiceImpl<CollaborationSettlementMapper, CollaborationSettlementEntity>
    implements CollaborationSettlementService {

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

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

}
