diff --git a/boot-service/src/main/java/com/xwbing/domain/entity/sys/SysUserLoginInOut.java b/boot-service/src/main/java/com/xwbing/domain/entity/sys/SysUserLoginInOut.java index 5ee860f..e58f99e 100644 --- a/boot-service/src/main/java/com/xwbing/domain/entity/sys/SysUserLoginInOut.java +++ b/boot-service/src/main/java/com/xwbing/domain/entity/sys/SysUserLoginInOut.java @@ -1,5 +1,6 @@ package com.xwbing.domain.entity.sys; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -14,11 +15,15 @@ import lombok.EqualsAndHashCode; public class SysUserLoginInOut extends BaseEntity { private static final long serialVersionUID = -2719103095945780275L; public static String table = "sys_user_login_in_out"; + @ApiModelProperty(example = "127.0.0.1", required = true) private String ip; + @ApiModelProperty(value = "登录登出类型(登录:1|登出:2)", example = "1", required = true) private int inoutType; private String userId; //临时字段 + @ApiModelProperty(value = "用户名字") private transient String userIdName; + @ApiModelProperty(value = "记录时间") private transient String recordTime; private transient String inoutTypeName; private transient String startDate; diff --git a/boot-service/src/main/java/com/xwbing/domain/entity/vo/ListSysRoleVo.java b/boot-service/src/main/java/com/xwbing/domain/entity/vo/ListSysRoleVo.java new file mode 100644 index 0000000..9d1927c --- /dev/null +++ b/boot-service/src/main/java/com/xwbing/domain/entity/vo/ListSysRoleVo.java @@ -0,0 +1,21 @@ +package com.xwbing.domain.entity.vo; + +import com.xwbing.domain.entity.sys.SysRole; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 项目名称: boot-module-demo + * 创建时间: 2018/1/18 15:52 + * 作者: xiangwb + * 说明: + */ +@Data +@ApiModel +public class ListSysRoleVo extends RestMessageVo { + @ApiModelProperty(value = "返回数据") + private List data; +} diff --git a/boot-service/src/main/java/com/xwbing/domain/entity/vo/SysAuthVo.java b/boot-service/src/main/java/com/xwbing/domain/entity/vo/SysAuthVo.java index 4c99110..ca9b175 100644 --- a/boot-service/src/main/java/com/xwbing/domain/entity/vo/SysAuthVo.java +++ b/boot-service/src/main/java/com/xwbing/domain/entity/vo/SysAuthVo.java @@ -2,7 +2,7 @@ package com.xwbing.domain.entity.vo; import com.xwbing.domain.entity.sys.SysAuthority; import lombok.Data; -import org.apache.commons.beanutils.BeanUtils; +import org.springframework.beans.BeanUtils; import java.util.List; @@ -20,11 +20,7 @@ public class SysAuthVo extends SysAuthority { } public SysAuthVo(SysAuthority orig) { - try { - BeanUtils.copyProperties(this, orig); - } catch (Exception e) { - e.printStackTrace(); - } + BeanUtils.copyProperties(orig, this); } private List children; diff --git a/boot-service/src/main/java/com/xwbing/service/sys/SysUserLoginInOutService.java b/boot-service/src/main/java/com/xwbing/service/sys/SysUserLoginInOutService.java index 349b8fc..7d6e71d 100644 --- a/boot-service/src/main/java/com/xwbing/service/sys/SysUserLoginInOutService.java +++ b/boot-service/src/main/java/com/xwbing/service/sys/SysUserLoginInOutService.java @@ -52,9 +52,11 @@ public class SysUserLoginInOutService { * @param inout * @return */ - public Pagination pageByType(int inout, String startDate, String endDate, Pagination page) { + public Pagination page(Integer inout, String startDate, String endDate, Pagination page) { Map map = new HashMap<>(); - map.put("inout", inout); + if (inout != null) { + map.put("inout", inout); + } if (StringUtils.isNotEmpty(startDate)) { map.put("startDate", startDate + " 00:00:00"); } @@ -64,12 +66,13 @@ public class SysUserLoginInOutService { PageInfo pageInfo = PageHelper.startPage(page.getCurrentPage(), page.getPageSize()).doSelectPageInfo(() -> loginInOutMapper.findByInoutType(map)); List list = pageInfo.getList(); if (CollectionUtils.isNotEmpty(list)) { - list.forEach(inOut -> { + list.forEach(loginInOut -> { //登录登出 - CommonEnum.LoginInOutEnum inOutEnum = Arrays.stream(CommonEnum.LoginInOutEnum.values()).filter(obj -> obj.getValue() == inout).findFirst().get(); - inOut.setInoutTypeName(inOutEnum.getName()); + CommonEnum.LoginInOutEnum inOutEnum = Arrays.stream(CommonEnum.LoginInOutEnum.values()).filter(obj -> obj.getValue() == loginInOut.getInoutType()).findFirst().get(); + loginInOut.setInoutTypeName(inOutEnum.getName()); }); } return page.result(page, pageInfo); } + } diff --git a/boot-service/src/main/resources/mapper/sys/SysUserLoginInOut.xml b/boot-service/src/main/resources/mapper/sys/SysUserLoginInOut.xml index 388cbf8..6f758f6 100644 --- a/boot-service/src/main/resources/mapper/sys/SysUserLoginInOut.xml +++ b/boot-service/src/main/resources/mapper/sys/SysUserLoginInOut.xml @@ -52,13 +52,18 @@ SELECT a.inout_type,a.ip,date_format(a.create_time,'%Y-%m-%d %H:%i:%s') recordTime,b.name userIdName FROM sys_user_login_in_out a left join sys_user_info b on (a.user_id=b.id) - where a.inout_type=#{inout} - - and a.create_time>=#{startDate} - - - and a.create_time #{endDate} - + + + a.inout_type=#{inout} + + + and a.create_time>=#{startDate} + + + and a.create_time #{endDate} + + ORDER BY a.create_time DESC + \ No newline at end of file diff --git a/boot-web/src/main/java/com/xwbing/controller/sys/CommonControl.java b/boot-web/src/main/java/com/xwbing/controller/rest/CommonControl.java similarity index 97% rename from boot-web/src/main/java/com/xwbing/controller/sys/CommonControl.java rename to boot-web/src/main/java/com/xwbing/controller/rest/CommonControl.java index 89934df..61cc439 100644 --- a/boot-web/src/main/java/com/xwbing/controller/sys/CommonControl.java +++ b/boot-web/src/main/java/com/xwbing/controller/rest/CommonControl.java @@ -1,4 +1,4 @@ -package com.xwbing.controller.sys; +package com.xwbing.controller.rest; import com.alibaba.fastjson.JSONObject; import com.xwbing.annotation.LogInfo; diff --git a/boot-web/src/main/java/com/xwbing/controller/sys/SysAuthorityControl.java b/boot-web/src/main/java/com/xwbing/controller/sys/SysAuthorityControl.java index 6476d10..7549f69 100644 --- a/boot-web/src/main/java/com/xwbing/controller/sys/SysAuthorityControl.java +++ b/boot-web/src/main/java/com/xwbing/controller/sys/SysAuthorityControl.java @@ -103,11 +103,11 @@ public class SysAuthorityControl { @LogInfo("根据是否启用分页查询所有权限") @ApiOperation(value = "根据是否启用分页查询所有权限", response = PageSysAuthorityVo.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "currentPage", value = "当前页", example = "1", paramType = "query", dataType = "int"), - @ApiImplicitParam(name = "pageSize", value = "每页显示的条数", example = "10", paramType = "query", dataType = "int") + @ApiImplicitParam(name = "currentPage", value = "当前页", defaultValue = "1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "pageSize", value = "每页显示的条数", defaultValue = "10", paramType = "query", dataType = "int") }) @GetMapping("pageByEnable") - public JSONObject pageByEnable(@RequestParam(required = false, defaultValue = "Y") String enable, @ApiIgnore Pagination page) { + public JSONObject pageByEnable(@RequestParam(required = false) String enable, @ApiIgnore Pagination page) { Pagination pagination = sysAuthorityService.pageByEnable(enable, page); return JsonResult.toJSONObj(pagination, ""); } @@ -129,7 +129,7 @@ public class SysAuthorityControl { @LogInfo("递归查询所有权限") @ApiOperation(value = "递归查询所有权限", response = ListSysAuthorityVo.class) @GetMapping("listTree") - public JSONObject listTree(@RequestParam(required = false, defaultValue = "Y") String enable) { + public JSONObject listTree(@RequestParam(required = false) String enable) { List authVos; //先去缓存里拿 boolean exists = redisService.exists(CommonConstant.AUTHORITY_THREE); diff --git a/boot-web/src/main/java/com/xwbing/controller/sys/SysRoleControl.java b/boot-web/src/main/java/com/xwbing/controller/sys/SysRoleControl.java index 274c3e1..035a39c 100644 --- a/boot-web/src/main/java/com/xwbing/controller/sys/SysRoleControl.java +++ b/boot-web/src/main/java/com/xwbing/controller/sys/SysRoleControl.java @@ -91,11 +91,11 @@ public class SysRoleControl { @LogInfo("根据是否启用分页查询所有角色") @ApiOperation(value = "根据是否启用分页查询所有角色", response = PageSysRoleVo.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "currentPage", value = "当前页", example = "1", paramType = "query", dataType = "int"), - @ApiImplicitParam(name = "pageSize", value = "每页显示的条数", example = "10", paramType = "query", dataType = "int") + @ApiImplicitParam(name = "currentPage", value = "当前页", defaultValue = "1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "pageSize", value = "每页显示的条数", defaultValue = "10", paramType = "query", dataType = "int") }) @GetMapping("pageByEnable") - public JSONObject pageByEnable(@RequestParam(required = false, defaultValue = "Y") String enable, @ApiIgnore Pagination page) { + public JSONObject pageByEnable(@RequestParam(required = false) String enable, @ApiIgnore Pagination page) { Pagination pagination = sysRoleService.pageByEnable(enable, page); return JsonResult.toJSONObj(pagination, ""); } @@ -103,7 +103,7 @@ public class SysRoleControl { @LogInfo("根据角色主键查找权限") @ApiOperation(value = "根据角色主键查找权限", response = PageSysRoleVo.class) @GetMapping("listAuthorityByRoleId") - public JSONObject listAuthorityByRoleId(@RequestParam String roleId, @RequestParam(required = false, defaultValue = "Y") String enable) { + public JSONObject listAuthorityByRoleId(@RequestParam String roleId, @RequestParam(required = false) String enable) { if (StringUtils.isEmpty(roleId)) { return JsonResult.toJSONObj("角色主键不能为空"); } diff --git a/boot-web/src/main/java/com/xwbing/controller/sys/SysUserControl.java b/boot-web/src/main/java/com/xwbing/controller/sys/SysUserControl.java index 67435e0..c9b94fc 100644 --- a/boot-web/src/main/java/com/xwbing/controller/sys/SysUserControl.java +++ b/boot-web/src/main/java/com/xwbing/controller/sys/SysUserControl.java @@ -93,11 +93,11 @@ public class SysUserControl { @LogInfo("查询所有用户") @ApiOperation(value = "查询所有用户", response = PageSysUserVo.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "currentPage", value = "当前页", example = "1", paramType = "query", dataType = "int"), - @ApiImplicitParam(name = "pageSize", value = "每页显示的条数", example = "10", paramType = "query", dataType = "int") + @ApiImplicitParam(name = "currentPage", value = "当前页", defaultValue = "1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "pageSize", value = "每页显示的条数", defaultValue = "10", paramType = "query", dataType = "int") }) @GetMapping("page") - public JSONObject page(@RequestParam(required = false) String name, @RequestParam(required = false, defaultValue = "0") String sex, @ApiIgnore Pagination page) { + public JSONObject page(@RequestParam(required = false) String name, @RequestParam(required = false) String sex, @ApiIgnore Pagination page) { Pagination pagination = sysUserService.page(name, sex, page); return JsonResult.toJSONObj(pagination, ""); } @@ -212,9 +212,9 @@ public class SysUserControl { } @LogInfo("根据用户主键查找所拥有的角色") - @ApiOperation(value = "根据用户主键查找所拥有的角色", response = PageSysRoleVo.class) + @ApiOperation(value = "根据用户主键查找所拥有的角色", response = ListSysRoleVo.class) @GetMapping("listRoleByUserId") - public JSONObject listRoleByUserId(@RequestParam String userId, @RequestParam(required = false, defaultValue = "Y") String enable) { + public JSONObject listRoleByUserId(@RequestParam String userId, @RequestParam(required = false) String enable) { if (StringUtils.isEmpty(userId)) { return JsonResult.toJSONObj("用户主键不能为空"); } @@ -223,9 +223,9 @@ public class SysUserControl { } @LogInfo("根据用户主键查找所拥有的权限") - @ApiOperation(value = "根据用户主键查找所拥有的权限", response = PageSysAuthorityVo.class) + @ApiOperation(value = "根据用户主键查找所拥有的权限", response = ListSysAuthorityVo.class) @GetMapping("listAuthorityByUserId") - public JSONObject listAuthorityByUserId(@RequestParam String userId, @RequestParam(required = false, defaultValue = "Y") String enable) { + public JSONObject listAuthorityByUserId(@RequestParam String userId, @RequestParam(required = false) String enable) { if (StringUtils.isEmpty(userId)) { return JsonResult.toJSONObj("用户主键不能为空"); } diff --git a/boot-web/src/main/java/com/xwbing/controller/sys/SysUserLoginInOutControl.java b/boot-web/src/main/java/com/xwbing/controller/sys/SysUserLoginInOutControl.java index d33cb07..147b9df 100644 --- a/boot-web/src/main/java/com/xwbing/controller/sys/SysUserLoginInOutControl.java +++ b/boot-web/src/main/java/com/xwbing/controller/sys/SysUserLoginInOutControl.java @@ -34,12 +34,12 @@ public class SysUserLoginInOutControl { @LogInfo("获取登录或登出信息") @ApiOperation(value = "获取登录或登出信息", response = PageSysUserLoginInOutVo.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "currentPage", value = "当前页", example = "1", paramType = "query", dataType = "int"), - @ApiImplicitParam(name = "pageSize", value = "页数", example = "10", paramType = "query", dataType = "int") + @ApiImplicitParam(name = "currentPage", value = "当前页", defaultValue = "1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "pageSize", value = "页数", defaultValue = "10", paramType = "query", dataType = "int") }) - @GetMapping("pageByType") - public JSONObject pageByType(@RequestParam int inout, @RequestParam String startDate, @RequestParam String endDate, @ApiIgnore Pagination page) { - Pagination pagination = inOutService.pageByType(inout, startDate, endDate, page); + @GetMapping("page") + public JSONObject page(@RequestParam(required = false) Integer inout, @RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate, @ApiIgnore Pagination page) { + Pagination pagination = inOutService.page(inout, startDate, endDate, page); return JsonResult.toJSONObj(pagination, "获取列表成功"); } }