修复端口映射管理bug
This commit is contained in:
@@ -14,6 +14,12 @@ export function licenseList() {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function licenseAuthList() {
|
||||||
|
return request({
|
||||||
|
url: '/license/auth-list',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function createLicense(data) {
|
export function createLicense(data) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container calendar-list-container">
|
<div class="app-container calendar-list-container">
|
||||||
<div class="filter-container" style="display:flex">
|
<div class="filter-container" style="display:flex">
|
||||||
<el-select v-model="listQuery.userId" placeholder="请选择用户" clearable style="margin-right:10px" @change="refrech">
|
<el-select v-model="listQuery.userId" placeholder="请选择用户" clearable style="margin-right:10px">
|
||||||
<el-option v-for="item in userList" :key="item.loginName" :label="item.name" :value="item.id" />
|
<el-option v-for="item in userList" :key="item.loginName" :label="item.name" :value="item.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select v-model="listQuery.license" placeholder="请选择license" clearable style="margin-right:10px">
|
<el-select v-model="listQuery.licenseId" placeholder="请选择license" clearable style="margin-right:10px">
|
||||||
<el-option v-for="item in licenseList" :key="item.key" :label="item.name" :value="item.id" />
|
<el-option v-for="item in licenseList" :key="item.key" :label="item.name" :value="item.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-input v-model="listQuery.serverPort" type="text" style="width:150px;margin-right:10px" class="filter-item"
|
<el-input v-model="listQuery.serverPort" type="text" style="width:150px;margin-right:10px" class="filter-item"
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
<!-- </el-form-item>-->
|
<!-- </el-form-item>-->
|
||||||
|
|
||||||
<el-form-item :label="$t('License')" prop="licenseId">
|
<el-form-item :label="$t('License')" prop="licenseId">
|
||||||
<DropdownTable v-model="temp.licenseId" :name.sync="temp.licenseName" :tableData="licenseList"
|
<DropdownTable v-model="temp.licenseId" :name.sync="temp.licenseName" :tableData="licenseAuthList"
|
||||||
@selectedData="selectedFeeItem" placeholder="请选择" :width="280" :disabled="dialogStatus === 'update'" />
|
@selectedData="selectedFeeItem" placeholder="请选择" :width="280" :disabled="dialogStatus === 'update'" />
|
||||||
<!-- <DropdownTable
|
<!-- <DropdownTable
|
||||||
:columns="countryColumns"
|
:columns="countryColumns"
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { fetchList, createUserPortMapping, updateUserPortMapping, updateEnableStatus, deletePortMapping } from '@/api/portMapping'
|
import { fetchList, createUserPortMapping, updateUserPortMapping, updateEnableStatus, deletePortMapping } from '@/api/portMapping'
|
||||||
import { portPoolList, availablePortList } from '@/api/portPool'
|
import { portPoolList, availablePortList } from '@/api/portPool'
|
||||||
import { licenseList } from '@/api/license'
|
import { licenseList, licenseAuthList } from '@/api/license'
|
||||||
import { userList } from '@/api/user'
|
import { userList } from '@/api/user'
|
||||||
import waves from '@/directive/waves' // 水波纹指令
|
import waves from '@/directive/waves' // 水波纹指令
|
||||||
import { parseTime } from '@/utils'
|
import { parseTime } from '@/utils'
|
||||||
@@ -192,7 +192,7 @@ export default {
|
|||||||
importance: undefined,
|
importance: undefined,
|
||||||
title: undefined,
|
title: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
userid: undefined,
|
userId: undefined,
|
||||||
license: undefined,
|
license: undefined,
|
||||||
port: undefined,
|
port: undefined,
|
||||||
isOnline: undefined,
|
isOnline: undefined,
|
||||||
@@ -205,6 +205,7 @@ export default {
|
|||||||
statusOptions: ['published', 'draft', 'deleted'],
|
statusOptions: ['published', 'draft', 'deleted'],
|
||||||
userList: [],
|
userList: [],
|
||||||
licenseList: [],
|
licenseList: [],
|
||||||
|
licenseAuthList: [],
|
||||||
serverPortList: [],
|
serverPortList: [],
|
||||||
showReviewer: false,
|
showReviewer: false,
|
||||||
temp: {
|
temp: {
|
||||||
@@ -269,11 +270,9 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.getDataList()
|
this.getDataList()
|
||||||
this.getLicenseList()
|
this.getLicenseList()
|
||||||
|
this.getLicenseAuthList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
refrech(val) {
|
|
||||||
this.$forceUpdate()
|
|
||||||
},
|
|
||||||
getList() {
|
getList() {
|
||||||
this.listLoading = true
|
this.listLoading = true
|
||||||
fetchList(this.listQuery).then(response => {
|
fetchList(this.listQuery).then(response => {
|
||||||
@@ -313,6 +312,11 @@ export default {
|
|||||||
this.licenseList = response.data.data
|
this.licenseList = response.data.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getLicenseAuthList() {
|
||||||
|
licenseAuthList().then(response => {
|
||||||
|
this.licenseAuthList = response.data.data
|
||||||
|
})
|
||||||
|
},
|
||||||
handleFilter() {
|
handleFilter() {
|
||||||
this.listQuery.current = 1
|
this.listQuery.current = 1
|
||||||
this.getList()
|
this.getList()
|
||||||
@@ -347,6 +351,7 @@ export default {
|
|||||||
clientPort: undefined,
|
clientPort: undefined,
|
||||||
userId: undefined
|
userId: undefined
|
||||||
}
|
}
|
||||||
|
this.serverPortList = []
|
||||||
},
|
},
|
||||||
handleCreate() {
|
handleCreate() {
|
||||||
this.resetTemp()
|
this.resetTemp()
|
||||||
|
|||||||
+5
@@ -56,6 +56,11 @@ public class LicenseController {
|
|||||||
return licenseService.list(req);
|
return licenseService.list(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mapping("/auth-list")
|
||||||
|
public List<LicenseListRes> queryCurUserLicense(LicenseListReq req) {
|
||||||
|
return licenseService.queryCurUserLicense(req);
|
||||||
|
}
|
||||||
|
|
||||||
@Post
|
@Post
|
||||||
@Mapping("/create")
|
@Mapping("/create")
|
||||||
@Authorization(onlyAdmin = true)
|
@Authorization(onlyAdmin = true)
|
||||||
|
|||||||
+76
-71
@@ -1,16 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2022 aoshiguchen
|
* Copyright (c) 2022 aoshiguchen
|
||||||
*
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
* in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
* furnished to do so, subject to the following conditions:
|
||||||
*
|
* <p>
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
* <p>
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
@@ -39,83 +39,88 @@ import java.util.Set;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface LicenseMapper extends BaseMapper<LicenseDO> {
|
public interface LicenseMapper extends BaseMapper<LicenseDO> {
|
||||||
|
|
||||||
default List<LicenseDO> listAll() {
|
default List<LicenseDO> listAll() {
|
||||||
return this.selectList(new LambdaQueryWrapper<>());
|
return this.selectList(new LambdaQueryWrapper<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<LicenseDO> listByUserId(Integer userId) {
|
default List<LicenseDO> listByUserId(Integer userId) {
|
||||||
return this.selectList(new LambdaQueryWrapper<LicenseDO>()
|
return this.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getUserId, userId)
|
.eq(LicenseDO::getUserId, userId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
|
default LicenseDO queryById(Integer licenseId) {
|
||||||
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
return this.selectOne(new LambdaQueryWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getId, id)
|
.eq(LicenseDO::getId, licenseId));
|
||||||
.set(LicenseDO::getEnable, enable)
|
}
|
||||||
.set(LicenseDO::getUpdateTime, updateTime)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
default void updateOnlineStatus(Integer id, Integer isOnline, Date updateTime) {
|
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
|
||||||
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getId, id)
|
.eq(LicenseDO::getId, id)
|
||||||
.set(LicenseDO::getIsOnline, isOnline)
|
.set(LicenseDO::getEnable, enable)
|
||||||
.set(LicenseDO::getUpdateTime, updateTime)
|
.set(LicenseDO::getUpdateTime, updateTime)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void updateOnlineStatus(Integer isOnline, Date updateTime) {
|
default void updateOnlineStatus(Integer id, Integer isOnline, Date updateTime) {
|
||||||
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||||
.set(LicenseDO::getIsOnline, updateTime)
|
.eq(LicenseDO::getId, id)
|
||||||
.set(LicenseDO::getUpdateTime, updateTime)
|
.set(LicenseDO::getIsOnline, isOnline)
|
||||||
);
|
.set(LicenseDO::getUpdateTime, updateTime)
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
default void reset(Integer id, String key, Date updateTime) {
|
default void updateOnlineStatus(Integer isOnline, Date updateTime) {
|
||||||
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getId, id)
|
.set(LicenseDO::getIsOnline, updateTime)
|
||||||
.set(LicenseDO::getKey, key)
|
.set(LicenseDO::getUpdateTime, updateTime)
|
||||||
.set(LicenseDO::getUpdateTime, updateTime)
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
default LicenseDO findById(Integer id) {
|
default void reset(Integer id, String key, Date updateTime) {
|
||||||
return this.selectById(id);
|
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||||
}
|
.eq(LicenseDO::getId, id)
|
||||||
|
.set(LicenseDO::getKey, key)
|
||||||
|
.set(LicenseDO::getUpdateTime, updateTime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
default void update(Integer id, String name, Date updateTime) {
|
default LicenseDO findById(Integer id) {
|
||||||
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
return this.selectById(id);
|
||||||
.eq(LicenseDO::getId, id)
|
}
|
||||||
.set(LicenseDO::getName, name)
|
|
||||||
.set(LicenseDO::getUpdateTime, updateTime)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<LicenseDO> findByIds(Set<Integer> ids) {
|
default void update(Integer id, String name, Date updateTime) {
|
||||||
return selectBatchIds(ids);
|
this.update(null, new LambdaUpdateWrapper<LicenseDO>()
|
||||||
}
|
.eq(LicenseDO::getId, id)
|
||||||
|
.set(LicenseDO::getName, name)
|
||||||
|
.set(LicenseDO::getUpdateTime, updateTime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
default LicenseDO checkRepeat(Integer userId, String name) {
|
default List<LicenseDO> findByIds(Set<Integer> ids) {
|
||||||
return this.selectOne(new LambdaQueryWrapper<LicenseDO>()
|
return selectBatchIds(ids);
|
||||||
.eq(LicenseDO::getUserId, userId)
|
}
|
||||||
.eq(LicenseDO::getName, name)
|
|
||||||
.last("limit 1")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
default LicenseDO checkRepeat(Integer userId, String name, Set<Integer> excludeIds) {
|
default LicenseDO checkRepeat(Integer userId, String name) {
|
||||||
return this.selectOne(new LambdaQueryWrapper<LicenseDO>()
|
return this.selectOne(new LambdaQueryWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getUserId, userId)
|
.eq(LicenseDO::getUserId, userId)
|
||||||
.eq(LicenseDO::getName, name)
|
.eq(LicenseDO::getName, name)
|
||||||
.notIn(LicenseDO::getId, excludeIds)
|
.last("limit 1")
|
||||||
.last("limit 1")
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
default LicenseDO findByKey(String licenseKey) {
|
default LicenseDO checkRepeat(Integer userId, String name, Set<Integer> excludeIds) {
|
||||||
return selectOne(new LambdaQueryWrapper<LicenseDO>()
|
return this.selectOne(new LambdaQueryWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getKey, licenseKey)
|
.eq(LicenseDO::getUserId, userId)
|
||||||
);
|
.eq(LicenseDO::getName, name)
|
||||||
}
|
.notIn(LicenseDO::getId, excludeIds)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
default LicenseDO findByKey(String licenseKey) {
|
||||||
|
return selectOne(new LambdaQueryWrapper<LicenseDO>()
|
||||||
|
.eq(LicenseDO::getKey, licenseKey)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
@@ -24,6 +24,7 @@ import fun.asgc.neutrino.proxy.server.dal.entity.UserDO;
|
|||||||
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
|
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
|
||||||
import ma.glasnost.orika.MapperFacade;
|
import ma.glasnost.orika.MapperFacade;
|
||||||
import org.apache.ibatis.solon.annotation.Db;
|
import org.apache.ibatis.solon.annotation.Db;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.noear.solon.annotation.Component;
|
import org.noear.solon.annotation.Component;
|
||||||
import org.noear.solon.annotation.Inject;
|
import org.noear.solon.annotation.Inject;
|
||||||
import org.noear.solon.core.Lifecycle;
|
import org.noear.solon.core.Lifecycle;
|
||||||
@@ -79,6 +80,12 @@ public class LicenseService implements Lifecycle {
|
|||||||
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||||
.eq(LicenseDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
.eq(LicenseDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||||
);
|
);
|
||||||
|
List<LicenseListRes> licenseList = assembleConvertLicenses(list);
|
||||||
|
return licenseList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private List<LicenseListRes> assembleConvertLicenses(List<LicenseDO> list) {
|
||||||
List<LicenseListRes> licenseList = mapperFacade.mapAsList(list, LicenseListRes.class);
|
List<LicenseListRes> licenseList = mapperFacade.mapAsList(list, LicenseListRes.class);
|
||||||
if (!CollectionUtil.isEmpty(licenseList)) {
|
if (!CollectionUtil.isEmpty(licenseList)) {
|
||||||
Set<Integer> userIds = licenseList.stream().map(LicenseListRes::getUserId).collect(Collectors.toSet());
|
Set<Integer> userIds = licenseList.stream().map(LicenseListRes::getUserId).collect(Collectors.toSet());
|
||||||
@@ -220,4 +227,20 @@ public class LicenseService implements Lifecycle {
|
|||||||
public void stop() throws Throwable {
|
public void stop() throws Throwable {
|
||||||
licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前角色下的license,若为管理员 则返回全部license
|
||||||
|
*/
|
||||||
|
public List<LicenseListRes> queryCurUserLicense(LicenseListReq req) {
|
||||||
|
if(SystemContextHolder.isAdmin()){
|
||||||
|
return this.list(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LicenseDO> list = licenseMapper.selectList(new LambdaQueryWrapper<LicenseDO>()
|
||||||
|
.eq(LicenseDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||||
|
.eq(LicenseDO::getUserId,SystemContextHolder.getUserId())
|
||||||
|
);
|
||||||
|
List<LicenseListRes> licenseList = assembleConvertLicenses(list);
|
||||||
|
return licenseList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-19
@@ -1,16 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2022 aoshiguchen
|
* Copyright (c) 2022 aoshiguchen
|
||||||
*
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
* in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
* furnished to do so, subject to the following conditions:
|
||||||
*
|
* <p>
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
* copies or substantial portions of the Software.
|
* copies or substantial portions of the Software.
|
||||||
*
|
* <p>
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
@@ -33,13 +33,11 @@ import fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum;
|
|||||||
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
|
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
|
||||||
import fun.asgc.neutrino.proxy.server.controller.req.*;
|
import fun.asgc.neutrino.proxy.server.controller.req.*;
|
||||||
import fun.asgc.neutrino.proxy.server.controller.res.*;
|
import fun.asgc.neutrino.proxy.server.controller.res.*;
|
||||||
|
import fun.asgc.neutrino.proxy.server.dal.LicenseMapper;
|
||||||
import fun.asgc.neutrino.proxy.server.dal.PortGroupMapper;
|
import fun.asgc.neutrino.proxy.server.dal.PortGroupMapper;
|
||||||
import fun.asgc.neutrino.proxy.server.dal.PortMappingMapper;
|
import fun.asgc.neutrino.proxy.server.dal.PortMappingMapper;
|
||||||
import fun.asgc.neutrino.proxy.server.dal.PortPoolMapper;
|
import fun.asgc.neutrino.proxy.server.dal.PortPoolMapper;
|
||||||
import fun.asgc.neutrino.proxy.server.dal.entity.PortGroupDO;
|
import fun.asgc.neutrino.proxy.server.dal.entity.*;
|
||||||
import fun.asgc.neutrino.proxy.server.dal.entity.PortMappingDO;
|
|
||||||
import fun.asgc.neutrino.proxy.server.dal.entity.PortPoolDO;
|
|
||||||
import fun.asgc.neutrino.proxy.server.dal.entity.UserDO;
|
|
||||||
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
|
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
|
||||||
import ma.glasnost.orika.MapperFacade;
|
import ma.glasnost.orika.MapperFacade;
|
||||||
import org.apache.ibatis.solon.annotation.Db;
|
import org.apache.ibatis.solon.annotation.Db;
|
||||||
@@ -68,8 +66,10 @@ public class PortPoolService {
|
|||||||
|
|
||||||
@Db
|
@Db
|
||||||
private PortGroupMapper portGroupMapper;
|
private PortGroupMapper portGroupMapper;
|
||||||
@Db
|
@Db
|
||||||
private PortMappingMapper portMappingMapper;
|
private PortMappingMapper portMappingMapper;
|
||||||
|
@Db
|
||||||
|
private LicenseMapper licenseMapper;
|
||||||
|
|
||||||
public PageInfo<PortPoolListRes> page(PageQuery pageQuery, PortPoolListReq req) {
|
public PageInfo<PortPoolListRes> page(PageQuery pageQuery, PortPoolListReq req) {
|
||||||
Page<PortPoolListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
Page<PortPoolListRes> result = PageHelper.startPage(pageQuery.getCurrent(), pageQuery.getSize());
|
||||||
@@ -82,19 +82,20 @@ public class PortPoolService {
|
|||||||
List<PortPoolDO> list = portPoolMapper.selectList(new LambdaQueryWrapper<PortPoolDO>()
|
List<PortPoolDO> list = portPoolMapper.selectList(new LambdaQueryWrapper<PortPoolDO>()
|
||||||
.eq(PortPoolDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
.eq(PortPoolDO::getEnable, EnableStatusEnum.ENABLE.getStatus())
|
||||||
);
|
);
|
||||||
return mapperFacade.mapAsList(this.filterUsedPorts(list), PortPoolListRes.class);
|
return mapperFacade.mapAsList(this.filterUsedPorts(list), PortPoolListRes.class);
|
||||||
}
|
}
|
||||||
private List<PortPoolDO> filterUsedPorts(List<PortPoolDO> list) {
|
|
||||||
//Gets the used ports
|
|
||||||
List<PortMappingDO> usePorts = portMappingMapper.selectList(new LambdaQueryWrapper<PortMappingDO>().orderByAsc(PortMappingDO::getId));
|
|
||||||
|
|
||||||
List<Integer> serverPorts = usePorts.stream().map(item -> item.getServerPort()).collect(Collectors.toList());
|
private List<PortPoolDO> filterUsedPorts(List<PortPoolDO> list) {
|
||||||
|
//Gets the used ports
|
||||||
|
List<PortMappingDO> usePorts = portMappingMapper.selectList(new LambdaQueryWrapper<PortMappingDO>().orderByAsc(PortMappingDO::getId));
|
||||||
|
|
||||||
return list.stream().filter(item -> !serverPorts.contains(item.getPort())).collect(Collectors.toList());
|
List<Integer> serverPorts = usePorts.stream().map(item -> item.getServerPort()).collect(Collectors.toList());
|
||||||
}
|
|
||||||
|
return list.stream().filter(item -> !serverPorts.contains(item.getPort())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PortPoolCreateRes create(PortPoolCreateReq req) {
|
public PortPoolCreateRes create(PortPoolCreateReq req) {
|
||||||
PortPoolDO oldPortPoolDO = portPoolMapper.findByPort(req.getPort());
|
PortPoolDO oldPortPoolDO = portPoolMapper.findByPort(req.getPort());
|
||||||
ParamCheckUtil.checkMustNull(oldPortPoolDO, ExceptionConstant.PORT_CANNOT_REPEAT);
|
ParamCheckUtil.checkMustNull(oldPortPoolDO, ExceptionConstant.PORT_CANNOT_REPEAT);
|
||||||
PortGroupDO portGroupDO = portGroupMapper.selectById(req.getGroupId());
|
PortGroupDO portGroupDO = portGroupMapper.selectById(req.getGroupId());
|
||||||
@@ -155,8 +156,13 @@ public class PortPoolService {
|
|||||||
return new PortPoolUpdateGroupRes();
|
return new PortPoolUpdateGroupRes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员: 全局端口 + 当前选择的用户独占端口 + 当前选择license独占端口
|
||||||
|
* 游客:全局端口 + 当前选择用户独占端口 + 当前选择license独占端口
|
||||||
|
* 非管理员身份时:下拉选择license,只能选当前用户下的LICENSE
|
||||||
|
*/
|
||||||
public List<PortPoolListRes> getAvailablePortList(AvailablePortListReq req) {
|
public List<PortPoolListRes> getAvailablePortList(AvailablePortListReq req) {
|
||||||
UserDO user = SystemContextHolder.getUser();
|
LicenseDO licenseDO = licenseMapper.queryById(req.getLicenseId());
|
||||||
return portPoolMapper.getAvailablePortList(req.getLicenseId(), user.getId());
|
return portPoolMapper.getAvailablePortList(req.getLicenseId(), licenseDO.getUserId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user