From 3d80dd78362cb0dc6f6e5427a161b5437373e1e5 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Sun, 14 Aug 2022 17:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E3=80=81=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/UserController.java | 21 +++++++ .../server/controller/req/UserListReq.java | 31 ++++++++++ .../server/controller/res/UserListRes.java | 61 +++++++++++++++++++ .../neutrino/proxy/server/dal/UserMapper.java | 11 ++++ .../proxy/server/service/UserService.java | 20 ++++++ 5 files changed, 144 insertions(+) create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/UserListReq.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/UserListRes.java diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java index 549666a2..f18a6033 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/UserController.java @@ -23,9 +23,17 @@ 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.GetMapping; import fun.asgc.neutrino.core.web.annotation.RequestMapping; import fun.asgc.neutrino.core.web.annotation.RestController; +import fun.asgc.neutrino.proxy.server.controller.req.UserListReq; +import fun.asgc.neutrino.proxy.server.controller.res.UserListRes; import fun.asgc.neutrino.proxy.server.service.UserService; +import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil; + +import java.util.List; /** * 用户管理 @@ -38,4 +46,17 @@ import fun.asgc.neutrino.proxy.server.service.UserService; public class UserController { @Autowired private UserService userService; + + @GetMapping("page") + public Page page(PageQuery pageQuery, UserListReq req) { + ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); + + return userService.page(pageQuery, req); + } + + @GetMapping("list") + public List list(UserListReq req) { + + return userService.list(req); + } } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/UserListReq.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/UserListReq.java new file mode 100644 index 00000000..d26d7734 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/UserListReq.java @@ -0,0 +1,31 @@ +/** + * 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; + +/** + * 用户列表请求 + * @author: aoshiguchen + * @date: 2022/8/14 + */ +public class UserListReq { + +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/UserListRes.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/UserListRes.java new file mode 100644 index 00000000..ae1ea8fd --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/UserListRes.java @@ -0,0 +1,61 @@ +/** + * 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/14 + */ +@Data +public class UserListRes { + private Integer id; + /** + * 用户名 + */ + private String name; + /** + * 登录名 + */ + private String loginName; + /** + * 登录密码 + */ + private String loginPassword; + /** + * 是否禁用 + */ + private Integer enable; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/UserMapper.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/UserMapper.java index f958d3ea..d2054809 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/UserMapper.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/UserMapper.java @@ -26,6 +26,9 @@ import fun.asgc.neutrino.core.annotation.Param; import fun.asgc.neutrino.core.db.annotation.ResultType; import fun.asgc.neutrino.core.db.annotation.Select; import fun.asgc.neutrino.core.db.mapper.SqlMapper; +import fun.asgc.neutrino.core.db.page.Page; +import fun.asgc.neutrino.proxy.server.controller.req.UserListReq; +import fun.asgc.neutrino.proxy.server.controller.res.UserListRes; import fun.asgc.neutrino.proxy.server.dal.entity.UserDO; import java.util.List; @@ -58,4 +61,12 @@ public interface UserMapper extends SqlMapper { @ResultType(UserDO.class) @Select("select * from user where id in (:ids)") List findByIds(@Param("ids") Set ids); + + @ResultType(UserListRes.class) + @Select("select * from user") + void page(Page page, UserListReq req); + + @ResultType(UserListRes.class) + @Select("select * from user where enable = 1") + List list(); } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/UserService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/UserService.java index 852ff490..8b9c337d 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/UserService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/UserService.java @@ -23,12 +23,19 @@ 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.core.util.CollectionUtil; import fun.asgc.neutrino.core.util.DateUtil; +import fun.asgc.neutrino.core.web.annotation.GetMapping; import fun.asgc.neutrino.proxy.server.base.rest.constant.ExceptionConstant; import fun.asgc.neutrino.proxy.server.base.rest.ServiceException; import fun.asgc.neutrino.proxy.server.base.rest.SystemContextHolder; import fun.asgc.neutrino.proxy.server.controller.req.LoginReq; +import fun.asgc.neutrino.proxy.server.controller.req.UserListReq; +import fun.asgc.neutrino.proxy.server.controller.res.LicenseListRes; import fun.asgc.neutrino.proxy.server.controller.res.LoginRes; +import fun.asgc.neutrino.proxy.server.controller.res.UserListRes; import fun.asgc.neutrino.proxy.server.dal.UserLoginRecordMapper; import fun.asgc.neutrino.proxy.server.dal.UserMapper; import fun.asgc.neutrino.proxy.server.dal.UserTokenMapper; @@ -36,9 +43,11 @@ import fun.asgc.neutrino.proxy.server.dal.entity.UserDO; import fun.asgc.neutrino.proxy.server.dal.entity.UserLoginRecordDO; import fun.asgc.neutrino.proxy.server.dal.entity.UserTokenDO; import fun.asgc.neutrino.proxy.server.util.Md5Util; +import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil; import java.util.Calendar; import java.util.Date; +import java.util.List; import java.util.UUID; /** @@ -116,4 +125,15 @@ public class UserService { Date expirationTime = DateUtil.addDate(now, Calendar.HOUR, 1); userTokenMapper.updateTokenExpirationTime(token, expirationTime); } + + public Page page(PageQuery pageQuery, UserListReq req) { + Page page = Page.create(pageQuery); + userMapper.page(page, req); + return page; + } + + public List list(UserListReq req) { + List list = userMapper.list(); + return list; + } }