package com.zcloud.basic.info.gatewayimpl;

import com.zcloud.basic.info.domain.gateway.UserJobHandoverGateway;
import com.zcloud.basic.info.domain.model.UserJobHandoverE;
import com.zcloud.basic.info.persistence.dataobject.UserJobHandoverDO;
import com.zcloud.basic.info.persistence.repository.UserJobHandoverRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

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

/**
 * web-infrastructure
 *
 * @Author SondonYong
 * @Date 2025-12-02 14:08:56
 */
@Service
@AllArgsConstructor
public class UserJobHandoverGatewayImpl implements UserJobHandoverGateway {
    private final UserJobHandoverRepository userJobHandoverRepository;

    @Override
    public Boolean add(UserJobHandoverE userJobHandoverE) {
        UserJobHandoverDO d = new UserJobHandoverDO();
        BeanUtils.copyProperties(userJobHandoverE, d);
        userJobHandoverRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(UserJobHandoverE userJobHandoverE) {
        UserJobHandoverDO d = new UserJobHandoverDO();
        BeanUtils.copyProperties(userJobHandoverE, d);
        userJobHandoverRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedUserJobHandoverById(Long id) {
        return userJobHandoverRepository.removeById(id);
    }

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


}

