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.port.pool.LazyNettyServerPermeatePortPool;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolRepository;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.converter.LazyNettyServerPermeatePortPoolConverter;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.infrastructure.entity.LazyNettyServerPermeatePortPoolDO;
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:26 夜间
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence 
 **/
@Repository
public class LazyNettyServerPermeatePortPoolRepositoryImpl  implements  LazyNettyServerPermeatePortPoolRepository {

    @Resource
    LazyLambdaStream lazyLambdaStream;

    /**
     * describe 新增服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPool 新增服务端内网渗透端口池     
     * @return {@link Result<LazyNettyServerPermeatePortPool>} 服务端内网渗透端口池新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<LazyNettyServerPermeatePortPool> story(LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool) {
        LazyNettyServerPermeatePortPoolDO lazyNettyServerPermeatePortPoolDO = LazyNettyServerPermeatePortPoolConverter.INSTANCE.fromLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPool);
        lazyLambdaStream.upsert(lazyNettyServerPermeatePortPoolDO);
        return ResultFactory.successOf();
    }

    /**
     * describe 批量新增服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPoolList 批量新增服务端内网渗透端口池     
     * @return {@link Result<List<LazyNettyServerPermeatePortPool>>} 服务端内网渗透端口池新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<List<LazyNettyServerPermeatePortPool>> batchStory(List<LazyNettyServerPermeatePortPool> lazyNettyServerPermeatePortPoolList) {
        List<LazyNettyServerPermeatePortPoolDO> lazyNettyServerPermeatePortPoolDOList = lazyNettyServerPermeatePortPoolList.stream().map(LazyNettyServerPermeatePortPoolConverter.INSTANCE::fromLazyNettyServerPermeatePortPool).collect(Collectors.toList());
        lazyLambdaStream.upsert(lazyNettyServerPermeatePortPoolDOList);
        return ResultFactory.successOf();
    }

    /**
     * describe 查询单个服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPool 查询单个服务端内网渗透端口池     
     * @return {@link Result<LazyNettyServerPermeatePortPool>} 服务端内网渗透端口池领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<LazyNettyServerPermeatePortPool> findOne(LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool) {
        LazyNettyServerPermeatePortPoolDO lazyNettyServerPermeatePortPoolDO = LazyNettyServerPermeatePortPoolConverter.INSTANCE.fromLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPool);
        LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPoolOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(lazyNettyServerPermeatePortPoolDO), LazyNettyServerPermeatePortPool.class);
        return ResultFactory.successOf(lazyNettyServerPermeatePortPoolOne);
    }

    /**
     * describe 查询多个服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPool 查询多个服务端内网渗透端口池     
     * @return {@link Result<List<LazyNettyServerPermeatePortPool>>} 服务端内网渗透端口池领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<List<LazyNettyServerPermeatePortPool>> findList(LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool) {
        LazyNettyServerPermeatePortPoolDO lazyNettyServerPermeatePortPoolDO = LazyNettyServerPermeatePortPoolConverter.INSTANCE.fromLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPool);
        List<LazyNettyServerPermeatePortPool> lazyNettyServerPermeatePortPoolList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(lazyNettyServerPermeatePortPoolDO), LazyNettyServerPermeatePortPool.class);
        return ResultFactory.successOf(lazyNettyServerPermeatePortPoolList);
    }

    /**
     * describe 分页查询多个服务端内网渗透端口池
     *
     * @param size 当前页数
     * @param current 当前页
     * @param lazyNettyServerPermeatePortPool 分页查询多个服务端内网渗透端口池     
     * @return {@link Result<LazyPage<LazyNettyServerPermeatePortPool>>} 分页服务端内网渗透端口池领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<LazyPage<LazyNettyServerPermeatePortPool>> findPage(int size,int current,LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool) {
        LazyNettyServerPermeatePortPoolDO lazyNettyServerPermeatePortPoolDO = LazyNettyServerPermeatePortPoolConverter.INSTANCE.fromLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPool);
        LazyPage<LazyNettyServerPermeatePortPool> lazyPage = new LazyPage<>(current,size);
        LazyPage<LazyNettyServerPermeatePortPool> lazyNettyServerPermeatePortPoolLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(lazyNettyServerPermeatePortPoolDO),lazyPage, LazyNettyServerPermeatePortPool.class);
        return ResultFactory.successOf(lazyNettyServerPermeatePortPoolLazyPage);
    }

    /**
     * describe 删除服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPool 删除服务端内网渗透端口池     
     * @return {@link Result<LazyNettyServerPermeatePortPool>} 服务端内网渗透端口池     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<LazyNettyServerPermeatePortPool> remove(LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool) {
        LazyNettyServerPermeatePortPoolDO lazyNettyServerPermeatePortPoolDO = LazyNettyServerPermeatePortPoolConverter.INSTANCE.fromLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPool);
        lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(lazyNettyServerPermeatePortPoolDO));
        return ResultFactory.successOf();
    }

    /**
     * describe 是否存在服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPool 服务端内网渗透端口池领域对象     
     * @return {@link Result<Boolean>} 是否存在 true 存在，false 不存在     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<Boolean> exists(LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool) {
        LazyNettyServerPermeatePortPoolDO lazyNettyServerPermeatePortPoolDO = LazyNettyServerPermeatePortPoolConverter.INSTANCE.fromLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPool);
        Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(lazyNettyServerPermeatePortPoolDO));
        return ResultFactory.successOf(exists);
    }

}