新增用户分页、用户列表接口

This commit is contained in:
aoshiguchen
2022-08-14 17:25:00 +08:00
parent c36a3958ee
commit 3d80dd7836
5 changed files with 144 additions and 0 deletions
@@ -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<UserListRes> page(PageQuery pageQuery, UserListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return userService.page(pageQuery, req);
}
@GetMapping("list")
public List<UserListRes> list(UserListReq req) {
return userService.list(req);
}
}
@@ -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 {
}
@@ -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;
}
@@ -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<UserDO> findByIds(@Param("ids") Set<Integer> 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<UserListRes> list();
}
@@ -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<UserListRes> page(PageQuery pageQuery, UserListReq req) {
Page<UserListRes> page = Page.create(pageQuery);
userMapper.page(page, req);
return page;
}
public List<UserListRes> list(UserListReq req) {
List<UserListRes> list = userMapper.list();
return list;
}
}