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.client.mapping.LazyInternalNetworkClientPermeateClientMapping;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.client.permeate.client.mapping.LazyInternalNetworkClientPermeateClientMappingRepository;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.converter.LazyInternalNetworkClientPermeateClientMappingConverter;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.entity.LazyInternalNetworkClientPermeateClientMappingDO;
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:55 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence 
 **/
@Repository
public class LazyInternalNetworkClientPermeateClientMappingRepositoryImpl  implements  LazyInternalNetworkClientPermeateClientMappingRepository {

    @Resource
    LazyLambdaStream lazyLambdaStream;

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

    @Override
    public Result<LazyInternalNetworkClientPermeateClientMapping> story(LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMapping) {
        LazyInternalNetworkClientPermeateClientMappingDO lazyInternalNetworkClientPermeateClientMappingDO = LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateClientMapping(lazyInternalNetworkClientPermeateClientMapping);
        lazyLambdaStream.upsert(lazyInternalNetworkClientPermeateClientMappingDO);
        return ResultFactory.successOf();
    }

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

    @Override
    public Result<List<LazyInternalNetworkClientPermeateClientMapping>> batchStory(List<LazyInternalNetworkClientPermeateClientMapping> lazyInternalNetworkClientPermeateClientMappingList) {
        List<LazyInternalNetworkClientPermeateClientMappingDO> lazyInternalNetworkClientPermeateClientMappingDOList = lazyInternalNetworkClientPermeateClientMappingList.stream().map(LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE::fromLazyInternalNetworkClientPermeateClientMapping).collect(Collectors.toList());
        lazyLambdaStream.upsert(lazyInternalNetworkClientPermeateClientMappingDOList);
        return ResultFactory.successOf();
    }

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

    @Override
    public Result<LazyInternalNetworkClientPermeateClientMapping> findOne(LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMapping) {
        LazyInternalNetworkClientPermeateClientMappingDO lazyInternalNetworkClientPermeateClientMappingDO = LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateClientMapping(lazyInternalNetworkClientPermeateClientMapping);
        LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMappingOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateClientMappingDO), LazyInternalNetworkClientPermeateClientMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkClientPermeateClientMappingOne);
    }

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

    @Override
    public Result<List<LazyInternalNetworkClientPermeateClientMapping>> findList(LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMapping) {
        LazyInternalNetworkClientPermeateClientMappingDO lazyInternalNetworkClientPermeateClientMappingDO = LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateClientMapping(lazyInternalNetworkClientPermeateClientMapping);
        List<LazyInternalNetworkClientPermeateClientMapping> lazyInternalNetworkClientPermeateClientMappingList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateClientMappingDO), LazyInternalNetworkClientPermeateClientMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkClientPermeateClientMappingList);
    }

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

    @Override
    public Result<LazyPage<LazyInternalNetworkClientPermeateClientMapping>> findPage(int size,int current,LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMapping) {
        LazyInternalNetworkClientPermeateClientMappingDO lazyInternalNetworkClientPermeateClientMappingDO = LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateClientMapping(lazyInternalNetworkClientPermeateClientMapping);
        LazyPage<LazyInternalNetworkClientPermeateClientMapping> lazyPage = new LazyPage<>(current,size);
        LazyPage<LazyInternalNetworkClientPermeateClientMapping> lazyInternalNetworkClientPermeateClientMappingLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateClientMappingDO),lazyPage, LazyInternalNetworkClientPermeateClientMapping.class);
        return ResultFactory.successOf(lazyInternalNetworkClientPermeateClientMappingLazyPage);
    }

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

    @Override
    public Result<LazyInternalNetworkClientPermeateClientMapping> remove(LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMapping) {
        LazyInternalNetworkClientPermeateClientMappingDO lazyInternalNetworkClientPermeateClientMappingDO = LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateClientMapping(lazyInternalNetworkClientPermeateClientMapping);
        lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateClientMappingDO));
        return ResultFactory.successOf();
    }

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

    @Override
    public Result<Boolean> exists(LazyInternalNetworkClientPermeateClientMapping lazyInternalNetworkClientPermeateClientMapping) {
        LazyInternalNetworkClientPermeateClientMappingDO lazyInternalNetworkClientPermeateClientMappingDO = LazyInternalNetworkClientPermeateClientMappingConverter.INSTANCE.fromLazyInternalNetworkClientPermeateClientMapping(lazyInternalNetworkClientPermeateClientMapping);
        Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(lazyInternalNetworkClientPermeateClientMappingDO));
        return ResultFactory.successOf(exists);
    }

}