package com.zcloud.basic.info.gatewayimpl;

import com.zcloud.basic.info.domain.gateway.UserEmploymentLogGateway;
import com.zcloud.basic.info.domain.model.UserEmploymentLogE;
import com.zcloud.basic.info.persistence.dataobject.UserEmploymentLogDO;
import com.zcloud.basic.info.persistence.repository.UserEmploymentLogRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * web-infrastructure
 *
 * @Author zhangyue
 * @Date 2025-11-06 19:15:37
 */
@Service
@AllArgsConstructor
public class UserEmploymentLogGatewayImpl implements UserEmploymentLogGateway {
    private final UserEmploymentLogRepository userEmploymentLogRepository;

    @Override
    public Boolean add(UserEmploymentLogE userEmploymentLogE) {
        UserEmploymentLogDO d = new UserEmploymentLogDO();
        BeanUtils.copyProperties(userEmploymentLogE, d);
        userEmploymentLogRepository.save(d);
        return true;
    }

    @Override
    public Boolean update(UserEmploymentLogE userEmploymentLogE) {
        UserEmploymentLogDO d = new UserEmploymentLogDO();
        BeanUtils.copyProperties(userEmploymentLogE, d);
        userEmploymentLogRepository.updateById(d);
        return true;
    }

    @Override
    public Boolean deletedUserEmploymentLogById(Long id) {
        return userEmploymentLogRepository.removeById(id);
    }

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

