package org.framework.lazy.cloud.network.heartbeat.server.standalone.application.impl;

import org.framework.lazy.cloud.network.heartbeat.server.properties.ServerNodeProperties;
import org.wu.framework.database.lazy.web.plus.stereotype.LazyApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyNettyServerPermeatePortPoolApplication;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.application.command.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolRemoveCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolStoryCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolUpdateCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolQueryListCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolQueryOneCommand;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.assembler.LazyNettyServerPermeatePortPoolDTOAssembler;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyNettyServerPermeatePortPoolDTO;
import java.util.stream.Collectors;
import jakarta.annotation.Resource;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.server.permeate.port.pool.LazyNettyServerPermeatePortPoolRepository;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe 服务端内网渗透端口池 
 *
 * @author Jia wei Wu
 * @date 2024/09/17 01:26 夜间
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl 
 **/
@LazyApplication
public class LazyNettyServerPermeatePortPoolApplicationImpl implements LazyNettyServerPermeatePortPoolApplication {

    @Resource
    LazyNettyServerPermeatePortPoolRepository lazyNettyServerPermeatePortPoolRepository;


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

    @Override
    public Result<LazyNettyServerPermeatePortPool> story(LazyNettyServerPermeatePortPoolStoryCommand lazyNettyServerPermeatePortPoolStoryCommand) {
        LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool = LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE.toLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPoolStoryCommand);
        String serverId = serverNodeProperties.getNodeId();
        lazyNettyServerPermeatePortPool.setServerId(serverId);
        return lazyNettyServerPermeatePortPoolRepository.story(lazyNettyServerPermeatePortPool);
    }
    /**
     * describe 批量新增服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPoolStoryCommandList 批量新增服务端内网渗透端口池     
     * @return {@link Result<List<LazyNettyServerPermeatePortPool>>} 服务端内网渗透端口池新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<List<LazyNettyServerPermeatePortPool>> batchStory(List<LazyNettyServerPermeatePortPoolStoryCommand> lazyNettyServerPermeatePortPoolStoryCommandList) {
        List<LazyNettyServerPermeatePortPool> lazyNettyServerPermeatePortPoolList = lazyNettyServerPermeatePortPoolStoryCommandList.stream().map( LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE::toLazyNettyServerPermeatePortPool).collect(Collectors.toList());
        for (LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool : lazyNettyServerPermeatePortPoolList) {
            String serverId = serverNodeProperties.getNodeId();
            lazyNettyServerPermeatePortPool.setServerId(serverId);
        }
        return lazyNettyServerPermeatePortPoolRepository.batchStory(lazyNettyServerPermeatePortPoolList);
    }
    /**
     * describe 更新服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPoolUpdateCommand 更新服务端内网渗透端口池     
     * @return {@link Result<LazyNettyServerPermeatePortPool>} 服务端内网渗透端口池领域对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<LazyNettyServerPermeatePortPool> updateOne(LazyNettyServerPermeatePortPoolUpdateCommand lazyNettyServerPermeatePortPoolUpdateCommand) {
        LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool = LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE.toLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPoolUpdateCommand);
        String serverId = serverNodeProperties.getNodeId();
        lazyNettyServerPermeatePortPool.setServerId(serverId);
        return lazyNettyServerPermeatePortPoolRepository.story(lazyNettyServerPermeatePortPool);
    }

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

    @Override
    public Result<LazyNettyServerPermeatePortPoolDTO> findOne(LazyNettyServerPermeatePortPoolQueryOneCommand lazyNettyServerPermeatePortPoolQueryOneCommand) {
        LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool = LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE.toLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPoolQueryOneCommand);
        return lazyNettyServerPermeatePortPoolRepository.findOne(lazyNettyServerPermeatePortPool).convert(LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE::fromLazyNettyServerPermeatePortPool);
    }

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

    @Override
    public Result<List<LazyNettyServerPermeatePortPoolDTO>> findList(LazyNettyServerPermeatePortPoolQueryListCommand lazyNettyServerPermeatePortPoolQueryListCommand) {
        LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool = LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE.toLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPoolQueryListCommand);
        return lazyNettyServerPermeatePortPoolRepository.findList(lazyNettyServerPermeatePortPool)        .convert(lazyNettyServerPermeatePortPools -> lazyNettyServerPermeatePortPools.stream().map(LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE::fromLazyNettyServerPermeatePortPool).collect(Collectors.toList())) ;
    }

    /**
     * describe 分页查询多个服务端内网渗透端口池
     *
     * @param lazyNettyServerPermeatePortPoolQueryListCommand 分页查询多个服务端内网渗透端口池     
     * @return {@link Result<LazyPage<LazyNettyServerPermeatePortPoolDTO>>} 分页服务端内网渗透端口池DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/09/17 01:26 夜间
     **/

    @Override
    public Result<LazyPage<LazyNettyServerPermeatePortPoolDTO>> findPage(int size,int current,LazyNettyServerPermeatePortPoolQueryListCommand lazyNettyServerPermeatePortPoolQueryListCommand) {
        LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool = LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE.toLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPoolQueryListCommand);
        return lazyNettyServerPermeatePortPoolRepository.findPage(size,current,lazyNettyServerPermeatePortPool)        .convert(page -> page.convert(LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE::fromLazyNettyServerPermeatePortPool))            ;
    }

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

    @Override
    public Result<LazyNettyServerPermeatePortPool> remove(LazyNettyServerPermeatePortPoolRemoveCommand lazyNettyServerPermeatePortPoolRemoveCommand) {
     LazyNettyServerPermeatePortPool lazyNettyServerPermeatePortPool = LazyNettyServerPermeatePortPoolDTOAssembler.INSTANCE.toLazyNettyServerPermeatePortPool(lazyNettyServerPermeatePortPoolRemoveCommand);
     return lazyNettyServerPermeatePortPoolRepository.remove(lazyNettyServerPermeatePortPool);
    }

}