package com.zcloud.domain.gatewayimpl;

import com.zcloud.domain.domain.gateway.ProjectTaskInfoGateway;
import com.zcloud.domain.domain.model.ProjectTaskInfoE;
import com.zcloud.domain.persistence.dataobject.ProjectTaskInfoDO;
import com.zcloud.domain.persistence.repository.ProjectTaskInfoRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author zhaokai
 * @Date 2026-01-27 11:30:29
 */
@Service
@AllArgsConstructor
public class ProjectTaskInfoGatewayImpl implements ProjectTaskInfoGateway {
    private final ProjectTaskInfoRepository projectTaskInfoRepository;

    @Override
    public Boolean add(ProjectTaskInfoE projectTaskInfoE) {
        ProjectTaskInfoDO d = new ProjectTaskInfoDO();
        BeanUtils.copyProperties(projectTaskInfoE, d);
        projectTaskInfoRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(ProjectTaskInfoE projectTaskInfoE) {
        ProjectTaskInfoDO d = new ProjectTaskInfoDO();
        BeanUtils.copyProperties(projectTaskInfoE, d);
        projectTaskInfoRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedProjectTaskInfoById(Long id) {
        return projectTaskInfoRepository.removeById(id);
    }

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

