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.netty.server.permeate.server.mapping.LazyInternalNetworkServerPermeateServerMapping;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.server.permeate.server.mapping.LazyInternalNetworkServerPermeateServerMappingRepository;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.converter.LazyInternalNetworkServerPermeateServerMappingConverter;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.entity.LazyInternalNetworkServerPermeateServerMappingDO;
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 LazyInternalNetworkServerPermeateServerMappingRepositoryImpl implements LazyInternalNetworkServerPermeateServerMappingRepository {

    @Resource
    LazyLambdaStream lazyLambdaStream;

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

    @Override
    public Result<LazyInternalNetworkServerPermeateServerMapping> story(LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMapping) {
        LazyInternalNetworkServerPermeateServerMappingDO lazyInternalNetworkServerPermeateServerMappingDO = LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateServerMapping);
        lazyLambdaStream.upsert(lazyInternalNetworkServerPermeateServerMappingDO);
        return ResultFactory.successOf();
    }

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

    @Override
    public Result<List<LazyInternalNetworkServerPermeateServerMapping>> batchStory(List<LazyInternalNetworkServerPermeateServerMapping> lazyInternalNetworkServerPermeateServerMappingList) {
        List<LazyInternalNetworkServerPermeateServerMappingDO> lazyInternalNetworkServerPermeateServerMappingDOList = lazyInternalNetworkServerPermeateServerMappingList.stream().map(LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE::fromLazyInternalNetworkServerPermeateMapping).collect(Collectors.toList());
        lazyLambdaStream.upsert(lazyInternalNetworkServerPermeateServerMappingDOList);
        return ResultFactory.successOf();
    }

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

    @Override
    public Result<LazyInternalNetworkServerPermeateServerMapping> findOne(LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMapping) {
        LazyInternalNetworkServerPermeateServerMappingDO lazyInternalNetworkServerPermeateServerMappingDO = LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateServerMapping);
        LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMappingOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateServerMappingDO), LazyInternalNetworkServerPermeateServerMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkServerPermeateServerMappingOne);
    }

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

    @Override
    public Result<List<LazyInternalNetworkServerPermeateServerMapping>> findList(LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMapping) {
        LazyInternalNetworkServerPermeateServerMappingDO lazyInternalNetworkServerPermeateServerMappingDO = LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateServerMapping);
        List<LazyInternalNetworkServerPermeateServerMapping> lazyInternalNetworkServerPermeateServerMappingList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateServerMappingDO), LazyInternalNetworkServerPermeateServerMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkServerPermeateServerMappingList);
    }

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

    @Override
    public Result<LazyPage<LazyInternalNetworkServerPermeateServerMapping>> findPage(int size, int current, LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMapping) {
        LazyInternalNetworkServerPermeateServerMappingDO lazyInternalNetworkServerPermeateServerMappingDO = LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateServerMapping);
        LazyPage<LazyInternalNetworkServerPermeateServerMapping> lazyPage = new LazyPage<>(current,size);
        LazyPage<LazyInternalNetworkServerPermeateServerMapping> lazyInternalNetworkServerPermeateMappingLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateServerMappingDO),lazyPage, LazyInternalNetworkServerPermeateServerMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkServerPermeateMappingLazyPage);
    }

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

    @Override
    public Result<LazyInternalNetworkServerPermeateServerMapping> remove(LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMapping) {
        LazyInternalNetworkServerPermeateServerMappingDO lazyInternalNetworkServerPermeateServerMappingDO = LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateServerMapping);
        lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateServerMappingDO));
        return ResultFactory.successOf();
    }

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

    @Override
    public Result<Boolean> exists(LazyInternalNetworkServerPermeateServerMapping lazyInternalNetworkServerPermeateServerMapping) {
        LazyInternalNetworkServerPermeateServerMappingDO lazyInternalNetworkServerPermeateServerMappingDO = LazyInternalNetworkServerPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkServerPermeateMapping(lazyInternalNetworkServerPermeateServerMapping);
        Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkServerPermeateServerMappingDO));
        return ResultFactory.successOf(exists);
    }

}