mirror of
https://gitee.com/wujiawei1207537021/wu-lazy-cloud-network.git
synced 2025-06-07 05:47:57 +08:00
[fix] 添加流量控制
This commit is contained in:
parent
1ee7021aa1
commit
0c8f82bf60
@ -41,13 +41,16 @@ public class ClientHandleDistributeSingleClientRealConnectTypeAdvanced extends A
|
||||
byte[] clientTargetIp = msg.getClientTargetIp();
|
||||
byte[] clientTargetPort = msg.getClientTargetPort();
|
||||
byte[] visitorIdBytes = msg.getVisitorId();
|
||||
InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient = new InternalNetworkPenetrationRealClient();
|
||||
internalNetworkPenetrationRealClient.setClientId(new String(clientIdBytes));
|
||||
internalNetworkPenetrationRealClient.setVisitorPort(Integer.valueOf(new String(visitorPort)));
|
||||
internalNetworkPenetrationRealClient.setClientTargetIp(new String( clientTargetIp));
|
||||
internalNetworkPenetrationRealClient.setClientTargetPort(Integer.valueOf(new String( clientTargetPort)));
|
||||
String visitorId=new String(visitorIdBytes);// 访客ID
|
||||
internalNetworkPenetrationRealClient.setVisitorId(visitorId);
|
||||
InternalNetworkPenetrationRealClient internalNetworkPenetrationRealClient =
|
||||
InternalNetworkPenetrationRealClient
|
||||
.builder()
|
||||
.clientId(new String(clientIdBytes))
|
||||
.visitorPort(Integer.valueOf(new String(visitorPort)))
|
||||
.clientTargetIp(new String( clientTargetIp))
|
||||
.clientTargetPort(Integer.valueOf(new String( clientTargetPort)))
|
||||
.visitorId(new String(visitorIdBytes))
|
||||
.build()
|
||||
;
|
||||
|
||||
// 绑定真实服务端口
|
||||
NettyClientRealSocket.buildRealServer(internalNetworkPenetrationRealClient,nettyServerProperties, handleChannelTypeAdvancedList);
|
||||
|
@ -25,11 +25,15 @@ public class NettyClientRealHandler extends SimpleChannelInboundHandler<ByteBuf>
|
||||
buf.readBytes(bytes);
|
||||
log.debug("接收客户端真实服务数据:{}", new String(bytes));
|
||||
String visitorId = ChannelAttributeKeyUtils.getVisitorId(ctx.channel());
|
||||
Integer visitorPort = ChannelAttributeKeyUtils.getVisitorPort(ctx.channel());
|
||||
String clientId = ChannelAttributeKeyUtils.getClientId(ctx.channel());
|
||||
// 访客通信通道 上报服务端代理完成
|
||||
Channel visitorChannel = NettyCommunicationIdContext.getVisitor(visitorId);
|
||||
NettyProxyMsg returnMessage = new NettyProxyMsg();
|
||||
returnMessage.setType(MessageType.REPORT_CLIENT_TRANSFER);
|
||||
returnMessage.setVisitorId(visitorId);
|
||||
returnMessage.setClientId(clientId);
|
||||
returnMessage.setVisitorPort(visitorPort);
|
||||
returnMessage.setData(bytes);
|
||||
|
||||
visitorChannel.writeAndFlush(returnMessage);
|
||||
|
@ -66,6 +66,7 @@ public class NettyClientRealSocket {
|
||||
// 绑定访客ID到当前真实通道属性
|
||||
ChannelAttributeKeyUtils.buildVisitorId(realChannel, visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(realChannel, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorPort(realChannel, visitorPort);
|
||||
// 通知服务端访客连接成功
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ public abstract class AbstractHandleChannelFlowAdvanced implements HandleChannel
|
||||
* @param channelFlow 数据
|
||||
* @return boolean
|
||||
*/
|
||||
abstract boolean doSupport(ChannelFlow channelFlow);
|
||||
protected abstract boolean doSupport(ChannelFlow channelFlow);
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
@ -43,5 +43,5 @@ public abstract class AbstractHandleChannelFlowAdvanced implements HandleChannel
|
||||
* @param channel 当前通道
|
||||
* @param channelFlow 通道数据
|
||||
*/
|
||||
abstract void doHandler(Channel channel, ChannelFlow channelFlow);
|
||||
protected abstract void doHandler(Channel channel, ChannelFlow channelFlow);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import io.netty.util.AttributeKey;
|
||||
public class ChannelAttributeKeyUtils {
|
||||
|
||||
private static final AttributeKey<String> VISITOR_ID = AttributeKey.newInstance("visitorId");
|
||||
private static final AttributeKey<Integer> VISITOR_PORT = AttributeKey.newInstance("visitorPort");
|
||||
private static final AttributeKey<String> CLIENT_ID = AttributeKey.newInstance("clientId");
|
||||
private static final AttributeKey<Integer> OUT_FLOW = AttributeKey.newInstance("outFlow");
|
||||
private static final AttributeKey<Integer> IN_FLOW = AttributeKey.newInstance("inFlow");
|
||||
@ -111,4 +112,23 @@ public class ChannelAttributeKeyUtils {
|
||||
public static Integer getInFlow(Channel channel) {
|
||||
return channel.attr(IN_FLOW).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 为通道绑定 通道中访客端口
|
||||
*
|
||||
* @param channel 通道
|
||||
* @param visitorPort 进口流量
|
||||
*/
|
||||
public static void buildVisitorPort(Channel channel, Integer visitorPort) {
|
||||
channel.attr(VISITOR_PORT).set(visitorPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 通道中访客端口
|
||||
*
|
||||
* @param channel 通道
|
||||
*/
|
||||
public static Integer getVisitorPort(Channel channel) {
|
||||
return channel.attr(VISITOR_PORT).get();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
spring:
|
||||
lazy:
|
||||
netty:
|
||||
# inet-host: 127.0.0.1
|
||||
# inet-port: 7001
|
||||
inet-host: 127.0.0.1
|
||||
inet-port: 7001
|
||||
# inet-path: wu-lazy-cloud-heartbeat-server
|
||||
inet-host: 124.222.48.62 # 服务端地址
|
||||
inet-port: 30676 #服务端端口
|
||||
# inet-host: 124.222.48.62 # 服务端地址
|
||||
# inet-port: 30676 #服务端端口
|
||||
# inet-path: wu-lazy-cloud-heartbeat-server
|
||||
client-id: wujiawei # 客户端ID
|
||||
client-id: local # 客户端ID
|
||||
data:
|
||||
redis:
|
||||
host: 192.168.17.221
|
||||
|
@ -0,0 +1,109 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application;
|
||||
|
||||
import com.wu.framework.response.Result;
|
||||
import com.wu.framework.response.ResultFactory;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowRemoveCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowStoryCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowUpdateCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryListCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryOneCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.dto.VisitorFlowDTO;
|
||||
import java.util.List;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.domain.LazyPage;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyApplication
|
||||
**/
|
||||
|
||||
public interface VisitorFlowApplication {
|
||||
|
||||
|
||||
/**
|
||||
* describe 新增访客端流量
|
||||
*
|
||||
* @param visitorFlowStoryCommand 新增访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量新增后领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlow> story(VisitorFlowStoryCommand visitorFlowStoryCommand);
|
||||
|
||||
/**
|
||||
* describe 批量新增访客端流量
|
||||
*
|
||||
* @param visitorFlowStoryCommandList 批量新增访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量新增后领域对象集合
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<List<VisitorFlow>> batchStory(List<VisitorFlowStoryCommand> visitorFlowStoryCommandList);
|
||||
|
||||
/**
|
||||
* describe 更新访客端流量
|
||||
*
|
||||
* @param visitorFlowUpdateCommand 更新访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlow> updateOne(VisitorFlowUpdateCommand visitorFlowUpdateCommand);
|
||||
|
||||
/**
|
||||
* describe 查询单个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryOneCommand 查询单个访客端流量
|
||||
* @return {@link Result<VisitorFlowDTO>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlowDTO> findOne(VisitorFlowQueryOneCommand visitorFlowQueryOneCommand);
|
||||
|
||||
/**
|
||||
* describe 查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 查询多个访客端流量
|
||||
* @return {@link Result <List<VisitorFlowDTO>>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result <List<VisitorFlowDTO>> findList(VisitorFlowQueryListCommand visitorFlowQueryListCommand);
|
||||
|
||||
/**
|
||||
* describe 分页查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 分页查询多个访客端流量
|
||||
* @return {@link Result <LazyPage<VisitorFlowDTO>>} 分页访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result <LazyPage<VisitorFlowDTO>> findPage(int size,int current,VisitorFlowQueryListCommand visitorFlowQueryListCommand);
|
||||
|
||||
/**
|
||||
* describe 删除访客端流量
|
||||
*
|
||||
* @param visitorFlowRemoveCommand 删除访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlow> remove(VisitorFlowRemoveCommand visitorFlowRemoveCommand);
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.assembler;
|
||||
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowRemoveCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowStoryCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowUpdateCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryListCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryOneCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.dto.VisitorFlowDTO;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.mapstruct.Mapper;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyAssembler
|
||||
**/
|
||||
@Mapper
|
||||
public interface VisitorFlowDTOAssembler {
|
||||
|
||||
|
||||
/**
|
||||
* describe MapStruct 创建的代理对象
|
||||
*
|
||||
|
||||
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlowDTOAssembler INSTANCE = Mappers.getMapper(VisitorFlowDTOAssembler.class);
|
||||
/**
|
||||
* describe 应用层存储入参转换成 领域对象
|
||||
*
|
||||
* @param visitorFlowStoryCommand 保存访客端流量对象
|
||||
* @return {@link VisitorFlow} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlow toVisitorFlow(VisitorFlowStoryCommand visitorFlowStoryCommand);
|
||||
/**
|
||||
* describe 应用层更新入参转换成 领域对象
|
||||
*
|
||||
* @param visitorFlowUpdateCommand 更新访客端流量对象
|
||||
* @return {@link VisitorFlow} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlow toVisitorFlow(VisitorFlowUpdateCommand visitorFlowUpdateCommand);
|
||||
/**
|
||||
* describe 应用层查询入参转换成 领域对象
|
||||
*
|
||||
* @param visitorFlowQueryOneCommand 查询单个访客端流量对象参数
|
||||
* @return {@link VisitorFlow} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlow toVisitorFlow(VisitorFlowQueryOneCommand visitorFlowQueryOneCommand);
|
||||
/**
|
||||
* describe 应用层查询入参转换成 领域对象
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 查询集合访客端流量对象参数
|
||||
* @return {@link VisitorFlow} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlow toVisitorFlow(VisitorFlowQueryListCommand visitorFlowQueryListCommand);
|
||||
/**
|
||||
* describe 应用层删除入参转换成 领域对象
|
||||
*
|
||||
* @param visitorFlowRemoveCommand 删除访客端流量对象参数
|
||||
* @return {@link VisitorFlow} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlow toVisitorFlow(VisitorFlowRemoveCommand visitorFlowRemoveCommand);
|
||||
/**
|
||||
* describe 持久层领域对象转换成DTO对象
|
||||
*
|
||||
* @param visitorFlow 访客端流量领域对象
|
||||
* @return {@link VisitorFlowDTO} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlowDTO fromVisitorFlow(VisitorFlow visitorFlow);
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyQueryListCommand
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow_query_List_command",description = "访客端流量")
|
||||
public class VisitorFlowQueryListCommand {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyQueryOneCommand
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow_query_one_command",description = "访客端流量")
|
||||
public class VisitorFlowQueryOneCommand {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyRemoveCommand
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow_remove_command",description = "访客端流量")
|
||||
public class VisitorFlowRemoveCommand {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyStoryCommand
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow_story_command",description = "访客端流量")
|
||||
public class VisitorFlowStoryCommand {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyUpdateCommand
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow_update_command",description = "访客端流量")
|
||||
public class VisitorFlowUpdateCommand {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyDTO
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow_command_dto",description = "访客端流量")
|
||||
public class VisitorFlowDTO {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.application.impl;
|
||||
|
||||
import com.wu.framework.database.lazy.web.plus.stereotype.LazyApplication;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.VisitorFlowApplication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.wu.framework.response.Result;
|
||||
import com.wu.framework.response.ResultFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowRemoveCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowStoryCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowUpdateCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryListCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryOneCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.assembler.VisitorFlowDTOAssembler;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.dto.VisitorFlowDTO;
|
||||
import java.util.stream.Collectors;
|
||||
import jakarta.annotation.Resource;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlowRepository;
|
||||
import java.util.List;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.domain.LazyPage;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl
|
||||
**/
|
||||
@LazyApplication
|
||||
public class VisitorFlowApplicationImpl implements VisitorFlowApplication {
|
||||
|
||||
@Resource
|
||||
VisitorFlowRepository visitorFlowRepository;
|
||||
/**
|
||||
* describe 新增访客端流量
|
||||
*
|
||||
* @param visitorFlowStoryCommand 新增访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量新增后领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlow> story(VisitorFlowStoryCommand visitorFlowStoryCommand) {
|
||||
VisitorFlow visitorFlow = VisitorFlowDTOAssembler.INSTANCE.toVisitorFlow(visitorFlowStoryCommand);
|
||||
return visitorFlowRepository.story(visitorFlow);
|
||||
}
|
||||
/**
|
||||
* describe 批量新增访客端流量
|
||||
*
|
||||
* @param visitorFlowStoryCommandList 批量新增访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量新增后领域对象集合
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<List<VisitorFlow>> batchStory(List<VisitorFlowStoryCommand> visitorFlowStoryCommandList) {
|
||||
List<VisitorFlow> visitorFlowList = visitorFlowStoryCommandList.stream().map( VisitorFlowDTOAssembler.INSTANCE::toVisitorFlow).collect(Collectors.toList());
|
||||
return visitorFlowRepository.batchStory(visitorFlowList);
|
||||
}
|
||||
/**
|
||||
* describe 更新访客端流量
|
||||
*
|
||||
* @param visitorFlowUpdateCommand 更新访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlow> updateOne(VisitorFlowUpdateCommand visitorFlowUpdateCommand) {
|
||||
VisitorFlow visitorFlow = VisitorFlowDTOAssembler.INSTANCE.toVisitorFlow(visitorFlowUpdateCommand);
|
||||
return visitorFlowRepository.story(visitorFlow);
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 查询单个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryOneCommand 查询单个访客端流量
|
||||
* @return {@link Result<VisitorFlowDTO>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlowDTO> findOne(VisitorFlowQueryOneCommand visitorFlowQueryOneCommand) {
|
||||
VisitorFlow visitorFlow = VisitorFlowDTOAssembler.INSTANCE.toVisitorFlow(visitorFlowQueryOneCommand);
|
||||
return visitorFlowRepository.findOne(visitorFlow).convert(VisitorFlowDTOAssembler.INSTANCE::fromVisitorFlow);
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 查询多个访客端流量
|
||||
* @return {@link Result<List<VisitorFlowDTO>>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<List<VisitorFlowDTO>> findList(VisitorFlowQueryListCommand visitorFlowQueryListCommand) {
|
||||
VisitorFlow visitorFlow = VisitorFlowDTOAssembler.INSTANCE.toVisitorFlow(visitorFlowQueryListCommand);
|
||||
return visitorFlowRepository.findList(visitorFlow) .convert(visitorFlows -> visitorFlows.stream().map(VisitorFlowDTOAssembler.INSTANCE::fromVisitorFlow).collect(Collectors.toList())) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 分页查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 分页查询多个访客端流量
|
||||
* @return {@link Result<LazyPage<VisitorFlowDTO>>} 分页访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<LazyPage<VisitorFlowDTO>> findPage(int size,int current,VisitorFlowQueryListCommand visitorFlowQueryListCommand) {
|
||||
VisitorFlow visitorFlow = VisitorFlowDTOAssembler.INSTANCE.toVisitorFlow(visitorFlowQueryListCommand);
|
||||
return visitorFlowRepository.findPage(size,current,visitorFlow) .convert(page -> page.convert(VisitorFlowDTOAssembler.INSTANCE::fromVisitorFlow)) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 删除访客端流量
|
||||
*
|
||||
* @param visitorFlowRemoveCommand 删除访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlow> remove(VisitorFlowRemoveCommand visitorFlowRemoveCommand) {
|
||||
VisitorFlow visitorFlow = VisitorFlowDTOAssembler.INSTANCE.toVisitorFlow(visitorFlowRemoveCommand);
|
||||
return visitorFlowRepository.remove(visitorFlow);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import com.wu.framework.inner.layer.web.EasyController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.wu.framework.response.Result;
|
||||
import com.wu.framework.response.ResultFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import jakarta.annotation.Resource;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowRemoveCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowStoryCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowUpdateCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryListCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.command.visitor.flow.VisitorFlowQueryOneCommand;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.VisitorFlowApplication;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.dto.VisitorFlowDTO;
|
||||
import java.util.List;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.domain.LazyPage;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyController
|
||||
**/
|
||||
@Tag(name = "访客端流量提供者")
|
||||
@EasyController("/visitor/flow")
|
||||
public class VisitorFlowProvider {
|
||||
|
||||
@Resource
|
||||
private VisitorFlowApplication visitorFlowApplication;
|
||||
|
||||
/**
|
||||
* describe 新增访客端流量
|
||||
*
|
||||
* @param visitorFlowStoryCommand 新增访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量新增后领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "新增访客端流量")
|
||||
@PostMapping("/story")
|
||||
public Result<VisitorFlow> story(@RequestBody VisitorFlowStoryCommand visitorFlowStoryCommand){
|
||||
return visitorFlowApplication.story(visitorFlowStoryCommand);
|
||||
}
|
||||
/**
|
||||
* describe 批量新增访客端流量
|
||||
*
|
||||
* @param visitorFlowStoryCommandList 批量新增访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量新增后领域对象集合
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "批量新增访客端流量")
|
||||
@PostMapping("/batchStory")
|
||||
public Result<List<VisitorFlow>> batchStory(@RequestBody List<VisitorFlowStoryCommand> visitorFlowStoryCommandList){
|
||||
return visitorFlowApplication.batchStory(visitorFlowStoryCommandList);
|
||||
}
|
||||
/**
|
||||
* describe 更新访客端流量
|
||||
*
|
||||
* @param visitorFlowUpdateCommand 更新访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "更新访客端流量")
|
||||
@PutMapping("/updateOne")
|
||||
public Result<VisitorFlow> updateOne(@RequestBody VisitorFlowUpdateCommand visitorFlowUpdateCommand){
|
||||
return visitorFlowApplication.updateOne(visitorFlowUpdateCommand);
|
||||
}
|
||||
/**
|
||||
* describe 查询单个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryOneCommand 查询单个访客端流量
|
||||
* @return {@link Result<VisitorFlowDTO>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "查询单个访客端流量")
|
||||
@GetMapping("/findOne")
|
||||
public Result<VisitorFlowDTO> findOne(@ModelAttribute VisitorFlowQueryOneCommand visitorFlowQueryOneCommand){
|
||||
return visitorFlowApplication.findOne(visitorFlowQueryOneCommand);
|
||||
}
|
||||
/**
|
||||
* describe 查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 查询多个访客端流量
|
||||
* @return {@link Result<List<VisitorFlowDTO>>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "查询多个访客端流量")
|
||||
@GetMapping("/findList")
|
||||
public Result<List<VisitorFlowDTO>> findList(@ModelAttribute VisitorFlowQueryListCommand visitorFlowQueryListCommand){
|
||||
return visitorFlowApplication.findList(visitorFlowQueryListCommand);
|
||||
}
|
||||
/**
|
||||
* describe 分页查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlowQueryListCommand 分页查询多个访客端流量
|
||||
* @return {@link Result<LazyPage<VisitorFlowDTO>>} 分页访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "分页查询多个访客端流量")
|
||||
@GetMapping("/findPage")
|
||||
public Result<LazyPage<VisitorFlowDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
|
||||
@Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute VisitorFlowQueryListCommand visitorFlowQueryListCommand){
|
||||
return visitorFlowApplication.findPage(size,current,visitorFlowQueryListCommand);
|
||||
}
|
||||
/**
|
||||
* describe 删除访客端流量
|
||||
*
|
||||
* @param visitorFlowRemoveCommand 删除访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Operation(summary = "删除访客端流量")
|
||||
@DeleteMapping("/remove")
|
||||
public Result<VisitorFlow> remove(@ModelAttribute VisitorFlowRemoveCommand visitorFlowRemoveCommand){
|
||||
return visitorFlowApplication.remove(visitorFlowRemoveCommand);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyDomain
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "visitor_flow",description = "访客端流量")
|
||||
public class VisitorFlow {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow;
|
||||
|
||||
import com.wu.framework.response.Result;
|
||||
import com.wu.framework.response.ResultFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import java.util.List;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.domain.LazyPage;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyDomainRepository
|
||||
**/
|
||||
|
||||
public interface VisitorFlowRepository {
|
||||
|
||||
|
||||
/**
|
||||
* describe 新增访客端流量
|
||||
*
|
||||
* @param visitorFlow 新增访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量新增后领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlow> story(VisitorFlow visitorFlow);
|
||||
|
||||
/**
|
||||
* describe 批量新增访客端流量
|
||||
*
|
||||
* @param visitorFlowList 批量新增访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量新增后领域对象集合
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<List<VisitorFlow>> batchStory(List<VisitorFlow> visitorFlowList);
|
||||
|
||||
/**
|
||||
* describe 查询单个访客端流量
|
||||
*
|
||||
* @param visitorFlow 查询单个访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlow> findOne(VisitorFlow visitorFlow);
|
||||
|
||||
/**
|
||||
* describe 查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlow 查询多个访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量DTO对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<List<VisitorFlow>> findList(VisitorFlow visitorFlow);
|
||||
|
||||
/**
|
||||
* describe 分页查询多个访客端流量
|
||||
*
|
||||
* @param size 当前页数
|
||||
* @param current 当前页
|
||||
* @param visitorFlow 分页查询多个访客端流量
|
||||
* @return {@link Result<LazyPage<VisitorFlow>>} 分页访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<LazyPage<VisitorFlow>> findPage(int size,int current,VisitorFlow visitorFlow);
|
||||
|
||||
/**
|
||||
* describe 删除访客端流量
|
||||
*
|
||||
* @param visitorFlow 删除访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<VisitorFlow> remove(VisitorFlow visitorFlow);
|
||||
|
||||
/**
|
||||
* describe 是否存在访客端流量
|
||||
*
|
||||
* @param visitorFlow 是否存在访客端流量
|
||||
* @return {@link Result<Boolean>} 访客端流量是否存在
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
Result<Boolean> exists(VisitorFlow visitorFlow);
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.infrastructure.converter;
|
||||
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.infrastructure.entity.VisitorFlowDO;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.mapstruct.Mapper;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructureConverter
|
||||
**/
|
||||
@Mapper
|
||||
public interface VisitorFlowConverter {
|
||||
|
||||
|
||||
/**
|
||||
* describe MapStruct 创建的代理对象
|
||||
*
|
||||
|
||||
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlowConverter INSTANCE = Mappers.getMapper(VisitorFlowConverter.class);
|
||||
/**
|
||||
* describe 实体对象 转换成领域对象
|
||||
*
|
||||
* @param visitorFlowDO 访客端流量实体对象
|
||||
* @return {@link VisitorFlow} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlow toVisitorFlow(VisitorFlowDO visitorFlowDO);
|
||||
/**
|
||||
* describe 领域对象 转换成实体对象
|
||||
*
|
||||
* @param visitorFlow 访客端流量领域对象
|
||||
* @return {@link VisitorFlowDO} 访客端流量实体对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
VisitorFlowDO fromVisitorFlow(VisitorFlow visitorFlow);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.infrastructure.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.wu.framework.inner.lazy.stereotype.LazyTableIndex;
|
||||
import com.wu.framework.inner.layer.stereotype.LayerField;
|
||||
import com.wu.framework.inner.layer.stereotype.LayerField.LayerFieldType;
|
||||
import com.wu.framework.inner.lazy.stereotype.LazyTable;
|
||||
import com.wu.framework.inner.lazy.stereotype.LazyTableField;
|
||||
import com.wu.framework.inner.lazy.stereotype.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.lang.String;
|
||||
import java.time.LocalDateTime;
|
||||
import java.lang.Long;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructureEntity
|
||||
**/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@LazyTable(tableName = "visitor_flow",schema = "wu_lazy_cloud_netty_server",comment = "访客端流量")
|
||||
@Schema(title = "visitor_flow",description = "访客端流量")
|
||||
public class VisitorFlowDO {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 客户端ID
|
||||
*/
|
||||
@Schema(description ="客户端ID",name ="clientId",example = "")
|
||||
@LazyTableFieldUnique(name="client_id",comment="客户端ID",columnType="varchar(50)")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
*
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description ="创建时间",name ="createTime",example = "")
|
||||
@LazyTableFieldCreateTime
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 主键
|
||||
*/
|
||||
@Schema(description ="主键",name ="id",example = "")
|
||||
@LazyTableFieldId(name="id",comment="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客当前进口流量
|
||||
*/
|
||||
@Schema(description ="当前访客当前进口流量",name ="inFlow",example = "")
|
||||
@LazyTableField(name="in_flow",comment="当前访客当前进口流量",columnType="int")
|
||||
private Integer inFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 是否删除
|
||||
*/
|
||||
@Schema(description ="是否删除",name ="isDeleted",example = "")
|
||||
@LazyTableField(name="is_deleted",comment="是否删除",defaultValue="'0'",upsertStrategy = LazyFieldStrategy.NEVER,columnType="tinyint")
|
||||
private Boolean isDeleted;
|
||||
|
||||
/**
|
||||
*
|
||||
* 当前访客出口流量
|
||||
*/
|
||||
@Schema(description ="当前访客出口流量",name ="outFlow",example = "")
|
||||
@LazyTableField(name="out_flow",comment="当前访客出口流量",columnType="int")
|
||||
private Integer outFlow;
|
||||
|
||||
/**
|
||||
*
|
||||
* 修改时间
|
||||
*/
|
||||
@Schema(description ="修改时间",name ="updateTime",example = "")
|
||||
@LazyTableFieldUpdateTime
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* 访客端口
|
||||
*/
|
||||
@Schema(description ="访客端口",name ="visitorPort",example = "")
|
||||
@LazyTableFieldUnique(name="visitor_port",comment="访客端口",columnType="int")
|
||||
private Integer visitorPort;
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.infrastructure.mapper;
|
||||
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructureMapper
|
||||
**/
|
||||
|
||||
public interface VisitorFlowMapper {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.infrastructure.persistence;
|
||||
|
||||
import wu.framework.lazy.cloud.heartbeat.server.infrastructure.entity.VisitorFlowDO;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.infrastructure.converter.VisitorFlowConverter;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.infrastructure.mapper.VisitorFlowMapper;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlowRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.stream.Collectors;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.stream.wrapper.LazyWrappers;
|
||||
import com.wu.framework.response.Result;
|
||||
import com.wu.framework.response.ResultFactory;
|
||||
import jakarta.annotation.Resource;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.stream.lambda.LazyLambdaStream;
|
||||
import java.util.List;
|
||||
import com.wu.framework.inner.lazy.database.expand.database.persistence.domain.LazyPage;
|
||||
/**
|
||||
* describe 访客端流量
|
||||
*
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
* @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence
|
||||
**/
|
||||
@Repository
|
||||
public class VisitorFlowRepositoryImpl implements VisitorFlowRepository {
|
||||
|
||||
@Resource
|
||||
LazyLambdaStream lazyLambdaStream;
|
||||
|
||||
/**
|
||||
* describe 新增访客端流量
|
||||
*
|
||||
* @param visitorFlow 新增访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量新增后领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlow> story(VisitorFlow visitorFlow) {
|
||||
VisitorFlowDO visitorFlowDO = VisitorFlowConverter.INSTANCE.fromVisitorFlow(visitorFlow);
|
||||
lazyLambdaStream.upsertRemoveNull(visitorFlowDO);
|
||||
return ResultFactory.successOf();
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 批量新增访客端流量
|
||||
*
|
||||
* @param visitorFlowList 批量新增访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量新增后领域对象集合
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<List<VisitorFlow>> batchStory(List<VisitorFlow> visitorFlowList) {
|
||||
List<VisitorFlowDO> visitorFlowDOList = visitorFlowList.stream().map(VisitorFlowConverter.INSTANCE::fromVisitorFlow).collect(Collectors.toList());
|
||||
lazyLambdaStream.upsert(visitorFlowDOList);
|
||||
return ResultFactory.successOf();
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 查询单个访客端流量
|
||||
*
|
||||
* @param visitorFlow 查询单个访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlow> findOne(VisitorFlow visitorFlow) {
|
||||
VisitorFlowDO visitorFlowDO = VisitorFlowConverter.INSTANCE.fromVisitorFlow(visitorFlow);
|
||||
VisitorFlow visitorFlowOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(visitorFlowDO), VisitorFlow.class);
|
||||
return ResultFactory.successOf(visitorFlowOne);
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 查询多个访客端流量
|
||||
*
|
||||
* @param visitorFlow 查询多个访客端流量
|
||||
* @return {@link Result<List<VisitorFlow>>} 访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<List<VisitorFlow>> findList(VisitorFlow visitorFlow) {
|
||||
VisitorFlowDO visitorFlowDO = VisitorFlowConverter.INSTANCE.fromVisitorFlow(visitorFlow);
|
||||
List<VisitorFlow> visitorFlowList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(visitorFlowDO), VisitorFlow.class);
|
||||
return ResultFactory.successOf(visitorFlowList);
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 分页查询多个访客端流量
|
||||
*
|
||||
* @param size 当前页数
|
||||
* @param current 当前页
|
||||
* @param visitorFlow 分页查询多个访客端流量
|
||||
* @return {@link Result<LazyPage<VisitorFlow>>} 分页访客端流量领域对象
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<LazyPage<VisitorFlow>> findPage(int size,int current,VisitorFlow visitorFlow) {
|
||||
VisitorFlowDO visitorFlowDO = VisitorFlowConverter.INSTANCE.fromVisitorFlow(visitorFlow);
|
||||
LazyPage<VisitorFlow> lazyPage = new LazyPage<>(current,size);
|
||||
LazyPage<VisitorFlow> visitorFlowLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(visitorFlowDO),lazyPage, VisitorFlow.class);
|
||||
return ResultFactory.successOf(visitorFlowLazyPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 删除访客端流量
|
||||
*
|
||||
* @param visitorFlow 删除访客端流量
|
||||
* @return {@link Result<VisitorFlow>} 访客端流量
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<VisitorFlow> remove(VisitorFlow visitorFlow) {
|
||||
VisitorFlowDO visitorFlowDO = VisitorFlowConverter.INSTANCE.fromVisitorFlow(visitorFlow);
|
||||
// lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(visitorFlowDO));
|
||||
return ResultFactory.successOf();
|
||||
}
|
||||
|
||||
/**
|
||||
* describe 是否存在访客端流量
|
||||
*
|
||||
* @param visitorFlow 访客端流量领域对象
|
||||
* @return {@link Result<Boolean>} 是否存在 true 存在,false 不存在
|
||||
|
||||
* @author Jia wei Wu
|
||||
* @date 2024/01/24 05:19 下午
|
||||
**/
|
||||
|
||||
@Override
|
||||
public Result<Boolean> exists(VisitorFlow visitorFlow) {
|
||||
VisitorFlowDO visitorFlowDO = VisitorFlowConverter.INSTANCE.fromVisitorFlow(visitorFlow);
|
||||
Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(visitorFlowDO));
|
||||
return ResultFactory.successOf(exists);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="wu.framework.lazy.cloud.heartbeat.server.infrastructure.mapper.VisitorFlowMapper">
|
||||
<resultMap id="BaseResultMap" type="wu.framework.lazy.cloud.heartbeat.server.infrastructure.entity.VisitorFlowDO">
|
||||
<result column="client_id" property="clientId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<id column="id" property="id" />
|
||||
<result column="in_flow" property="inFlow" />
|
||||
<result column="is_deleted" property="isDeleted" />
|
||||
<result column="out_flow" property="outFlow" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="visitor_port" property="visitorPort" />
|
||||
</resultMap>
|
||||
</mapper>
|
@ -3,11 +3,14 @@ package wu.framework.lazy.cloud.heartbeat.server.netty.advanced;
|
||||
|
||||
import wu.framework.lazy.cloud.heartbeat.common.NettyProxyMsg;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.NettyRealIdContext;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.advanced.server.AbstractHandleReportHandleChannelTransferTypeAdvanced;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.enums.ChannelFlowEnum;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.netty.flow.ServerChannelFlow;
|
||||
|
||||
|
||||
/**
|
||||
@ -18,6 +21,12 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ServerHandleReportHandleChannelTransferTypeAdvanced extends AbstractHandleReportHandleChannelTransferTypeAdvanced<NettyProxyMsg> {
|
||||
|
||||
private final ChannelFlowAdapter channelFlowAdapter;
|
||||
|
||||
public ServerHandleReportHandleChannelTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
|
||||
this.channelFlowAdapter = channelFlowAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
@ -26,7 +35,9 @@ public class ServerHandleReportHandleChannelTransferTypeAdvanced extends Abstrac
|
||||
*/
|
||||
@Override
|
||||
public void doHandler(Channel channel, NettyProxyMsg msg) {
|
||||
log.debug("接收到客户端:[{}]内网穿透返回的数据:[{}]", new String(msg.getClientId()), new String(msg.getData()));
|
||||
String clientId = new String(msg.getClientId());
|
||||
Integer visitorPort = Integer.valueOf(new String(msg.getVisitorPort()));
|
||||
log.debug("接收到客户端:[{}]内网穿透返回的数据:[{}]", clientId, new String(msg.getData()));
|
||||
// 将数据转发访客通道
|
||||
byte[] visitorId = msg.getVisitorId();
|
||||
Channel visitor = NettyRealIdContext.getReal(visitorId);
|
||||
@ -34,6 +45,16 @@ public class ServerHandleReportHandleChannelTransferTypeAdvanced extends Abstrac
|
||||
ByteBuf buf = visitor.config().getAllocator().buffer(msg.getData().length);
|
||||
buf.writeBytes(msg.getData());
|
||||
visitor.writeAndFlush(buf);
|
||||
|
||||
// 记录出口数据
|
||||
ServerChannelFlow serverChannelFlow = ServerChannelFlow
|
||||
.builder()
|
||||
.channelFlowEnum(ChannelFlowEnum.OUT_FLOW)
|
||||
.port(visitorPort)
|
||||
.clientId(clientId)
|
||||
.flow(msg.getData().length)
|
||||
.build();
|
||||
channelFlowAdapter.handler(channel,serverChannelFlow);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class ServerHandleReportSingleClientRealConnectTypeAdvanced extends Abstr
|
||||
NettyCommunicationIdContext.pushVisitor(channel,new String(visitorId));
|
||||
ChannelAttributeKeyUtils.buildVisitorId(channel, visitorId);
|
||||
ChannelAttributeKeyUtils.buildClientId(channel, clientId);
|
||||
ChannelAttributeKeyUtils.buildVisitorPort(channel,Integer.valueOf(new String(visitorPort)));
|
||||
// 访客通道开启自动读取
|
||||
Channel visitorRealChannel = NettyRealIdContext.getReal(new String(visitorId));
|
||||
visitorRealChannel.config().setOption(ChannelOption.AUTO_READ, true);
|
||||
|
@ -4,6 +4,7 @@ package wu.framework.lazy.cloud.heartbeat.server.netty.config;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.InternalNetworkPenetrationMappingApplication;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.NettyClientBlacklistApplication;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.application.ServerNettyConfigApplication;
|
||||
@ -31,8 +32,8 @@ public class HeartbeatServerConfiguration {
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Bean
|
||||
public ServerHandleReportHandleChannelTransferTypeAdvanced serverReportChannelTransferTypeAdvanced() {
|
||||
return new ServerHandleReportHandleChannelTransferTypeAdvanced();
|
||||
public ServerHandleReportHandleChannelTransferTypeAdvanced serverReportChannelTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
|
||||
return new ServerHandleReportHandleChannelTransferTypeAdvanced(channelFlowAdapter);
|
||||
}
|
||||
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
|
@ -6,6 +6,9 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.adapter.ChannelFlowAdapter;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.advanced.flow.HandleChannelFlowAdvanced;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlowRepository;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.netty.flow.ServerHandlerInFlowHandler;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.netty.flow.ServerHandlerOutFlowHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -15,17 +18,39 @@ import java.util.List;
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public class ServerFlowConfiguration {
|
||||
/**
|
||||
* 进口数据处理
|
||||
*
|
||||
* @return ServerHandlerInFlowHandler
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Bean
|
||||
public ServerHandlerInFlowHandler serverHandlerInFlowHandler(VisitorFlowRepository visitorFlowRepository) {
|
||||
return new ServerHandlerInFlowHandler(visitorFlowRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 出口数据处理
|
||||
*
|
||||
* @return ServerHandlerOutFlowHandler
|
||||
*/
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@Bean
|
||||
public ServerHandlerOutFlowHandler serverHandlerOutFlowHandler(VisitorFlowRepository visitorFlowRepository) {
|
||||
return new ServerHandlerOutFlowHandler(visitorFlowRepository);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 服务端流量适配器
|
||||
*
|
||||
* @param handleChannelFlowAdvancedList 服务端流量适配者
|
||||
* @return 服务端流量适配器
|
||||
*/
|
||||
@ConditionalOnMissingBean(ChannelFlowAdapter.class)
|
||||
@Bean
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public ChannelFlowAdapter channelFlowAdapter(List<HandleChannelFlowAdvanced> handleChannelFlowAdvancedList){
|
||||
public ChannelFlowAdapter channelFlowAdapter(List<HandleChannelFlowAdvanced> handleChannelFlowAdvancedList) {
|
||||
return new ChannelFlowAdapter(handleChannelFlowAdvancedList);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.netty.flow;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.advanced.flow.AbstractHandleChannelFlowAdvanced;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.advanced.flow.ChannelFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.enums.ChannelFlowEnum;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlowRepository;
|
||||
|
||||
/**
|
||||
* 进口流量处理
|
||||
*/
|
||||
public class ServerHandlerInFlowHandler extends AbstractHandleChannelFlowAdvanced {
|
||||
private final VisitorFlowRepository visitorFlowRepository;
|
||||
|
||||
public ServerHandlerInFlowHandler(VisitorFlowRepository visitorFlowRepository) {
|
||||
this.visitorFlowRepository = visitorFlowRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理是否支持这种类型
|
||||
*
|
||||
* @param channelFlow 数据
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
protected boolean doSupport(ChannelFlow channelFlow) {
|
||||
return ChannelFlowEnum.IN_FLOW.equals(channelFlow.channelFlowEnum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelFlow 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, ChannelFlow channelFlow) {
|
||||
String clientId = channelFlow.clientId();
|
||||
Integer port = channelFlow.port();
|
||||
Integer flow = channelFlow.flow();
|
||||
|
||||
// 进口流量处理
|
||||
VisitorFlow visitorFlow = new VisitorFlow();
|
||||
visitorFlow.setInFlow(flow);
|
||||
visitorFlow.setClientId(clientId);
|
||||
visitorFlow.setVisitorPort(port);
|
||||
visitorFlow.setIsDeleted(false);
|
||||
// 查询是否存在已有流量 而后进行统计汇总
|
||||
VisitorFlow findOneVisitorFlowQuery = new VisitorFlow();
|
||||
findOneVisitorFlowQuery.setClientId(clientId);
|
||||
findOneVisitorFlowQuery.setVisitorPort(port);
|
||||
visitorFlowRepository.findOne(findOneVisitorFlowQuery).accept(existVisitorFlow -> {
|
||||
Integer inFlow = existVisitorFlow.getInFlow();
|
||||
Integer outFlow = existVisitorFlow.getOutFlow();
|
||||
if(!ObjectUtils.isEmpty(inFlow)){
|
||||
visitorFlow.setInFlow(visitorFlow.getInFlow()+inFlow);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(outFlow)) {
|
||||
visitorFlow.setOutFlow( outFlow);
|
||||
}
|
||||
});
|
||||
visitorFlowRepository.story(visitorFlow);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package wu.framework.lazy.cloud.heartbeat.server.netty.flow;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.advanced.flow.AbstractHandleChannelFlowAdvanced;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.advanced.flow.ChannelFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.common.enums.ChannelFlowEnum;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlow;
|
||||
import wu.framework.lazy.cloud.heartbeat.server.domain.model.visitor.flow.VisitorFlowRepository;
|
||||
|
||||
/**
|
||||
* 出口流量处理
|
||||
*/
|
||||
public class ServerHandlerOutFlowHandler extends AbstractHandleChannelFlowAdvanced {
|
||||
private final VisitorFlowRepository visitorFlowRepository;
|
||||
|
||||
public ServerHandlerOutFlowHandler(VisitorFlowRepository visitorFlowRepository) {
|
||||
this.visitorFlowRepository = visitorFlowRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理是否支持这种类型
|
||||
*
|
||||
* @param channelFlow 数据
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
protected boolean doSupport(ChannelFlow channelFlow) {
|
||||
return ChannelFlowEnum.OUT_FLOW.equals(channelFlow.channelFlowEnum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理当前数据
|
||||
*
|
||||
* @param channel 当前通道
|
||||
* @param channelFlow 通道数据
|
||||
*/
|
||||
@Override
|
||||
protected void doHandler(Channel channel, ChannelFlow channelFlow) {
|
||||
String clientId = channelFlow.clientId();
|
||||
Integer port = channelFlow.port();
|
||||
Integer flow = channelFlow.flow();
|
||||
|
||||
// 进口流量处理
|
||||
VisitorFlow visitorFlow = new VisitorFlow();
|
||||
visitorFlow.setOutFlow(flow);
|
||||
visitorFlow.setClientId(clientId);
|
||||
visitorFlow.setVisitorPort(port);
|
||||
visitorFlow.setIsDeleted(false);
|
||||
// 查询是否存在已有流量 而后进行统计汇总
|
||||
VisitorFlow findOneVisitorFlowQuery = new VisitorFlow();
|
||||
findOneVisitorFlowQuery.setClientId(clientId);
|
||||
findOneVisitorFlowQuery.setVisitorPort(port);
|
||||
visitorFlowRepository.findOne(findOneVisitorFlowQuery).accept(existVisitorFlow -> {
|
||||
Integer outFlow = existVisitorFlow.getOutFlow();
|
||||
Integer inFlow = existVisitorFlow.getInFlow();
|
||||
if (!ObjectUtils.isEmpty(outFlow)) {
|
||||
visitorFlow.setOutFlow(visitorFlow.getOutFlow() + outFlow);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(inFlow)) {
|
||||
visitorFlow.setInFlow( inFlow);
|
||||
}
|
||||
});
|
||||
visitorFlowRepository.story(visitorFlow);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user