package com.zcloud.domain.gatewayimpl;

import com.zcloud.domain.domain.gateway.ProjectTaskGroupUserGateway;
import com.zcloud.domain.domain.model.ProjectTaskGroupUserE;
import com.zcloud.domain.persistence.dataobject.ProjectTaskGroupUserDO;
import com.zcloud.domain.persistence.repository.ProjectTaskGroupUserRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * web-infrastructure
 *
 * @Author zhaokai
 * @Date 2026-01-29 11:28:09
 */
@Service
@AllArgsConstructor
public class ProjectTaskGroupUserGatewayImpl implements ProjectTaskGroupUserGateway {
    private final ProjectTaskGroupUserRepository projectTaskGroupUserRepository;

    @Override
    public Boolean add(ProjectTaskGroupUserE projectTaskGroupUserE) {
        ProjectTaskGroupUserDO d = new ProjectTaskGroupUserDO();
        BeanUtils.copyProperties(projectTaskGroupUserE, d);
        projectTaskGroupUserRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(ProjectTaskGroupUserE projectTaskGroupUserE) {
        ProjectTaskGroupUserDO d = new ProjectTaskGroupUserDO();
        BeanUtils.copyProperties(projectTaskGroupUserE, d);
        projectTaskGroupUserRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedProjectTaskGroupUserById(Long id) {
        return projectTaskGroupUserRepository.removeById(id);
    }

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

}

