package org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.persistence;

import jakarta.annotation.Resource;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.internal.network.server.permeate.mapping.LazyInternalNetworkServerPermeateMapping;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.internal.network.server.permeate.mapping.LazyInternalNetworkServerPermeateMappingRepository;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.converter.LazyInternalNetworkServerPermeateMappingConverter;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.entity.LazyInternalNetworkServerPermeateMappingDO;
import org.springframework.stereotype.Repository;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
import org.wu.framework.lazy.orm.database.lambda.stream.wrapper.LazyWrappers;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;

import java.util.List;
import java.util.stream.Collectors;
/**
 * describe 服务端网络渗透映射 
 *
 * @author Jia wei Wu
 * @date 2024/09/17 01:35 下午
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence 
 **/
@Repository
public class LazyInternalNetworkServerPermeateMappingRepositoryImpl  implements  LazyInternalNetworkServerPermeateMappingRepository {

    @Resource
    LazyLambdaStream lazyLambdaStream;

    /**
     * describe 新增服务端网络渗透映射
     *
     * @param lazyInternalNetworkServerPermeateMapping 新增服务端网络渗透映射     
     * @return {@link Result<LazyInternalNetworkServerPermeateMapping>} 服务端网络渗透映射新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<LazyInternalNetworkServerPermeateMapping> story(LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMapping) {
        LazyInternalNetworkServerPermeateMappingDO lazyInternalNetworkServerPermeateMappingDO = LazyInternalNetworkServerPermeateMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateMapping);
        lazyLambdaStream.upsert(lazyInternalNetworkServerPermeateMappingDO);
        return ResultFactory.successOf();
    }

    /**
     * describe 批量新增服务端网络渗透映射
     *
     * @param lazyInternalNetworkServerPermeateMappingList 批量新增服务端网络渗透映射     
     * @return {@link Result<List<LazyInternalNetworkServerPermeateMapping>>} 服务端网络渗透映射新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<List<LazyInternalNetworkServerPermeateMapping>> batchStory(List<LazyInternalNetworkServerPermeateMapping> lazyInternalNetworkServerPermeateMappingList) {
        List<LazyInternalNetworkServerPermeateMappingDO> lazyInternalNetworkServerPermeateMappingDOList = lazyInternalNetworkServerPermeateMappingList.stream().map(LazyInternalNetworkServerPermeateMappingConverter.INSTANCE::fromLazyInternalNetworkServerPermeateMapping).collect(Collectors.toList());
        lazyLambdaStream.upsert(lazyInternalNetworkServerPermeateMappingDOList);
        return ResultFactory.successOf();
    }

    /**
     * describe 查询单个服务端网络渗透映射
     *
     * @param lazyInternalNetworkServerPermeateMapping 查询单个服务端网络渗透映射     
     * @return {@link Result<LazyInternalNetworkServerPermeateMapping>} 服务端网络渗透映射领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<LazyInternalNetworkServerPermeateMapping> findOne(LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMapping) {
        LazyInternalNetworkServerPermeateMappingDO lazyInternalNetworkServerPermeateMappingDO = LazyInternalNetworkServerPermeateMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateMapping);
        LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMappingOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateMappingDO), LazyInternalNetworkServerPermeateMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkServerPermeateMappingOne);
    }

    /**
     * describe 查询多个服务端网络渗透映射
     *
     * @param lazyInternalNetworkServerPermeateMapping 查询多个服务端网络渗透映射     
     * @return {@link Result<List<LazyInternalNetworkServerPermeateMapping>>} 服务端网络渗透映射领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<List<LazyInternalNetworkServerPermeateMapping>> findList(LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMapping) {
        LazyInternalNetworkServerPermeateMappingDO lazyInternalNetworkServerPermeateMappingDO = LazyInternalNetworkServerPermeateMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateMapping);
        List<LazyInternalNetworkServerPermeateMapping> lazyInternalNetworkServerPermeateMappingList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateMappingDO), LazyInternalNetworkServerPermeateMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkServerPermeateMappingList);
    }

    /**
     * describe 分页查询多个服务端网络渗透映射
     *
     * @param size 当前页数
     * @param current 当前页
     * @param lazyInternalNetworkServerPermeateMapping 分页查询多个服务端网络渗透映射     
     * @return {@link Result<LazyPage<LazyInternalNetworkServerPermeateMapping>>} 分页服务端网络渗透映射领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<LazyPage<LazyInternalNetworkServerPermeateMapping>> findPage(int size,int current,LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMapping) {
        LazyInternalNetworkServerPermeateMappingDO lazyInternalNetworkServerPermeateMappingDO = LazyInternalNetworkServerPermeateMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateMapping);
        LazyPage<LazyInternalNetworkServerPermeateMapping> lazyPage = new LazyPage<>(current,size);
        LazyPage<LazyInternalNetworkServerPermeateMapping> lazyInternalNetworkServerPermeateMappingLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateMappingDO),lazyPage, LazyInternalNetworkServerPermeateMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkServerPermeateMappingLazyPage);
    }

    /**
     * describe 删除服务端网络渗透映射
     *
     * @param lazyInternalNetworkServerPermeateMapping 删除服务端网络渗透映射     
     * @return {@link Result<LazyInternalNetworkServerPermeateMapping>} 服务端网络渗透映射     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<LazyInternalNetworkServerPermeateMapping> remove(LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMapping) {
        LazyInternalNetworkServerPermeateMappingDO lazyInternalNetworkServerPermeateMappingDO = LazyInternalNetworkServerPermeateMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateMapping);
        lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateMappingDO));
        return ResultFactory.successOf();
    }

    /**
     * describe 是否存在服务端网络渗透映射
     *
     * @param lazyInternalNetworkServerPermeateMapping 服务端网络渗透映射领域对象     
     * @return {@link Result<Boolean>} 是否存在 true 存在，false 不存在     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:35 下午
     **/

    @Override
    public Result<Boolean> exists(LazyInternalNetworkServerPermeateMapping lazyInternalNetworkServerPermeateMapping) {
        LazyInternalNetworkServerPermeateMappingDO lazyInternalNetworkServerPermeateMappingDO = LazyInternalNetworkServerPermeateMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateMapping);
        Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateMappingDO));
        return ResultFactory.successOf(exists);
    }

}