From 7ac57eaa78305303fcc5269ee3ffbac456681d3c Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Sun, 7 Aug 2022 13:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=AB=AF=E5=8F=A3=E6=B1=A0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3rest=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/PortPoolController.java | 72 ++++++++++++++++ .../controller/req/PortPoolCreateReq.java | 34 ++++++++ .../controller/req/PortPoolListReq.java | 34 ++++++++ .../req/PortPoolUpdateEnableStatusReq.java | 41 ++++++++++ .../controller/res/PortPoolCreateRes.java | 34 ++++++++ .../controller/res/PortPoolListRes.java | 53 ++++++++++++ .../res/PortPoolUpdateEnableStatusRes.java | 34 ++++++++ .../proxy/server/dal/PortPoolMapper.java | 53 ++++++++++++ .../proxy/server/dal/entity/PortPoolDO.java | 60 ++++++++++++++ .../proxy/server/service/PortPoolService.java | 82 +++++++++++++++++++ .../src/main/resources/sql/init-structure.sql | 9 +- 11 files changed, 500 insertions(+), 6 deletions(-) create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolCreateReq.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolListReq.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolUpdateEnableStatusReq.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolCreateRes.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolListRes.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolUpdateEnableStatusRes.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortPoolMapper.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/entity/PortPoolDO.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortPoolService.java diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java new file mode 100644 index 00000000..809e7908 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/PortPoolController.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller; + +import fun.asgc.neutrino.core.annotation.Autowired; +import fun.asgc.neutrino.core.annotation.NonIntercept; +import fun.asgc.neutrino.core.db.page.Page; +import fun.asgc.neutrino.core.db.page.PageQuery; +import fun.asgc.neutrino.core.web.annotation.*; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolCreateReq; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolListReq; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolUpdateEnableStatusReq; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolCreateRes; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolListRes; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolUpdateEnableStatusRes; +import fun.asgc.neutrino.proxy.server.service.PortPoolService; + +/** + * 端口池 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@NonIntercept +@RequestMapping("port-pool") +@RestController +public class PortPoolController { + @Autowired + private PortPoolService portPoolService; + + @GetMapping("page") + public Page page(PageQuery pageQuery, PortPoolListReq req) { + // TODO 参数校验 + return portPoolService.page(pageQuery, req); + } + + @PostMapping("create") + public PortPoolCreateRes create(@RequestBody PortPoolCreateReq req) { + // TODO 参数校验 + return portPoolService.create(req); + } + + @PostMapping("update/enable-status") + public PortPoolUpdateEnableStatusRes updateEnableStatus(@RequestBody PortPoolUpdateEnableStatusReq req) { + // TODO 参数校验 + return portPoolService.updateEnableStatus(req); + } + + @PostMapping("delete") + public void delete(@RequestParam("id") Integer id) { + // TODO 参数校验 + portPoolService.delete(id); + } +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolCreateReq.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolCreateReq.java new file mode 100644 index 00000000..f23a7d98 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolCreateReq.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller.req; + +import lombok.Data; + +/** + * 端口池创建请求 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Data +public class PortPoolCreateReq { + private Integer port; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolListReq.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolListReq.java new file mode 100644 index 00000000..c8f35bbb --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolListReq.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller.req; + +import lombok.Data; + +/** + * 端口池列表请求 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Data +public class PortPoolListReq { + +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolUpdateEnableStatusReq.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolUpdateEnableStatusReq.java new file mode 100644 index 00000000..29a04f35 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/PortPoolUpdateEnableStatusReq.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller.req; + +import lombok.Data; + +/** + * 端口池更新启用状态请求 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Data +public class PortPoolUpdateEnableStatusReq { + /** + * id + */ + private Integer id; + /** + * 启用状态 + */ + private Integer enable; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolCreateRes.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolCreateRes.java new file mode 100644 index 00000000..12d4d81c --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolCreateRes.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller.res; + +import lombok.Data; + +/** + * 端口池创建响应 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Data +public class PortPoolCreateRes { + +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolListRes.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolListRes.java new file mode 100644 index 00000000..6abf2fce --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolListRes.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller.res; + +import fun.asgc.neutrino.core.db.annotation.Id; +import lombok.Data; + +import java.util.Date; + +/** + * 端口池列表响应 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Data +public class PortPoolListRes { + private Integer id; + /** + * 端口 + */ + private Integer port; + /** + * 是否禁用 + */ + private Integer enable; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolUpdateEnableStatusRes.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolUpdateEnableStatusRes.java new file mode 100644 index 00000000..d7edde31 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/PortPoolUpdateEnableStatusRes.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.controller.res; + +import lombok.Data; + +/** + * 端口池更新启用状态响应 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Data +public class PortPoolUpdateEnableStatusRes { + +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortPoolMapper.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortPoolMapper.java new file mode 100644 index 00000000..2a6c3a83 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortPoolMapper.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.dal; + +import fun.asgc.neutrino.core.annotation.Component; +import fun.asgc.neutrino.core.annotation.Param; +import fun.asgc.neutrino.core.db.annotation.*; +import fun.asgc.neutrino.core.db.mapper.SqlMapper; +import fun.asgc.neutrino.core.db.page.Page; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolListReq; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolListRes; +import fun.asgc.neutrino.proxy.server.dal.entity.PortPoolDO; + +/** + * + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Component +public interface PortPoolMapper extends SqlMapper { + + @ResultType(PortPoolListRes.class) + @Select("select * from port_pool") + void page(Page page, PortPoolListReq req); + + @Insert("insert into port_pool(`port`,`enable`,`create_time`,`update_time`) values(:port,:enable,:createTime,:updateTime)") + void add(PortPoolDO portPool); + + @Update("update `port_pool` set enable = :enable where id = :id") + void updateEnableStatus(@Param("id") Integer id, @Param("enable") Integer enable); + + @Delete("delete from `port_pool` where id = ?") + void delete(Integer id); +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/entity/PortPoolDO.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/entity/PortPoolDO.java new file mode 100644 index 00000000..ea4502fa --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/entity/PortPoolDO.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.dal.entity; + +import fun.asgc.neutrino.core.db.annotation.Id; +import fun.asgc.neutrino.core.db.annotation.Table; +import lombok.Data; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 端口池 + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@ToString +@Accessors(chain = true) +@Data +@Table("port-pool") +public class PortPoolDO { + @Id + private Integer id; + /** + * 端口 + */ + private Integer port; + /** + * 是否禁用 + */ + private Integer enable; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortPoolService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortPoolService.java new file mode 100644 index 00000000..9adbd6cf --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortPoolService.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2022 aoshiguchen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package fun.asgc.neutrino.proxy.server.service; + +import fun.asgc.neutrino.core.annotation.Autowired; +import fun.asgc.neutrino.core.annotation.Component; +import fun.asgc.neutrino.core.db.page.Page; +import fun.asgc.neutrino.core.db.page.PageQuery; +import fun.asgc.neutrino.proxy.server.base.rest.constant.EnableStatusEnum; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolCreateReq; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolListReq; +import fun.asgc.neutrino.proxy.server.controller.req.PortPoolUpdateEnableStatusReq; +import fun.asgc.neutrino.proxy.server.controller.res.LicenseListRes; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolCreateRes; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolListRes; +import fun.asgc.neutrino.proxy.server.controller.res.PortPoolUpdateEnableStatusRes; +import fun.asgc.neutrino.proxy.server.dal.PortPoolMapper; +import fun.asgc.neutrino.proxy.server.dal.entity.PortPoolDO; + +import java.util.Date; + +/** + * + * @author: aoshiguchen + * @date: 2022/8/7 + */ +@Component +public class PortPoolService { + + @Autowired + private PortPoolMapper portPoolMapper; + + public Page page(PageQuery pageQuery, PortPoolListReq req) { + Page page = Page.create(pageQuery); + portPoolMapper.page(page, req); + return page; + } + + public PortPoolCreateRes create(PortPoolCreateReq req) { + Date now = new Date(); + + portPoolMapper.add(new PortPoolDO() + .setPort(req.getPort()) + .setEnable(EnableStatusEnum.ENABLE.getStatus()) + .setCreateTime(now) + .setUpdateTime(now) + ); + + return new PortPoolCreateRes(); + } + + public PortPoolUpdateEnableStatusRes updateEnableStatus(PortPoolUpdateEnableStatusReq req) { + + portPoolMapper.updateEnableStatus(req.getId(), req.getEnable()); + + return new PortPoolUpdateEnableStatusRes(); + } + + public void delete(Integer id) { + portPoolMapper.delete(id); + } + +} diff --git a/neutrino-proxy-server/src/main/resources/sql/init-structure.sql b/neutrino-proxy-server/src/main/resources/sql/init-structure.sql index d4b3a8b0..7ae8a608 100644 --- a/neutrino-proxy-server/src/main/resources/sql/init-structure.sql +++ b/neutrino-proxy-server/src/main/resources/sql/init-structure.sql @@ -41,13 +41,10 @@ CREATE TABLE IF NOT EXISTS `user_login_record` ( `create_time` INTEGER(20) NOT NULL ); -#可用端口配置表 -CREATE TABLE IF NOT EXISTS `user_login_record` ( +#端口池 +CREATE TABLE IF NOT EXISTS `port_pool` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - `user_id` INTEGER NOT NULL, - `ip` varchar(50) NOT NULL, - `token` varchar(50) NOT NULL, - `type` INTEGER(2) NOT NULL, + `port` INTEGER NOT NULL, `enable` INTEGER(2) NOT NULL, `update_time` INTEGER(20) NOT NULL, `create_time` INTEGER(20) NOT NULL