package com.zcloud.domain.gatewayimpl;

import com.zcloud.domain.domain.gateway.ProjectTaskScoreInfoGateway;
import com.zcloud.domain.domain.model.ProjectTaskScoreInfoE;
import com.zcloud.domain.persistence.dataobject.ProjectTaskScoreInfoDO;
import com.zcloud.domain.persistence.repository.ProjectTaskScoreInfoRepository;
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:45
 */
@Service
@AllArgsConstructor
public class ProjectTaskScoreInfoGatewayImpl implements ProjectTaskScoreInfoGateway {
    private final ProjectTaskScoreInfoRepository projectTaskScoreInfoRepository;

    @Override
    public Boolean add(ProjectTaskScoreInfoE projectTaskScoreInfoE) {
        ProjectTaskScoreInfoDO d = new ProjectTaskScoreInfoDO();
        BeanUtils.copyProperties(projectTaskScoreInfoE, d);
        projectTaskScoreInfoRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(ProjectTaskScoreInfoE projectTaskScoreInfoE) {
        ProjectTaskScoreInfoDO d = new ProjectTaskScoreInfoDO();
        BeanUtils.copyProperties(projectTaskScoreInfoE, d);
        projectTaskScoreInfoRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedProjectTaskScoreInfoById(Long id) {
        return projectTaskScoreInfoRepository.removeById(id);
    }

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

