nodes) {
this.sysResources.setNodes(nodes);
}
}
-
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/entity/Role.java b/shiro-core/src/main/java/com/zyd/shiro/business/entity/Role.java
index 6295b72..7dc5753 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/entity/Role.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/entity/Role.java
@@ -24,11 +24,11 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 角色信息
+ * @date: 2019-08-15 9:36 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class Role {
private SysRole sysRole;
@@ -96,4 +96,3 @@ public void setUpdateTime(Date updateTime) {
}
}
-
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/entity/RoleResources.java b/shiro-core/src/main/java/com/zyd/shiro/business/entity/RoleResources.java
index 3a2cd90..460d667 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/entity/RoleResources.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/entity/RoleResources.java
@@ -24,11 +24,11 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 连接角色与资源信息的桥梁
+ * @date: 2019-08-15 9:41 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class RoleResources {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/entity/User.java b/shiro-core/src/main/java/com/zyd/shiro/business/entity/User.java
index 9086f89..8ce0fa8 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/entity/User.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/entity/User.java
@@ -19,7 +19,9 @@
*/
package com.zyd.shiro.business.entity;
-import com.zyd.shiro.business.enums.*;
+import com.zyd.shiro.business.enums.UserGenderEnum;
+import com.zyd.shiro.business.enums.UserStatusEnum;
+import com.zyd.shiro.business.enums.UserTypeEnum;
import com.zyd.shiro.framework.object.AbstractBO;
import com.zyd.shiro.persistence.beans.SysUser;
import com.zyd.shiro.util.PasswordUtil;
@@ -28,11 +30,11 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户信息
+ * @date: 2019-08-15 9:34 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class User extends AbstractBO {
private SysUser sysUser;
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/entity/UserRole.java b/shiro-core/src/main/java/com/zyd/shiro/business/entity/UserRole.java
index 42241fe..6376155 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/entity/UserRole.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/entity/UserRole.java
@@ -24,11 +24,11 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 连接用户与角色信息的桥梁
+ * @date: 2019-08-15 9:40 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class UserRole {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResourceTypeEnum.java b/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResourceTypeEnum.java
index e2c4058..c846a97 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResourceTypeEnum.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResourceTypeEnum.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -24,14 +24,15 @@
package com.zyd.shiro.business.enums;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 资源类型
+ * @date: 2019-08-15 10:14 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public enum ResourceTypeEnum {
- menu("菜单"), button("按钮");
+ menu("菜单"),
+ button("按钮");
private final String info;
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResponseStatus.java b/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResponseStatus.java
index f2b7817..f6437a5 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResponseStatus.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/enums/ResponseStatus.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -24,11 +24,11 @@
package com.zyd.shiro.business.enums;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 错误操作的提示信息
+ * @date: 2019-08-15 10:08 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public enum ResponseStatus {
@@ -52,6 +52,12 @@ public enum ResponseStatus {
this.message = message;
}
+ /**
+ * @description: 获取错误操作的响应状态
+ * @param: message
+ * @date: 2019-08-15 10:11 AM
+ * @return: com.zyd.shiro.business.enums.ResponseStatus
+ */
public static ResponseStatus getResponseStatus(String message) {
for (ResponseStatus ut : ResponseStatus.values()) {
if (ut.getMessage() == message) {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserGenderEnum.java b/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserGenderEnum.java
index f3c1b5f..83b9f53 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserGenderEnum.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserGenderEnum.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -24,11 +24,11 @@
package com.zyd.shiro.business.enums;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户性别信息
+ * @date: 2019-08-15 10:05 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public enum UserGenderEnum {
MALE(1, "男"), FEMALE(0, "女"), UNKNOW(-1, "");
@@ -40,6 +40,12 @@ public enum UserGenderEnum {
this.desc = desc;
}
+ /**
+ * @description: (never used)通过code码获取用户的性别信息
+ * @param: code
+ * @date: 2019-08-15 10:05 AM
+ * @return: com.zyd.shiro.business.enums.UserGenderEnum
+ */
public static UserGenderEnum getUserSex(Integer code) {
if (code == null) {
return UNKNOW;
@@ -52,14 +58,20 @@ public static UserGenderEnum getUserSex(Integer code) {
return UNKNOW;
}
+ /**
+ * @description: (never used)通过字符code获取用户性别信息
+ * @param: code
+ * @date: 2019-08-15 10:06 AM
+ * @return: com.zyd.shiro.business.enums.UserGenderEnum
+ */
public static UserGenderEnum getUserSex(String code) {
if (code == null) {
return UNKNOW;
}
- if("m".equals(code)){
+ if ("m".equals(code)) {
return MALE;
}
- if("f".equals(code)){
+ if ("f".equals(code)) {
return FEMALE;
}
return UNKNOW;
@@ -69,6 +81,7 @@ public int getCode() {
return code;
}
+ //the method is never used
public String getDesc() {
return desc;
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserStatusEnum.java b/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserStatusEnum.java
index ffb68af..243f938 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserStatusEnum.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserStatusEnum.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -24,11 +24,11 @@
package com.zyd.shiro.business.enums;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户状态信息
+ * @date: 2019-08-15 9:56 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public enum UserStatusEnum {
NORMAL(1, "正常"),
@@ -41,6 +41,12 @@ public enum UserStatusEnum {
this.desc = desc;
}
+ /**
+ * @description: 获取用户的状态(是否可使用)
+ * @param: code
+ * @date: 2019-08-15 10:00 AM
+ * @return: com.zyd.shiro.business.enums.UserStatusEnum
+ */
public static UserStatusEnum get(Integer code) {
if (null == code) {
return NORMAL;
@@ -58,6 +64,7 @@ public Integer getCode() {
return code;
}
+ //the method is never used
public String getDesc() {
return desc;
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserTypeEnum.java b/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserTypeEnum.java
index a8faab2..86697b7 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserTypeEnum.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/enums/UserTypeEnum.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -26,11 +26,11 @@
import org.springframework.util.StringUtils;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户的身份类型信息
+ * @date: 2019-08-15 9:51 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public enum UserTypeEnum {
ROOT("超级管理员"),
@@ -43,6 +43,12 @@ public enum UserTypeEnum {
this.desc = desc;
}
+ /**
+ * @description: 获取用户的身份类型
+ * @param: type
+ * @date: 2019-08-15 9:55 AM
+ * @return: com.zyd.shiro.business.enums.UserTypeEnum
+ */
public static UserTypeEnum getByType(String type) {
if (StringUtils.isEmpty(type)) {
return UserTypeEnum.UNKNOW;
@@ -55,6 +61,7 @@ public static UserTypeEnum getByType(String type) {
return UserTypeEnum.UNKNOW;
}
+ //the method is never used
public String getDesc() {
return desc;
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/ShiroService.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/ShiroService.java
index 7bc1d66..352249d 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/ShiroService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/ShiroService.java
@@ -24,37 +24,43 @@
import java.util.Map;
/**
- * Shiro-权限相关的业务处理
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/25 14:37
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: Shiro-权限相关的业务处理
+ * @date: 2019-08-14 3:57 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface ShiroService {
/**
- * 初始化权限
+ * @description: 初始化权限
+ * @param:
+ * @date: 2019-08-14 3:53 PM
+ * @return: java.util.Map
*/
Map loadFilterChainDefinitions();
/**
- * 重新加载权限
+ * @description: 重新加载权限
+ * @param:
+ * @date: 2019-08-14 3:53 PM
+ * @return: void
*/
void updatePermission();
/**
- * 重新加载用户权限
- *
- * @param user
+ * @description: 重新加载用户权限
+ * @param: user
+ * @date: 2019-08-14 3:54 PM
+ * @return: void
*/
void reloadAuthorizingByUserId(User user);
/**
- * 重新加载所有拥有roleId角色的用户的权限
- *
- * @param roleId
+ * @description: 重新加载所有拥有roleId角色的用户的权限
+ * @param: roleId
+ * @date: 2019-08-14 3:54 PM
+ * @return: void
*/
void reloadAuthorizingByRoleId(Long roleId);
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysResourcesService.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysResourcesService.java
index e197ff5..d77958f 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysResourcesService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysResourcesService.java
@@ -28,66 +28,67 @@
import java.util.Map;
/**
- * 系统资源
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 系统资源相关的业务处理
+ * @date: 2019-08-14 4:05 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface SysResourcesService extends AbstractService {
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询资源列表
+ * @param: vo
+ * @date: 2019-08-14 4:05 PM
+ * @return: com.github.pagehelper.PageInfo
*/
PageInfo findPageBreakByCondition(ResourceConditionVO vo);
/**
- * 获取用户的资源列表
- *
- * @param map
- * @return
+ * @description: 获取用户所拥有的资源列表
+ * @param: map
+ * @date: 2019-08-14 4:06 PM
+ * @return: java.util.List
*/
List listUserResources(Map map);
/**
- * 获取ztree使用的资源列表
- *
- * @param rid
- * @return
+ * @description: 通过角色id获取ztree使用的资源列表
+ * @param: rid
+ * @date: 2019-08-14 4:06 PM
+ * @return: java.util.List>
*/
List> queryResourcesListWithSelected(Long rid);
/**
- * 获取资源的url和permission
- *
- * @return
+ * @description: 获取资源的url和Permission
+ * @param:
+ * @date: 2019-08-14 4:07 PM
+ * @return: java.util.List
*/
List listUrlAndPermission();
/**
- * 获取所有可用的菜单资源
- *
- * @return
+ * @description: 获取所有可用的菜单资源
+ * @param:
+ * @date: 2019-08-14 4:07 PM
+ * @return: java.util.List
*/
List listAllAvailableMenu();
/**
- * 获取父级资源下所有menu资源
- *
- * @return
+ * @description: (never used)获取父级资源下所有menu资源
+ * @param: pid
+ * @date: 2019-08-14 4:08 PM
+ * @return: java.util.List>
*/
List> listChildMenuByPid(Long pid);
/**
- * 获取用户关联的所有资源
- *
- * @param userId
- * @return
+ * @description: 通过用户id获取用户关联的所有资源
+ * @param: userId
+ * @date: 2019-08-14 4:08 PM
+ * @return: java.util.List
*/
List listByUserId(Long userId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleResourcesService.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleResourcesService.java
index 91f473b..68df668 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleResourcesService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleResourcesService.java
@@ -24,28 +24,28 @@
import com.zyd.shiro.framework.object.AbstractService;
/**
- * 角色资源
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 角色资源相关的业务处理
+ * @date: 2019-08-14 4:01 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface SysRoleResourcesService extends AbstractService {
/**
- * 添加角色资源
- *
- * @param roleId
- * @param resourcesIds
+ * @description: 添加角色资源
+ * @param: roleId
+ * @param: resourcesIds
+ * @date: 2019-08-14 4:13 PM
+ * @return: void
*/
void addRoleResources(Long roleId, String resourcesIds);
/**
- * 通过角色id批量删除
- *
- * @param roleId
+ * @description: 通过角色id批量删除
+ * @param: roleId
+ * @date: 2019-08-14 4:13 PM
+ * @return: void
*/
void removeByRoleId(Long roleId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleService.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleService.java
index de1a759..60387a9 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysRoleService.java
@@ -29,37 +29,35 @@
import java.util.Map;
/**
- * 角色
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 角色相关的业务处理
+ * @date: 2019-08-14 4:01 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface SysRoleService extends AbstractService {
/**
- * 获取ztree使用的角色列表
- *
- * @param uid
- * @return
+ * @description: 通过用户id获取ztree使用的角色列表
+ * @param: uid
+ * @date: 2019-08-14 4:02 PM
+ * @return: java.util.List>
*/
List> queryRoleListWithSelected(Integer uid);
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询角色列表
+ * @param: vo
+ * @date: 2019-08-14 4:02 PM
+ * @return: com.github.pagehelper.PageInfo
*/
PageInfo findPageBreakByCondition(RoleConditionVO vo);
/**
- * 获取用户的角色
- *
- * @param userId
- * @return
+ * @description: 通过用户id获取用户所拥有的角色信息
+ * @param: userId
+ * @date: 2019-08-14 4:03 PM
+ * @return: java.util.List
*/
List listRolesByUserId(Long userId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserRoleService.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserRoleService.java
index 5519ec8..20db7f6 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserRoleService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserRoleService.java
@@ -24,28 +24,28 @@
import com.zyd.shiro.framework.object.AbstractService;
/**
- * 用户角色
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户角色相关的业务处理
+ * @date: 2019-08-14 4:10 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface SysUserRoleService extends AbstractService {
/**
- * 添加用户角色
- *
- * @param userId
- * @param roleIds
+ * @description: 添加用户角色
+ * @param: userId
+ * @param: roleIds
+ * @date: 2019-08-14 4:10 PM
+ * @return: void
*/
void addUserRole(Long userId, String roleIds);
/**
- * 根据用户ID删除用户角色
- *
- * @param userId
+ * @description: 根据用户id删除用户角色
+ * @param: userId
+ * @date: 2019-08-14 4:10 PM
+ * @return: void
*/
void removeByUserId(Long userId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserService.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserService.java
index 9933a1e..9bb3c55 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/SysUserService.java
@@ -28,45 +28,43 @@
import java.util.List;
/**
- * 用户
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户相关的业务处理
+ * @date: 2019-08-14 3:57 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface SysUserService extends AbstractService {
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询用户信息
+ * @param: vo
+ * @date: 2019-08-14 3:58 PM
+ * @return: com.github.pagehelper.PageInfo
*/
PageInfo findPageBreakByCondition(UserConditionVO vo);
/**
- * 更新用户最后一次登录的状态信息
- *
- * @param user
- * @return
+ * @description: (never used)更新用户最后一次登录的状态信息
+ * @param: user
+ * @date: 2019-08-14 3:59 PM
+ * @return: com.zyd.shiro.business.entity.User
*/
User updateUserLastLoginInfo(User user);
/**
- * 根据用户名查找
- *
- * @param userName
- * @return
+ * @description: 根据用户名查找指定的用户信息
+ * @param: userName
+ * @date: 2019-08-14 4:00 PM
+ * @return: com.zyd.shiro.business.entity.User
*/
User getByUserName(String userName);
/**
- * 通过角色Id获取用户列表
- *
- * @param roleId
- * @return
+ * @description: 通过角色id获取用户列表
+ * @param: roleId
+ * @date: 2019-08-14 4:00 PM
+ * @return: java.util.List
*/
List listByRoleId(Long roleId);
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/ShiroServiceImpl.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/ShiroServiceImpl.java
index 80d269c..09d7da9 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/ShiroServiceImpl.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/ShiroServiceImpl.java
@@ -45,13 +45,11 @@
import java.util.Map;
/**
- * Shiro-权限相关的业务处理
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/25 14:37
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 实现Shiro权限相关的业务处理
+ * @date: 2019-08-17 12:55 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Slf4j
@Service
@@ -63,18 +61,21 @@ public class ShiroServiceImpl implements ShiroService {
private SysUserService userService;
/**
- * 初始化权限
+ * @description: 初始化权限
+ * @param:
+ * @date: 2019-08-17 1:06 PM
+ * @return: java.util.Map
*/
@Override
public Map loadFilterChainDefinitions() {
/*
配置访问权限
- anon:所有url都都可以匿名访问
- - authc: 需要认证才能进行访问(此处指所有非匿名的路径都需要登陆才能访问)
+ - authc: 需要认证才能进行访问(此处指所有非匿名的路径都需要登陆才能访问)
- user:配置记住我或认证通过可以访问
*/
Map filterChainDefinitionMap = new LinkedHashMap();
- // 配置退出过滤器,其中的具体的退出代码Shiro已经替我们实现了
+ // 配置退出过滤器(注:其中的具体的注销代码Shiro已经替我们实现咯)
filterChainDefinitionMap.put("/passport/logout", "logout");
filterChainDefinitionMap.put("/passport/login", "anon");
filterChainDefinitionMap.put("/passport/signin", "anon");
@@ -89,13 +90,17 @@ public Map loadFilterChainDefinitions() {
filterChainDefinitionMap.put(resources.getUrl(), permission);
}
}
- // 本例子中并不存在什么特别关键的操作,所以直接使用user认证。如果有朋友是参考本例子的shiro开发其他安全功能(比如支付等)时,建议针对这类操作使用authc权限 by yadong.zhang
+ // 本项目中并不存在什么特别关键的操作,所以直接使用user认证
+ // 如果有朋友是参考本例子的shiro开发其他安全功能(比如支付等)时,建议针对这类操作使用authc权限 by yadong.zhang
filterChainDefinitionMap.put("/**", "user");
return filterChainDefinitionMap;
}
/**
- * 重新加载权限
+ * @description: 重新加载权限
+ * @param:
+ * @date: 2019-08-17 1:10 PM
+ * @return: void
*/
@Override
public void updatePermission() {
@@ -107,14 +112,13 @@ public void updatePermission() {
} catch (Exception e) {
throw new RuntimeException("get ShiroFilter from shiroFilterFactoryBean error!");
}
-
PathMatchingFilterChainResolver filterChainResolver = (PathMatchingFilterChainResolver) shiroFilter.getFilterChainResolver();
DefaultFilterChainManager manager = (DefaultFilterChainManager) filterChainResolver.getFilterChainManager();
// 清空老的权限控制
manager.getFilterChains().clear();
-
shirFilter.getFilterChainDefinitionMap().clear();
+ // 重新初始化过滤链
shirFilter.setFilterChainDefinitionMap(loadFilterChainDefinitions());
// 重新构建生成
Map chains = shirFilter.getFilterChainDefinitionMap();
@@ -127,9 +131,10 @@ public void updatePermission() {
}
/**
- * 重新加载用户权限
- *
- * @param user
+ * @description: 重新加载用户权限
+ * @param: user
+ * @date: 2019-08-17 1:11 PM
+ * @return: void
*/
@Override
public void reloadAuthorizingByUserId(User user) {
@@ -147,9 +152,10 @@ public void reloadAuthorizingByUserId(User user) {
}
/**
- * 重新加载所有拥有roleId角色的用户的权限
- *
- * @param roleId
+ * @description: 重新加载所有拥有roleId角色的用户的权限
+ * @param: roleId
+ * @date: 2019-08-17 1:11 PM
+ * @return: void
*/
@Override
public void reloadAuthorizingByRoleId(Long roleId) {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysResourcesServiceImpl.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysResourcesServiceImpl.java
index 050dd40..69990a1 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysResourcesServiceImpl.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysResourcesServiceImpl.java
@@ -34,13 +34,11 @@
import java.util.*;
/**
- * 系统资源
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 实现系统资源相关的业务处理
+ * @date: 2019-08-17 11:45 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Service
public class SysResourcesServiceImpl implements SysResourcesService {
@@ -49,10 +47,10 @@ public class SysResourcesServiceImpl implements SysResourcesService {
private SysResourceMapper resourceMapper;
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询系统资源信息
+ * @param: vo
+ * @date: 2019-08-17 11:45 AM
+ * @return: com.github.pagehelper.PageInfo
*/
@Override
public PageInfo findPageBreakByCondition(ResourceConditionVO vo) {
@@ -71,10 +69,10 @@ public PageInfo findPageBreakByCondition(ResourceConditionVO vo) {
}
/**
- * 获取用户的资源列表
- *
- * @param map
- * @return
+ * @description: 获取用户所拥有的资源列表
+ * @param: map
+ * @date: 2019-08-17 12:27 PM
+ * @return: java.util.List
*/
@Override
public List listUserResources(Map map) {
@@ -90,10 +88,10 @@ public List listUserResources(Map map) {
}
/**
- * 获取ztree使用的资源列表
- *
- * @param rid
- * @return
+ * @description: 获取ztree使用的资源列表
+ * @param: rid
+ * @date: 2019-08-17 12:28 PM
+ * @return: java.util.List>
*/
@Override
public List> queryResourcesListWithSelected(Long rid) {
@@ -115,9 +113,10 @@ public List> queryResourcesListWithSelected(Long rid) {
}
/**
- * 获取资源的url和permission
- *
- * @return
+ * @description: 获取资源的url和permission
+ * @param:
+ * @date: 2019-08-17 12:29 PM
+ * @return: java.util.List
*/
@Override
public List listUrlAndPermission() {
@@ -126,9 +125,10 @@ public List listUrlAndPermission() {
}
/**
- * 获取所有可用的菜单资源
- *
- * @return
+ * @description: 获取所有可用的菜单资源
+ * @param:
+ * @date: 2019-08-17 12:29 PM
+ * @return: java.util.List
*/
@Override
public List listAllAvailableMenu() {
@@ -137,15 +137,15 @@ public List listAllAvailableMenu() {
}
/**
- * 获取父级资源下所有menu资源
- *
- * @param pid
- * @return
+ * @description: 获取父级资源下所有的menu资源
+ * @param: pid
+ * @date: 2019-08-17 12:30 PM
+ * @return: java.util.List>
*/
@Override
public List> listChildMenuByPid(Long pid) {
List sysResources = resourceMapper.listMenuResourceByPid(pid);
- if(CollectionUtils.isEmpty(sysResources)){
+ if (CollectionUtils.isEmpty(sysResources)) {
return null;
}
List> result = new LinkedList<>();
@@ -160,10 +160,10 @@ public List> listChildMenuByPid(Long pid) {
}
/**
- * 获取用户关联的所有资源
- *
- * @param userId
- * @return
+ * @description: 获取用户关联的所有资源
+ * @param: userId
+ * @date: 2019-08-17 12:31 PM
+ * @return: java.util.List
*/
@Override
public List listByUserId(Long userId) {
@@ -172,10 +172,10 @@ public List listByUserId(Long userId) {
}
/**
- * 保存一个实体,null的属性不会保存,会使用数据库默认值
- *
- * @param entity
- * @return
+ * @description: 保存一个实体, null的属性不会保存(会使用数据库默认值)
+ * @param: entity
+ * @date: 2019-08-17 12:31 PM
+ * @return: com.zyd.shiro.business.entity.Resources
*/
@Override
public Resources insert(Resources entity) {
@@ -187,9 +187,10 @@ public Resources insert(Resources entity) {
}
/**
- * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
- *
- * @param entities
+ * @description: 批量插入:支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
+ * @param: entities
+ * @date: 2019-08-17 12:31 PM
+ * @return: void
*/
@Override
public void insertList(List entities) {
@@ -204,10 +205,10 @@ public void insertList(List entities) {
}
/**
- * 根据主键字段进行删除,方法参数必须包含完整的主键属性
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行删除, 方法参数必须包含完整的主键属性
+ * @param: primaryKey
+ * @date: 2019-08-17 12:32 PM
+ * @return: boolean
*/
@Override
public boolean removeByPrimaryKey(Long primaryKey) {
@@ -215,10 +216,10 @@ public boolean removeByPrimaryKey(Long primaryKey) {
}
/**
- * 根据主键更新实体全部字段,null值会被更新
- *
- * @param entity
- * @return
+ * @description: 根据主键更新实体全部字段(null值也会被更新)
+ * @param: entity
+ * @date: 2019-08-17 12:32 PM
+ * @return: boolean
*/
@Override
public boolean update(Resources entity) {
@@ -228,10 +229,10 @@ public boolean update(Resources entity) {
}
/**
- * 根据主键更新属性不为null的值
- *
- * @param entity
- * @return
+ * @description: 根据主键更新属性不为null的值
+ * @param: entity
+ * @date: 2019-08-17 12:33 PM
+ * @return: boolean
*/
@Override
public boolean updateSelective(Resources entity) {
@@ -241,10 +242,10 @@ public boolean updateSelective(Resources entity) {
}
/**
- * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行查询, 方法参数必须包含完整的主键属性, 查询条件使用等号
+ * @param: primaryKey
+ * @date: 2019-08-17 12:33 PM
+ * @return: com.zyd.shiro.business.entity.Resources
*/
@Override
public Resources getByPrimaryKey(Long primaryKey) {
@@ -254,10 +255,10 @@ public Resources getByPrimaryKey(Long primaryKey) {
}
/**
- * 根据实体中的属性进行查询,只能有一个返回值,有多个结果时抛出异常,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性进行查询, 只能有一个返回值, 有多个结果时抛出异常, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 12:34 PM
+ * @return: com.zyd.shiro.business.entity.Resources
*/
@Override
public Resources getOneByEntity(Resources entity) {
@@ -267,9 +268,10 @@ public Resources getOneByEntity(Resources entity) {
}
/**
- * 查询全部结果,listByEntity(null)方法能达到同样的效果
- *
- * @return
+ * @description: 查询全部结果, listByEntity(null)方法能达到同样的效果
+ * @param:
+ * @date: 2019-08-17 12:34 PM
+ * @return: java.util.List
*/
@Override
public List listAll() {
@@ -278,10 +280,10 @@ public List listAll() {
}
/**
- * 根据实体中的属性值进行查询,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性值进行查询, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 12:34 PM
+ * @return: java.util.List
*/
@Override
public List listByEntity(Resources entity) {
@@ -290,6 +292,12 @@ public List listByEntity(Resources entity) {
return getResources(sysResources);
}
+ /**
+ * @description: 抽取所有系统资源信息
+ * @param: sysResources
+ * @date: 2019-08-17 12:35 PM
+ * @return: java.util.List
+ */
private List getResources(List sysResources) {
if (CollectionUtils.isEmpty(sysResources)) {
return null;
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleResourcesServiceImpl.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleResourcesServiceImpl.java
index a54dca6..ca5ff63 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleResourcesServiceImpl.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleResourcesServiceImpl.java
@@ -37,24 +37,23 @@
import java.util.List;
/**
- * 角色资源
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 实现角色资源相关的业务处理
+ * @date: 2019-08-17 12:55 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Service
public class SysRoleResourcesServiceImpl implements SysRoleResourcesService {
+
@Autowired
private SysRoleResourcesMapper resourceMapper;
/**
- * 保存一个实体,null的属性不会保存,会使用数据库默认值
- *
- * @param entity
- * @return
+ * @description: 保存一个实体, null的属性不会保存(使用数据库默认值)
+ * @param: entity
+ * @date: 2019-08-17 12:55 PM
+ * @return: com.zyd.shiro.business.entity.RoleResources
*/
@Override
public RoleResources insert(RoleResources entity) {
@@ -66,9 +65,10 @@ public RoleResources insert(RoleResources entity) {
}
/**
- * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
- *
- * @param entities
+ * @description: 批量插入:支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
+ * @param: entities
+ * @date: 2019-08-17 12:55 PM
+ * @return: void
*/
@Override
public void insertList(List entities) {
@@ -85,11 +85,12 @@ public void insertList(List entities) {
resourceMapper.insertList(sysRoleResources);
}
+
/**
- * 根据主键字段进行删除,方法参数必须包含完整的主键属性
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行删除, 方法参数必须包含完整的主键属性
+ * @param: primaryKey
+ * @date: 2019-08-17 12:56 PM
+ * @return: boolean
*/
@Override
public boolean removeByPrimaryKey(Long primaryKey) {
@@ -97,10 +98,10 @@ public boolean removeByPrimaryKey(Long primaryKey) {
}
/**
- * 根据主键更新实体全部字段,null值会被更新
- *
- * @param entity
- * @return
+ * @description: 根据主键更新实体全部字段(null值也会被更新)
+ * @param: entity
+ * @date: 2019-08-17 12:56 PM
+ * @return: boolean
*/
@Override
public boolean update(RoleResources entity) {
@@ -110,10 +111,10 @@ public boolean update(RoleResources entity) {
}
/**
- * 根据主键更新属性不为null的值
- *
- * @param entity
- * @return
+ * @description: 根据主键更新属性不为null的值
+ * @param: entity
+ * @date: 2019-08-17 12:57 PM
+ * @return: boolean
*/
@Override
public boolean updateSelective(RoleResources entity) {
@@ -123,10 +124,10 @@ public boolean updateSelective(RoleResources entity) {
}
/**
- * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行查询, 方法参数必须包含完整的主键属性, 查询条件使用等号
+ * @param: primaryKey
+ * @date: 2019-08-17 12:57 PM
+ * @return: com.zyd.shiro.business.entity.RoleResources
*/
@Override
public RoleResources getByPrimaryKey(Long primaryKey) {
@@ -136,10 +137,10 @@ public RoleResources getByPrimaryKey(Long primaryKey) {
}
/**
- * 根据实体中的属性进行查询,只能有一个返回值,有多个结果时抛出异常,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性进行查询, 只能有一个返回值, 有多个结果时抛出异常, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 12:58 PM
+ * @return: com.zyd.shiro.business.entity.RoleResources
*/
@Override
public RoleResources getOneByEntity(RoleResources entity) {
@@ -149,9 +150,10 @@ public RoleResources getOneByEntity(RoleResources entity) {
}
/**
- * 查询全部结果,listByEntity(null)方法能达到同样的效果
- *
- * @return
+ * @description: 查询全部结果, listByEntity(null)方法能达到同样的效果
+ * @param:
+ * @date: 2019-08-17 12:58 PM
+ * @return: java.util.List
*/
@Override
public List listAll() {
@@ -160,10 +162,10 @@ public List listAll() {
}
/**
- * 根据实体中的属性值进行查询,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性值进行查询, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 12:58 PM
+ * @return: java.util.List
*/
@Override
public List listByEntity(RoleResources entity) {
@@ -172,23 +174,13 @@ public List listByEntity(RoleResources entity) {
return getRoleResources(sysRoleResources);
}
- private List getRoleResources(List sysRoleResources) {
- if (CollectionUtils.isEmpty(sysRoleResources)) {
- return null;
- }
- List rr = new ArrayList<>();
- for (SysRoleResources r : sysRoleResources) {
- rr.add(new RoleResources(r));
- }
- return rr;
- }
/**
- * 添加角色资源
- * 该节代码参考自http://blog.csdn.net/poorcoder_/article/details/71374002
- *
- * @param roleId
- * @param resourcesIds
+ * @description: 添加角色资源, 该节代码参考自: http://blog.csdn.net/poorcoder_/article/details/71374002
+ * @param: roleId
+ * @param: resourcesIds
+ * @date: 2019-08-17 1:04 PM
+ * @return: void
*/
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@@ -223,9 +215,10 @@ public void addRoleResources(Long roleId, String resourcesIds) {
}
/**
- * 通过角色id批量删除
- *
- * @param roleId
+ * @description: 通过角色id批量删除
+ * @param: roleId
+ * @date: 2019-08-17 1:04 PM
+ * @return: void
*/
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@@ -236,4 +229,21 @@ public void removeByRoleId(Long roleId) {
criteria.andEqualTo("roleId", roleId);
resourceMapper.deleteByExample(example);
}
+
+ /**
+ * @description: 抽取所有角色资源信息
+ * @param: sysRoleResources
+ * @date: 2019-08-17 12:59 PM
+ * @return: java.util.List
+ */
+ private List getRoleResources(List sysRoleResources) {
+ if (CollectionUtils.isEmpty(sysRoleResources)) {
+ return null;
+ }
+ List rr = new ArrayList<>();
+ for (SysRoleResources r : sysRoleResources) {
+ rr.add(new RoleResources(r));
+ }
+ return rr;
+ }
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleServiceImpl.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleServiceImpl.java
index 01b4c77..c0cfc83 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleServiceImpl.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysRoleServiceImpl.java
@@ -34,13 +34,11 @@
import java.util.*;
/**
- * 角色
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 实现角色相关的业务处理
+ * @date: 2019-08-17 11:29 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Service
public class SysRoleServiceImpl implements SysRoleService {
@@ -49,10 +47,10 @@ public class SysRoleServiceImpl implements SysRoleService {
private SysRoleMapper roleMapper;
/**
- * 获取ztree使用的角色列表
- *
- * @param userId
- * @return
+ * @description: 获取ztree使用的角色列表
+ * @param: userId
+ * @date: 2019-08-17 11:30 AM
+ * @return: java.util.List>
*/
@Override
public List> queryRoleListWithSelected(Integer userId) {
@@ -74,10 +72,10 @@ public List> queryRoleListWithSelected(Integer userId) {
}
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询系统角色信息
+ * @param: vo
+ * @date: 2019-08-17 11:30 AM
+ * @return: com.github.pagehelper.PageInfo
*/
@Override
public PageInfo findPageBreakByCondition(RoleConditionVO vo) {
@@ -96,10 +94,10 @@ public PageInfo findPageBreakByCondition(RoleConditionVO vo) {
}
/**
- * 获取用户的角色
- *
- * @param userId
- * @return
+ * @description: 获取用户所拥有的角色信息
+ * @param: userId
+ * @date: 2019-08-17 11:32 AM
+ * @return: java.util.List
*/
@Override
public List listRolesByUserId(Long userId) {
@@ -115,10 +113,10 @@ public List listRolesByUserId(Long userId) {
}
/**
- * 保存一个实体,null的属性不会保存,会使用数据库默认值
- *
- * @param entity
- * @return
+ * @description: 保存一个实体, null的属性不会保存(会使用数据库默认值)
+ * @param: entity
+ * @date: 2019-08-17 11:33 AM
+ * @return: com.zyd.shiro.business.entity.Role
*/
@Override
public Role insert(Role entity) {
@@ -130,9 +128,10 @@ public Role insert(Role entity) {
}
/**
- * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
- *
- * @param entities
+ * @description: 批量插入:支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
+ * @param: entities
+ * @date: 2019-08-17 11:34 AM
+ * @return: void
*/
@Override
public void insertList(List entities) {
@@ -146,11 +145,11 @@ public void insertList(List entities) {
roleMapper.insertList(sysRole);
}
- /**
- * 根据主键字段进行删除,方法参数必须包含完整的主键属性
- *
- * @param primaryKey
- * @return
+ /***
+ *@description: 根据主键字段进行删除, 方法参数必须包含完整的主键属性
+ *@param: primaryKey
+ *@date: 2019-08-17 11:36 AM
+ *@return: boolean
*/
@Override
public boolean removeByPrimaryKey(Long primaryKey) {
@@ -158,10 +157,10 @@ public boolean removeByPrimaryKey(Long primaryKey) {
}
/**
- * 根据主键更新实体全部字段,null值会被更新
- *
- * @param entity
- * @return
+ * @description: 根据主键更新实体全部字段, null值会被更新
+ * @param: entity
+ * @date: 2019-08-17 11:36 AM
+ * @return: boolean
*/
@Override
public boolean update(Role entity) {
@@ -171,10 +170,10 @@ public boolean update(Role entity) {
}
/**
- * 根据主键更新属性不为null的值
- *
- * @param entity
- * @return
+ * @description: 根据主键更新属性不为null的值
+ * @param: entity
+ * @date: 2019-08-17 11:36 AM
+ * @return: boolean
*/
@Override
public boolean updateSelective(Role entity) {
@@ -184,10 +183,10 @@ public boolean updateSelective(Role entity) {
}
/**
- * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行查询, 方法参数必须包含完整的主键属性, 查询条件使用等号
+ * @param: primaryKey
+ * @date: 2019-08-17 11:37 AM
+ * @return: com.zyd.shiro.business.entity.Role
*/
@Override
public Role getByPrimaryKey(Long primaryKey) {
@@ -197,10 +196,10 @@ public Role getByPrimaryKey(Long primaryKey) {
}
/**
- * 根据实体中的属性进行查询,只能有一个返回值,有多个结果时抛出异常,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性进行查询, 只能有一个返回值, 有多个结果时抛出异常, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 11:37 AM
+ * @return: com.zyd.shiro.business.entity.Role
*/
@Override
public Role getOneByEntity(Role entity) {
@@ -210,9 +209,10 @@ public Role getOneByEntity(Role entity) {
}
/**
- * 查询全部结果,listByEntity(null)方法能达到同样的效果
- *
- * @return
+ * @description: 获取所有角色信息, listByEntity(null)方法能达到同样的效果
+ * @param:
+ * @date: 2019-08-17 11:38 AM
+ * @return: java.util.List
*/
@Override
public List listAll() {
@@ -221,10 +221,10 @@ public List listAll() {
}
/**
- * 根据实体中的属性值进行查询,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性值进行查询, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 11:40 AM
+ * @return: java.util.List
*/
@Override
public List listByEntity(Role entity) {
@@ -233,6 +233,12 @@ public List listByEntity(Role entity) {
return getRole(sysRole);
}
+ /***
+ *@description: 抽取所用角色信息
+ *@param: sysRole
+ *@date: 2019-08-17 11:40 AM
+ *@return: java.util.List
+ */
private List getRole(List sysRole) {
if (CollectionUtils.isEmpty(sysRole)) {
return null;
@@ -243,4 +249,5 @@ private List getRole(List sysRole) {
}
return roleList;
}
+
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserRoleServiceImpl.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserRoleServiceImpl.java
index 9a24443..892b212 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserRoleServiceImpl.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserRoleServiceImpl.java
@@ -37,13 +37,11 @@
import java.util.List;
/**
- * 用户角色
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 实现用户角色相关的业务处理
+ * @date: 2019-08-17 12:37 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {
@@ -52,10 +50,10 @@ public class SysUserRoleServiceImpl implements SysUserRoleService {
private SysUserRoleMapper resourceMapper;
/**
- * 保存一个实体,null的属性不会保存,会使用数据库默认值
- *
- * @param entity
- * @return
+ * @description: 保存一个实体, null的属性不会保存(使用数据库默认值)
+ * @param: entity
+ * @date: 2019-08-17 12:37 PM
+ * @return: com.zyd.shiro.business.entity.UserRole
*/
@Override
public UserRole insert(UserRole entity) {
@@ -67,9 +65,10 @@ public UserRole insert(UserRole entity) {
}
/**
- * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
- *
- * @param entities
+ * @description: 批量插入:支持批量插入的数据库可以使用, 例如MySQL, H2等, 另外该接口限制实体包含id属性并且必须为自增列
+ * @param: entities
+ * @date: 2019-08-17 12:38 PM
+ * @return: void
*/
@Override
public void insertList(List entities) {
@@ -87,10 +86,10 @@ public void insertList(List entities) {
}
/**
- * 根据主键字段进行删除,方法参数必须包含完整的主键属性
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行删除, 方法参数必须包含完整的主键属性
+ * *@param: primaryKey
+ * @date: 2019-08-17 12:38 PM
+ * @return: boolean
*/
@Override
public boolean removeByPrimaryKey(Long primaryKey) {
@@ -98,10 +97,10 @@ public boolean removeByPrimaryKey(Long primaryKey) {
}
/**
- * 根据主键更新实体全部字段,null值会被更新
- *
- * @param entity
- * @return
+ * @description: 根据主键更新实体全部字段(null值也会被更新)
+ * @param: entity
+ * @date: 2019-08-17 12:38 PM
+ * @return: boolean
*/
@Override
public boolean update(UserRole entity) {
@@ -111,10 +110,10 @@ public boolean update(UserRole entity) {
}
/**
- * 根据主键更新属性不为null的值
- *
- * @param entity
- * @return
+ * @description: 根据主键更新属性不为null的值
+ * @param: entity
+ * @date: 2019-08-17 12:39 PM
+ * @return: boolean
*/
@Override
public boolean updateSelective(UserRole entity) {
@@ -124,10 +123,10 @@ public boolean updateSelective(UserRole entity) {
}
/**
- * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行查询, 方法参数必须包含完整的主键属性, 查询条件使用等号
+ * @param: primaryKey
+ * @date: 2019-08-17 12:40 PM
+ * @return: com.zyd.shiro.business.entity.UserRole
*/
@Override
public UserRole getByPrimaryKey(Long primaryKey) {
@@ -137,10 +136,10 @@ public UserRole getByPrimaryKey(Long primaryKey) {
}
/**
- * 根据实体中的属性进行查询,只能有一个返回值,有多个结果时抛出异常,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性进行查询, 只能有一个返回值, 有多个结果时抛出异常, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 12:40 PM
+ * @return: com.zyd.shiro.business.entity.UserRole
*/
@Override
public UserRole getOneByEntity(UserRole entity) {
@@ -150,9 +149,10 @@ public UserRole getOneByEntity(UserRole entity) {
}
/**
- * 查询全部结果,listByEntity(null)方法能达到同样的效果
- *
- * @return
+ * @description: 查询全部结果, listByEntity(null)方法能达到同样的效果
+ * @param:
+ * @date: 2019-08-17 12:41 PM
+ * @return: java.util.List
*/
@Override
public List listAll() {
@@ -161,10 +161,10 @@ public List listAll() {
}
/**
- * 根据实体中的属性值进行查询,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性值进行查询, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 12:41 PM
+ * @return: java.util.List
*/
@Override
public List listByEntity(UserRole entity) {
@@ -173,23 +173,13 @@ public List listByEntity(UserRole entity) {
return getUserRole(sysUserRole);
}
- private List getUserRole(List sysUserRole) {
- if (CollectionUtils.isEmpty(sysUserRole)) {
- return null;
- }
- List urList = new ArrayList<>();
- for (SysUserRole r : sysUserRole) {
- urList.add(new UserRole(r));
- }
- return urList;
- }
/**
- * 添加用户角色
- * 该节代码参考自http://blog.csdn.net/poorcoder_/article/details/71374002
- *
- * @param userId
- * @param roleIds
+ * @description: 添加用户角色, 该节代码参考自: http://blog.csdn.net/poorcoder_/article/details/71374002
+ * @param: userId
+ * @param: roleIds
+ * @date: 2019-08-17 12:44 PM
+ * @return: void
*/
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@@ -216,9 +206,10 @@ public void addUserRole(Long userId, String roleIds) {
}
/**
- * 根据用户ID删除用户角色
- *
- * @param userId
+ * @description: 根据用户id删除指定的用户角色
+ * @param: userId
+ * @date: 2019-08-17 12:45 PM
+ * @return: void
*/
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@@ -228,4 +219,21 @@ public void removeByUserId(Long userId) {
criteria.andEqualTo("userId", userId);
resourceMapper.deleteByExample(example);
}
+
+ /**
+ * @description: 抽取所有的用户角色信息
+ * @param: sysUserRole
+ * @date: 2019-08-17 12:42 PM
+ * @return: java.util.List
+ */
+ private List getUserRole(List sysUserRole) {
+ if (CollectionUtils.isEmpty(sysUserRole)) {
+ return null;
+ }
+ List urList = new ArrayList<>();
+ for (SysUserRole r : sysUserRole) {
+ urList.add(new UserRole(r));
+ }
+ return urList;
+ }
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserServiceImpl.java b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserServiceImpl.java
index b0845e9..5892bfb 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserServiceImpl.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/service/impl/SysUserServiceImpl.java
@@ -45,13 +45,11 @@
import java.util.List;
/**
- * 用户
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 实现用户相关的业务处理
+ * @date: 2019-08-17 8:36 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Slf4j
@Service
@@ -61,8 +59,14 @@ public class SysUserServiceImpl implements SysUserService {
private SysUserMapper sysUserMapper;
@Autowired
- private SysRoleService roleService;
+ private SysRoleService roleService; //never accessed
+ /**
+ * @description: 添加新用户信息
+ * @param: user
+ * @date: 2019-08-17 8:38 AM
+ * @return: com.zyd.shiro.business.entity.User
+ */
@Override
@Transactional(rollbackFor = Exception.class)
public User insert(User user) {
@@ -75,6 +79,12 @@ public User insert(User user) {
return user;
}
+ /**
+ * @description: 批量插入:支持批量插入的数据库可以使用, 例如MySQL, H2等. 另外该接口限制实体包含id属性并且必须为自增列
+ * @param: users
+ * @date: 2019-08-17 8:45 AM
+ * @return: void
+ */
@Override
@Transactional(rollbackFor = Exception.class)
public void insertList(List users) {
@@ -91,10 +101,10 @@ public void insertList(List users) {
}
/**
- * 根据主键字段进行删除,方法参数必须包含完整的主键属性
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行删除, 方法参数必须包含完整的主键属性
+ * @param: primaryKey
+ * @date: 2019-08-17 9:01 AM
+ * @return: boolean
*/
@Override
@Transactional(rollbackFor = Exception.class)
@@ -102,6 +112,12 @@ public boolean removeByPrimaryKey(Long primaryKey) {
return sysUserMapper.deleteByPrimaryKey(primaryKey) > 0;
}
+ /**
+ * @description: 更新用户信息
+ * @param: user
+ * @date: 2019-08-17 9:02 AM
+ * @return: boolean
+ */
@Override
@Transactional(rollbackFor = Exception.class)
public boolean update(User user) {
@@ -117,6 +133,12 @@ public boolean update(User user) {
return sysUserMapper.updateByPrimaryKey(user.getSysUser()) > 0;
}
+ /**
+ * @description: 选择性地更新用户信息
+ * @param: user
+ * @date: 2019-08-17 9:04 AM
+ * @return: boolean
+ */
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateSelective(User user) {
@@ -136,12 +158,11 @@ public boolean updateSelective(User user) {
}
/**
- * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行查询, 方法参数必须包含完整的主键属性, 查询条件使用等号
+ * @param: primaryKey
+ * @date: 2019-08-17 9:08 AM
+ * @return: com.zyd.shiro.business.entity.User
*/
-
@Override
public User getByPrimaryKey(Long primaryKey) {
Assert.notNull(primaryKey, "PrimaryKey不可为空!");
@@ -150,10 +171,10 @@ public User getByPrimaryKey(Long primaryKey) {
}
/**
- * 根据实体中的属性进行查询,只能有一个返回值,有多个结果时抛出异常,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性进行查询, 只能有一个返回值, 有多个结果时抛出异常, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-17 11:02 AM
+ * @return: com.zyd.shiro.business.entity.User
*/
@Override
public User getOneByEntity(User entity) {
@@ -162,10 +183,15 @@ public User getOneByEntity(User entity) {
return null == sysUser ? null : new User(sysUser);
}
+ /**
+ * @description: 获取所有用户列表
+ * @param:
+ * @date: 2019-08-17 11:02 AM
+ * @return: java.util.List
+ */
@Override
public List listAll() {
List sysUsers = sysUserMapper.selectAll();
-
if (CollectionUtils.isEmpty(sysUsers)) {
return null;
}
@@ -176,6 +202,12 @@ public List listAll() {
return users;
}
+ /**
+ * @description: 根据实体中的属性值进行查询, 查询条件使用等号
+ * @param: user
+ * @date: 2019-08-17 11:03 AM
+ * @return: java.util.List
+ */
@Override
public List listByEntity(User user) {
Assert.notNull(user, "User不可为空!");
@@ -191,10 +223,10 @@ public List listByEntity(User user) {
}
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询用户信息
+ * @param: vo
+ * @date: 2019-08-17 11:05 AM
+ * @return: com.github.pagehelper.PageInfo
*/
@Override
public PageInfo findPageBreakByCondition(UserConditionVO vo) {
@@ -213,10 +245,10 @@ public PageInfo findPageBreakByCondition(UserConditionVO vo) {
}
/**
- * 更新用户最后一次登录的状态信息
- *
- * @param user
- * @return
+ * @description: 更新用户最后一次登录的状态信息
+ * @param: user
+ * @date: 2019-08-17 11:06 AM
+ * @return: com.zyd.shiro.business.entity.User
*/
@Override
public User updateUserLastLoginInfo(User user) {
@@ -231,10 +263,10 @@ public User updateUserLastLoginInfo(User user) {
}
/**
- * 根据用户名查找
- *
- * @param userName
- * @return
+ * @description: 根据用户名获取指定的用户信息
+ * @param: userName
+ * @date: 2019-08-17 11:08 AM
+ * @return: com.zyd.shiro.business.entity.User
*/
@Override
public User getByUserName(String userName) {
@@ -243,10 +275,10 @@ public User getByUserName(String userName) {
}
/**
- * 通过角色Id获取用户列表
- *
- * @param roleId
- * @return
+ * @description: 通过角色id获取用户列表
+ * @param: roleId
+ * @date: 2019-08-17 11:10 AM
+ * @return: java.util.List
*/
@Override
public List listByRoleId(Long roleId) {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/shiro/credentials/CredentialsMatcher.java b/shiro-core/src/main/java/com/zyd/shiro/business/shiro/credentials/CredentialsMatcher.java
index a57dd2b..a2b24b6 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/shiro/credentials/CredentialsMatcher.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/shiro/credentials/CredentialsMatcher.java
@@ -36,14 +36,22 @@
*/
public class CredentialsMatcher extends SimpleCredentialsMatcher {
+ /**
+ * @description: 用户密码加密
+ * @param: token 用户登录信息
+ * @param: info 用户认证信息
+ * @date: 2019-08-13 1:12 PM
+ * @return: boolean
+ */
@Override
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
UsernamePasswordToken utoken = (UsernamePasswordToken) token;
//获得用户输入的密码:(可以采用加盐(salt)的方式去检验)
String inPassword = new String(utoken.getPassword());
- //获得数据库中的密码
+ //根据用户的认证信息获得数据库中的密码
String dbPassword = (String) info.getCredentials();
try {
+ //解密数据库中的用户密码
dbPassword = PasswordUtil.decrypt(dbPassword, utoken.getUsername());
} catch (Exception e) {
e.printStackTrace();
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/shiro/realm/ShiroRealm.java b/shiro-core/src/main/java/com/zyd/shiro/business/shiro/realm/ShiroRealm.java
index eb9de16..88b484a 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/shiro/realm/ShiroRealm.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/shiro/realm/ShiroRealm.java
@@ -62,7 +62,10 @@ public class ShiroRealm extends AuthorizingRealm {
private SysRoleService roleService;
/**
- * 提供账户信息返回认证信息(用户的角色信息集合)
+ * @description: 登录认证:提供帐户信息,返回认证信息(用户的角色信息集合)
+ * @param: token
+ * @date: 2019-08-13 1:33 PM
+ * @return: org.apache.shiro.authc.AuthenticationInfo
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
@@ -86,21 +89,22 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
}
/**
- * 权限认证,为当前登录的Subject授予角色和权限(角色的权限信息集合)
+ * @description: 授权认证:提供用户信息(当前登录的Subject),返回权限信息(角色的权限信息集合)
+ * @param: principalCollection
+ * @date: 2019-08-13 1:34 PM
+ * @return: org.apache.shiro.authz.AuthorizationInfo
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
// 权限信息对象info,用来存放查出的用户的所有的角色(role)及权限(permission)
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
-
+ //获取用户id
Long userId = (Long) SecurityUtils.getSubject().getPrincipal();
-
// 赋予角色
List roleList = roleService.listRolesByUserId(userId);
for (Role role : roleList) {
info.addRole(role.getName());
}
-
// 赋予权限
List resourcesList = null;
User user = userService.getByPrimaryKey(userId);
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/vo/ResourceConditionVO.java b/shiro-core/src/main/java/com/zyd/shiro/business/vo/ResourceConditionVO.java
index 32a9e34..4481e1b 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/vo/ResourceConditionVO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/vo/ResourceConditionVO.java
@@ -19,22 +19,19 @@
*/
package com.zyd.shiro.business.vo;
-import com.zyd.shiro.business.entity.Resources;
import com.zyd.shiro.framework.object.BaseConditionVO;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 资源信息
+ * @date: 2019-08-15 10:26 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class ResourceConditionVO extends BaseConditionVO {
private String type;
}
-
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/vo/RoleConditionVO.java b/shiro-core/src/main/java/com/zyd/shiro/business/vo/RoleConditionVO.java
index 5f73865..9163148 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/vo/RoleConditionVO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/vo/RoleConditionVO.java
@@ -25,16 +25,14 @@
import lombok.EqualsAndHashCode;
/**
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 角色信息
+ * @date: 2019-08-15 10:26 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class RoleConditionVO extends BaseConditionVO {
private Role role;
}
-
diff --git a/shiro-core/src/main/java/com/zyd/shiro/business/vo/UserConditionVO.java b/shiro-core/src/main/java/com/zyd/shiro/business/vo/UserConditionVO.java
index ed9da8e..2dffc99 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/business/vo/UserConditionVO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/business/vo/UserConditionVO.java
@@ -25,12 +25,11 @@
import lombok.EqualsAndHashCode;
/**
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户信息
+ * @date: 2019-08-15 10:20 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/DruidConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/DruidConfig.java
index 1bc65ad..1cb96c1 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/DruidConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/DruidConfig.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -37,13 +37,11 @@
import java.util.List;
/**
- * Druid Monitor 配置
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2017/9/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: Druid Monitor的配置信息
+ * @date: 2019-08-15 11:38 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
public class DruidConfig {
@@ -55,29 +53,29 @@ public class DruidConfig {
public ServletRegistrationBean druidStatViewServlet() {
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), druidProperties.getServletPath());
- // IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
+ // IP黑名单(存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry,you are not permitted to view this page.
List denyIps = druidProperties.getDenyIps();
- if(!CollectionUtils.isEmpty(denyIps)){
+ if (!CollectionUtils.isEmpty(denyIps)) {
bean.addInitParameter("deny", StringUtils.collectionToDelimitedString(denyIps, ","));
}
-
// IP白名单
List allowIps = druidProperties.getAllowIps();
- if(!CollectionUtils.isEmpty(allowIps)){
+ if (!CollectionUtils.isEmpty(allowIps)) {
bean.addInitParameter("allow", StringUtils.collectionToDelimitedString(allowIps, ","));
}
-
- // 登录查看信息的账号密码.
+ // 登录查看信息的账号密码
bean.addInitParameter("loginUsername", druidProperties.getUsername());
bean.addInitParameter("loginPassword", druidProperties.getPassword());
- // 禁用HTML页面上的"Reset All"功能(默认false)
+ // 禁用HTML页面上的"Reset All"功能(默认false)
bean.addInitParameter("resetEnable", String.valueOf(druidProperties.getResetEnable()));
return bean;
}
/**
- * Druid的StatFilter
- * @return
+ * @description: 配置Druid的StatFilter
+ * @param:
+ * @date: 2019-08-15 11:39 AM
+ * @return: org.springframework.boot.web.servlet.FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean druidStatFilter() {
@@ -85,7 +83,7 @@ public FilterRegistrationBean druidStatFilter() {
// 添加过滤规则
bean.addUrlPatterns("/*");
// 排除的url
- bean.addInitParameter("exclusions","*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
+ bean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
return bean;
}
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/ErrorPagesConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/ErrorPagesConfig.java
index cdbb4df..943a46d 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/ErrorPagesConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/ErrorPagesConfig.java
@@ -31,21 +31,20 @@
import org.springframework.stereotype.Component;
/**
- * 自定义的异常页面配置
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 自定义异常页的配置类
+ * @date: 2019-08-15 11:40 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Component
public class ErrorPagesConfig {
/**
- * 自定义异常处理路径
- *
- * @return
+ * @description: 自定义异常处理路径
+ * @param:
+ * @date: 2019-08-15 11:40 AM
+ * @return: org.springframework.boot.web.server.WebServerFactoryCustomizer
*/
@Bean
public WebServerFactoryCustomizer containerCustomizer() {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/FreeMarkerConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/FreeMarkerConfig.java
index c982544..7326605 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/FreeMarkerConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/FreeMarkerConfig.java
@@ -28,12 +28,11 @@
import javax.annotation.PostConstruct;
/**
- * freemarker配置类
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: FreeMarker配置类
+ * @date: 2019-08-15 11:42 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
public class FreeMarkerConfig {
@@ -44,7 +43,10 @@ public class FreeMarkerConfig {
protected CustomTagDirective customTagDirective;
/**
- * 添加自定义标签
+ * @description: 添加自定义标签
+ * @param:
+ * @date: 2019-08-15 11:42 AM
+ * @return: void
*/
@PostConstruct
public void setSharedVariable() {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/MybatisConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/MybatisConfig.java
index 18fcac7..efda77e 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/MybatisConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/MybatisConfig.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -27,12 +27,11 @@
import org.springframework.stereotype.Component;
/**
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: MyBatis配置类
+ * @date: 2019-08-15 11:42 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Component
@MapperScan("com.zyd.shiro.persistence.mapper")
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/RedisConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/RedisConfig.java
index 12255f7..0810668 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/RedisConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/RedisConfig.java
@@ -43,20 +43,21 @@
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: Redis配置类
+ * @date: 2019-08-15 11:42 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport {
/**
- * 缓存数据时Key的生成器,可以依据业务和技术场景自行定制
- *
- * @return
+ * @description: 缓存数据时Key的生成器, 可依据业务和技术场景自行定制
+ * @param:
+ * @date: 2019-08-15 11:44 AM
+ * @return: org.springframework.cache.interceptor.KeyGenerator
*/
@Bean
@Override
@@ -77,7 +78,7 @@ public KeyGenerator keyGenerator() {
@Bean
public CacheManager cacheManager(RedisConnectionFactory factory) {
return RedisCacheManager.builder(RedisCacheWriter.nonLockingRedisCacheWriter(factory))
- // 默认缓存过期时间:天
+ // 默认缓存过期时间:30天
.cacheDefaults(RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofDays(30)))
.transactionAware()
.build();
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/ShiroConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/ShiroConfig.java
index 894ff2f..75c487f 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/ShiroConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/ShiroConfig.java
@@ -48,13 +48,11 @@
import java.util.Map;
/**
- * Shiro配置类
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/24 14:37
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: Shiro配置类
+ * @date: 2019-08-15 11:42 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
@Order(-1)
@@ -65,38 +63,54 @@ public class ShiroConfig {
@Autowired
private RedisProperties redisProperties;
+ /**
+ * @description: 将Shiro安全管理器注入到Bean的实例
+ * @param: securityManager
+ * @date: 2019-08-15 11:48 AM
+ * @return: org.springframework.beans.factory.config.MethodInvokingFactoryBean
+ */
@Bean
- public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager){
+ public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager) {
MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
bean.setArguments(securityManager);
return bean;
}
+ /**
+ * @description: 生命周期处理器
+ * @param:
+ * @date: 2019-08-15 11:48 AM
+ * @return: org.apache.shiro.spring.LifecycleBeanPostProcessor
+ */
@Bean(name = "lifecycleBeanPostProcessor")
public static LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
return new LifecycleBeanPostProcessor();
}
+ /*
+ * Filter Chain定义说明:
+ * 1、一个URL可以配置多个Filter,使用逗号分隔
+ * 2、当设置多个过滤器时,全部验证通过,才视为通过
+ * 3、部分过滤器可指定参数,如perms,roles
+ */
+
/**
- * ShiroFilterFactoryBean 处理拦截资源文件问题。
- * 注意:单独一个ShiroFilterFactoryBean配置是或报错的,因为在
- * 初始化ShiroFilterFactoryBean的时候需要注入:SecurityManager
- * Filter Chain定义说明
- * 1、一个URL可以配置多个Filter,使用逗号分隔
- * 2、当设置多个过滤器时,全部验证通过,才视为通过
- * 3、部分过滤器可指定参数,如perms,roles
+ * @description: 配置Shiro过滤器
+ * @param: securityManager
+ * @date: 2019-08-15 11:49 AM
+ * @return: org.apache.shiro.spring.web.ShiroFilterFactoryBean
*/
@Bean(name = "shiroFilter")
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
- // 必须设置 SecurityManager
+ // 必须设置SecurityManager
shiroFilterFactoryBean.setSecurityManager(securityManager);
// 如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
shiroFilterFactoryBean.setLoginUrl("/passport/login/");
- // 登录成功后要跳转的链接
+ // 指定登录成功后要跳转的链接
shiroFilterFactoryBean.setSuccessUrl("/index");
- // 未授权界面;
+ // 指定未授权操作要跳转的链接
shiroFilterFactoryBean.setUnauthorizedUrl("/error/403");
// 配置数据库中的resource
Map filterChainDefinitionMap = shiroService.loadFilterChainDefinitions();
@@ -104,6 +118,12 @@ public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
return shiroFilterFactoryBean;
}
+ /**
+ * @description: 开启shiro注解模式(如果使用注解模式, 必须采用cglib针对类进行代理)
+ * @param:
+ * @date: 2019-08-15 11:50 AM
+ * @return: org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator
+ */
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
@@ -112,33 +132,57 @@ public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
return creator;
}
+ /**
+ * @description: 开启Shiro-aop注解支持(采用cglib针对类进行代理)
+ * @param: securityManager
+ * @date: 2019-08-15 11:54 AM
+ * @return: org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor
+ */
+ @Bean
+ public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
+ AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
+ authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
+ return authorizationAttributeSourceAdvisor;
+ }
+
+ /**
+ * @description: 配置安全管理器
+ * @param: authRealm
+ * @date: 2019-08-15 11:51 AM
+ * @return: org.apache.shiro.mgt.SecurityManager
+ */
@Bean(name = "securityManager")
public SecurityManager securityManager(@Qualifier("shiroRealm") ShiroRealm authRealm) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
- // 设置realm.
+ // 关联自定义realm
securityManager.setRealm(authRealm);
+ // 关联安全管理器
securityManager.setCacheManager(redisCacheManager());
- // 自定义session管理 使用redis
+ // 自定义Session管理器
securityManager.setSessionManager(sessionManager());
- // 注入记住我管理器
+ // 关联Cookie管理器
securityManager.setRememberMeManager(rememberMeManager());
return securityManager;
}
- @Bean(name = "shiroRealm")
+ /**
+ * @description: 配置自定义Realm
+ * @param: matcher
+ * @date: 2019-08-15 11:51 AM
+ * @return: com.zyd.shiro.business.shiro.realm.ShiroRealm
+ */
+ @Bean(name = "shiroRealm")//the parameter is never used
public ShiroRealm shiroRealm(@Qualifier("credentialsMatcher") RetryLimitCredentialsMatcher matcher) {
ShiroRealm shiroRealm = new ShiroRealm();
- shiroRealm.setCredentialsMatcher(credentialsMatcher());
+ shiroRealm.setCredentialsMatcher(credentialsMatcher()); //设置凭证匹配器
return shiroRealm;
}
/**
- * 凭证匹配器
- * (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了
- * 所以我们需要修改下doGetAuthenticationInfo中的代码;
- * )
- *
- * @return
+ * @description: 自定义凭证匹配器
+ * @param:
+ * @date: 2019-08-15 11:53 AM
+ * @return: com.zyd.shiro.business.shiro.credentials.RetryLimitCredentialsMatcher
*/
@Bean(name = "credentialsMatcher")
public RetryLimitCredentialsMatcher credentialsMatcher() {
@@ -147,24 +191,10 @@ public RetryLimitCredentialsMatcher credentialsMatcher() {
/**
- * 开启shiro aop注解支持.
- * 使用代理方式;所以需要开启代码支持;
- *
- * @param securityManager
- * @return
- */
- @Bean
- public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
- AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
- authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
- return authorizationAttributeSourceAdvisor;
- }
-
- /**
- * 配置shiro redisManager
- * 使用的是shiro-redis开源插件
- *
- * @return
+ * @description: Redis管理器(使用的是shiro - redis开源插件)
+ * @param:
+ * @date: 2019-08-15 11:54 AM
+ * @return: org.crazycake.shiro.RedisManager
*/
public RedisManager redisManager() {
CustomRedisManager redisManager = new CustomRedisManager();
@@ -177,32 +207,36 @@ public RedisManager redisManager() {
}
/**
- * cacheManager 缓存 redis实现
- * 使用的是shiro-redis开源插件
- *
- * @return
+ * @description: Redis缓存管理器(使用的是shiro - redis开源插件)
+ * @param:
+ * @date: 2019-08-15 11:55 AM
+ * @return: org.crazycake.shiro.RedisCacheManager
*/
@Bean
public RedisCacheManager redisCacheManager() {
RedisCacheManager redisCacheManager = new RedisCacheManager();
- redisCacheManager.setRedisManager(redisManager());
+ redisCacheManager.setRedisManager(redisManager()); //设置Redis管理器
return redisCacheManager;
}
/**
- * RedisSessionDAO shiro sessionDao层的实现 通过redis
- * 使用的是shiro-redis开源插件
+ * @description: RedisSessionDAO:shiro sessionDao层的实现(使用的是shiro-redis开源插件)
+ * @param:
+ * @date: 2019-08-15 11:56 AM
+ * @return: org.crazycake.shiro.RedisSessionDAO
*/
-// @Bean
public RedisSessionDAO redisSessionDAO() {
RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
- redisSessionDAO.setRedisManager(redisManager());
+ redisSessionDAO.setRedisManager(redisManager()); //设置Redis管理器
return redisSessionDAO;
}
/**
- * shiro session的管理
+ * @description: Session管理器
+ * @param:
+ * @date: 2019-08-15 11:57 AM
+ * @return: org.apache.shiro.web.session.mgt.DefaultWebSessionManager
*/
@Bean
public DefaultWebSessionManager sessionManager() {
@@ -213,27 +247,29 @@ public DefaultWebSessionManager sessionManager() {
}
/**
- * cookie对象;
- *
- * @return
+ * @description: 设置Cookie(RememberMe功能)
+ * @param:
+ * @date: 2019-08-15 11:58 AM
+ * @return: org.apache.shiro.web.servlet.SimpleCookie
*/
public SimpleCookie rememberMeCookie() {
- // 这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
+ // 这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
- // 记住我cookie生效时间30天 ,单位秒。 注释掉,默认永久不过期 2018-07-15
+ // 记住我cookie生效时间30天,单位秒,默认情况下永不过期
simpleCookie.setMaxAge(redisProperties.getExpire());
return simpleCookie;
}
/**
- * cookie管理对象;记住我功能
- *
- * @return
+ * @description: Cookie管理器(开启RememberMe功能)
+ * @param:
+ * @date: 2019-08-15 11:58 AM
+ * @return: org.apache.shiro.web.mgt.CookieRememberMeManager
*/
public CookieRememberMeManager rememberMeManager() {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCookie(rememberMeCookie());
- //rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)
+ //设置rememberMe cookie加密的密钥,建议每个项目都不一样,默认AES算法:密钥长度(128 256 512 位)
cookieRememberMeManager.setCipherKey(Base64.decode("1QWLxg+NYmxraMoxAXu/Iw=="));
return cookieRememberMeManager;
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/config/WebMvcConfig.java b/shiro-core/src/main/java/com/zyd/shiro/framework/config/WebMvcConfig.java
index 1724579..fc8c310 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/config/WebMvcConfig.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/config/WebMvcConfig.java
@@ -26,11 +26,11 @@
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/7/15 15:03
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: WebMVC配置类
+ * @date: 2019-08-15 1:29 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/holder/RequestHolder.java b/shiro-core/src/main/java/com/zyd/shiro/framework/holder/RequestHolder.java
index 71cd5bc..baf5fc3 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/holder/RequestHolder.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/holder/RequestHolder.java
@@ -33,20 +33,20 @@
import javax.servlet.http.HttpSession;
/**
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 请求层的基础支架
+ * @date: 2019-08-16 2:07 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Slf4j
public class RequestHolder {
/**
- * 获取request
- *
- * @return HttpServletRequest
+ * @description: 获取request
+ * @param:
+ * @date: 2019-08-16 2:09 PM
+ * @return: javax.servlet.http.HttpServletRequest
*/
public static HttpServletRequest getRequest() {
log.debug("getRequest -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
@@ -58,9 +58,10 @@ public static HttpServletRequest getRequest() {
}
/**
- * 获取Response
- *
- * @return HttpServletRequest
+ * @description: (never used)获取Response
+ * @param:
+ * @date: 2019-08-16 2:11 PM
+ * @return: javax.servlet.http.HttpServletResponse
*/
public static HttpServletResponse getResponse() {
log.debug("getResponse -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
@@ -72,9 +73,10 @@ public static HttpServletResponse getResponse() {
}
/**
- * 获取session
- *
- * @return HttpSession
+ * @description: (never used)获取session
+ * @param:
+ * @date: 2019-08-16 2:11 PM
+ * @return: javax.servlet.http.HttpSession
*/
public static HttpSession getSession() {
log.debug("getSession -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
@@ -86,10 +88,10 @@ public static HttpSession getSession() {
}
/**
- * 获取session的Attribute
- *
- * @param name session的key
- * @return Object
+ * @description: 获取session中的Attribute
+ * @param: name
+ * @date: 2019-08-16 2:12 PM
+ * @return: java.lang.Object
*/
public static Object getSession(String name) {
log.debug("getSession -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
@@ -101,10 +103,11 @@ public static Object getSession(String name) {
}
/**
- * 添加session
- *
- * @param name
- * @param value
+ * @description: 添加session
+ * @param: name
+ * @param: value
+ * @date: 2019-08-16 2:14 PM
+ * @return: void
*/
public static void setSession(String name, Object value) {
log.debug("setSession -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
@@ -116,10 +119,10 @@ public static void setSession(String name, Object value) {
}
/**
- * 清除指定session
- *
- * @param name
- * @return void
+ * @description: 清除指定session
+ * @param: name
+ * @date: 2019-08-16 2:15 PM
+ * @return: void
*/
public static void removeSession(String name) {
log.debug("removeSession -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
@@ -131,9 +134,10 @@ public static void removeSession(String name) {
}
/**
- * 获取所有session key
- *
- * @return String[]
+ * @description: 获取所有的session key
+ * @param:
+ * @date: 2019-08-16 2:15 PM
+ * @return: java.lang.String[]
*/
public static String[] getSessionKeys() {
log.debug("getSessionKeys -- Thread id :{}, name : {}", Thread.currentThread().getId(), Thread.currentThread().getName());
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/holder/SpringContextHolder.java b/shiro-core/src/main/java/com/zyd/shiro/framework/holder/SpringContextHolder.java
index 1c33792..55bf32f 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/holder/SpringContextHolder.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/holder/SpringContextHolder.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -29,11 +29,11 @@
import org.springframework.stereotype.Component;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: SpringContext的基础支架
+ * @date: 2019-08-16 3:18 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Component
public class SpringContextHolder implements ApplicationContextAware {
@@ -41,10 +41,10 @@ public class SpringContextHolder implements ApplicationContextAware {
private static ApplicationContext appContext = null;
/**
- * 通过name获取 Bean.
- *
- * @param name
- * @return
+ * @description: (never used)通过name获取指定的Bean
+ * @param: name
+ * @date: 2019-08-16 3:20 PM
+ * @return: java.lang.Object
*/
public static Object getBean(String name) {
return appContext.getBean(name);
@@ -52,28 +52,32 @@ public static Object getBean(String name) {
}
/**
- * 通过class获取Bean.
- *
- * @param clazz
- * @param
- * @return
+ * @description: 通过class获取指定的Bean
+ * @param: clazz
+ * @date: 2019-08-16 3:20 PM
+ * @return: T
*/
public static T getBean(Class clazz) {
return appContext.getBean(clazz);
}
/**
- * 通过name,以及Clazz返回指定的Bean
- *
- * @param name
- * @param clazz
- * @param
- * @return
+ * @description: (never used)通过name及clazz获取指定的Bean
+ * @param: name
+ * @param: clazz
+ * @date: 2019-08-16 3:21 PM
+ * @return: T
*/
public static T getBean(String name, Class clazz) {
return appContext.getBean(name, clazz);
}
+ /**
+ * @description: 初始化applicationContext
+ * @param: applicationContext
+ * @date: 2019-08-16 3:21 PM
+ * @return: void
+ */
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (appContext == null) {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractBO.java b/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractBO.java
index 795ac71..02dc935 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractBO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractBO.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -26,11 +26,11 @@
import java.io.Serializable;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: (Business Object)业务对象
+ * @date: 2019-08-16 3:37 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public abstract class AbstractBO implements Serializable {
private static final long serialVersionUID = -3737736141782545763L;
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractDO.java b/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractDO.java
index dce65ff..cfe517e 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractDO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractDO.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -33,22 +33,22 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: (Data Transfer Object)数据传输对象
+ * @date: 2019-08-16 3:41 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class AbstractDO implements Serializable {
+
/**
* @fieldName: serialVersionUID
* @fieldType: long
*/
private static final long serialVersionUID = 5088697673359856350L;
-
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractService.java b/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractService.java
index 2fb2a74..8fb5f12 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractService.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/object/AbstractService.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -26,81 +26,83 @@
import java.util.List;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 通用的Service接口:提高代码的简洁及可维护性
+ * @date: 2019-08-16 3:47 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface AbstractService {
/**
- * 保存一个实体,null的属性不会保存,会使用数据库默认值
- *
- * @param entity
- * @return
+ * @description: 保存一个实体, null的属性不会保存(使用数据库默认值)
+ * @param: entity
+ * @date: 2019-08-16 3:47 PM
+ * @return: T
*/
T insert(T entity);
/**
- * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
- *
- * @param entities
+ * @description: 批量插入:既支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
+ * @param: entities
+ * @date: 2019-08-16 4:05 PM
+ * @return: void
*/
void insertList(List entities);
/**
- * 根据主键字段进行删除,方法参数必须包含完整的主键属性
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行删除, 方法参数必须包含完整的主键属性
+ * @param: primaryKey
+ * @date: 2019-08-16 4:06 PM
+ * @return: boolean
*/
boolean removeByPrimaryKey(PK primaryKey);
/**
- * 根据主键更新实体全部字段,null值会被更新
- *
- * @param entity
- * @return
+ * @description: 根据主键更新实体全部字段, null值也会被更新
+ * @param: entity
+ * @date: 2019-08-16 4:07 PM
+ * @return: boolean
*/
boolean update(T entity);
/**
- * 根据主键更新属性不为null的值
- *
- * @param entity
- * @return
+ * @description: 根据主键更新属性不为null的值
+ * @param: entity
+ * @date: 2019-08-16 4:08 PM
+ * @return: boolean
*/
boolean updateSelective(T entity);
/**
- * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号
- *
- * @param primaryKey
- * @return
+ * @description: 根据主键字段进行查询, 方法参数必须包含完整的主键属性, 查询条件使用等号
+ * @param: primaryKey
+ * @date: 2019-08-16 4:09 PM
+ * @return: T
*/
T getByPrimaryKey(PK primaryKey);
/**
- * 根据实体中的属性进行查询,只能有一个返回值,有多个结果时抛出异常,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: 根据实体中的属性进行查询, 只能有一个返回值, 有多个结果时抛出异常, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-16 4:11 PM
+ * @return: T
*/
T getOneByEntity(T entity);
/**
- * 查询全部结果,listByEntity(null)方法能达到同样的效果
- *
- * @return
+ * @description: 查询全部结果, 注:listByEntity(null)方法能达到同样的效果
+ * @param:
+ * @date: 2019-08-16 4:12 PM
+ * @return: java.util.List
*/
List listAll();
/**
- * 根据实体中的属性值进行查询,查询条件使用等号
- *
- * @param entity
- * @return
+ * @description: (never used)根据实体中的属性值进行查询, 查询条件使用等号
+ * @param: entity
+ * @date: 2019-08-16 4:12 PM
+ * @return: java.util.List
*/
List listByEntity(T entity);
-}
\ No newline at end of file
+}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/object/BaseConditionVO.java b/shiro-core/src/main/java/com/zyd/shiro/framework/object/BaseConditionVO.java
index f797155..9371c6c 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/object/BaseConditionVO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/object/BaseConditionVO.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -30,11 +30,11 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 基础的条件值对象(Value Object)
+ * @date: 2019-08-16 4:30 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -55,6 +55,7 @@ public int getPageSize() {
return pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE;
}
+ //the method is never used
public int getPageStart() {
return pageNumber > 0 ? (pageNumber - 1) * getPageSize() : 0;
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/object/PageResult.java b/shiro-core/src/main/java/com/zyd/shiro/framework/object/PageResult.java
index 1741cd9..e26d6a8 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/object/PageResult.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/object/PageResult.java
@@ -25,13 +25,11 @@
import java.util.List;
/**
- * bootstrap table用到的返回json格式
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 分页结果:BootStrap table中需获取的json格式数据
+ * @date: 2019-08-16 4:17 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -44,6 +42,7 @@ public PageResult(Long total, List rows) {
this.rows = rows;
}
+ //the constructor is never used
public PageResult() {
}
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/object/ResponseVO.java b/shiro-core/src/main/java/com/zyd/shiro/framework/object/ResponseVO.java
index 37aeeb5..f1b1d98 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/object/ResponseVO.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/object/ResponseVO.java
@@ -29,13 +29,11 @@
import java.util.List;
/**
- * controller返回json
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: Controller层需返回的json格式数据
+ * @date: 2019-08-16 4:17 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -50,10 +48,12 @@ public ResponseVO(Integer status, String message, T data) {
this.data = data;
}
+ //the constructor is never used
public ResponseVO(ResponseStatus status, T data) {
this(status.getCode(), status.getMessage(), data);
}
+ //the method is never used
public String toJson() {
T t = this.getData();
if (t instanceof List || t instanceof Collection) {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/property/DruidProperties.java b/shiro-core/src/main/java/com/zyd/shiro/framework/property/DruidProperties.java
index c78c6c4..cd92787 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/property/DruidProperties.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/property/DruidProperties.java
@@ -28,13 +28,11 @@
import java.util.List;
/**
- * druid属性
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/5/17 11:13
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: druid属性信息
+ * @date: 2019-08-15 11:35 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
@ConfigurationProperties(prefix = "zyd.druid")
diff --git a/shiro-core/src/main/java/com/zyd/shiro/framework/property/RedisProperties.java b/shiro-core/src/main/java/com/zyd/shiro/framework/property/RedisProperties.java
index d6fe8f0..a6f407e 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/framework/property/RedisProperties.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/framework/property/RedisProperties.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -30,13 +30,11 @@
import org.springframework.core.annotation.Order;
/**
- * redis属性配置文件
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: redis属性信息
+ * @date: 2019-08-15 11:37 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Configuration
@ConfigurationProperties(prefix = "spring.redis")
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysResources.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysResources.java
index ff2797a..3508bac 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysResources.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysResources.java
@@ -27,11 +27,11 @@
import java.util.List;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 资源信息
+ * @date: 2019-08-14 2:19 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRole.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRole.java
index 0a07911..83b9911 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRole.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRole.java
@@ -26,11 +26,11 @@
import javax.persistence.Transient;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 角色信息
+ * @date: 2019-08-14 2:22 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRoleResources.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRoleResources.java
index c5933f0..ab1d37f 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRoleResources.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysRoleResources.java
@@ -24,11 +24,11 @@
import lombok.EqualsAndHashCode;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 连接用户与资源信息的桥梁
+ * @date: 2019-08-14 2:23 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUser.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUser.java
index 0f6f653..f5c5c41 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUser.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUser.java
@@ -26,11 +26,11 @@
import java.util.Date;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户信息
+ * @date: 2019-08-14 1:56 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUserRole.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUserRole.java
index c6b8860..2698c8a 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUserRole.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/beans/SysUserRole.java
@@ -24,11 +24,11 @@
import lombok.EqualsAndHashCode;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 连接用户与角色信息的桥梁
+ * @date: 2019-08-14 2:32 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Data
@EqualsAndHashCode(callSuper = false)
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysResourceMapper.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysResourceMapper.java
index bdc52ce..eca6aaa 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysResourceMapper.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysResourceMapper.java
@@ -28,39 +28,68 @@
import java.util.Map;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 操控系统资源信息
+ * @date: 2019-08-14 3:06 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Repository
public interface SysResourceMapper extends BaseMapper {
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询系统资源
+ * @param: vo
+ * @date: 2019-08-14 3:08 PM
+ * @return: java.util.List
*/
List findPageBreakByCondition(ResourceConditionVO vo);
+ /**
+ * @description: 获取用户的资源列表
+ * @param: map
+ * @date: 2019-08-14 3:10 PM
+ * @return: java.util.List
+ */
List listUserResources(Map map);
/**
- * 该节代码参考自http://blog.csdn.net/poorcoder_/article/details/71374002
- * 感谢网友
- *
- * @param rid
- * @return
+ * @description: 根据角色id获取ztree使用的资源列表, 代码参考自 http://blog.csdn.net/poorcoder_/article/details/71374002
+ * @param: rid
+ * @date: 2019-08-14 3:12 PM
+ * @return: java.util.List
*/
List queryResourcesListWithSelected(Long rid);
+ /**
+ * @description: 获取资源的url和Permission
+ * @param:
+ * @date: 2019-08-14 3:13 PM
+ * @return: java.util.List
+ */
List listUrlAndPermission();
+ /**
+ * @description: 获取所有可用的菜单资源
+ * @param:
+ * @date: 2019-08-14 3:15 PM
+ * @return: java.util.List
+ */
List listAllAvailableMenu();
+ /**
+ * @description: 通过父级菜单id获取父级资源下所有menu资源
+ * @param: pid
+ * @date: 2019-08-14 3:16 PM
+ * @return: java.util.List
+ */
List listMenuResourceByPid(Long pid);
+ /**
+ * @description: 通过用户id获取用户关联的所有资源
+ * @param: userId
+ * @date: 2019-08-14 3:18 PM
+ * @return: java.util.List
+ */
List listByUserId(Long userId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleMapper.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleMapper.java
index 4a9058b..56ab172 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleMapper.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleMapper.java
@@ -27,31 +27,36 @@
import java.util.List;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 操控系统角色信息
+ * @date: 2019-08-14 2:48 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Repository
public interface SysRoleMapper extends BaseMapper {
/**
- * 分页查询
- *
- * @param vo
- * @return
+ * @description: 分页查询角色信息
+ * @param: vo
+ * @date: 2019-08-14 2:49 PM
+ * @return: java.util.List
*/
List findPageBreakByCondition(RoleConditionVO vo);
/**
- * 该节代码参考自http://blog.csdn.net/poorcoder_/article/details/71374002
- * 感谢网友
- *
- * @param userId
- * @return
+ * @description: 通过用户id获取ztree使用的角色列表, 代码参考自 http://blog.csdn.net/poorcoder_/article/details/71374002
+ * @param: userId
+ * @date: 2019-08-14 2:50 PM
+ * @return: java.util.List
*/
List queryRoleListWithSelected(Integer userId);
+ /**
+ * @description: 通过用户id获取用户所拥有的角色信息
+ * @param: userId
+ * @date: 2019-08-14 2:51 PM
+ * @return: java.util.List
+ */
List listRolesByUserId(Long userId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleResourcesMapper.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleResourcesMapper.java
index b2915e3..854248a 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleResourcesMapper.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysRoleResourcesMapper.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -28,11 +28,11 @@
import org.springframework.stereotype.Repository;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 角色与资源信息的连表操作
+ * @date: 2019-08-14 3:39 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Repository
public interface SysRoleResourcesMapper extends BaseMapper {
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserMapper.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserMapper.java
index 524d9bf..ad88f30 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserMapper.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserMapper.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -31,17 +31,29 @@
import java.util.List;
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 操控系统用户信息
+ * @date: 2019-08-14 2:47 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Repository
public interface SysUserMapper extends BaseMapper {
+ /**
+ * @description: 分页查询用户信息
+ * @param: vo
+ * @date: 2019-08-14 2:34 PM
+ * @return: java.util.List
+ */
List findPageBreakByCondition(UserConditionVO vo);
+ /**
+ * @description: 通过角色Id获取用户列表
+ * @param: roleId
+ * @date: 2019-08-14 2:34 PM
+ * @return: java.util.List
+ */
List listByRoleId(Long roleId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserRoleMapper.java b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserRoleMapper.java
index 54a5fa2..55d5375 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserRoleMapper.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/persistence/mapper/SysUserRoleMapper.java
@@ -1,18 +1,18 @@
/**
* MIT License
- *
+ *
* Copyright (c) 2018 yadong.zhang
- *
+ *
* 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
@@ -29,14 +29,22 @@
import java.util.List;
+
/**
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 用户与角色信息的连表操作
+ * @date: 2019-08-14 2:59 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Repository
public interface SysUserRoleMapper extends BaseMapper {
+
+ /**
+ * @description: (never used)通过角色id查询指定的用户信息
+ * @param: roleId
+ * @date: 2019-08-14 3:04 PM
+ * @return: java.util.List
+ */
List findUserIdByRoleId(Integer roleId);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/plugin/BaseMapper.java b/shiro-core/src/main/java/com/zyd/shiro/plugin/BaseMapper.java
index dcabc53..1170bdd 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/plugin/BaseMapper.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/plugin/BaseMapper.java
@@ -23,14 +23,12 @@
import tk.mybatis.mapper.common.MySqlMapper;
/**
- * 公有Mapper
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 通用的Mapper接口:提高代码的简洁及可维护性
+ * @date: 2019-08-16 3:51 PM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public interface BaseMapper extends Mapper, MySqlMapper {
- // 特别注意,该接口不能被扫描到,否则会出错
+ // 特别注意:该接口不能被扫描到,否则会出错
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/util/AesUtil.java b/shiro-core/src/main/java/com/zyd/shiro/util/AesUtil.java
index 84d6297..c9a3143 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/util/AesUtil.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/util/AesUtil.java
@@ -29,83 +29,71 @@
import java.security.SecureRandom;
/**
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @website https://www.zhyd.me
- * @version 1.0
- * @date 2018/4/16 16:26
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 加密工具类:AES(Advanced Encryption Standard),又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准
+ * @date: 2019-08-15 10:35 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class AesUtil {
private static final String KEY_ALGORITHM = "AES";
private static final String DEFAULT_CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
/**
- * AES加密
- *
- * @param passwd
- * 加密的密钥
- * @param content
- * 需要加密的字符串
- * @return 返回Base64转码后的加密数据
- * @throws Exception
+ * @description: AES加密
+ * @param: passwd 加密的密钥
+ * @param: content 需要加密的字符串
+ * @date: 2019-08-15 10:40 AM
+ * @return: java.lang.String 返回Base64转码后的加密数据
*/
public static String encrypt(String passwd, String content) throws Exception {
// 创建密码器
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
-
+ // 指定待加密字符的编码格式
byte[] byteContent = content.getBytes("utf-8");
-
// 初始化为加密模式的密码器
cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(passwd));
-
// 加密
byte[] result = cipher.doFinal(byteContent);
-
//通过Base64转码返回
return Base64.encodeBase64String(result);
}
/**
- * AES解密
- *
- * @param passwd
- * 加密的密钥
- * @param encrypted
- * 已加密的密文
- * @return 返回解密后的数据
- * @throws Exception
+ * @description: AES解密
+ * @param: passwd 加密的密钥
+ * @param: encrypted 已加密的密文
+ * @date: 2019-08-15 10:44 AM
+ * @return: java.lang.String 返回解密后的数据
*/
public static String decrypt(String passwd, String encrypted) throws Exception {
//实例化
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
-
- //使用密钥初始化,设置为解密模式
+ //使用密钥初始化,设置为解密模式
cipher.init(Cipher.DECRYPT_MODE, getSecretKey(passwd));
-
- //执行操作
+ //解密
byte[] result = cipher.doFinal(Base64.decodeBase64(encrypted));
-
+ //返回解密后的数据
return new String(result, "utf-8");
}
/**
- * 生成加密秘钥
- *
- * @return
+ * @description: 生成加密秘钥
+ * @param: password
+ * @date: 2019-08-15 10:46 AM
+ * @return: javax.crypto.spec.SecretKeySpec
*/
private static SecretKeySpec getSecretKey(final String password) throws NoSuchAlgorithmException {
- //返回生成指定算法密钥生成器的 KeyGenerator 对象
+ // 获取生成指定算法密钥生成器的 KeyGenerator 对象
KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM);
- // javax.crypto.BadPaddingException: Given final block not properly padded解决方案
+ // 异常:javax.crypto.BadPaddingException: Given final block not properly padded的解决方案如下
// https://www.cnblogs.com/zempty/p/4318902.html - 用此法解决的
// https://www.cnblogs.com/digdeep/p/5580244.html - 留作参考吧
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
random.setSeed(password.getBytes());
- //AES 要求密钥长度为 128
+ // AES要求密钥长度为128
kg.init(128, random);
-
- //生成一个密钥
+ // 生成一个密钥
SecretKey secretKey = kg.generateKey();
// 转换为AES专用密钥
return new SecretKeySpec(secretKey.getEncoded(), KEY_ALGORITHM);
diff --git a/shiro-core/src/main/java/com/zyd/shiro/util/IpUtil.java b/shiro-core/src/main/java/com/zyd/shiro/util/IpUtil.java
index 7c9ed6b..ba61382 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/util/IpUtil.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/util/IpUtil.java
@@ -24,21 +24,19 @@
import javax.servlet.http.HttpServletRequest;
/**
- * 获取IP的工具类
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/18 11:48
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 获取IP的工具类
+ * @date: 2019-08-15 10:55 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class IpUtil {
/**
- * 获取真实IP
- *
- * @param request
- * @return
+ * @description: 获取真实的IP地址
+ * @param: request
+ * @date: 2019-08-15 10:52 AM
+ * @return: java.lang.String
*/
public static String getRealIp(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
@@ -49,10 +47,10 @@ public static String getRealIp(HttpServletRequest request) {
}
/**
- * 校验IP
- *
- * @param ip
- * @return
+ * @description: 校验IP地址
+ * @param: ip
+ * @date: 2019-08-15 10:53 AM
+ * @return: boolean
*/
private static boolean checkIp(String ip) {
return !StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip);
diff --git a/shiro-core/src/main/java/com/zyd/shiro/util/Md5Util.java b/shiro-core/src/main/java/com/zyd/shiro/util/Md5Util.java
index 6e06bd5..09154a5 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/util/Md5Util.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/util/Md5Util.java
@@ -24,33 +24,31 @@
import java.security.MessageDigest;
/**
- * MD5加密工具类
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/18 11:48
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: MD5加密工具类
+ * @date: 2019-08-15 10:55 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
@Slf4j
public class Md5Util {
/**
- * 通过盐值对字符串进行MD5加密
- *
- * @param param 需要加密的字符串
- * @param salt 盐值
- * @return
+ * @description: (never used)通过盐值对字符串进行MD5加密
+ * @param: param 需要加密的字符串
+ * @param: salt 盐值
+ * @date: 2019-08-15 10:56 AM
+ * @return: java.lang.String
*/
public static String MD5(String param, String salt) {
return MD5(param + salt);
}
/**
- * 加密字符串
- *
- * @param s 字符串
- * @return
+ * @description: 加密字符串
+ * @param: s
+ * @date: 2019-08-15 10:57 AM
+ * @return: java.lang.String
*/
public static String MD5(String s) {
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
diff --git a/shiro-core/src/main/java/com/zyd/shiro/util/PasswordUtil.java b/shiro-core/src/main/java/com/zyd/shiro/util/PasswordUtil.java
index 80c566e..cf4f86d 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/util/PasswordUtil.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/util/PasswordUtil.java
@@ -22,32 +22,33 @@
import com.zyd.shiro.business.consts.CommonConst;
/**
- * @author: yadong.zhang
+ * @project: springboot-shiro
+ * @description: 用户密码加密/解密工具
* @date: 2017/12/15 17:03
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class PasswordUtil {
/**
- * AES 加密
- * @param password
- * 未加密的密码
- * @param salt
- * 盐值,默认使用用户名就可
- * @return
* @throws Exception
+ * @description: AES 加密
+ * @param: password 未加密的用户密码
+ * @param: salt 默认使用用户名作为盐值
+ * @date: 2019-08-13 1:15 PM
+ * @return: java.lang.String
*/
public static String encrypt(String password, String salt) throws Exception {
return AesUtil.encrypt(Md5Util.MD5(salt + CommonConst.ZYD_SECURITY_KEY), password);
}
/**
- * AES 解密
- * @param encryptPassword
- * 加密后的密码
- * @param salt
- * 盐值,默认使用用户名就可
- * @return
* @throws Exception
+ * @description: AES 解密
+ * @param: encryptPassword 加密后的用户密码
+ * @param: salt 默认使用用户名作为盐值
+ * @date: 2019-08-13 1:17 PM
+ * @return: java.lang.String
*/
public static String decrypt(String encryptPassword, String salt) throws Exception {
return AesUtil.decrypt(Md5Util.MD5(salt + CommonConst.ZYD_SECURITY_KEY), encryptPassword);
diff --git a/shiro-core/src/main/java/com/zyd/shiro/util/ResultUtil.java b/shiro-core/src/main/java/com/zyd/shiro/util/ResultUtil.java
index 2145b5c..cebb166 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/util/ResultUtil.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/util/ResultUtil.java
@@ -31,13 +31,11 @@
import java.util.Map;
/**
- * 接口返回工具类,支持ModelAndView、ResponseVO、PageResult
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/18 11:48
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: 接口返回工具类:支持ModelAndView、ResponseVO、PageResult
+ * @date: 2019-08-15 10:59 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class ResultUtil {
@@ -45,6 +43,7 @@ public static ModelAndView view(String view) {
return new ModelAndView(view);
}
+ //the method is not used
public static ModelAndView view(String view, Map model) {
return new ModelAndView(view, model);
}
diff --git a/shiro-core/src/main/java/com/zyd/shiro/util/SessionUtil.java b/shiro-core/src/main/java/com/zyd/shiro/util/SessionUtil.java
index d33116c..987bfae 100644
--- a/shiro-core/src/main/java/com/zyd/shiro/util/SessionUtil.java
+++ b/shiro-core/src/main/java/com/zyd/shiro/util/SessionUtil.java
@@ -26,66 +26,79 @@
import java.util.UUID;
/**
- * Session工具类
- *
- * @author yadong.zhang (yadong.zhang0415(a)gmail.com)
- * @version 1.0
- * @website https://www.zhyd.me
- * @date 2018/4/18 11:48
- * @since 1.0
+ * @project: springboot-shiro
+ * @description: Session工具类
+ * @date: 2019-08-15 11:04 AM
+ * @version: 1.0
+ * @website: https://yubuntu0109.github.io/
*/
public class SessionUtil {
/**
- * 获取session中的用户信息
- *
- * @return User
+ * @description: 获取session中的用户信息
+ * @param:
+ * @date: 2019-08-15 11:04 AM
+ * @return: com.zyd.shiro.business.entity.User
*/
public static User getUser() {
return (User) RequestHolder.getSession(SessionConst.USER_SESSION_KEY);
}
/**
- * 添加session
- *
- * @param user
+ * @description: 将用户信息添加到session
+ * @param: user
+ * @date: 2019-08-15 11:05 AM
+ * @return: void
*/
public static void setUser(User user) {
RequestHolder.setSession(SessionConst.USER_SESSION_KEY, user);
}
/**
- * 删除session信息
+ * @description: 删除session中的用户信息
+ * @param:
+ * @date: 2019-08-15 11:05 AM
+ * @return: void
*/
public static void removeUser() {
RequestHolder.removeSession(SessionConst.USER_SESSION_KEY);
}
/**
- * 获取session中的Token信息
- *
- * @return String
+ * @description: 获取session中的Token信息
+ * @param: key
+ * @date: 2019-08-15 11:09 AM
+ * @return: java.lang.String
*/
public static String getToken(String key) {
return (String) RequestHolder.getSession(key);
}
/**
- * 添加Token
+ * @description: 将Token信息添加到session
+ * @param: key
+ * @date: 2019-08-15 11:09 AM
+ * @return: void
*/
public static void setToken(String key) {
RequestHolder.setSession(key, UUID.randomUUID().toString());
}
/**
- * 删除Token信息
+ * @description: 删除session中的Token信息
+ * @param: key
+ * @date: 2019-08-15 11:10 AM
+ * @return: void
*/
public static void removeToken(String key) {
RequestHolder.removeSession(key);
}
/**
- * 删除所有的session信息
+ * @description: 删除所有的session信息
+ * @param:
+ * @date: 2019-08-15 11:11 AM
+ * @return: void
*/
public static void removeAllSession() {
String[] keys = RequestHolder.getSessionKeys();
diff --git a/shiro-core/src/main/resources/mybatis/SysResourceMapper.xml b/shiro-core/src/main/resources/mybatis/SysResourceMapper.xml
index af2afaa..1708a96 100644
--- a/shiro-core/src/main/resources/mybatis/SysResourceMapper.xml
+++ b/shiro-core/src/main/resources/mybatis/SysResourceMapper.xml
@@ -1,7 +1,10 @@
-
+
+
@@ -14,6 +17,7 @@
+
@@ -24,7 +28,9 @@
-
+
+
@@ -36,163 +42,149 @@
+
+
SELECT
- com.*,
- f.id parent_id,
- f.`name` parent_name,
- f.`icon` parent_icon,
- f.type parent_type
+ com.*,
+ f.id parent_id,
+ f.`name` parent_name,
+ f.`icon` parent_icon,
+ f.type parent_type
FROM
- sys_resources com
+ sys_resources com
LEFT JOIN sys_resources f ON com.parent_id = f.id
WHERE
- 1 = 1
-
- AND (
- com.name LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') OR
- com.url LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') OR
- com.permission LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%')
- )
-
+ 1 = 1
+
+ AND (
+ com.name LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') OR
+ com.url LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') OR
+ com.permission LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%')
+ )
+
ORDER by
- com.parent_id ASC,
- com.name DESC
+ com.parent_id ASC,
+ com.name DESC
+
- SELECT
- url,
- permission
- FROM
- sys_resources
- WHERE
- url IS NOT NULL
- ORDER BY
- sort ASC
+ SELECT url,
+ permission
+ FROM sys_resources
+ WHERE url IS NOT NULL
+ ORDER BY sort ASC
+
SELECT
- re.id,
- re.`name`,
- re.parent_id,
- re.url,
- re.permission,
- re.icon,
- re.external,
- re.`available`,
- node.id AS node_id,
- node.`name` AS node_name,
- node.`type` AS node_type,
- node.`url` AS node_url,
- node.parent_id AS node_parent_id,
- node.`permission` AS node_permission,
- node.`available` AS node_available,
- node.`external` AS node_external,
- node.icon AS node_icon
+ re.id,
+ re.`name`,
+ re.parent_id,
+ re.url,
+ re.permission,
+ re.icon,
+ re.external,
+ re.`available`,
+ node.id AS node_id,
+ node.`name` AS node_name,
+ node.`type` AS node_type,
+ node.`url` AS node_url,
+ node.parent_id AS node_parent_id,
+ node.`permission` AS node_permission,
+ node.`available` AS node_available,
+ node.`external` AS node_external,
+ node.icon AS node_icon
FROM
- sys_resources re
+ sys_resources re
LEFT JOIN sys_role_resources rr ON re.id = rr.resources_id
LEFT JOIN sys_user_role ur ON rr.role_id = ur.role_id
LEFT JOIN sys_resources node ON node.parent_id = re.id AND node.available = 1
WHERE
- (re.parent_id = 0 OR re.parent_id IS NULL )
+ (re.parent_id = 0 OR re.parent_id IS NULL )
AND re.available = 1
AND ur.user_id = #{userId}
AND re.type= #{type}
ORDER BY
- re.sort ASC,
- node.sort ASC
+ re.sort ASC,
+ node.sort ASC
+
- SELECT
- re.id,
- re.`name`,
- re.parent_id,
- re.url,
- re.type,
- re.icon,
- (
- CASE
- WHEN EXISTS (
- SELECT
- 1
- FROM
- sys_role_resources rr
- WHERE
- rr.resources_id = re.id
- AND rr.role_id = #{rid}
- )
- THEN
- 'true'
- ELSE
- 'false'
- END
- ) AS checked
- FROM
- sys_resources re
- ORDER BY
- re.sort ASC
-
+ SELECT re.id,
+ re.`name`,
+ re.parent_id,
+ re.url,
+ re.type,
+ re.icon,
+ (
+ CASE
+ WHEN EXISTS(
+ SELECT 1
+ FROM sys_role_resources rr
+ WHERE rr.resources_id = re.id
+ AND rr.role_id = #{rid}
+ )
+ THEN
+ 'true'
+ ELSE
+ 'false'
+ END
+ ) AS checked
+ FROM sys_resources re
+ ORDER BY re.sort ASC
+
+
+ SELECT r.id,
+ r.`name`,
+ node.id AS node_id,
+ node.`name` AS node_name,
+ node.parent_id
+ FROM sys_resources r
+ LEFT JOIN sys_resources node ON (
+ node.parent_id = r.id
+ AND node.available = 1
+ AND node.type = 'menu'
+ )
+ WHERE r.available = 1
+ AND r.type = 'menu'
+ AND (r.url IS NULL OR r.url = '')
+ AND (r.permission IS NULL OR r.permission = '')
+ ORDER BY r.sort ASC,
+ node.sort ASC
+
+
+ ORDER BY re.sort ASC
+
+
- SELECT
- re.id,
- re.`name`,
- re.parent_id,
- re.url,
- re.permission,
- re.icon,
- re.sort
- FROM
- sys_resources re
- INNER JOIN sys_role_resources rr ON re.id = rr.resources_id
- INNER JOIN sys_user_role ur ON rr.role_id = ur.role_id
- WHERE
- ur.user_id = #{userId}
- AND re.available = 1
- ORDER BY
- re.parent_id ASC,
- re.sort ASC
-
+ SELECT re.id,
+ re.`name`,
+ re.parent_id,
+ re.url,
+ re.permission,
+ re.icon,
+ re.sort
+ FROM sys_resources re
+ INNER JOIN sys_role_resources rr ON re.id = rr.resources_id
+ INNER JOIN sys_user_role ur ON rr.role_id = ur.role_id
+ WHERE ur.user_id = #{userId}
+ AND re.available = 1
+ ORDER BY re.parent_id ASC,
+ re.sort ASC
+
-
diff --git a/shiro-core/src/main/resources/mybatis/SysRoleMapper.xml b/shiro-core/src/main/resources/mybatis/SysRoleMapper.xml
index 52a5508..c7b0a6c 100644
--- a/shiro-core/src/main/resources/mybatis/SysRoleMapper.xml
+++ b/shiro-core/src/main/resources/mybatis/SysRoleMapper.xml
@@ -1,69 +1,65 @@
-
+
-
-
-
-
-
-
-
-
-
- SELECT
- com.*
- FROM
- sys_role com
- WHERE
- 1 = 1
-
- AND (
- com.description LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%')
- )
-
- ORDER BY
- com.create_time DESC
-
+
+
+
+
+
+
+
+
-
- SELECT
- r.id,
- r.name,
- r.description,
- (
- CASE
- WHEN (
- SELECT
- ur.role_id
- FROM
- sys_user_role ur
- WHERE
- ur.user_id = #{userId}
- AND ur.role_id = r.id
- ) THEN
- 1
- ELSE
- 0
- END
- ) AS selected
- FROM
- sys_role r
- WHERE
- r.available = 1
-
+
+
+ SELECT
+ com.*
+ FROM
+ sys_role com
+ WHERE
+ 1 = 1
+
+ AND (
+ com.description LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%')
+ )
+
+ ORDER BY
+ com.create_time DESC
+
-
- SELECT
- r.id,
- r.name,
- r.description
- FROM
- sys_role r
- INNER JOIN sys_user_role ur ON ur.role_id = r.id
- WHERE
- ur.user_id = #{userId}
- AND r.available = 1
-
-
+
+
+ SELECT r.id,
+ r.name,
+ r.description,
+ (
+ CASE
+ WHEN (
+ SELECT ur.role_id
+ FROM sys_user_role ur
+ WHERE ur.user_id = #{userId}
+ AND ur.role_id = r.id
+ ) THEN
+ 1
+ ELSE
+ 0
+ END
+ ) AS selected
+ FROM sys_role r
+ WHERE r.available = 1
+
+
+
+ SELECT r.id,
+ r.name,
+ r.description
+ FROM sys_role r
+ INNER JOIN sys_user_role ur ON ur.role_id = r.id
+ WHERE ur.user_id = #{userId}
+ AND r.available = 1
+
+
diff --git a/shiro-core/src/main/resources/mybatis/SysUserMapper.xml b/shiro-core/src/main/resources/mybatis/SysUserMapper.xml
index 7ba7326..7c410ca 100644
--- a/shiro-core/src/main/resources/mybatis/SysUserMapper.xml
+++ b/shiro-core/src/main/resources/mybatis/SysUserMapper.xml
@@ -1,88 +1,90 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- SELECT
- s.*
- FROM
- sys_user s
- WHERE
- 1 = 1
-
- AND
- (
- s.nickname LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- s.mobile LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- s.username LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- s.password LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- s.email LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- s.qq LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- s.remark LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
- )
-
-
-
-
- AND s.id = #{user.id}
-
-
- AND s.gender = #{user.gender}
-
-
- AND s.user_type = #{user.userType}
-
-
- AND s.username = #{user.username}
-
-
- AND s.password = #{user.password}
-
-
- AND s.last_login_ip = #{user.lastLoginIp}
-
-
- AND s.last_login_time = #{user.lastLoginTime}
-
-
- GROUP BY
- s.id
- ORDER BY
- s.create_time DESC
-
+
+
+ SELECT
+ s.*
+ FROM
+ sys_user s
+ WHERE
+ 1 = 1
+
+
+ AND
+ (
+ s.nickname LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ s.mobile LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ s.username LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ s.password LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ s.email LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ s.qq LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ s.remark LIKE CONCAT('%',#{keywords , jdbcType=VARCHAR},'%') or
+ )
+
+
+
+
+ AND s.id = #{user.id}
+
+
+ AND s.gender = #{user.gender}
+
+
+ AND s.user_type = #{user.userType}
+
+
+ AND s.username = #{user.username}
+
+
+ AND s.password = #{user.password}
+
+
+ AND s.last_login_ip = #{user.lastLoginIp}
+
+
+ AND s.last_login_time = #{user.lastLoginTime}
+
+
+ GROUP BY
+ s.id
+ ORDER BY
+ s.create_time DESC
+
-
- SELECT
- s.id,
- s.username,
- s.nickname
- FROM
- sys_user s
- INNER JOIN sys_user_role sur ON sur.user_id = s.id
- WHERE
- sur.role_id = #{roleId}
-
+
+
+ SELECT s.id,
+ s.username,
+ s.nickname
+ FROM sys_user s
+ INNER JOIN sys_user_role sur ON sur.user_id = s.id
+ WHERE sur.role_id = #{roleId}
+
-
diff --git a/shiro-core/src/main/resources/mybatis/SysUserRoleMapper.xml b/shiro-core/src/main/resources/mybatis/SysUserRoleMapper.xml
index b77b764..2e13a97 100644
--- a/shiro-core/src/main/resources/mybatis/SysUserRoleMapper.xml
+++ b/shiro-core/src/main/resources/mybatis/SysUserRoleMapper.xml
@@ -1,6 +1,10 @@
+
+
@@ -8,13 +12,10 @@
-
+
- SELECT
- user_id
- FROM
- sys_user_role
- WHERE
- role_id = #{roleId}
+ SELECT user_id
+ FROM sys_user_role
+ WHERE role_id = #{roleId}
-
\ No newline at end of file
+