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.client.permeate.server.mapping.LazyInternalNetworkClientPermeateServerMapping;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.client.permeate.server.mapping.LazyInternalNetworkClientPermeateServerMappingRepository;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.converter.LazyInternalNetworkClientPermeateServerMappingConverter;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.entity.LazyInternalNetworkClientPermeateServerMappingDO;
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 09:26 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence 
 **/
@Repository
public class LazyInternalNetworkClientPermeateServerMappingRepositoryImpl  implements  LazyInternalNetworkClientPermeateServerMappingRepository {

    @Resource
    LazyLambdaStream lazyLambdaStream;

    /**
     * describe 新增客户端渗透服务端映射
     *
     * @param lazyInternalNetworkClientPermeateServerMapping 新增客户端渗透服务端映射     
     * @return {@link Result<LazyInternalNetworkClientPermeateServerMapping>} 客户端渗透服务端映射新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<LazyInternalNetworkClientPermeateServerMapping> story(LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMapping) {
        LazyInternalNetworkClientPermeateServerMappingDO lazyInternalNetworkClientPermeateServerMappingDO = LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateServerMapping(lazyInternalNetworkClientPermeateServerMapping);
        lazyLambdaStream.upsert(lazyInternalNetworkClientPermeateServerMappingDO);
        return ResultFactory.successOf();
    }

    /**
     * describe 批量新增客户端渗透服务端映射
     *
     * @param lazyInternalNetworkClientPermeateServerMappingList 批量新增客户端渗透服务端映射     
     * @return {@link Result<List<LazyInternalNetworkClientPermeateServerMapping>>} 客户端渗透服务端映射新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<List<LazyInternalNetworkClientPermeateServerMapping>> batchStory(List<LazyInternalNetworkClientPermeateServerMapping> lazyInternalNetworkClientPermeateServerMappingList) {
        List<LazyInternalNetworkClientPermeateServerMappingDO> lazyInternalNetworkClientPermeateServerMappingDOList = lazyInternalNetworkClientPermeateServerMappingList.stream().map(LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE::fromLazyInternalNetworkClientPermeateServerMapping).collect(Collectors.toList());
        lazyLambdaStream.upsert(lazyInternalNetworkClientPermeateServerMappingDOList);
        return ResultFactory.successOf();
    }

    /**
     * describe 查询单个客户端渗透服务端映射
     *
     * @param lazyInternalNetworkClientPermeateServerMapping 查询单个客户端渗透服务端映射     
     * @return {@link Result<LazyInternalNetworkClientPermeateServerMapping>} 客户端渗透服务端映射领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<LazyInternalNetworkClientPermeateServerMapping> findOne(LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMapping) {
        LazyInternalNetworkClientPermeateServerMappingDO lazyInternalNetworkClientPermeateServerMappingDO = LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateServerMapping(lazyInternalNetworkClientPermeateServerMapping);
        LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMappingOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateServerMappingDO), LazyInternalNetworkClientPermeateServerMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkClientPermeateServerMappingOne);
    }

    /**
     * describe 查询多个客户端渗透服务端映射
     *
     * @param lazyInternalNetworkClientPermeateServerMapping 查询多个客户端渗透服务端映射     
     * @return {@link Result<List<LazyInternalNetworkClientPermeateServerMapping>>} 客户端渗透服务端映射领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<List<LazyInternalNetworkClientPermeateServerMapping>> findList(LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMapping) {
        LazyInternalNetworkClientPermeateServerMappingDO lazyInternalNetworkClientPermeateServerMappingDO = LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateServerMapping(lazyInternalNetworkClientPermeateServerMapping);
        List<LazyInternalNetworkClientPermeateServerMapping> lazyInternalNetworkClientPermeateServerMappingList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateServerMappingDO), LazyInternalNetworkClientPermeateServerMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkClientPermeateServerMappingList);
    }

    /**
     * describe 分页查询多个客户端渗透服务端映射
     *
     * @param size 当前页数
     * @param current 当前页
     * @param lazyInternalNetworkClientPermeateServerMapping 分页查询多个客户端渗透服务端映射     
     * @return {@link Result<LazyPage<LazyInternalNetworkClientPermeateServerMapping>>} 分页客户端渗透服务端映射领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<LazyPage<LazyInternalNetworkClientPermeateServerMapping>> findPage(int size,int current,LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMapping) {
        LazyInternalNetworkClientPermeateServerMappingDO lazyInternalNetworkClientPermeateServerMappingDO = LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateServerMapping(lazyInternalNetworkClientPermeateServerMapping);
        LazyPage<LazyInternalNetworkClientPermeateServerMapping> lazyPage = new LazyPage<>(current,size);
        LazyPage<LazyInternalNetworkClientPermeateServerMapping> lazyInternalNetworkClientPermeateServerMappingLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateServerMappingDO),lazyPage, LazyInternalNetworkClientPermeateServerMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkClientPermeateServerMappingLazyPage);
    }

    /**
     * describe 删除客户端渗透服务端映射
     *
     * @param lazyInternalNetworkClientPermeateServerMapping 删除客户端渗透服务端映射     
     * @return {@link Result<LazyInternalNetworkClientPermeateServerMapping>} 客户端渗透服务端映射     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<LazyInternalNetworkClientPermeateServerMapping> remove(LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMapping) {
        LazyInternalNetworkClientPermeateServerMappingDO lazyInternalNetworkClientPermeateServerMappingDO = LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateServerMapping(lazyInternalNetworkClientPermeateServerMapping);
        lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateServerMappingDO));
        return ResultFactory.successOf();
    }

    /**
     * describe 是否存在客户端渗透服务端映射
     *
     * @param lazyInternalNetworkClientPermeateServerMapping 客户端渗透服务端映射领域对象     
     * @return {@link Result<Boolean>} 是否存在 true 存在，false 不存在     
     
     * @author Jia wei Wu
     * @date 2024/09/17 09:26 晚上
     **/

    @Override
    public Result<Boolean> exists(LazyInternalNetworkClientPermeateServerMapping lazyInternalNetworkClientPermeateServerMapping) {
        LazyInternalNetworkClientPermeateServerMappingDO lazyInternalNetworkClientPermeateServerMappingDO = LazyInternalNetworkClientPermeateServerMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateServerMapping(lazyInternalNetworkClientPermeateServerMapping);
        Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateServerMappingDO));
        return ResultFactory.successOf(exists);
    }

}