From a95b534701bde783d4642b271c6f1b68b77d7015 Mon Sep 17 00:00:00 2001
From: Metal <13144144057@163.com>
Date: Thu, 6 Jul 2023 21:22:42 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=9A=E9=80=89=E6=8B=A9=E5=99=A8=E6=94=AF?=
=?UTF-8?q?=E6=8C=81=E6=BB=9A=E5=8A=A8=E5=8A=A0=E8=BD=BD=202=E3=80=81?=
=?UTF-8?q?=E4=BB=A3=E7=90=86=E9=85=8D=E7=BD=AE-=E7=AB=AF=E5=8F=A3?=
=?UTF-8?q?=E6=98=A0=E5=B0=84=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=92=8C=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E5=8A=9F=E8=83=BD=E6=9C=8D=E5=8A=A1=E7=AB=AF=E7=AB=AF?=
=?UTF-8?q?=E5=8F=A3=E5=AD=97=E6=AE=B5=E9=80=89=E6=8B=A9=E5=99=A8=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=94=AF=E6=8C=81=E6=BB=9A=E5=8A=A8=E5=8A=A0?=
=?UTF-8?q?=E8=BD=BD=203=E3=80=81=E4=BB=A3=E7=90=86=E9=85=8D=E7=BD=AE-?=
=?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=98=A0=E5=B0=84=EF=BC=8C=E5=90=8E=E5=8F=B0?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3getAvailablePortList=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E5=8F=82=E6=95=B0=E5=86=85=E5=AE=B9=E5=B9=B6=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=8A=A0=E8=BD=BD=E6=A8=A1=E5=BC=8F=E4=B9=9F?=
=?UTF-8?q?=E5=8D=B3=E6=98=AF=E5=88=86=E9=A1=B5=E5=8A=A0=E8=BD=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
neutrino-proxy-admin/src/api/portPool.js | 6 +-
.../src/components/Select/SelectLoadMore.vue | 168 ++++++++++++++++++
.../src/views/proxy/portMapping.vue | 70 ++++++--
.../server/controller/PortPoolController.java | 2 +-
.../req/system/AvailablePortListReq.java | 14 ++
.../server/dal/PortPoolMapper.java | 2 +-
.../server/service/PortPoolService.java | 12 +-
.../main/resources/mapper/PortPoolMapper.xml | 5 +-
8 files changed, 258 insertions(+), 21 deletions(-)
create mode 100644 neutrino-proxy-admin/src/components/Select/SelectLoadMore.vue
diff --git a/neutrino-proxy-admin/src/api/portPool.js b/neutrino-proxy-admin/src/api/portPool.js
index 310c8933..4a8ee331 100644
--- a/neutrino-proxy-admin/src/api/portPool.js
+++ b/neutrino-proxy-admin/src/api/portPool.js
@@ -14,13 +14,11 @@ export function portPoolList() {
method: 'get'
})
}
-export function availablePortList(licenseId) {
+export function availablePortList(query) {
return request({
url: '/port-pool/get-available-port-list',
method: 'get',
- params: {
- licenseId: licenseId
- }
+ params: query
})
}
diff --git a/neutrino-proxy-admin/src/components/Select/SelectLoadMore.vue b/neutrino-proxy-admin/src/components/Select/SelectLoadMore.vue
new file mode 100644
index 00000000..82a27536
--- /dev/null
+++ b/neutrino-proxy-admin/src/components/Select/SelectLoadMore.vue
@@ -0,0 +1,168 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/neutrino-proxy-admin/src/views/proxy/portMapping.vue b/neutrino-proxy-admin/src/views/proxy/portMapping.vue
index 725ac591..ec5f643a 100644
--- a/neutrino-proxy-admin/src/views/proxy/portMapping.vue
+++ b/neutrino-proxy-admin/src/views/proxy/portMapping.vue
@@ -142,11 +142,22 @@
-
+
+
+
@@ -196,6 +207,8 @@ import waves from '@/directive/waves' // 水波纹指令
import { parseTime } from '@/utils'
import ButtonPopover from '../../components/Button/buttonPopover'
import DropdownTable from '../../components/Dropdown/DropdownTable'
+// 下拉选择加载组件
+import loadSelect from "@/components/Select/SelectLoadMore";
const calendarTypeOptions = [
{ key: 'CN', display_name: 'China' },
@@ -217,7 +230,8 @@ export default {
},
components: {
DropdownTable,
- ButtonPopover
+ ButtonPopover,
+ loadSelect
},
data() {
return {
@@ -282,7 +296,13 @@ export default {
countryColumns: [
{ prop: 'userName', label: '用户名', align: 'center' },
{ prop: 'name', label: 'License', align: 'center' }
- ]
+ ],
+ loadServerPortQuery:{ //下拉框加载数据请求参数
+ page:1,
+ size:50,
+ licenseId:null,
+ },
+ more: true,
}
},
filters: {
@@ -343,15 +363,9 @@ export default {
this.domainName = response.data.data
})
},
- getPortPoolList() {
- portPoolList().then(response => {
- this.serverPortList = response.data.data
- })
- },
getAvailablePortList(licenseId) {
- availablePortList(licenseId).then(response => {
- this.serverPortList = response.data.data
- })
+ this.loadServerPortQuery.licenseId = licenseId;
+ this.serverPortList = []; //清掉数据
},
getAllUserList() {
userList().then(response => {
@@ -408,6 +422,8 @@ export default {
userId: undefined
}
this.serverPortList = []
+ this.loadServerPortQuery.licenseId = null;
+ this.more = true;
},
handleCreate() {
this.resetTemp()
@@ -526,7 +542,37 @@ export default {
return v[j]
}
}))
- }
+ },
+ // 传入给load-select组件的函数
+ loadServerPort({page = 1, more = false, keyword = ""} = {}) {
+ if(this.loadServerPortQuery.licenseId==null || this.loadServerPortQuery.licenseId==''){
+ this.more = false;
+ this.$message({
+ message: '请先选择License',
+ type: 'warning'
+ })
+ return ;
+ }
+ return new Promise(resolve => {
+ this.loadServerPortQuery.page = page;
+ this.loadServerPortQuery.keyword = keyword;
+ // 访问后端接口API
+ availablePortList(this.loadServerPortQuery).then(res => {
+ let result = res.data;
+ if (more) {
+ this.serverPortList = [...this.serverPortList, ...result.data.records];
+ } else {
+ this.serverPortList = result.data.records;
+ }
+
+ // this.loadServerPortQuery.page = result.data.current;
+ let {total, current, size} = result.data;
+ this.more = page * size < total;
+ this.loadServerPortQuery.page = current;
+ resolve();
+ });
+ });
+ },
}
}
diff --git a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java
index 86743108..76ac35fe 100644
--- a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java
+++ b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/PortPoolController.java
@@ -102,7 +102,7 @@ public class PortPoolController {
@Get
@Mapping("/get-available-port-list")
- public List getAvailablePortList(AvailablePortListReq req) {
+ public PageInfo getAvailablePortList(AvailablePortListReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getLicenseId(), "licenseId");
return portPoolService.getAvailablePortList(req);
diff --git a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/req/system/AvailablePortListReq.java b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/req/system/AvailablePortListReq.java
index 81526756..448700b9 100644
--- a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/req/system/AvailablePortListReq.java
+++ b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/controller/req/system/AvailablePortListReq.java
@@ -12,4 +12,18 @@ public class AvailablePortListReq {
* licenseId
*/
private Integer licenseId;
+
+ /**
+ * 当前页
+ */
+ private int page = 1;
+ /**
+ * 分页大小
+ */
+ private int size = 10;
+
+ /**
+ * 搜索关键字
+ */
+ private String keyword;
}
diff --git a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/dal/PortPoolMapper.java b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/dal/PortPoolMapper.java
index 7c045a98..29776db2 100644
--- a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/dal/PortPoolMapper.java
+++ b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/dal/PortPoolMapper.java
@@ -67,5 +67,5 @@ public interface PortPoolMapper extends BaseMapper {
List selectResList(@Param("req") PortPoolListReq req);
- List getAvailablePortList(@Param("licenseId") Integer licenseId,@Param("userId") Integer userId);
+ List getAvailablePortList(@Param("licenseId") Integer licenseId,@Param("userId") Integer userId, @Param("keyword") String keyword);
}
diff --git a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java
index b3f03491..a8e42f00 100644
--- a/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java
+++ b/neutrino-proxy-server/src/main/java/org/dromara/neutrinoproxy/server/service/PortPoolService.java
@@ -175,9 +175,17 @@ public class PortPoolService {
* 游客:全局端口 + 当前选择用户独占端口 + 当前选择license独占端口
* 非管理员身份时:下拉选择license,只能选当前用户下的LICENSE
*/
- public List getAvailablePortList(AvailablePortListReq req) {
+ public PageInfo getAvailablePortList(AvailablePortListReq req) {
+
LicenseDO licenseDO = licenseMapper.queryById(req.getLicenseId());
- return portPoolMapper.getAvailablePortList(req.getLicenseId(), licenseDO.getUserId());
+ if(StringUtils.isNotEmpty(req.getKeyword())){
+ req.setKeyword(req.getKeyword()+"%");
+ }
+
+ Page result = PageHelper.startPage(req.getPage(), req.getSize());
+ List portList = portPoolMapper.getAvailablePortList(req.getLicenseId(), licenseDO.getUserId(), req.getKeyword());
+
+ return PageInfo.of(portList, result.getTotal(), req.getPage(), req.getSize());
}
public void deleteBatch(List ids) {
diff --git a/neutrino-proxy-server/src/main/resources/mapper/PortPoolMapper.xml b/neutrino-proxy-server/src/main/resources/mapper/PortPoolMapper.xml
index 6cbb1935..e2c22c2c 100644
--- a/neutrino-proxy-server/src/main/resources/mapper/PortPoolMapper.xml
+++ b/neutrino-proxy-server/src/main/resources/mapper/PortPoolMapper.xml
@@ -32,6 +32,9 @@
possessor_type = 0
OR ( possessor_type = 1 AND possessor_id = #{userId,jdbcType=INTEGER} )
OR ( possessor_type = 2 AND possessor_id = #{licenseId,jdbcType=INTEGER} )
- )
+ )
+
+ AND `port` LIKE #{keyword}
+