端口映射管理搜索条件增加

This commit is contained in:
Yohanes
2023-03-20 15:48:50 +08:00
parent ae5140b543
commit 0f6625e1e1
7 changed files with 387 additions and 285 deletions
@@ -0,0 +1,21 @@
package fun.asgc.neutrino.proxy.server.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 端口池分组枚举类型
* @author Yohanes
* @date 2023/03/17
*/
@Getter
@AllArgsConstructor
public enum PoolGroupEnum {
GLOBAL(0, "全局"),
USER(1, "用户"),
LICENSE(2, "License");
private Integer status;
private String desc;
}
@@ -21,6 +21,7 @@
*/
package fun.asgc.neutrino.proxy.server.controller.req;
import fun.asgc.neutrino.proxy.server.constant.OnlineStatusEnum;
import lombok.Data;
/**
@@ -30,5 +31,27 @@ import lombok.Data;
*/
@Data
public class PortMappingListReq {
/**
* 用户ID
*/
private Integer userId;
/**
* licenseId
*/
private Integer licenseId;
/**
* 服务端口号
*/
private Integer serverPort;
/**
* 是否在线
* {@link OnlineStatusEnum}
*/
private Integer isOnline;
/**
* 启用状态
* {@link fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum}
*/
private Integer enable;
}
@@ -59,4 +59,8 @@ public class PortPoolListRes {
* 分组
*/
private String groupName;
/**
* 分组ID
*/
private String groupId;
}
@@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingListReq;
import fun.asgc.neutrino.proxy.server.controller.res.PortMappingListRes;
import fun.asgc.neutrino.proxy.server.dal.entity.PortMappingDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
@@ -82,4 +85,6 @@ public interface PortMappingMapper extends BaseMapper<PortMappingDO> {
.set(PortMappingDO::getUpdateTime, updateTime)
);
}
List<PortMappingDO> selectPortMappingByCondition(@Param("req") PortMappingListReq req);
}
@@ -12,10 +12,7 @@ import fun.asgc.neutrino.proxy.server.base.rest.SystemContextHolder;
import fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum;
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
import fun.asgc.neutrino.proxy.server.constant.OnlineStatusEnum;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingCreateReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingListReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingUpdateReq;
import fun.asgc.neutrino.proxy.server.controller.req.*;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.dal.LicenseMapper;
import fun.asgc.neutrino.proxy.server.dal.PortMappingMapper;
@@ -56,17 +53,18 @@ public class PortMappingService implements Lifecycle {
@Inject
private VisitorChannelService visitorChannelService;
@Inject
private PortPoolService portPoolService;
public PageInfo<PortMappingListRes> page(PageQuery pageQuery, PortMappingListReq req) {
Page<PortMappingListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
List<PortMappingDO> list = portMappingMapper.selectList(new LambdaQueryWrapper<PortMappingDO>()
.orderByAsc(PortMappingDO::getId)
);
List<PortMappingDO> list = portMappingMapper.selectPortMappingByCondition(req);
List<PortMappingListRes> respList = mapperFacade.mapAsList(list, PortMappingListRes.class);
if (CollectionUtils.isEmpty(list)) {
return PageInfo.of(respList, result.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
}
Set<Integer> licenseIds = respList.stream().map(PortMappingListRes::getLicenseId).collect(Collectors.toSet());
List<LicenseDO> licenseList = licenseMapper.findByIds(licenseIds);
if (CollectionUtil.isEmpty(licenseList)) {