package com.zcloud.primeport.gatewayimpl;

import com.zcloud.primeport.domain.gateway.VideoGateway;
import com.zcloud.primeport.domain.model.VideoE;
import com.zcloud.primeport.persistence.dataobject.VideoDO;
import com.zcloud.primeport.persistence.repository.VideoRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:30
 */
@Service
@AllArgsConstructor
public class VideoGatewayImpl implements VideoGateway {
    private final VideoRepository videoRepository;

    @Override
    public Boolean add(VideoE videoE) {
        VideoDO d = new VideoDO();
        BeanUtils.copyProperties(videoE, d);
        videoRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(VideoE videoE) {
        VideoDO d = new VideoDO();
        BeanUtils.copyProperties(videoE, d);
        videoRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedVideoById(Long id) {
        return videoRepository.removeById(id);
    }

    @Override
    public Boolean deletedVideoByIds(Long[] ids) {
        return videoRepository.removeByIds(Collections.singletonList(ids));
    }
}

