feat:修改任务

dev
wangxy 2 months ago
parent 9f0222e0a8
commit 07fa856090

@ -1,19 +1,19 @@
/* */ package com.archive.common.exception.user;
/* */
/* */ import com.archive.common.exception.user.UserException;
/* */
/* */
/* */
/* */
/* */ public class RoleBlockedException
/* */ extends UserException
/* */ {
/* */ private static final long serialVersionUID = 1L;
/* */
/* */ public RoleBlockedException() {
/* 14 */ super("role.blocked", null);
/* */ }
/* */ }
package com.archive.common.exception.user;
import com.archive.common.exception.user.UserException;
public class RoleBlockedException
extends UserException
{
private static final long serialVersionUID = 1L;
public RoleBlockedException() {
super("role.blocked", null);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\common\exceptio\\user\RoleBlockedException.class

@ -1,169 +1,169 @@
/* */ package com.archive.common.utils
package com.archive.common.utils
;
/* */
/* */ import com.archive.common.utils.StringUtils;
/* */ import com.archive.common.utils.text.Convert;
/* */ import java.io.IOException;
/* */ import javax.servlet.http.HttpServletRequest;
/* */ import javax.servlet.http.HttpServletResponse;
/* */ import javax.servlet.http.HttpSession;
/* */ import org.springframework.web.context.request.RequestAttributes;
/* */ import org.springframework.web.context.request.RequestContextHolder;
/* */ import org.springframework.web.context.request.ServletRequestAttributes;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ServletUtils
/* */ {
/* 22 */ private static final String[] agent = new String[] { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
/* */
/* */
/* */
/* */
/* */
/* */ public static String getParameter(String name) {
/* 29 */ return getRequest().getParameter(name);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static String getParameter(String name, String defaultValue) {
/* 37 */ return Convert.toStr(getRequest().getParameter(name), defaultValue);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static Integer getParameterToInt(String name) {
/* 45 */ return Convert.toInt(getRequest().getParameter(name));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static Integer getParameterToInt(String name, Integer defaultValue) {
/* 53 */ return Convert.toInt(getRequest().getParameter(name), defaultValue);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static HttpServletRequest getRequest() {
/* 61 */ return getRequestAttributes().getRequest();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static HttpServletResponse getResponse() {
/* 69 */ return getRequestAttributes().getResponse();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static HttpSession getSession() {
/* 77 */ return getRequest().getSession();
/* */ }
/* */
/* */
/* */ public static ServletRequestAttributes getRequestAttributes() {
/* 82 */ RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
/* 83 */ return (ServletRequestAttributes)attributes;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static String renderString(HttpServletResponse response, String string) {
/* */ try {
/* 97 */ response.setContentType("application/json");
/* 98 */ response.setCharacterEncoding("utf-8");
/* 99 */ response.getWriter().print(string);
/* */ }
/* 101 */ catch (IOException e) {
/* */
/* 103 */ e.printStackTrace();
/* */ }
/* 105 */ return null;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static boolean isAjaxRequest(HttpServletRequest request) {
/* 115 */ String accept = request.getHeader("accept");
/* 116 */ if (accept != null && accept.indexOf("application/json") != -1)
/* */ {
/* 118 */ return true;
/* */ }
/* */
/* 121 */ String xRequestedWith = request.getHeader("X-Requested-With");
/* 122 */ if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
/* */ {
/* 124 */ return true;
/* */ }
/* */
/* 127 */ String uri = request.getRequestURI();
/* 128 */ if (StringUtils.inStringIgnoreCase(uri, new String[] { ".json", ".xml" }))
/* */ {
/* 130 */ return true;
/* */ }
/* */
/* 133 */ String ajax = request.getParameter("__ajax");
/* 134 */ if (StringUtils.inStringIgnoreCase(ajax, new String[] { "json", "xml" }))
/* */ {
/* 136 */ return true;
/* */ }
/* 138 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static boolean checkAgentIsMobile(String ua) {
/* 146 */ boolean flag = false;
/* 147 */ if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;")))
/* */ {
/* */
/* 150 */ if (!ua.contains("Windows NT") && !ua.contains("Macintosh"))
/* */ {
/* 152 */ for (String item : agent) {
/* */
/* 154 */ if (ua.contains(item)) {
/* */
/* 156 */ flag = true;
/* */ break;
/* */ }
/* */ }
/* */ }
/* */ }
/* 162 */ return flag;
/* */ }
/* */ }
import com.archive.common.utils.StringUtils;
import com.archive.common.utils.text.Convert;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
public class ServletUtils
{
private static final String[] agent = new String[] { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
public static String getParameter(String name) {
return getRequest().getParameter(name);
}
public static String getParameter(String name, String defaultValue) {
return Convert.toStr(getRequest().getParameter(name), defaultValue);
}
public static Integer getParameterToInt(String name) {
return Convert.toInt(getRequest().getParameter(name));
}
public static Integer getParameterToInt(String name, Integer defaultValue) {
return Convert.toInt(getRequest().getParameter(name), defaultValue);
}
public static HttpServletRequest getRequest() {
return getRequestAttributes().getRequest();
}
public static HttpServletResponse getResponse() {
return getRequestAttributes().getResponse();
}
public static HttpSession getSession() {
return getRequest().getSession();
}
public static ServletRequestAttributes getRequestAttributes() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes)attributes;
}
public static String renderString(HttpServletResponse response, String string) {
try {
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().print(string);
}
catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static boolean isAjaxRequest(HttpServletRequest request) {
String accept = request.getHeader("accept");
if (accept != null && accept.indexOf("application/json") != -1)
{
return true;
}
String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
{
return true;
}
String uri = request.getRequestURI();
if (StringUtils.inStringIgnoreCase(uri, new String[] { ".json", ".xml" }))
{
return true;
}
String ajax = request.getParameter("__ajax");
if (StringUtils.inStringIgnoreCase(ajax, new String[] { "json", "xml" }))
{
return true;
}
return false;
}
public static boolean checkAgentIsMobile(String ua) {
boolean flag = false;
if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;")))
{
if (!ua.contains("Windows NT") && !ua.contains("Macintosh"))
{
for (String item : agent) {
if (ua.contains(item)) {
flag = true;
break;
}
}
}
}
return flag;
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\ServletUtils.class

@ -1,413 +1,413 @@
/* */ package com.archive.common.utils.reflect;
/* */
/* */ import com.archive.common.utils.DateUtils;
/* */ import com.archive.common.utils.text.Convert;
/* */ import java.lang.reflect.Field;
/* */ import java.lang.reflect.InvocationTargetException;
/* */ import java.lang.reflect.Method;
/* */ import java.lang.reflect.Modifier;
/* */ import java.lang.reflect.ParameterizedType;
/* */ import java.lang.reflect.Type;
/* */ import java.util.Date;
/* */ import org.apache.commons.lang3.StringUtils;
/* */ import org.apache.commons.lang3.Validate;
/* */ import org.apache.poi.ss.usermodel.DateUtil;
/* */ import org.slf4j.Logger;
/* */ import org.slf4j.LoggerFactory;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ReflectUtils
/* */ {
/* */ private static final String SETTER_PREFIX = "set";
/* */ private static final String GETTER_PREFIX = "get";
/* */ private static final String CGLIB_CLASS_SEPARATOR = "$$";
/* 32 */ private static Logger logger = LoggerFactory.getLogger(com.archive.common.utils.reflect.ReflectUtils.class);
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <E> E invokeGetter(Object obj, String propertyName) {
/* 41 */ Object object = obj;
/* 42 */ for (String name : StringUtils.split(propertyName, ".")) {
/* */
/* 44 */ String getterMethodName = "get" + StringUtils.capitalize(name);
/* 45 */ object = invokeMethod(object, getterMethodName, new Class[0], new Object[0]);
/* */ }
/* 47 */ return (E)object;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <E> void invokeSetter(Object obj, String propertyName, E value) {
/* 56 */ Object object = obj;
/* 57 */ String[] names = StringUtils.split(propertyName, ".");
/* 58 */ for (int i = 0; i < names.length; i++) {
/* */
/* 60 */ if (i < names.length - 1) {
/* */
/* 62 */ String getterMethodName = "get" + StringUtils.capitalize(names[i]);
/* 63 */ object = invokeMethod(object, getterMethodName, new Class[0], new Object[0]);
/* */ }
/* */ else {
/* */
/* 67 */ String setterMethodName = "set" + StringUtils.capitalize(names[i]);
/* 68 */ invokeMethodByName(object, setterMethodName, new Object[] { value });
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <E> E getFieldValue(Object obj, String fieldName) {
/* 79 */ Field field = getAccessibleField(obj, fieldName);
/* 80 */ if (field == null) {
/* */
/* 82 */ logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
/* 83 */ return null;
/* */ }
/* 85 */ E result = null;
/* */
/* */ try {
/* 88 */ result = (E)field.get(obj);
/* */ }
/* 90 */ catch (IllegalAccessException e) {
/* */
/* 92 */ logger.error("不可能抛出的异常{}", e.getMessage());
/* */ }
/* 94 */ return result;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static <E> void setFieldValue(Object obj, String fieldName, E value) {
/* 102 */ Field field = getAccessibleField(obj, fieldName);
/* 103 */ if (field == null) {
/* */
/* */
/* 106 */ logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
/* */
/* */ return;
/* */ }
/* */ try {
/* 111 */ field.set(obj, value);
/* */ }
/* 113 */ catch (IllegalAccessException e) {
/* */
/* 115 */ logger.error("不可能抛出的异常: {}", e.getMessage());
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <E> E invokeMethod(Object obj, String methodName, Class<?>[] parameterTypes, Object[] args) {
/* 128 */ if (obj == null || methodName == null)
/* */ {
/* 130 */ return null;
/* */ }
/* 132 */ Method method = getAccessibleMethod(obj, methodName, parameterTypes);
/* 133 */ if (method == null) {
/* */
/* 135 */ logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
/* 136 */ return null;
/* */ }
/* */
/* */ try {
/* 140 */ return (E)method.invoke(obj, args);
/* */ }
/* 142 */ catch (Exception e) {
/* */
/* 144 */ String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
/* 145 */ throw convertReflectionExceptionToUnchecked(msg, e);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <E> E invokeMethodByName(Object obj, String methodName, Object[] args) {
/* 157 */ Method method = getAccessibleMethodByName(obj, methodName, args.length);
/* 158 */ if (method == null) {
/* */
/* */
/* 161 */ logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
/* 162 */ return null;
/* */ }
/* */
/* */
/* */ try {
/* 167 */ Class<?>[] cs = method.getParameterTypes();
/* 168 */ for (int i = 0; i < cs.length; i++) {
/* */
/* 170 */ if (args[i] != null && !args[i].getClass().equals(cs[i]))
/* */ {
/* 172 */ if (cs[i] == String.class) {
/* */
/* 174 */ args[i] = Convert.toStr(args[i]);
/* 175 */ if (StringUtils.endsWith((String)args[i], ".0"))
/* */ {
/* 177 */ args[i] = StringUtils.substringBefore((String)args[i], ".0");
/* */ }
/* */ }
/* 180 */ else if (cs[i] == Integer.class) {
/* */
/* 182 */ args[i] = Convert.toInt(args[i]);
/* */ }
/* 184 */ else if (cs[i] == Long.class) {
/* */
/* 186 */ args[i] = Convert.toLong(args[i]);
/* */ }
/* 188 */ else if (cs[i] == Double.class) {
/* */
/* 190 */ args[i] = Convert.toDouble(args[i]);
/* */ }
/* 192 */ else if (cs[i] == Float.class) {
/* */
/* 194 */ args[i] = Convert.toFloat(args[i]);
/* */ }
/* 196 */ else if (cs[i] == Date.class) {
/* */
/* 198 */ if (args[i] instanceof String)
/* */ {
/* 200 */ args[i] = DateUtils.parseDate(args[i]);
/* */ }
/* */ else
/* */ {
/* 204 */ args[i] = DateUtil.getJavaDate(((Double)args[i]).doubleValue());
/* */ }
/* */
/* 207 */ } else if (cs[i] == boolean.class || cs[i] == Boolean.class) {
/* */
/* 209 */ args[i] = Convert.toBool(args[i]);
/* */ }
/* */ }
/* */ }
/* 213 */ return (E)method.invoke(obj, args);
/* */ }
/* 215 */ catch (Exception e) {
/* */
/* 217 */ String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
/* 218 */ throw convertReflectionExceptionToUnchecked(msg, e);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static Field getAccessibleField(Object obj, String fieldName) {
/* 229 */ if (obj == null)
/* */ {
/* 231 */ return null;
/* */ }
/* 233 */ Validate.notBlank(fieldName, "fieldName can't be blank", new Object[0]);
/* 234 */ for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
/* */
/* */
/* */ try {
/* 238 */ Field field = superClass.getDeclaredField(fieldName);
/* 239 */ makeAccessible(field);
/* 240 */ return field;
/* */ }
/* 242 */ catch (NoSuchFieldException e) {}
/* */ }
/* */
/* */
/* */
/* 247 */ return null;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static Method getAccessibleMethod(Object obj, String methodName, Class<?>... parameterTypes) {
/* 260 */ if (obj == null)
/* */ {
/* 262 */ return null;
/* */ }
/* 264 */ Validate.notBlank(methodName, "methodName can't be blank", new Object[0]);
/* 265 */ for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
/* */
/* */
/* */ try {
/* 269 */ Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
/* 270 */ makeAccessible(method);
/* 271 */ return method;
/* */ }
/* 273 */ catch (NoSuchMethodException e) {}
/* */ }
/* */
/* */
/* */
/* 278 */ return null;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static Method getAccessibleMethodByName(Object obj, String methodName, int argsNum) {
/* 290 */ if (obj == null)
/* */ {
/* 292 */ return null;
/* */ }
/* 294 */ Validate.notBlank(methodName, "methodName can't be blank", new Object[0]);
/* 295 */ for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
/* */
/* 297 */ Method[] methods = searchType.getDeclaredMethods();
/* 298 */ for (Method method : methods) {
/* */
/* 300 */ if (method.getName().equals(methodName) && (method.getParameterTypes()).length == argsNum) {
/* */
/* 302 */ makeAccessible(method);
/* 303 */ return method;
/* */ }
/* */ }
/* */ }
/* 307 */ return null;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static void makeAccessible(Method method) {
/* 315 */ if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) &&
/* 316 */ !method.isAccessible())
/* */ {
/* 318 */ method.setAccessible(true);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static void makeAccessible(Field field) {
/* 327 */ if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
/* 328 */ Modifier.isFinal(field.getModifiers())) && !field.isAccessible())
/* */ {
/* 330 */ field.setAccessible(true);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <T> Class<T> getClassGenricType(Class clazz) {
/* 341 */ return getClassGenricType(clazz, 0);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static Class getClassGenricType(Class clazz, int index) {
/* 350 */ Type genType = clazz.getGenericSuperclass();
/* */
/* 352 */ if (!(genType instanceof ParameterizedType)) {
/* */
/* 354 */ logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
/* 355 */ return Object.class;
/* */ }
/* */
/* 358 */ Type[] params = ((ParameterizedType)genType).getActualTypeArguments();
/* */
/* 360 */ if (index >= params.length || index < 0) {
/* */
/* 362 */ logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length);
/* */
/* 364 */ return Object.class;
/* */ }
/* 366 */ if (!(params[index] instanceof Class)) {
/* */
/* 368 */ logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
/* 369 */ return Object.class;
/* */ }
/* */
/* 372 */ return (Class)params[index];
/* */ }
/* */
/* */
/* */ public static Class<?> getUserClass(Object instance) {
/* 377 */ if (instance == null)
/* */ {
/* 379 */ throw new RuntimeException("Instance must not be null");
/* */ }
/* 381 */ Class<?> clazz = instance.getClass();
/* 382 */ if (clazz != null && clazz.getName().contains("$$")) {
/* */
/* 384 */ Class<?> superClass = clazz.getSuperclass();
/* 385 */ if (superClass != null && !Object.class.equals(superClass))
/* */ {
/* 387 */ return superClass;
/* */ }
/* */ }
/* 390 */ return clazz;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) {
/* 399 */ if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException || e instanceof NoSuchMethodException)
/* */ {
/* */
/* 402 */ return new IllegalArgumentException(msg, e);
/* */ }
/* 404 */ if (e instanceof InvocationTargetException)
/* */ {
/* 406 */ return new RuntimeException(msg, ((InvocationTargetException)e).getTargetException());
/* */ }
/* 408 */ return new RuntimeException(msg, e);
/* */ }
/* */ }
package com.archive.common.utils.reflect;
import com.archive.common.utils.DateUtils;
import com.archive.common.utils.text.Convert;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.poi.ss.usermodel.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReflectUtils
{
private static final String SETTER_PREFIX = "set";
private static final String GETTER_PREFIX = "get";
private static final String CGLIB_CLASS_SEPARATOR = "$$";
private static Logger logger = LoggerFactory.getLogger(com.archive.common.utils.reflect.ReflectUtils.class);
public static <E> E invokeGetter(Object obj, String propertyName) {
Object object = obj;
for (String name : StringUtils.split(propertyName, ".")) {
String getterMethodName = "get" + StringUtils.capitalize(name);
object = invokeMethod(object, getterMethodName, new Class[0], new Object[0]);
}
return (E)object;
}
public static <E> void invokeSetter(Object obj, String propertyName, E value) {
Object object = obj;
String[] names = StringUtils.split(propertyName, ".");
for (int i = 0; i < names.length; i++) {
if (i < names.length - 1) {
String getterMethodName = "get" + StringUtils.capitalize(names[i]);
object = invokeMethod(object, getterMethodName, new Class[0], new Object[0]);
}
else {
String setterMethodName = "set" + StringUtils.capitalize(names[i]);
invokeMethodByName(object, setterMethodName, new Object[] { value });
}
}
}
public static <E> E getFieldValue(Object obj, String fieldName) {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
return null;
}
E result = null;
try {
result = (E)field.get(obj);
}
catch (IllegalAccessException e) {
logger.error("不可能抛出的异常{}", e.getMessage());
}
return result;
}
public static <E> void setFieldValue(Object obj, String fieldName, E value) {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
return;
}
try {
field.set(obj, value);
}
catch (IllegalAccessException e) {
logger.error("不可能抛出的异常: {}", e.getMessage());
}
}
public static <E> E invokeMethod(Object obj, String methodName, Class<?>[] parameterTypes, Object[] args) {
if (obj == null || methodName == null)
{
return null;
}
Method method = getAccessibleMethod(obj, methodName, parameterTypes);
if (method == null) {
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
return null;
}
try {
return (E)method.invoke(obj, args);
}
catch (Exception e) {
String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
throw convertReflectionExceptionToUnchecked(msg, e);
}
}
public static <E> E invokeMethodByName(Object obj, String methodName, Object[] args) {
Method method = getAccessibleMethodByName(obj, methodName, args.length);
if (method == null) {
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
return null;
}
try {
Class<?>[] cs = method.getParameterTypes();
for (int i = 0; i < cs.length; i++) {
if (args[i] != null && !args[i].getClass().equals(cs[i]))
{
if (cs[i] == String.class) {
args[i] = Convert.toStr(args[i]);
if (StringUtils.endsWith((String)args[i], ".0"))
{
args[i] = StringUtils.substringBefore((String)args[i], ".0");
}
}
else if (cs[i] == Integer.class) {
args[i] = Convert.toInt(args[i]);
}
else if (cs[i] == Long.class) {
args[i] = Convert.toLong(args[i]);
}
else if (cs[i] == Double.class) {
args[i] = Convert.toDouble(args[i]);
}
else if (cs[i] == Float.class) {
args[i] = Convert.toFloat(args[i]);
}
else if (cs[i] == Date.class) {
if (args[i] instanceof String)
{
args[i] = DateUtils.parseDate(args[i]);
}
else
{
args[i] = DateUtil.getJavaDate(((Double)args[i]).doubleValue());
}
} else if (cs[i] == boolean.class || cs[i] == Boolean.class) {
args[i] = Convert.toBool(args[i]);
}
}
}
return (E)method.invoke(obj, args);
}
catch (Exception e) {
String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
throw convertReflectionExceptionToUnchecked(msg, e);
}
}
public static Field getAccessibleField(Object obj, String fieldName) {
if (obj == null)
{
return null;
}
Validate.notBlank(fieldName, "fieldName can't be blank", new Object[0]);
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
try {
Field field = superClass.getDeclaredField(fieldName);
makeAccessible(field);
return field;
}
catch (NoSuchFieldException e) {}
}
return null;
}
public static Method getAccessibleMethod(Object obj, String methodName, Class<?>... parameterTypes) {
if (obj == null)
{
return null;
}
Validate.notBlank(methodName, "methodName can't be blank", new Object[0]);
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
try {
Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
makeAccessible(method);
return method;
}
catch (NoSuchMethodException e) {}
}
return null;
}
public static Method getAccessibleMethodByName(Object obj, String methodName, int argsNum) {
if (obj == null)
{
return null;
}
Validate.notBlank(methodName, "methodName can't be blank", new Object[0]);
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
Method[] methods = searchType.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(methodName) && (method.getParameterTypes()).length == argsNum) {
makeAccessible(method);
return method;
}
}
}
return null;
}
public static void makeAccessible(Method method) {
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) &&
!method.isAccessible())
{
method.setAccessible(true);
}
}
public static void makeAccessible(Field field) {
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) ||
Modifier.isFinal(field.getModifiers())) && !field.isAccessible())
{
field.setAccessible(true);
}
}
public static <T> Class<T> getClassGenricType(Class clazz) {
return getClassGenricType(clazz, 0);
}
public static Class getClassGenricType(Class clazz, int index) {
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
return Object.class;
}
Type[] params = ((ParameterizedType)genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length);
return Object.class;
}
if (!(params[index] instanceof Class)) {
logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
return Object.class;
}
return (Class)params[index];
}
public static Class<?> getUserClass(Object instance) {
if (instance == null)
{
throw new RuntimeException("Instance must not be null");
}
Class<?> clazz = instance.getClass();
if (clazz != null && clazz.getName().contains("$$")) {
Class<?> superClass = clazz.getSuperclass();
if (superClass != null && !Object.class.equals(superClass))
{
return superClass;
}
}
return clazz;
}
public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) {
if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException || e instanceof NoSuchMethodException)
{
return new IllegalArgumentException(msg, e);
}
if (e instanceof InvocationTargetException)
{
return new RuntimeException(msg, ((InvocationTargetException)e).getTargetException());
}
return new RuntimeException(msg, e);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\reflect\ReflectUtils.class

@ -1,78 +1,78 @@
/* */ package com.archive.common.utils.security;
/* */
/* */ import com.archive.common.utils.StringUtils;
/* */ import com.archive.common.utils.bean.BeanUtils;
/* */ import com.archive.project.system.user.domain.User;
/* */ import org.apache.shiro.SecurityUtils;
/* */ import org.apache.shiro.session.Session;
/* */ import org.apache.shiro.subject.PrincipalCollection;
/* */ import org.apache.shiro.subject.SimplePrincipalCollection;
/* */ import org.apache.shiro.subject.Subject;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ShiroUtils
/* */ {
/* */ public static Subject getSubject() {
/* 21 */ return SecurityUtils.getSubject();
/* */ }
/* */
/* */
/* */ public static Session getSession() {
/* 26 */ return SecurityUtils.getSubject().getSession();
/* */ }
/* */
/* */
/* */ public static void logout() {
/* 31 */ getSubject().logout();
/* */ }
/* */
/* */
/* */ public static User getSysUser() {
/* 36 */ User user = null;
/* 37 */ Object obj = getSubject().getPrincipal();
/* 38 */ if (StringUtils.isNotNull(obj)) {
/* */
/* 40 */ user = new User();
/* 41 */ BeanUtils.copyBeanProp(user, obj);
/* */ }
/* 43 */ return user;
/* */ }
/* */
/* */
/* */ public static void setSysUser(User user) {
/* 48 */ Subject subject = getSubject();
/* 49 */ PrincipalCollection principalCollection = subject.getPrincipals();
/* 50 */ String realmName = principalCollection.getRealmNames().iterator().next();
/* 51 */ SimplePrincipalCollection simplePrincipalCollection = new SimplePrincipalCollection(user, realmName);
/* */
/* 53 */ subject.runAs((PrincipalCollection)simplePrincipalCollection);
/* */ }
/* */
/* */
/* */ public static Long getUserId() {
/* 58 */ return Long.valueOf(getSysUser().getUserId().longValue());
/* */ }
/* */
/* */
/* */ public static String getLoginName() {
/* 63 */ return getSysUser().getLoginName();
/* */ }
/* */
/* */
/* */ public static String getIp() {
/* 68 */ return getSubject().getSession().getHost();
/* */ }
/* */
/* */
/* */ public static String getSessionId() {
/* 73 */ return String.valueOf(getSubject().getSession().getId());
/* */ }
/* */ }
package com.archive.common.utils.security;
import com.archive.common.utils.StringUtils;
import com.archive.common.utils.bean.BeanUtils;
import com.archive.project.system.user.domain.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
public class ShiroUtils
{
public static Subject getSubject() {
return SecurityUtils.getSubject();
}
public static Session getSession() {
return SecurityUtils.getSubject().getSession();
}
public static void logout() {
getSubject().logout();
}
public static User getSysUser() {
User user = null;
Object obj = getSubject().getPrincipal();
if (StringUtils.isNotNull(obj)) {
user = new User();
BeanUtils.copyBeanProp(user, obj);
}
return user;
}
public static void setSysUser(User user) {
Subject subject = getSubject();
PrincipalCollection principalCollection = subject.getPrincipals();
String realmName = principalCollection.getRealmNames().iterator().next();
SimplePrincipalCollection simplePrincipalCollection = new SimplePrincipalCollection(user, realmName);
subject.runAs((PrincipalCollection)simplePrincipalCollection);
}
public static Long getUserId() {
return Long.valueOf(getSysUser().getUserId().longValue());
}
public static String getLoginName() {
return getSysUser().getLoginName();
}
public static String getIp() {
return getSubject().getSession().getHost();
}
public static String getSessionId() {
return String.valueOf(getSubject().getSession().getId());
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\security\ShiroUtils.class

@ -1,149 +1,149 @@
/* */ package com.archive.common.utils.spring;
/* */
/* */ import com.archive.common.utils.StringUtils;
/* */ import org.springframework.aop.framework.AopContext;
/* */ import org.springframework.beans.BeansException;
/* */ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
/* */ import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
/* */ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
/* */ import org.springframework.context.ApplicationContext;
/* */ import org.springframework.context.ApplicationContextAware;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public final class SpringUtils
/* */ implements BeanFactoryPostProcessor, ApplicationContextAware
/* */ {
/* */ private static ConfigurableListableBeanFactory beanFactory;
/* */ private static ApplicationContext applicationContext;
/* */
/* */ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
/* 29 */ com.archive.common.utils.spring.SpringUtils.beanFactory = beanFactory;
/* */ }
/* */
/* */
/* */
/* */ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
/* 35 */ com.archive.common.utils.spring.SpringUtils.applicationContext = applicationContext;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <T> T getBean(String name) throws BeansException {
/* 49 */ return (T)beanFactory.getBean(name);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <T> T getBean(Class<T> clz) throws BeansException {
/* 62 */ T result = (T)beanFactory.getBean(clz);
/* 63 */ return result;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static boolean containsBean(String name) {
/* 74 */ return beanFactory.containsBean(name);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
/* 87 */ return beanFactory.isSingleton(name);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
/* 98 */ return beanFactory.getType(name);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
/* 111 */ return beanFactory.getAliases(name);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static <T> T getAopProxy(T invoker) {
/* 123 */ return (T)AopContext.currentProxy();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static String[] getActiveProfiles() {
/* 133 */ return applicationContext.getEnvironment().getActiveProfiles();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static String getActiveProfile() {
/* 143 */ String[] activeProfiles = getActiveProfiles();
/* 144 */ return StringUtils.isNotEmpty((Object[])activeProfiles) ? activeProfiles[0] : null;
/* */ }
/* */ }
package com.archive.common.utils.spring;
import com.archive.common.utils.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public final class SpringUtils
implements BeanFactoryPostProcessor, ApplicationContextAware
{
private static ConfigurableListableBeanFactory beanFactory;
private static ApplicationContext applicationContext;
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
com.archive.common.utils.spring.SpringUtils.beanFactory = beanFactory;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
com.archive.common.utils.spring.SpringUtils.applicationContext = applicationContext;
}
public static <T> T getBean(String name) throws BeansException {
return (T)beanFactory.getBean(name);
}
public static <T> T getBean(Class<T> clz) throws BeansException {
T result = (T)beanFactory.getBean(clz);
return result;
}
public static boolean containsBean(String name) {
return beanFactory.containsBean(name);
}
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return beanFactory.isSingleton(name);
}
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
return beanFactory.getType(name);
}
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
return beanFactory.getAliases(name);
}
public static <T> T getAopProxy(T invoker) {
return (T)AopContext.currentProxy();
}
public static String[] getActiveProfiles() {
return applicationContext.getEnvironment().getActiveProfiles();
}
public static String getActiveProfile() {
String[] activeProfiles = getActiveProfiles();
return StringUtils.isNotEmpty((Object[])activeProfiles) ? activeProfiles[0] : null;
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\spring\SpringUtils.class

@ -1,40 +1,40 @@
/* */ package com.archive.common.utils.sql;
/* */
/* */ import com.archive.common.exception.base.BaseException;
/* */ import com.archive.common.utils.StringUtils;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class SqlUtil
/* */ {
/* 16 */ public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
/* */
/* */
/* */
/* */
/* */
/* */ public static String escapeOrderBySql(String value) {
/* 23 */ if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
/* */ {
/* 25 */ throw new BaseException("参数不符合规范,不能进行查询");
/* */ }
/* 27 */ return value;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static boolean isValidOrderBySql(String value) {
/* 35 */ return value.matches(SQL_PATTERN);
/* */ }
/* */ }
package com.archive.common.utils.sql;
import com.archive.common.exception.base.BaseException;
import com.archive.common.utils.StringUtils;
public class SqlUtil
{
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
public static String escapeOrderBySql(String value) {
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
{
throw new BaseException("参数不符合规范,不能进行查询");
}
return value;
}
public static boolean isValidOrderBySql(String value) {
return value.matches(SQL_PATTERN);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\commo\\utils\sql\SqlUtil.class

@ -1,63 +1,63 @@
/* */ package com.archive.framework.config
package com.archive.framework.config
;
/* */
/* */ import com.archive.framework.config.ArchiveConfig;
/* */ import com.archive.framework.interceptor.RepeatSubmitInterceptor;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.beans.factory.annotation.Value;
/* */ import org.springframework.context.annotation.Configuration;
/* */ import org.springframework.web.servlet.HandlerInterceptor;
/* */ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
/* */ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
/* */ import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
/* */ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Configuration
/* */ public class ResourcesConfig
/* */ implements WebMvcConfigurer
/* */ {
/* */ @Value("${shiro.user.indexUrl}")
/* */ private String indexUrl;
/* */ @Autowired
/* */ private RepeatSubmitInterceptor repeatSubmitInterceptor;
/* */
/* */ public void addViewControllers(ViewControllerRegistry registry) {
/* 36 */ registry.addViewController("/").setViewName("forward:" + this.indexUrl);
/* */ }
/* */
/* */
/* */
/* */
/* */ public void addResourceHandlers(ResourceHandlerRegistry registry) {
/* 43 */ registry.addResourceHandler(new String[] { "/profile/**" }).addResourceLocations(new String[] { "file:" + ArchiveConfig.getInstance().getProfile() + "/" });
/* */
/* */
/* 46 */ registry.addResourceHandler(new String[] { "swagger-ui.html" }).addResourceLocations(new String[] { "classpath:/META-INF/resources/" });
/* 47 */ registry.addResourceHandler(new String[] { "/webjars/**" }).addResourceLocations(new String[] { "classpath:/META-INF/resources/webjars/" });
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void addInterceptors(InterceptorRegistry registry) {
/* 56 */ registry.addInterceptor((HandlerInterceptor)this.repeatSubmitInterceptor).addPathPatterns(new String[] { "/**" });
/* */ }
/* */ }
import com.archive.framework.config.ArchiveConfig;
import com.archive.framework.interceptor.RepeatSubmitInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class ResourcesConfig
implements WebMvcConfigurer
{
@Value("${shiro.user.indexUrl}")
private String indexUrl;
@Autowired
private RepeatSubmitInterceptor repeatSubmitInterceptor;
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("forward:" + this.indexUrl);
}
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler(new String[] { "/profile/**" }).addResourceLocations(new String[] { "file:" + ArchiveConfig.getInstance().getProfile() + "/" });
registry.addResourceHandler(new String[] { "swagger-ui.html" }).addResourceLocations(new String[] { "classpath:/META-INF/resources/" });
registry.addResourceHandler(new String[] { "/webjars/**" }).addResourceLocations(new String[] { "classpath:/META-INF/resources/webjars/" });
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor((HandlerInterceptor)this.repeatSubmitInterceptor).addPathPatterns(new String[] { "/**" });
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\ResourcesConfig.class

@ -1,38 +1,38 @@
/* */ package com.archive.framework.config
package com.archive.framework.config
;
/* */
/* */ import com.archive.common.utils.ServletUtils;
/* */ import javax.servlet.http.HttpServletRequest;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public class ServerConfig
/* */ {
/* */ public String getUrl() {
/* 23 */ HttpServletRequest request = ServletUtils.getRequest();
/* 24 */ return getDomain(request);
/* */ }
/* */
/* */
/* */ public static String getDomain(HttpServletRequest request) {
/* 29 */ StringBuffer url = request.getRequestURL();
/* 30 */ String contextPath = request.getServletContext().getContextPath();
/* 31 */ return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
/* */ }
/* */ }
import com.archive.common.utils.ServletUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component;
@Component
public class ServerConfig
{
public String getUrl() {
HttpServletRequest request = ServletUtils.getRequest();
return getDomain(request);
}
public static String getDomain(HttpServletRequest request) {
StringBuffer url = request.getRequestURL();
String contextPath = request.getServletContext().getContextPath();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\ServerConfig.class

@ -1,381 +1,381 @@
/* */ package com.archive.framework.config
package com.archive.framework.config
;
/* */
/* */ import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
/* */ import com.archive.common.utils.StringUtils;
/* */ import com.archive.common.utils.spring.SpringUtils;
/* */ import com.archive.framework.shiro.realm.UserRealm;
/* */ import com.archive.framework.shiro.session.OnlineSessionDAO;
/* */ import com.archive.framework.shiro.session.OnlineSessionFactory;
/* */ import com.archive.framework.shiro.web.filter.LogoutFilter;
/* */ import com.archive.framework.shiro.web.filter.captcha.CaptchaValidateFilter;
/* */ import com.archive.framework.shiro.web.filter.kickout.KickoutSessionFilter;
/* */ import com.archive.framework.shiro.web.filter.online.OnlineSessionFilter;
/* */ import com.archive.framework.shiro.web.filter.sync.SyncOnlineSessionFilter;
/* */ import com.archive.framework.shiro.web.session.OnlineWebSessionManager;
/* */ import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler;
/* */ import java.io.ByteArrayInputStream;
/* */ import java.io.IOException;
/* */ import java.io.InputStream;
/* */ import java.util.LinkedHashMap;
/* */ import java.util.Map;
/* */ import javax.servlet.Filter;
/* */ import net.sf.ehcache.CacheManager;
/* */ import org.apache.commons.io.IOUtils;
/* */
/* */ import org.apache.shiro.cache.ehcache.EhCacheManager;
/* */ import org.apache.shiro.codec.Base64;
/* */ import org.apache.shiro.config.ConfigurationException;
/* */ import org.apache.shiro.io.ResourceUtils;
/* */ import org.apache.shiro.mgt.RememberMeManager;
/* */ import org.apache.shiro.mgt.SecurityManager;
/* */ import org.apache.shiro.realm.Realm;
/* */ import org.apache.shiro.session.mgt.SessionFactory;
/* */ import org.apache.shiro.session.mgt.SessionManager;
/* */ import org.apache.shiro.session.mgt.SessionValidationScheduler;
/* */ import org.apache.shiro.session.mgt.eis.SessionDAO;
/* */ import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
/* */ import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
/* */ import org.apache.shiro.web.mgt.CookieRememberMeManager;
/* */ import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
/* */ import org.apache.shiro.web.servlet.Cookie;
/* */ import org.apache.shiro.web.servlet.SimpleCookie;
/* */ import org.springframework.beans.factory.annotation.Qualifier;
/* */ import org.springframework.beans.factory.annotation.Value;
/* */ import org.springframework.context.annotation.Bean;
/* */ import org.springframework.context.annotation.Configuration;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Configuration
/* */ public class ShiroConfig
/* */ {
/* */ @Value("${shiro.session.expireTime}")
/* */ private int expireTime;
/* */ @Value("${shiro.session.validationInterval}")
/* */ private int validationInterval;
/* */ @Value("${shiro.session.maxSession}")
/* */ private int maxSession;
/* */ @Value("${shiro.session.kickoutAfter}")
/* */ private boolean kickoutAfter;
/* */ @Value("${shiro.user.captchaEnabled}")
/* */ private boolean captchaEnabled;
/* */ @Value("${shiro.user.captchaType}")
/* */ private String captchaType;
/* */ @Value("${shiro.cookie.domain}")
/* */ private String domain;
/* */ @Value("${shiro.cookie.path}")
/* */ private String path;
/* */ @Value("${shiro.cookie.httpOnly}")
/* */ private boolean httpOnly;
/* */ @Value("${shiro.cookie.maxAge}")
/* */ private int maxAge;
/* */ @Value("${shiro.cookie.cipherKey}")
/* */ private String cipherKey;
/* */ @Value("${shiro.user.loginUrl}")
/* */ private String loginUrl;
/* */ @Value("${shiro.user.unauthorizedUrl}")
/* */ private String unauthorizedUrl;
/* */
/* */ @Bean
/* */ public EhCacheManager getEhCacheManager() {
/* 105 */ CacheManager cacheManager = CacheManager.getCacheManager("archive");
/* 106 */ EhCacheManager em = new EhCacheManager();
/* 107 */ if (StringUtils.isNull(cacheManager)) {
/* */
/* 109 */ em.setCacheManager(new CacheManager(getCacheManagerConfigFileInputStream()));
/* 110 */ return em;
/* */ }
/* */
/* */
/* 114 */ em.setCacheManager(cacheManager);
/* 115 */ return em;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ protected InputStream getCacheManagerConfigFileInputStream() {
/* 124 */ String configFile = "classpath:ehcache/ehcache-shiro.xml";
/* 125 */ InputStream inputStream = null;
/* */
/* */ try {
/* 128 */ inputStream = ResourceUtils.getInputStreamForPath(configFile);
/* 129 */ byte[] b = IOUtils.toByteArray(inputStream);
/* 130 */ InputStream in = new ByteArrayInputStream(b);
/* 131 */ return in;
/* */ }
/* 133 */ catch (IOException e) {
/* */
/* 135 */ throw new ConfigurationException("Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e);
/* */
/* */ }
/* */ finally {
/* */
/* 140 */ IOUtils.closeQuietly(inputStream);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public UserRealm userRealm(EhCacheManager cacheManager) {
/* 150 */ UserRealm userRealm = new UserRealm();
/* 151 */ userRealm.setAuthorizationCacheName("sys-authCache");
/* 152 */ userRealm.setCacheManager(cacheManager);
/* 153 */ return userRealm;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public OnlineSessionDAO sessionDAO() {
/* 162 */ OnlineSessionDAO sessionDAO = new OnlineSessionDAO();
/* 163 */ return sessionDAO;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public OnlineSessionFactory sessionFactory() {
/* 172 */ OnlineSessionFactory sessionFactory = new OnlineSessionFactory();
/* 173 */ return sessionFactory;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public OnlineWebSessionManager sessionManager() {
/* 182 */ OnlineWebSessionManager manager = new OnlineWebSessionManager();
/* */
/* 184 */ manager.setCacheManager(getEhCacheManager());
/* */
/* 186 */ manager.setDeleteInvalidSessions(true);
/* */
/* 188 */ manager.setGlobalSessionTimeout((this.expireTime * 60 * 1000));
/* */
/* 190 */ manager.setSessionIdUrlRewritingEnabled(false);
/* */
/* 192 */ manager.setSessionValidationScheduler((SessionValidationScheduler)SpringUtils.getBean(SpringSessionValidationScheduler.class));
/* */
/* 194 */ manager.setSessionValidationSchedulerEnabled(true);
/* */
/* 196 */ manager.setSessionDAO((SessionDAO)sessionDAO());
/* */
/* 198 */ manager.setSessionFactory((SessionFactory)sessionFactory());
/* 199 */ return manager;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public SecurityManager securityManager(UserRealm userRealm) {
/* 208 */ DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
/* */
/* 210 */ securityManager.setRealm((Realm)userRealm);
/* */
/* 212 */ securityManager.setRememberMeManager((RememberMeManager)rememberMeManager());
/* */
/* 214 */ securityManager.setCacheManager(getEhCacheManager());
/* */
/* 216 */ securityManager.setSessionManager((SessionManager)sessionManager());
/* 217 */ return (SecurityManager)securityManager;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public LogoutFilter logoutFilter() {
/* 225 */ LogoutFilter logoutFilter = new LogoutFilter();
/* 226 */ logoutFilter.setLoginUrl(this.loginUrl);
/* 227 */ return logoutFilter;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
/* 236 */ ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
/* */
/* 238 */ shiroFilterFactoryBean.setSecurityManager(securityManager);
/* */
/* 240 */ shiroFilterFactoryBean.setLoginUrl(this.loginUrl);
/* */
/* 242 */ shiroFilterFactoryBean.setUnauthorizedUrl(this.unauthorizedUrl);
/* */
/* 244 */ LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
/* */
/* 246 */ filterChainDefinitionMap.put("/favicon.ico**", "anon");
/* 247 */ filterChainDefinitionMap.put("/archive.png**", "anon");
/* 248 */ filterChainDefinitionMap.put("/css/**", "anon");
/* 249 */ filterChainDefinitionMap.put("/docs/**", "anon");
/* 250 */ filterChainDefinitionMap.put("/fonts/**", "anon");
/* 251 */ filterChainDefinitionMap.put("/img/**", "anon");
/* 252 */ filterChainDefinitionMap.put("/ajax/**", "anon");
/* 253 */ filterChainDefinitionMap.put("/plugins/**", "anon");
/* 254 */ filterChainDefinitionMap.put("/js/**", "anon");
/* 255 */ filterChainDefinitionMap.put("/archive/**", "anon");
/* 256 */ filterChainDefinitionMap.put("/captcha/captchaImage**", "anon");
/* */
/* 258 */ filterChainDefinitionMap.put("/logout", "logout");
/* */
/* 260 */ filterChainDefinitionMap.put("/login", "anon,captchaValidate");
/* 261 */ filterChainDefinitionMap.put("/browse/browseDocument", "anon,captchaValidate");
/* */
/* 263 */ filterChainDefinitionMap.put("/register", "anon,captchaValidate");
/* */
/* */
/* */
/* 267 */ Map<String, Filter> filters = new LinkedHashMap<>();
/* 268 */ filters.put("onlineSession", onlineSessionFilter());
/* 269 */ filters.put("syncOnlineSession", syncOnlineSessionFilter());
/* 270 */ filters.put("captchaValidate", captchaValidateFilter());
/* 271 */ filters.put("kickout", kickoutSessionFilter());
/* */
/* 273 */ filters.put("logout", logoutFilter());
/* 274 */ shiroFilterFactoryBean.setFilters(filters);
/* */
/* */
/* 277 */ filterChainDefinitionMap.put("/**", "user,kickout,onlineSession,syncOnlineSession");
/* 278 */ shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
/* */
/* 280 */ return shiroFilterFactoryBean;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public OnlineSessionFilter onlineSessionFilter() {
/* 288 */ OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter();
/* 289 */ onlineSessionFilter.setLoginUrl(this.loginUrl);
/* 290 */ onlineSessionFilter.setOnlineSessionDAO(sessionDAO());
/* 291 */ return onlineSessionFilter;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public SyncOnlineSessionFilter syncOnlineSessionFilter() {
/* 299 */ SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter();
/* 300 */ syncOnlineSessionFilter.setOnlineSessionDAO(sessionDAO());
/* 301 */ return syncOnlineSessionFilter;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public CaptchaValidateFilter captchaValidateFilter() {
/* 309 */ CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter();
/* 310 */ captchaValidateFilter.setCaptchaEnabled(this.captchaEnabled);
/* 311 */ captchaValidateFilter.setCaptchaType(this.captchaType);
/* 312 */ return captchaValidateFilter;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public SimpleCookie rememberMeCookie() {
/* 320 */ SimpleCookie cookie = new SimpleCookie("rememberMe");
/* 321 */ cookie.setDomain(this.domain);
/* 322 */ cookie.setPath(this.path);
/* 323 */ cookie.setHttpOnly(this.httpOnly);
/* 324 */ cookie.setMaxAge(this.maxAge * 24 * 60 * 60);
/* 325 */ return cookie;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public CookieRememberMeManager rememberMeManager() {
/* 333 */ CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
/* 334 */ cookieRememberMeManager.setCookie((Cookie)rememberMeCookie());
/* 335 */ cookieRememberMeManager.setCipherKey(Base64.decode(this.cipherKey));
/* 336 */ return cookieRememberMeManager;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public KickoutSessionFilter kickoutSessionFilter() {
/* 344 */ KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter();
/* 345 */ kickoutSessionFilter.setCacheManager(getEhCacheManager());
/* 346 */ kickoutSessionFilter.setSessionManager((SessionManager)sessionManager());
/* */
/* 348 */ kickoutSessionFilter.setMaxSession(this.maxSession);
/* */
/* 350 */ kickoutSessionFilter.setKickoutAfter(this.kickoutAfter);
/* */
/* 352 */ kickoutSessionFilter.setKickoutUrl("/login?kickout=1");
/* 353 */ return kickoutSessionFilter;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public ShiroDialect shiroDialect() {
/* 362 */ return new ShiroDialect();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Bean
/* */ public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(@Qualifier("securityManager") SecurityManager securityManager) {
/* 372 */ AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
/* 373 */ authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
/* 374 */ return authorizationAttributeSourceAdvisor;
/* */ }
/* */ }
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
import com.archive.common.utils.StringUtils;
import com.archive.common.utils.spring.SpringUtils;
import com.archive.framework.shiro.realm.UserRealm;
import com.archive.framework.shiro.session.OnlineSessionDAO;
import com.archive.framework.shiro.session.OnlineSessionFactory;
import com.archive.framework.shiro.web.filter.LogoutFilter;
import com.archive.framework.shiro.web.filter.captcha.CaptchaValidateFilter;
import com.archive.framework.shiro.web.filter.kickout.KickoutSessionFilter;
import com.archive.framework.shiro.web.filter.online.OnlineSessionFilter;
import com.archive.framework.shiro.web.filter.sync.SyncOnlineSessionFilter;
import com.archive.framework.shiro.web.session.OnlineWebSessionManager;
import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.Filter;
import net.sf.ehcache.CacheManager;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.config.ConfigurationException;
import org.apache.shiro.io.ResourceUtils;
import org.apache.shiro.mgt.RememberMeManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.session.mgt.SessionFactory;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.session.mgt.SessionValidationScheduler;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.CookieRememberMeManager;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.servlet.Cookie;
import org.apache.shiro.web.servlet.SimpleCookie;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ShiroConfig
{
@Value("${shiro.session.expireTime}")
private int expireTime;
@Value("${shiro.session.validationInterval}")
private int validationInterval;
@Value("${shiro.session.maxSession}")
private int maxSession;
@Value("${shiro.session.kickoutAfter}")
private boolean kickoutAfter;
@Value("${shiro.user.captchaEnabled}")
private boolean captchaEnabled;
@Value("${shiro.user.captchaType}")
private String captchaType;
@Value("${shiro.cookie.domain}")
private String domain;
@Value("${shiro.cookie.path}")
private String path;
@Value("${shiro.cookie.httpOnly}")
private boolean httpOnly;
@Value("${shiro.cookie.maxAge}")
private int maxAge;
@Value("${shiro.cookie.cipherKey}")
private String cipherKey;
@Value("${shiro.user.loginUrl}")
private String loginUrl;
@Value("${shiro.user.unauthorizedUrl}")
private String unauthorizedUrl;
@Bean
public EhCacheManager getEhCacheManager() {
CacheManager cacheManager = CacheManager.getCacheManager("archive");
EhCacheManager em = new EhCacheManager();
if (StringUtils.isNull(cacheManager)) {
em.setCacheManager(new CacheManager(getCacheManagerConfigFileInputStream()));
return em;
}
em.setCacheManager(cacheManager);
return em;
}
protected InputStream getCacheManagerConfigFileInputStream() {
String configFile = "classpath:ehcache/ehcache-shiro.xml";
InputStream inputStream = null;
try {
inputStream = ResourceUtils.getInputStreamForPath(configFile);
byte[] b = IOUtils.toByteArray(inputStream);
InputStream in = new ByteArrayInputStream(b);
return in;
}
catch (IOException e) {
throw new ConfigurationException("Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e);
}
finally {
IOUtils.closeQuietly(inputStream);
}
}
@Bean
public UserRealm userRealm(EhCacheManager cacheManager) {
UserRealm userRealm = new UserRealm();
userRealm.setAuthorizationCacheName("sys-authCache");
userRealm.setCacheManager(cacheManager);
return userRealm;
}
@Bean
public OnlineSessionDAO sessionDAO() {
OnlineSessionDAO sessionDAO = new OnlineSessionDAO();
return sessionDAO;
}
@Bean
public OnlineSessionFactory sessionFactory() {
OnlineSessionFactory sessionFactory = new OnlineSessionFactory();
return sessionFactory;
}
@Bean
public OnlineWebSessionManager sessionManager() {
OnlineWebSessionManager manager = new OnlineWebSessionManager();
manager.setCacheManager(getEhCacheManager());
manager.setDeleteInvalidSessions(true);
manager.setGlobalSessionTimeout((this.expireTime * 60 * 1000));
manager.setSessionIdUrlRewritingEnabled(false);
manager.setSessionValidationScheduler((SessionValidationScheduler)SpringUtils.getBean(SpringSessionValidationScheduler.class));
manager.setSessionValidationSchedulerEnabled(true);
manager.setSessionDAO((SessionDAO)sessionDAO());
manager.setSessionFactory((SessionFactory)sessionFactory());
return manager;
}
@Bean
public SecurityManager securityManager(UserRealm userRealm) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm((Realm)userRealm);
securityManager.setRememberMeManager((RememberMeManager)rememberMeManager());
securityManager.setCacheManager(getEhCacheManager());
securityManager.setSessionManager((SessionManager)sessionManager());
return (SecurityManager)securityManager;
}
public LogoutFilter logoutFilter() {
LogoutFilter logoutFilter = new LogoutFilter();
logoutFilter.setLoginUrl(this.loginUrl);
return logoutFilter;
}
@Bean
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(securityManager);
shiroFilterFactoryBean.setLoginUrl(this.loginUrl);
shiroFilterFactoryBean.setUnauthorizedUrl(this.unauthorizedUrl);
LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put("/favicon.ico**", "anon");
filterChainDefinitionMap.put("/archive.png**", "anon");
filterChainDefinitionMap.put("/css/**", "anon");
filterChainDefinitionMap.put("/docs/**", "anon");
filterChainDefinitionMap.put("/fonts/**", "anon");
filterChainDefinitionMap.put("/img/**", "anon");
filterChainDefinitionMap.put("/ajax/**", "anon");
filterChainDefinitionMap.put("/plugins/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/archive/**", "anon");
filterChainDefinitionMap.put("/captcha/captchaImage**", "anon");
filterChainDefinitionMap.put("/logout", "logout");
filterChainDefinitionMap.put("/login", "anon,captchaValidate");
filterChainDefinitionMap.put("/browse/browseDocument", "anon,captchaValidate");
filterChainDefinitionMap.put("/register", "anon,captchaValidate");
Map<String, Filter> filters = new LinkedHashMap<>();
filters.put("onlineSession", onlineSessionFilter());
filters.put("syncOnlineSession", syncOnlineSessionFilter());
filters.put("captchaValidate", captchaValidateFilter());
filters.put("kickout", kickoutSessionFilter());
filters.put("logout", logoutFilter());
shiroFilterFactoryBean.setFilters(filters);
filterChainDefinitionMap.put("/**", "user,kickout,onlineSession,syncOnlineSession");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
public OnlineSessionFilter onlineSessionFilter() {
OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter();
onlineSessionFilter.setLoginUrl(this.loginUrl);
onlineSessionFilter.setOnlineSessionDAO(sessionDAO());
return onlineSessionFilter;
}
public SyncOnlineSessionFilter syncOnlineSessionFilter() {
SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter();
syncOnlineSessionFilter.setOnlineSessionDAO(sessionDAO());
return syncOnlineSessionFilter;
}
public CaptchaValidateFilter captchaValidateFilter() {
CaptchaValidateFilter captchaValidateFilter = new CaptchaValidateFilter();
captchaValidateFilter.setCaptchaEnabled(this.captchaEnabled);
captchaValidateFilter.setCaptchaType(this.captchaType);
return captchaValidateFilter;
}
public SimpleCookie rememberMeCookie() {
SimpleCookie cookie = new SimpleCookie("rememberMe");
cookie.setDomain(this.domain);
cookie.setPath(this.path);
cookie.setHttpOnly(this.httpOnly);
cookie.setMaxAge(this.maxAge * 24 * 60 * 60);
return cookie;
}
public CookieRememberMeManager rememberMeManager() {
CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
cookieRememberMeManager.setCookie((Cookie)rememberMeCookie());
cookieRememberMeManager.setCipherKey(Base64.decode(this.cipherKey));
return cookieRememberMeManager;
}
public KickoutSessionFilter kickoutSessionFilter() {
KickoutSessionFilter kickoutSessionFilter = new KickoutSessionFilter();
kickoutSessionFilter.setCacheManager(getEhCacheManager());
kickoutSessionFilter.setSessionManager((SessionManager)sessionManager());
kickoutSessionFilter.setMaxSession(this.maxSession);
kickoutSessionFilter.setKickoutAfter(this.kickoutAfter);
kickoutSessionFilter.setKickoutUrl("/login?kickout=1");
return kickoutSessionFilter;
}
@Bean
public ShiroDialect shiroDialect() {
return new ShiroDialect();
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(@Qualifier("securityManager") SecurityManager securityManager) {
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
return authorizationAttributeSourceAdvisor;
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\config\ShiroConfig.class

@ -1,52 +1,52 @@
/* */ package com.archive.framework.interceptor
package com.archive.framework.interceptor
;
/* */
/* */ import com.alibaba.fastjson.JSONObject;
/* */ import com.archive.common.utils.ServletUtils;
/* */ import com.archive.framework.interceptor.annotation.RepeatSubmit;
/* */ import com.archive.framework.web.domain.AjaxResult;
/* */ import java.lang.reflect.Method;
/* */ import javax.servlet.http.HttpServletRequest;
/* */ import javax.servlet.http.HttpServletResponse;
/* */ import org.springframework.stereotype.Component;
/* */ import org.springframework.web.method.HandlerMethod;
/* */ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public abstract class RepeatSubmitInterceptor
/* */ extends HandlerInterceptorAdapter
/* */ {
/* */ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
/* 25 */ if (handler instanceof HandlerMethod) {
/* */
/* 27 */ HandlerMethod handlerMethod = (HandlerMethod)handler;
/* 28 */ Method method = handlerMethod.getMethod();
/* 29 */ RepeatSubmit annotation = method.<RepeatSubmit>getAnnotation(RepeatSubmit.class);
/* 30 */ if (annotation != null)
/* */ {
/* 32 */ if (isRepeatSubmit(request)) {
/* */
/* 34 */ AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
/* 35 */ ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
/* 36 */ return false;
/* */ }
/* */ }
/* 39 */ return true;
/* */ }
/* */
/* */
/* 43 */ return super.preHandle(request, response, handler);
/* */ }
/* */
/* */ public abstract boolean isRepeatSubmit(HttpServletRequest paramHttpServletRequest);
/* */ }
import com.alibaba.fastjson.JSONObject;
import com.archive.common.utils.ServletUtils;
import com.archive.framework.interceptor.annotation.RepeatSubmit;
import com.archive.framework.web.domain.AjaxResult;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@Component
public abstract class RepeatSubmitInterceptor
extends HandlerInterceptorAdapter
{
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod)handler;
Method method = handlerMethod.getMethod();
RepeatSubmit annotation = method.<RepeatSubmit>getAnnotation(RepeatSubmit.class);
if (annotation != null)
{
if (isRepeatSubmit(request)) {
AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
return false;
}
}
return true;
}
return super.preHandle(request, response, handler);
}
public abstract boolean isRepeatSubmit(HttpServletRequest paramHttpServletRequest);
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\interceptor\RepeatSubmitInterceptor.class

@ -1,99 +1,99 @@
/* */ package com.archive.framework.interceptor.impl
package com.archive.framework.interceptor.impl
;
/* */
/* */ import com.alibaba.fastjson.JSONObject;
/* */ import com.archive.framework.interceptor.RepeatSubmitInterceptor;
/* */ import java.util.HashMap;
/* */ import java.util.Map;
/* */ import javax.servlet.http.HttpServletRequest;
/* */ import javax.servlet.http.HttpSession;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public class SameUrlDataInterceptor
/* */ extends RepeatSubmitInterceptor
/* */ {
/* 20 */ public final String REPEAT_PARAMS = "repeatParams";
/* */
/* 22 */ public final String REPEAT_TIME = "repeatTime";
/* */
/* 24 */ public final String SESSION_REPEAT_KEY = "repeatData";
/* */
/* */
/* */
/* */
/* */
/* */
/* 31 */ private int intervalTime = 10;
/* */
/* */
/* */ public void setIntervalTime(int intervalTime) {
/* 35 */ this.intervalTime = intervalTime;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public boolean isRepeatSubmit(HttpServletRequest request) {
/* 43 */ String nowParams = JSONObject.toJSONString(request.getParameterMap());
/* 44 */ Map<String, Object> nowDataMap = new HashMap<>();
/* 45 */ nowDataMap.put("repeatParams", nowParams);
/* 46 */ nowDataMap.put("repeatTime", Long.valueOf(System.currentTimeMillis()));
/* */
/* */
/* 49 */ String url = request.getRequestURI();
/* */
/* 51 */ HttpSession session = request.getSession();
/* 52 */ Object sessionObj = session.getAttribute("repeatData");
/* 53 */ if (sessionObj != null) {
/* */
/* 55 */ Map<String, Object> map = (Map<String, Object>)sessionObj;
/* 56 */ if (map.containsKey(url)) {
/* */
/* 58 */ Map<String, Object> preDataMap = (Map<String, Object>)map.get(url);
/* 59 */ if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap))
/* */ {
/* 61 */ return true;
/* */ }
/* */ }
/* */ }
/* 65 */ Map<String, Object> sessionMap = new HashMap<>();
/* 66 */ sessionMap.put(url, nowDataMap);
/* 67 */ session.setAttribute("repeatData", sessionMap);
/* 68 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) {
/* 76 */ String nowParams = (String)nowMap.get("repeatParams");
/* 77 */ String preParams = (String)preMap.get("repeatParams");
/* 78 */ return nowParams.equals(preParams);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap) {
/* 86 */ long time1 = ((Long)nowMap.get("repeatTime")).longValue();
/* 87 */ long time2 = ((Long)preMap.get("repeatTime")).longValue();
/* 88 */ if (time1 - time2 < (this.intervalTime * 1000))
/* */ {
/* 90 */ return true;
/* */ }
/* 92 */ return false;
/* */ }
/* */ }
import com.alibaba.fastjson.JSONObject;
import com.archive.framework.interceptor.RepeatSubmitInterceptor;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Component;
@Component
public class SameUrlDataInterceptor
extends RepeatSubmitInterceptor
{
public final String REPEAT_PARAMS = "repeatParams";
public final String REPEAT_TIME = "repeatTime";
public final String SESSION_REPEAT_KEY = "repeatData";
private int intervalTime = 10;
public void setIntervalTime(int intervalTime) {
this.intervalTime = intervalTime;
}
public boolean isRepeatSubmit(HttpServletRequest request) {
String nowParams = JSONObject.toJSONString(request.getParameterMap());
Map<String, Object> nowDataMap = new HashMap<>();
nowDataMap.put("repeatParams", nowParams);
nowDataMap.put("repeatTime", Long.valueOf(System.currentTimeMillis()));
String url = request.getRequestURI();
HttpSession session = request.getSession();
Object sessionObj = session.getAttribute("repeatData");
if (sessionObj != null) {
Map<String, Object> map = (Map<String, Object>)sessionObj;
if (map.containsKey(url)) {
Map<String, Object> preDataMap = (Map<String, Object>)map.get(url);
if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap))
{
return true;
}
}
}
Map<String, Object> sessionMap = new HashMap<>();
sessionMap.put(url, nowDataMap);
session.setAttribute("repeatData", sessionMap);
return false;
}
private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) {
String nowParams = (String)nowMap.get("repeatParams");
String preParams = (String)preMap.get("repeatParams");
return nowParams.equals(preParams);
}
private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap) {
long time1 = ((Long)nowMap.get("repeatTime")).longValue();
long time2 = ((Long)preMap.get("repeatTime")).longValue();
if (time1 - time2 < (this.intervalTime * 1000))
{
return true;
}
return false;
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\interceptor\impl\SameUrlDataInterceptor.class

@ -1,90 +1,90 @@
/* */ package com.archive.framework.manager;
/* */
/* */ import com.archive.framework.manager.AsyncManager;
/* */ import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler;
/* */ import javax.annotation.PreDestroy;
/* */ import net.sf.ehcache.CacheManager;
/* */ import org.apache.shiro.cache.ehcache.EhCacheManager;
/* */ import org.slf4j.Logger;
/* */ import org.slf4j.LoggerFactory;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public class ShutdownManager
/* */ {
/* 20 */ private static final Logger logger = LoggerFactory.getLogger("sys-user");
/* */
/* */ @Autowired(required = false)
/* */ private SpringSessionValidationScheduler springSessionValidationScheduler;
/* */
/* */ @Autowired(required = false)
/* */ private EhCacheManager ehCacheManager;
/* */
/* */
/* */ @PreDestroy
/* */ public void destroy() {
/* 31 */ shutdownSpringSessionValidationScheduler();
/* 32 */ shutdownAsyncManager();
/* 33 */ shutdownEhCacheManager();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void shutdownSpringSessionValidationScheduler() {
/* 41 */ if (this.springSessionValidationScheduler != null && this.springSessionValidationScheduler.isEnabled()) {
/* */
/* */ try {
/* */
/* 45 */ logger.info("====关闭会话验证任务====");
/* 46 */ this.springSessionValidationScheduler.disableSessionValidation();
/* */ }
/* 48 */ catch (Exception e) {
/* */
/* 50 */ logger.error(e.getMessage(), e);
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void shutdownAsyncManager() {
/* */ try {
/* 62 */ logger.info("====关闭后台任务任务线程池====");
/* 63 */ AsyncManager.me().shutdown();
/* */ }
/* 65 */ catch (Exception e) {
/* */
/* 67 */ logger.error(e.getMessage(), e);
/* */ }
/* */ }
/* */
/* */
/* */
/* */ private void shutdownEhCacheManager() {
/* */ try {
/* 75 */ logger.info("====关闭缓存====");
/* 76 */ if (this.ehCacheManager != null)
/* */ {
/* 78 */ CacheManager cacheManager = this.ehCacheManager.getCacheManager();
/* 79 */ cacheManager.shutdown();
/* */ }
/* */
/* 82 */ } catch (Exception e) {
/* */
/* 84 */ logger.error(e.getMessage(), e);
/* */ }
/* */ }
/* */ }
package com.archive.framework.manager;
import com.archive.framework.manager.AsyncManager;
import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler;
import javax.annotation.PreDestroy;
import net.sf.ehcache.CacheManager;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ShutdownManager
{
private static final Logger logger = LoggerFactory.getLogger("sys-user");
@Autowired(required = false)
private SpringSessionValidationScheduler springSessionValidationScheduler;
@Autowired(required = false)
private EhCacheManager ehCacheManager;
@PreDestroy
public void destroy() {
shutdownSpringSessionValidationScheduler();
shutdownAsyncManager();
shutdownEhCacheManager();
}
private void shutdownSpringSessionValidationScheduler() {
if (this.springSessionValidationScheduler != null && this.springSessionValidationScheduler.isEnabled()) {
try {
logger.info("====关闭会话验证任务====");
this.springSessionValidationScheduler.disableSessionValidation();
}
catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
private void shutdownAsyncManager() {
try {
logger.info("====关闭后台任务任务线程池====");
AsyncManager.me().shutdown();
}
catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
private void shutdownEhCacheManager() {
try {
logger.info("====关闭缓存====");
if (this.ehCacheManager != null)
{
CacheManager cacheManager = this.ehCacheManager.getCacheManager();
cacheManager.shutdown();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\manager\ShutdownManager.class

@ -1,82 +1,82 @@
/* */ package com.archive.framework.shiro.service
package com.archive.framework.shiro.service
;
/* */
/* */ import com.archive.common.utils.DateUtils;
/* */ import com.archive.common.utils.MessageUtils;
/* */ import com.archive.common.utils.ServletUtils;
/* */ import com.archive.framework.manager.AsyncManager;
/* */ import com.archive.framework.manager.factory.AsyncFactory;
/* */ import com.archive.project.system.user.domain.User;
/* */ import com.archive.project.system.user.service.IUserService;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Component;
/* */ import org.springframework.util.StringUtils;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public class RegisterService
/* */ {
/* */ @Autowired
/* */ private IUserService userService;
/* */
/* */ public String register(User user) {
/* 33 */ String msg = "", loginName = user.getLoginName(), password = user.getPassword();
/* */
/* 35 */ if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute("captcha"))) {
/* */
/* 37 */ msg = "验证码错误";
/* */ }
/* 39 */ else if (StringUtils.isEmpty(loginName)) {
/* */
/* 41 */ msg = "用户名不能为空";
/* */ }
/* 43 */ else if (StringUtils.isEmpty(password)) {
/* */
/* 45 */ msg = "用户密码不能为空";
/* */ }
/* 47 */ else if (password.length() < 5 || password
/* 48 */ .length() > 20) {
/* */
/* 50 */ msg = "密码长度必须在5到20个字符之间";
/* */ }
/* 52 */ else if (loginName.length() < 2 || loginName
/* 53 */ .length() > 20) {
/* */
/* 55 */ msg = "账户长度必须在2到20个字符之间";
/* */ }
/* 57 */ else if ("1".equals(this.userService.checkLoginNameUnique(loginName))) {
/* */
/* 59 */ msg = "保存用户'" + loginName + "'失败,注册账号已存在";
/* */ }
/* */ else {
/* */
/* 63 */ user.setPwdUpdateDate(DateUtils.getNowDate());
/* 64 */ user.setUserName(loginName);
/* 65 */ boolean regFlag = this.userService.registerUser(user);
/* 66 */ if (!regFlag) {
/* */
/* 68 */ msg = "注册失败,请联系系统管理人员";
/* */ }
/* */ else {
/* */
/* 72 */ AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, "Register", MessageUtils.message("user.register.success", new Object[0]), new Object[0]));
/* */ }
/* */ }
/* 75 */ return msg;
/* */ }
/* */ }
import com.archive.common.utils.DateUtils;
import com.archive.common.utils.MessageUtils;
import com.archive.common.utils.ServletUtils;
import com.archive.framework.manager.AsyncManager;
import com.archive.framework.manager.factory.AsyncFactory;
import com.archive.project.system.user.domain.User;
import com.archive.project.system.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Component
public class RegisterService
{
@Autowired
private IUserService userService;
public String register(User user) {
String msg = "", loginName = user.getLoginName(), password = user.getPassword();
if (!StringUtils.isEmpty(ServletUtils.getRequest().getAttribute("captcha"))) {
msg = "验证码错误";
}
else if (StringUtils.isEmpty(loginName)) {
msg = "用户名不能为空";
}
else if (StringUtils.isEmpty(password)) {
msg = "用户密码不能为空";
}
else if (password.length() < 5 || password
.length() > 20) {
msg = "密码长度必须在5到20个字符之间";
}
else if (loginName.length() < 2 || loginName
.length() > 20) {
msg = "账户长度必须在2到20个字符之间";
}
else if ("1".equals(this.userService.checkLoginNameUnique(loginName))) {
msg = "保存用户'" + loginName + "'失败,注册账号已存在";
}
else {
user.setPwdUpdateDate(DateUtils.getNowDate());
user.setUserName(loginName);
boolean regFlag = this.userService.registerUser(user);
if (!regFlag) {
msg = "注册失败,请联系系统管理人员";
}
else {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, "Register", MessageUtils.message("user.register.success", new Object[0]), new Object[0]));
}
}
return msg;
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\shiro\service\RegisterService.class

@ -1,94 +1,94 @@
/* */ package com.archive.framework.shiro.web.session
package com.archive.framework.shiro.web.session
;
/* */
/* */ import com.archive.common.utils.Threads;
/* */ import java.util.concurrent.ScheduledExecutorService;
/* */ import java.util.concurrent.TimeUnit;
/* */ import org.apache.shiro.session.mgt.SessionValidationScheduler;
/* */ import org.apache.shiro.session.mgt.ValidatingSessionManager;
/* */ import org.slf4j.Logger;
/* */ import org.slf4j.LoggerFactory;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.beans.factory.annotation.Qualifier;
/* */ import org.springframework.beans.factory.annotation.Value;
/* */ import org.springframework.context.annotation.Lazy;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component
/* */ public class SpringSessionValidationScheduler
/* */ implements SessionValidationScheduler
/* */ {
/* 25 */ private static final Logger log = LoggerFactory.getLogger(com.archive.framework.shiro.web.session.SpringSessionValidationScheduler.class);
/* */
/* */
/* */
/* */ public static final long DEFAULT_SESSION_VALIDATION_INTERVAL = 3600000L;
/* */
/* */
/* */
/* */ @Autowired
/* */ @Qualifier("scheduledExecutorService")
/* */ private ScheduledExecutorService executorService;
/* */
/* */
/* */ private volatile boolean enabled = false;
/* */
/* */
/* */ @Autowired
/* */ @Qualifier("sessionManager")
/* */ @Lazy
/* */ private ValidatingSessionManager sessionManager;
/* */
/* */
/* */ @Value("${shiro.session.validationInterval}")
/* */ private long sessionValidationInterval;
/* */
/* */
/* */ @Override
/* */ public boolean isEnabled() {
/* 53 */ return this.enabled;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void setSessionValidationInterval(long sessionValidationInterval) {
/* 68 */ this.sessionValidationInterval = sessionValidationInterval;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Override
/* */ public void enableSessionValidation() {
/* 78 */ this.enabled = true;
/* */
/* 80 */ if (log.isDebugEnabled())
/* */ {
/* 82 */ log.debug("Scheduling session validation job using Spring Scheduler with session validation interval of [" + this.sessionValidationInterval + "]ms...");
/* */ }
/* */
/* */
/* */
/* */ try {
/* */
/* */
import com.archive.common.utils.Threads;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.shiro.session.mgt.SessionValidationScheduler;
import org.apache.shiro.session.mgt.ValidatingSessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@Component
public class SpringSessionValidationScheduler
implements SessionValidationScheduler
{
private static final Logger log = LoggerFactory.getLogger(com.archive.framework.shiro.web.session.SpringSessionValidationScheduler.class);
public static final long DEFAULT_SESSION_VALIDATION_INTERVAL = 3600000L;
@Autowired
@Qualifier("scheduledExecutorService")
private ScheduledExecutorService executorService;
private volatile boolean enabled = false;
@Autowired
@Qualifier("sessionManager")
@Lazy
private ValidatingSessionManager sessionManager;
@Value("${shiro.session.validationInterval}")
private long sessionValidationInterval;
@Override
public boolean isEnabled() {
return this.enabled;
}
public void setSessionValidationInterval(long sessionValidationInterval) {
this.sessionValidationInterval = sessionValidationInterval;
}
@Override
public void enableSessionValidation() {
this.enabled = true;
if (log.isDebugEnabled())
{
log.debug("Scheduling session validation job using Spring Scheduler with session validation interval of [" + this.sessionValidationInterval + "]ms...");
}
try {
executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@ -97,47 +97,47 @@
}
}
}, 1000, sessionValidationInterval * 60 * 1000, TimeUnit.MILLISECONDS);
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 100 */ this.enabled = true;
/* */
/* 102 */ if (log.isDebugEnabled())
/* */ {
/* 104 */ log.debug("Session validation job successfully scheduled with Spring Scheduler.");
/* */
/* */ }
/* */ }
/* 108 */ catch (Exception e) {
/* */
/* 110 */ if (log.isErrorEnabled())
/* */ {
/* 112 */ log.error("Error starting the Spring Scheduler session validation job. Session validation may not occur.", e);
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */ @Override
/* */ public void disableSessionValidation() {
/* 120 */ if (log.isDebugEnabled())
/* */ {
/* 122 */ log.debug("Stopping Spring Scheduler session validation job...");
/* */ }
/* */
/* 125 */ if (this.enabled)
/* */ {
/* 127 */ Threads.shutdownAndAwaitTermination(this.executorService);
/* */ }
/* 129 */ this.enabled = false;
/* */ }
/* */ }
this.enabled = true;
if (log.isDebugEnabled())
{
log.debug("Session validation job successfully scheduled with Spring Scheduler.");
}
}
catch (Exception e) {
if (log.isErrorEnabled())
{
log.error("Error starting the Spring Scheduler session validation job. Session validation may not occur.", e);
}
}
}
@Override
public void disableSessionValidation() {
if (log.isDebugEnabled())
{
log.debug("Stopping Spring Scheduler session validation job...");
}
if (this.enabled)
{
Threads.shutdownAndAwaitTermination(this.executorService);
}
this.enabled = false;
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\shiro\web\session\SpringSessionValidationScheduler.class

@ -1,110 +1,110 @@
/* */ package com.archive.project.dajs.recycle.service.impl
package com.archive.project.dajs.recycle.service.impl
;
/* */
/* */ import com.archive.project.common.service.IExecuteSqlService;
/* */ import com.archive.project.dajs.recycle.service.IRecycleService;
/* */ import com.archive.project.dasz.archivetype.domain.ArchiveType;
/* */ import com.archive.project.dasz.archivetype.mapper.ArchiveTypeMapper;
/* */ import com.archive.project.dasz.archivetype.service.IArchiveTypeService;
/* */ import com.archive.project.dasz.physicaltable.mapper.PhysicalTableMapper;
/* */ import com.archive.project.dasz.physicaltablecolumn.mapper.PhysicalTableColumnMapper;
/* */ import java.io.File;
/* */ import java.util.LinkedHashMap;
/* */ import java.util.List;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Service;
/* */ import org.springframework.transaction.annotation.Transactional;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Service
/* */ public class RecycleServiceImpl
/* */ implements IRecycleService
/* */ {
/* */ @Autowired
/* */ private ArchiveTypeMapper archiveTypeMapper;
/* */ @Autowired
/* */ private PhysicalTableMapper physicalTableMapper;
/* */ @Autowired
/* */ private IExecuteSqlService executeSqlService;
/* */ @Autowired
/* */ private PhysicalTableColumnMapper physicalTableColumnMapper;
/* */ @Autowired
/* */ private IArchiveTypeService iArchiveTypeService;
/* */
/* */ @Transactional
/* */ public boolean archivePhysicalDelete(String archiveTypeId, String type) {
/* 58 */ boolean res = false;
/* 59 */ ArchiveType archiveType = this.iArchiveTypeService.selectArchiveTypeById(Long.valueOf(Long.parseLong(archiveTypeId)));
/* 60 */ String archiveCode = archiveType.getArhciveCode();
/* 61 */ if (type.toLowerCase().equals("folder")) {
/* */
/* */
/* 64 */ String documentPathSql = "select filewaterpath,filepath from t_ar_" + archiveCode + "_document where is_delete='1'";
/* 65 */ getDocumentSqlDeleteFile(documentPathSql);
/* 66 */ String documentSql = "delete from t_ar_" + archiveCode + "_document where is_delete='1'";
/* 67 */ String filesql = "delete from t_ar_" + archiveCode + "_file where is_delete='1'";
/* 68 */ String folderSql = "delete from t_ar_" + archiveCode + "_folder where is_delete='1'";
/* 69 */ this.executeSqlService.delete(documentSql);
/* 70 */ this.executeSqlService.delete(filesql);
/* 71 */ this.executeSqlService.delete(folderSql);
/* 72 */ } else if (type.toLowerCase().equals("file")) {
/* */
/* */
/* 75 */ String documentPathSql = "select filewaterpath,filepath from t_ar_" + archiveCode + "_document where is_delete='1'";
/* 76 */ getDocumentSqlDeleteFile(documentPathSql);
/* 77 */ String documentSql = "delete from t_ar_" + archiveCode + "_document where is_delete='1'";
/* 78 */ String filesql = "delete from t_ar_" + archiveCode + "_file where is_delete='1'";
/* 79 */ this.executeSqlService.delete(documentSql);
/* 80 */ this.executeSqlService.delete(filesql);
/* */ }
/* 82 */ res = true;
/* 83 */ return res;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void getDocumentSqlDeleteFile(String sql) {
/* 92 */ List<LinkedHashMap<String, Object>> list = this.executeSqlService.queryList(sql);
/* 93 */ for (int i = 0; i < list.size(); i++) {
/* 94 */ String waterPath = (((LinkedHashMap)list.get(i)).get("filewaterpath") == null) ? "" : ((LinkedHashMap)list.get(i)).get("filewaterpath").toString();
/* 95 */ String filePath = (((LinkedHashMap)list.get(i)).get("filepath") == null) ? "" : ((LinkedHashMap)list.get(i)).get("filepath").toString();
/* 96 */ File waterFile = new File(waterPath);
/* 97 */ if (waterFile.exists()) {
/* 98 */ waterFile.delete();
/* */ }
/* 100 */ File file = new File(filePath);
/* 101 */ if (file.exists())
/* 102 */ file.delete();
/* */ }
/* */ }
/* */ }
import com.archive.project.common.service.IExecuteSqlService;
import com.archive.project.dajs.recycle.service.IRecycleService;
import com.archive.project.dasz.archivetype.domain.ArchiveType;
import com.archive.project.dasz.archivetype.mapper.ArchiveTypeMapper;
import com.archive.project.dasz.archivetype.service.IArchiveTypeService;
import com.archive.project.dasz.physicaltable.mapper.PhysicalTableMapper;
import com.archive.project.dasz.physicaltablecolumn.mapper.PhysicalTableColumnMapper;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class RecycleServiceImpl
implements IRecycleService
{
@Autowired
private ArchiveTypeMapper archiveTypeMapper;
@Autowired
private PhysicalTableMapper physicalTableMapper;
@Autowired
private IExecuteSqlService executeSqlService;
@Autowired
private PhysicalTableColumnMapper physicalTableColumnMapper;
@Autowired
private IArchiveTypeService iArchiveTypeService;
@Transactional
public boolean archivePhysicalDelete(String archiveTypeId, String type) {
boolean res = false;
ArchiveType archiveType = this.iArchiveTypeService.selectArchiveTypeById(Long.valueOf(Long.parseLong(archiveTypeId)));
String archiveCode = archiveType.getArhciveCode();
if (type.toLowerCase().equals("folder")) {
String documentPathSql = "select filewaterpath,filepath from t_ar_" + archiveCode + "_document where is_delete='1'";
getDocumentSqlDeleteFile(documentPathSql);
String documentSql = "delete from t_ar_" + archiveCode + "_document where is_delete='1'";
String filesql = "delete from t_ar_" + archiveCode + "_file where is_delete='1'";
String folderSql = "delete from t_ar_" + archiveCode + "_folder where is_delete='1'";
this.executeSqlService.delete(documentSql);
this.executeSqlService.delete(filesql);
this.executeSqlService.delete(folderSql);
} else if (type.toLowerCase().equals("file")) {
String documentPathSql = "select filewaterpath,filepath from t_ar_" + archiveCode + "_document where is_delete='1'";
getDocumentSqlDeleteFile(documentPathSql);
String documentSql = "delete from t_ar_" + archiveCode + "_document where is_delete='1'";
String filesql = "delete from t_ar_" + archiveCode + "_file where is_delete='1'";
this.executeSqlService.delete(documentSql);
this.executeSqlService.delete(filesql);
}
res = true;
return res;
}
public void getDocumentSqlDeleteFile(String sql) {
List<LinkedHashMap<String, Object>> list = this.executeSqlService.queryList(sql);
for (int i = 0; i < list.size(); i++) {
String waterPath = (((LinkedHashMap)list.get(i)).get("filewaterpath") == null) ? "" : ((LinkedHashMap)list.get(i)).get("filewaterpath").toString();
String filePath = (((LinkedHashMap)list.get(i)).get("filepath") == null) ? "" : ((LinkedHashMap)list.get(i)).get("filepath").toString();
File waterFile = new File(waterPath);
if (waterFile.exists()) {
waterFile.delete();
}
File file = new File(filePath);
if (file.exists())
file.delete();
}
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\dajs\recycle\service\impl\RecycleServiceImpl.class

@ -1,33 +1,33 @@
/* */ package com.archive.project.monitor.job.task
package com.archive.project.monitor.job.task
;
/* */
/* */ import com.archive.common.utils.StringUtils;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component("ryTask")
/* */ public class RyTask
/* */ {
/* */ public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
/* 16 */ System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", new Object[] { s, b, l, d, i }));
/* */ }
/* */
/* */
/* */ public void ryParams(String params) {
/* 21 */ System.out.println("执行有参方法:" + params);
/* */ }
/* */
/* */
/* */ public void ryNoParams() {
/* 26 */ System.out.println("执行无参方法");
/* */ }
/* */ }
import com.archive.common.utils.StringUtils;
import org.springframework.stereotype.Component;
@Component("ryTask")
public class RyTask
{
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", new Object[] { s, b, l, d, i }));
}
public void ryParams(String params) {
System.out.println("执行有参方法:" + params);
}
public void ryNoParams() {
System.out.println("执行无参方法");
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\monitor\job\task\RyTask.class

@ -1,47 +1,47 @@
/* */ package com.archive.project.monitor.job.task;
/* */
/* */ import com.archive.common.utils.DateUtils;
/* */
/* */ import com.archive.project.dasz.ccgl.service.ICcglService;
/* */ import com.archive.project.system.config.service.IConfigService;
/* */ import java.io.File;
/* */ import java.io.IOException;
/* */ import org.apache.commons.io.FileUtils;
package com.archive.project.monitor.job.task;
import com.archive.common.utils.DateUtils;
import com.archive.project.dasz.ccgl.service.ICcglService;
import com.archive.project.system.config.service.IConfigService;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Component;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Component("sqliteBackTask")
/* */ public class SqliteBackTask
/* */ {
/* */ @Autowired
/* */ private IConfigService configService;
/* */ @Autowired
/* */ private ICcglService ccglService;
/* */
/* */ public void Back() {
/* 28 */ String path = this.configService.selectConfigByKey("archive.SqliteAddress");
/* 29 */ if ((new File(path)).exists()) {
/* */
/* 31 */ String time = DateUtils.dateTimeNow();
/* 32 */ String backPath = this.ccglService.getPathByLjbs("archive.SqliteBackPath");
/* */ try {
/* 34 */ FileUtils.copyFile(new File(path), new File(backPath + File.separator + "archive_sqlite" + time + ".db"));
/* 35 */ } catch (IOException e) {
/* 36 */ e.printStackTrace();
/* */ }
/* 38 */ System.out.println("数据库备份完毕:" + backPath + File.separator + "archive_sqlite" + time + ".db");
/* */ } else {
/* 40 */ System.out.println("数据库文件不存在,请检查参数管理中-Sqlite数据存放位置-的参数值是否正确");
/* */ }
/* */ }
/* */ }
import org.springframework.stereotype.Component;
@Component("sqliteBackTask")
public class SqliteBackTask
{
@Autowired
private IConfigService configService;
@Autowired
private ICcglService ccglService;
public void Back() {
String path = this.configService.selectConfigByKey("archive.SqliteAddress");
if ((new File(path)).exists()) {
String time = DateUtils.dateTimeNow();
String backPath = this.ccglService.getPathByLjbs("archive.SqliteBackPath");
try {
FileUtils.copyFile(new File(path), new File(backPath + File.separator + "archive_sqlite" + time + ".db"));
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("数据库备份完毕:" + backPath + File.separator + "archive_sqlite" + time + ".db");
} else {
System.out.println("数据库文件不存在,请检查参数管理中-Sqlite数据存放位置-的参数值是否正确");
}
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\monitor\job\task\SqliteBackTask.class

@ -1,117 +1,117 @@
/* */ package com.archive.project.monitor.job.util
package com.archive.project.monitor.job.util
;
/* */
/* */ import com.archive.common.constant.ScheduleConstants;
/* */ import com.archive.common.constant.Status;
import com.archive.common.constant.ScheduleConstants;
import com.archive.common.constant.Status;
import com.archive.common.exception.job.Code;
import com.archive.common.exception.job.TaskException;
/* */ import com.archive.project.monitor.job.domain.Job;
/* */ import com.archive.project.monitor.job.util.QuartzDisallowConcurrentExecution;
/* */ import com.archive.project.monitor.job.util.QuartzJobExecution;
/* */ import org.quartz.CronScheduleBuilder;
/* */ import org.quartz.CronTrigger;
/* */
/* */ import org.quartz.JobBuilder;
/* */ import org.quartz.JobDetail;
/* */ import org.quartz.JobKey;
/* */ import org.quartz.ScheduleBuilder;
/* */ import org.quartz.Scheduler;
/* */ import org.quartz.SchedulerException;
/* */ import org.quartz.Trigger;
/* */ import org.quartz.TriggerBuilder;
/* */ import org.quartz.TriggerKey;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ScheduleUtils
/* */ {
/* */ private static Class<? extends org.quartz.Job> getQuartzJobClass(Job job) {
/* 33 */ boolean isConcurrent = "0".equals(job.getConcurrent());
/* 34 */ return isConcurrent ? (Class)QuartzJobExecution.class : (Class)QuartzDisallowConcurrentExecution.class;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static TriggerKey getTriggerKey(Long jobId, String jobGroup) {
/* 42 */ return TriggerKey.triggerKey("TASK_CLASS_NAME" + jobId, jobGroup);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static JobKey getJobKey(Long jobId, String jobGroup) {
/* 50 */ return JobKey.jobKey("TASK_CLASS_NAME" + jobId, jobGroup);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public static void createScheduleJob(Scheduler scheduler, Job job) throws SchedulerException, TaskException {
/* 58 */ Class<? extends org.quartz.Job> jobClass = getQuartzJobClass(job);
/* */
/* 60 */ Long jobId = job.getJobId();
/* 61 */ String jobGroup = job.getJobGroup();
/* 62 */ JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
/* */
/* */
/* 65 */ CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
/* 66 */ cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);
/* */
/* */
/* */
/* 70 */ CronTrigger trigger = (CronTrigger)TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)).withSchedule((ScheduleBuilder)cronScheduleBuilder).build();
/* */
/* */
/* 73 */ jobDetail.getJobDataMap().put("TASK_PROPERTIES", job);
/* */
/* */
/* 76 */ if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
/* */ {
/* */
/* 79 */ scheduler.deleteJob(getJobKey(jobId, jobGroup));
/* */ }
/* */
/* 82 */ scheduler.scheduleJob(jobDetail, (Trigger)trigger);
/* */
/* */
/* 85 */ if (job.getStatus().equals(Status.PAUSE.getValue()))
/* */ {
/* 87 */ scheduler.pauseJob(getJobKey(jobId, jobGroup));
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static CronScheduleBuilder handleCronScheduleMisfirePolicy(Job job, CronScheduleBuilder cb) throws TaskException {
/* 97 */ switch (job.getMisfirePolicy()) {
/* */
/* */ case "0":
/* 100 */ return cb;
/* */ case "1":
/* 102 */ return cb.withMisfireHandlingInstructionIgnoreMisfires();
/* */ case "2":
/* 104 */ return cb.withMisfireHandlingInstructionFireAndProceed();
/* */ case "3":
/* 106 */ return cb.withMisfireHandlingInstructionDoNothing();
/* */ }
/* 108 */ throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
/* */ }
/* */ }
import com.archive.project.monitor.job.domain.Job;
import com.archive.project.monitor.job.util.QuartzDisallowConcurrentExecution;
import com.archive.project.monitor.job.util.QuartzJobExecution;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.ScheduleBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
public class ScheduleUtils
{
private static Class<? extends org.quartz.Job> getQuartzJobClass(Job job) {
boolean isConcurrent = "0".equals(job.getConcurrent());
return isConcurrent ? (Class)QuartzJobExecution.class : (Class)QuartzDisallowConcurrentExecution.class;
}
public static TriggerKey getTriggerKey(Long jobId, String jobGroup) {
return TriggerKey.triggerKey("TASK_CLASS_NAME" + jobId, jobGroup);
}
public static JobKey getJobKey(Long jobId, String jobGroup) {
return JobKey.jobKey("TASK_CLASS_NAME" + jobId, jobGroup);
}
public static void createScheduleJob(Scheduler scheduler, Job job) throws SchedulerException, TaskException {
Class<? extends org.quartz.Job> jobClass = getQuartzJobClass(job);
Long jobId = job.getJobId();
String jobGroup = job.getJobGroup();
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);
CronTrigger trigger = (CronTrigger)TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)).withSchedule((ScheduleBuilder)cronScheduleBuilder).build();
jobDetail.getJobDataMap().put("TASK_PROPERTIES", job);
if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
{
scheduler.deleteJob(getJobKey(jobId, jobGroup));
}
scheduler.scheduleJob(jobDetail, (Trigger)trigger);
if (job.getStatus().equals(Status.PAUSE.getValue()))
{
scheduler.pauseJob(getJobKey(jobId, jobGroup));
}
}
public static CronScheduleBuilder handleCronScheduleMisfirePolicy(Job job, CronScheduleBuilder cb) throws TaskException {
switch (job.getMisfirePolicy()) {
case "0":
return cb;
case "1":
return cb.withMisfireHandlingInstructionIgnoreMisfires();
case "2":
return cb.withMisfireHandlingInstructionFireAndProceed();
case "3":
return cb.withMisfireHandlingInstructionDoNothing();
}
throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\monitor\jo\\util\ScheduleUtils.class

@ -1,36 +1,36 @@
/* */ package com.archive.project.monitor.server.controller
package com.archive.project.monitor.server.controller
;
/* */
/* */ import com.archive.framework.web.controller.BaseController;
/* */ import com.archive.project.monitor.server.domain.Server;
/* */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/* */ import org.springframework.stereotype.Controller;
/* */ import org.springframework.ui.ModelMap;
/* */ import org.springframework.web.bind.annotation.GetMapping;
/* */ import org.springframework.web.bind.annotation.RequestMapping;
/* */
/* */
/* */
/* */
/* */
/* */ @Controller
/* */ @RequestMapping({"/monitor/server"})
/* */ public class ServerController
/* */ extends BaseController
/* */ {
/* 20 */ private String prefix = "monitor/server";
/* */
/* */
/* */ @RequiresPermissions({"monitor:server:view"})
/* */ @GetMapping
/* */ public String server(ModelMap mmap) throws Exception {
/* 26 */ Server server = new Server();
/* 27 */ server.copyTo();
/* 28 */ mmap.put("server", server);
/* 29 */ return this.prefix + "/server";
/* */ }
/* */ }
import com.archive.framework.web.controller.BaseController;
import com.archive.project.monitor.server.domain.Server;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/monitor/server"})
public class ServerController
extends BaseController
{
private String prefix = "monitor/server";
@RequiresPermissions({"monitor:server:view"})
@GetMapping
public String server(ModelMap mmap) throws Exception {
Server server = new Server();
server.copyTo();
mmap.put("server", server);
return this.prefix + "/server";
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\monitor\server\controller\ServerController.class

@ -1,239 +1,239 @@
/* */ package com.archive.project.monitor.server.domain
package com.archive.project.monitor.server.domain
;
/* */
/* */ import com.archive.common.utils.Arith;
/* */ import com.archive.common.utils.IpUtils;
/* */ import com.archive.project.monitor.server.domain.Cpu;
/* */ import com.archive.project.monitor.server.domain.Jvm;
/* */ import com.archive.project.monitor.server.domain.Mem;
/* */ import com.archive.project.monitor.server.domain.Sys;
/* */ import com.archive.project.monitor.server.domain.SysFile;
/* */ import java.net.UnknownHostException;
/* */ import java.util.LinkedList;
/* */ import java.util.List;
/* */ import java.util.Properties;
/* */ import oshi.SystemInfo;
/* */ import oshi.hardware.CentralProcessor;
/* */ import oshi.hardware.GlobalMemory;
/* */ import oshi.hardware.HardwareAbstractionLayer;
/* */ import oshi.software.os.FileSystem;
/* */ import oshi.software.os.OSFileStore;
/* */ import oshi.software.os.OperatingSystem;
/* */ import oshi.util.Util;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Server
/* */ {
/* */ private static final int OSHI_WAIT_SECOND = 1000;
/* 31 */ private Cpu cpu = new Cpu();
/* */
/* */
/* */
/* */
/* 36 */ private Mem mem = new Mem();
/* */
/* */
/* */
/* */
/* 41 */ private Jvm jvm = new Jvm();
/* */
/* */
/* */
/* */
/* 46 */ private Sys sys = new Sys();
/* */
/* */
/* */
/* */
/* 51 */ private List<SysFile> sysFiles = new LinkedList<>();
/* */
/* */
/* */ public Cpu getCpu() {
/* 55 */ return this.cpu;
/* */ }
/* */
/* */
/* */ public void setCpu(Cpu cpu) {
/* 60 */ this.cpu = cpu;
/* */ }
/* */
/* */
/* */ public Mem getMem() {
/* 65 */ return this.mem;
/* */ }
/* */
/* */
/* */ public void setMem(Mem mem) {
/* 70 */ this.mem = mem;
/* */ }
/* */
/* */
/* */ public Jvm getJvm() {
/* 75 */ return this.jvm;
/* */ }
/* */
/* */
/* */ public void setJvm(Jvm jvm) {
/* 80 */ this.jvm = jvm;
/* */ }
/* */
/* */
/* */ public Sys getSys() {
/* 85 */ return this.sys;
/* */ }
/* */
/* */
/* */ public void setSys(Sys sys) {
/* 90 */ this.sys = sys;
/* */ }
/* */
/* */
/* */ public List<SysFile> getSysFiles() {
/* 95 */ return this.sysFiles;
/* */ }
/* */
/* */
/* */ public void setSysFiles(List<SysFile> sysFiles) {
/* 100 */ this.sysFiles = sysFiles;
/* */ }
/* */
/* */
/* */ public void copyTo() throws Exception {
/* 105 */ SystemInfo si = new SystemInfo();
/* 106 */ HardwareAbstractionLayer hal = si.getHardware();
/* */
/* 108 */ setCpuInfo(hal.getProcessor());
/* */
/* 110 */ setMemInfo(hal.getMemory());
/* */
/* 112 */ setSysInfo();
/* */
/* 114 */ setJvmInfo();
/* */
/* 116 */ setSysFiles(si.getOperatingSystem());
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void setCpuInfo(CentralProcessor processor) {
/* 125 */ long[] prevTicks = processor.getSystemCpuLoadTicks();
/* 126 */ Util.sleep(1000L);
/* 127 */ long[] ticks = processor.getSystemCpuLoadTicks();
/* 128 */ long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
/* 129 */ long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
/* 130 */ long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
/* 131 */ long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
/* 132 */ long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
/* 133 */ long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
/* 134 */ long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
/* 135 */ long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
/* 136 */ long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
/* 137 */ this.cpu.setCpuNum(processor.getLogicalProcessorCount());
/* 138 */ this.cpu.setTotal(totalCpu);
/* 139 */ this.cpu.setSys(cSys);
/* 140 */ this.cpu.setUsed(user);
/* 141 */ this.cpu.setWait(iowait);
/* 142 */ this.cpu.setFree(idle);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void setMemInfo(GlobalMemory memory) {
/* 150 */ this.mem.setTotal(memory.getTotal());
/* 151 */ this.mem.setUsed(memory.getTotal() - memory.getAvailable());
/* 152 */ this.mem.setFree(memory.getAvailable());
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void setSysInfo() {
/* 160 */ Properties props = System.getProperties();
/* 161 */ this.sys.setComputerName(IpUtils.getHostName());
/* 162 */ this.sys.setComputerIp(IpUtils.getHostIp());
/* 163 */ this.sys.setOsName(props.getProperty("os.name"));
/* 164 */ this.sys.setOsArch(props.getProperty("os.arch"));
/* 165 */ this.sys.setUserDir(props.getProperty("user.dir"));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void setJvmInfo() throws UnknownHostException {
/* 173 */ Properties props = System.getProperties();
/* 174 */ this.jvm.setTotal(Runtime.getRuntime().totalMemory());
/* 175 */ this.jvm.setMax(Runtime.getRuntime().maxMemory());
/* 176 */ this.jvm.setFree(Runtime.getRuntime().freeMemory());
/* 177 */ this.jvm.setVersion(props.getProperty("java.version"));
/* 178 */ this.jvm.setHome(props.getProperty("java.home"));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void setSysFiles(OperatingSystem os) {
/* 186 */ FileSystem fileSystem = os.getFileSystem();
/* 187 */ List<OSFileStore> fsArray = fileSystem.getFileStores();
/* 188 */ for (OSFileStore fs : fsArray) {
/* */
/* 190 */ long free = fs.getUsableSpace();
/* 191 */ long total = fs.getTotalSpace();
/* 192 */ long used = total - free;
/* 193 */ SysFile sysFile = new SysFile();
/* 194 */ sysFile.setDirName(fs.getMount());
/* 195 */ sysFile.setSysTypeName(fs.getType());
/* 196 */ sysFile.setTypeName(fs.getName());
/* 197 */ sysFile.setTotal(convertFileSize(total));
/* 198 */ sysFile.setFree(convertFileSize(free));
/* 199 */ sysFile.setUsed(convertFileSize(used));
/* 200 */ sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100.0D));
/* 201 */ this.sysFiles.add(sysFile);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public String convertFileSize(long size) {
/* 213 */ long kb = 1024L;
/* 214 */ long mb = kb * 1024L;
/* 215 */ long gb = mb * 1024L;
/* 216 */ if (size >= gb)
/* */ {
/* 218 */ return String.format("%.1f GB", new Object[] { Float.valueOf((float)size / (float)gb) });
/* */ }
/* 220 */ if (size >= mb) {
/* */
/* 222 */ float f = (float)size / (float)mb;
/* 223 */ return String.format((f > 100.0F) ? "%.0f MB" : "%.1f MB", new Object[] { Float.valueOf(f) });
/* */ }
/* 225 */ if (size >= kb) {
/* */
/* 227 */ float f = (float)size / (float)kb;
/* 228 */ return String.format((f > 100.0F) ? "%.0f KB" : "%.1f KB", new Object[] { Float.valueOf(f) });
/* */ }
/* */
/* */
/* 232 */ return String.format("%d B", new Object[] { Long.valueOf(size) });
/* */ }
/* */ }
import com.archive.common.utils.Arith;
import com.archive.common.utils.IpUtils;
import com.archive.project.monitor.server.domain.Cpu;
import com.archive.project.monitor.server.domain.Jvm;
import com.archive.project.monitor.server.domain.Mem;
import com.archive.project.monitor.server.domain.Sys;
import com.archive.project.monitor.server.domain.SysFile;
import java.net.UnknownHostException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.FileSystem;
import oshi.software.os.OSFileStore;
import oshi.software.os.OperatingSystem;
import oshi.util.Util;
public class Server
{
private static final int OSHI_WAIT_SECOND = 1000;
private Cpu cpu = new Cpu();
private Mem mem = new Mem();
private Jvm jvm = new Jvm();
private Sys sys = new Sys();
private List<SysFile> sysFiles = new LinkedList<>();
public Cpu getCpu() {
return this.cpu;
}
public void setCpu(Cpu cpu) {
this.cpu = cpu;
}
public Mem getMem() {
return this.mem;
}
public void setMem(Mem mem) {
this.mem = mem;
}
public Jvm getJvm() {
return this.jvm;
}
public void setJvm(Jvm jvm) {
this.jvm = jvm;
}
public Sys getSys() {
return this.sys;
}
public void setSys(Sys sys) {
this.sys = sys;
}
public List<SysFile> getSysFiles() {
return this.sysFiles;
}
public void setSysFiles(List<SysFile> sysFiles) {
this.sysFiles = sysFiles;
}
public void copyTo() throws Exception {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
setCpuInfo(hal.getProcessor());
setMemInfo(hal.getMemory());
setSysInfo();
setJvmInfo();
setSysFiles(si.getOperatingSystem());
}
private void setCpuInfo(CentralProcessor processor) {
long[] prevTicks = processor.getSystemCpuLoadTicks();
Util.sleep(1000L);
long[] ticks = processor.getSystemCpuLoadTicks();
long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
this.cpu.setCpuNum(processor.getLogicalProcessorCount());
this.cpu.setTotal(totalCpu);
this.cpu.setSys(cSys);
this.cpu.setUsed(user);
this.cpu.setWait(iowait);
this.cpu.setFree(idle);
}
private void setMemInfo(GlobalMemory memory) {
this.mem.setTotal(memory.getTotal());
this.mem.setUsed(memory.getTotal() - memory.getAvailable());
this.mem.setFree(memory.getAvailable());
}
private void setSysInfo() {
Properties props = System.getProperties();
this.sys.setComputerName(IpUtils.getHostName());
this.sys.setComputerIp(IpUtils.getHostIp());
this.sys.setOsName(props.getProperty("os.name"));
this.sys.setOsArch(props.getProperty("os.arch"));
this.sys.setUserDir(props.getProperty("user.dir"));
}
private void setJvmInfo() throws UnknownHostException {
Properties props = System.getProperties();
this.jvm.setTotal(Runtime.getRuntime().totalMemory());
this.jvm.setMax(Runtime.getRuntime().maxMemory());
this.jvm.setFree(Runtime.getRuntime().freeMemory());
this.jvm.setVersion(props.getProperty("java.version"));
this.jvm.setHome(props.getProperty("java.home"));
}
private void setSysFiles(OperatingSystem os) {
FileSystem fileSystem = os.getFileSystem();
List<OSFileStore> fsArray = fileSystem.getFileStores();
for (OSFileStore fs : fsArray) {
long free = fs.getUsableSpace();
long total = fs.getTotalSpace();
long used = total - free;
SysFile sysFile = new SysFile();
sysFile.setDirName(fs.getMount());
sysFile.setSysTypeName(fs.getType());
sysFile.setTypeName(fs.getName());
sysFile.setTotal(convertFileSize(total));
sysFile.setFree(convertFileSize(free));
sysFile.setUsed(convertFileSize(used));
sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100.0D));
this.sysFiles.add(sysFile);
}
}
public String convertFileSize(long size) {
long kb = 1024L;
long mb = kb * 1024L;
long gb = mb * 1024L;
if (size >= gb)
{
return String.format("%.1f GB", new Object[] { Float.valueOf((float)size / (float)gb) });
}
if (size >= mb) {
float f = (float)size / (float)mb;
return String.format((f > 100.0F) ? "%.0f MB" : "%.1f MB", new Object[] { Float.valueOf(f) });
}
if (size >= kb) {
float f = (float)size / (float)kb;
return String.format((f > 100.0F) ? "%.0f KB" : "%.1f KB", new Object[] { Float.valueOf(f) });
}
return String.format("%d B", new Object[] { Long.valueOf(size) });
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\monitor\server\domain\Server.class

@ -1,299 +1,299 @@
/* */ package com.archive.project.system.role.controller
package com.archive.project.system.role.controller
;
/* */
/* */ import com.archive.common.utils.poi.ExcelUtil;
/* */ import com.archive.common.utils.security.AuthorizationUtils;
/* */ import com.archive.framework.aspectj.lang.annotation.Log;
/* */ import com.archive.framework.aspectj.lang.enums.BusinessType;
/* */ import com.archive.framework.web.controller.BaseController;
/* */ import com.archive.framework.web.domain.AjaxResult;
/* */ import com.archive.framework.web.page.TableDataInfo;
/* */ import com.archive.project.system.role.domain.Role;
/* */ import com.archive.project.system.role.service.IRoleService;
/* */ import com.archive.project.system.user.domain.User;
/* */ import com.archive.project.system.user.domain.UserRole;
/* */ import com.archive.project.system.user.service.IUserService;
/* */ import java.util.List;
/* */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Controller;
/* */ import org.springframework.ui.ModelMap;
/* */ import org.springframework.validation.annotation.Validated;
/* */ import org.springframework.web.bind.annotation.GetMapping;
/* */ import org.springframework.web.bind.annotation.PathVariable;
/* */ import org.springframework.web.bind.annotation.PostMapping;
/* */ import org.springframework.web.bind.annotation.RequestMapping;
/* */ import org.springframework.web.bind.annotation.ResponseBody;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Controller
/* */ @RequestMapping({"/system/role"})
/* */ public class RoleController
/* */ extends BaseController
/* */ {
/* 37 */ private String prefix = "system/role";
/* */
/* */ @Autowired
/* */ private IRoleService roleService;
/* */
/* */ @Autowired
/* */ private IUserService userService;
/* */
/* */
/* */ @RequiresPermissions({"system:role:view"})
/* */ @GetMapping
/* */ public String role() {
/* 49 */ return this.prefix + "/role";
/* */ }
/* */
/* */
/* */ @RequiresPermissions({"system:role:list"})
/* */ @PostMapping({"/list"})
/* */ @ResponseBody
/* */ public TableDataInfo list(Role role) {
/* 57 */ startPage();
/* 58 */ List<Role> list = this.roleService.selectRoleList(role);
/* 59 */ return getDataTable(list);
/* */ }
/* */
/* */
/* */ @Log(title = "角色管理", businessType = BusinessType.EXPORT)
/* */ @RequiresPermissions({"system:role:export"})
/* */ @PostMapping({"/export"})
/* */ @ResponseBody
/* */ public AjaxResult export(Role role) {
/* 68 */ List<Role> list = this.roleService.selectRoleList(role);
/* 69 */ ExcelUtil<Role> util = new ExcelUtil(Role.class);
/* 70 */ return util.exportExcel(list, "角色数据");
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @GetMapping({"/add"})
/* */ public String add() {
/* 79 */ return this.prefix + "/add";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @RequiresPermissions({"system:role:add"})
/* */ @Log(title = "角色管理", businessType = BusinessType.INSERT)
/* */ @PostMapping({"/add"})
/* */ @ResponseBody
/* */ public AjaxResult addSave(@Validated Role role) {
/* 91 */ if ("1".equals(this.roleService.checkRoleNameUnique(role)))
/* */ {
/* 93 */ return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
/* */ }
/* 95 */ if ("1".equals(this.roleService.checkRoleKeyUnique(role)))
/* */ {
/* 97 */ return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
/* */ }
/* 99 */ AuthorizationUtils.clearAllCachedAuthorizationInfo();
/* 100 */ return toAjax(this.roleService.insertRole(role));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @GetMapping({"/edit/{roleId}"})
/* */ public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) {
/* 110 */ mmap.put("role", this.roleService.selectRoleById(roleId));
/* 111 */ return this.prefix + "/edit";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @RequiresPermissions({"system:role:edit"})
/* */ @Log(title = "角色管理", businessType = BusinessType.UPDATE)
/* */ @PostMapping({"/edit"})
/* */ @ResponseBody
/* */ public AjaxResult editSave(@Validated Role role) {
/* 123 */ this.roleService.checkRoleAllowed(role);
/* 124 */ if ("1".equals(this.roleService.checkRoleNameUnique(role)))
/* */ {
/* 126 */ return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
/* */ }
/* 128 */ if ("1".equals(this.roleService.checkRoleKeyUnique(role)))
/* */ {
/* 130 */ return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
/* */ }
/* 132 */ AuthorizationUtils.clearAllCachedAuthorizationInfo();
/* 133 */ return toAjax(this.roleService.updateRole(role));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @GetMapping({"/authDataScope/{roleId}"})
/* */ public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap) {
/* 142 */ mmap.put("role", this.roleService.selectRoleById(roleId));
/* 143 */ return this.prefix + "/dataScope";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @RequiresPermissions({"system:role:edit"})
/* */ @Log(title = "角色管理", businessType = BusinessType.UPDATE)
/* */ @PostMapping({"/authDataScope"})
/* */ @ResponseBody
/* */ public AjaxResult authDataScopeSave(Role role) {
/* 155 */ this.roleService.checkRoleAllowed(role);
/* 156 */ if (this.roleService.authDataScope(role) > 0) {
/* */
/* 158 */ setSysUser(this.userService.selectUserById(getSysUser().getUserId()));
/* 159 */ return success();
/* */ }
/* 161 */ return error();
/* */ }
/* */
/* */
/* */ @RequiresPermissions({"system:role:remove"})
/* */ @Log(title = "角色管理", businessType = BusinessType.DELETE)
/* */ @PostMapping({"/remove"})
/* */ @ResponseBody
/* */ public AjaxResult remove(String ids) {
/* 170 */ return toAjax(this.roleService.deleteRoleByIds(ids));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @PostMapping({"/checkRoleNameUnique"})
/* */ @ResponseBody
/* */ public String checkRoleNameUnique(Role role) {
/* 180 */ return this.roleService.checkRoleNameUnique(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @PostMapping({"/checkRoleKeyUnique"})
/* */ @ResponseBody
/* */ public String checkRoleKeyUnique(Role role) {
/* 190 */ return this.roleService.checkRoleKeyUnique(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @GetMapping({"/selectMenuTree"})
/* */ public String selectMenuTree() {
/* 199 */ return this.prefix + "/tree";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Log(title = "角色管理", businessType = BusinessType.UPDATE)
/* */ @RequiresPermissions({"system:role:edit"})
/* */ @PostMapping({"/changeStatus"})
/* */ @ResponseBody
/* */ public AjaxResult changeStatus(Role role) {
/* 211 */ this.roleService.checkRoleAllowed(role);
/* 212 */ return toAjax(this.roleService.changeStatus(role));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @RequiresPermissions({"system:role:edit"})
/* */ @GetMapping({"/authUser/{roleId}"})
/* */ public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap) {
/* 222 */ mmap.put("role", this.roleService.selectRoleById(roleId));
/* 223 */ return this.prefix + "/authUser";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @RequiresPermissions({"system:role:list"})
/* */ @PostMapping({"/authUser/allocatedList"})
/* */ @ResponseBody
/* */ public TableDataInfo allocatedList(User user) {
/* 234 */ startPage();
/* 235 */ List<User> list = this.userService.selectAllocatedList(user);
/* 236 */ return getDataTable(list);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Log(title = "角色管理", businessType = BusinessType.GRANT)
/* */ @PostMapping({"/authUser/cancel"})
/* */ @ResponseBody
/* */ public AjaxResult cancelAuthUser(UserRole userRole) {
/* 247 */ return toAjax(this.roleService.deleteAuthUser(userRole));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Log(title = "角色管理", businessType = BusinessType.GRANT)
/* */ @PostMapping({"/authUser/cancelAll"})
/* */ @ResponseBody
/* */ public AjaxResult cancelAuthUserAll(Long roleId, String userIds) {
/* 258 */ return toAjax(this.roleService.deleteAuthUsers(roleId, userIds));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @GetMapping({"/authUser/selectUser/{roleId}"})
/* */ public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap) {
/* 267 */ mmap.put("role", this.roleService.selectRoleById(roleId));
/* 268 */ return this.prefix + "/selectUser";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @RequiresPermissions({"system:role:list"})
/* */ @PostMapping({"/authUser/unallocatedList"})
/* */ @ResponseBody
/* */ public TableDataInfo unallocatedList(User user) {
/* 279 */ startPage();
/* 280 */ List<User> list = this.userService.selectUnallocatedList(user);
/* 281 */ return getDataTable(list);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ @Log(title = "角色管理", businessType = BusinessType.GRANT)
/* */ @PostMapping({"/authUser/selectAll"})
/* */ @ResponseBody
/* */ public AjaxResult selectAuthUserAll(Long roleId, String userIds) {
/* 292 */ return toAjax(this.roleService.insertAuthUsers(roleId, userIds));
/* */ }
/* */ }
import com.archive.common.utils.poi.ExcelUtil;
import com.archive.common.utils.security.AuthorizationUtils;
import com.archive.framework.aspectj.lang.annotation.Log;
import com.archive.framework.aspectj.lang.enums.BusinessType;
import com.archive.framework.web.controller.BaseController;
import com.archive.framework.web.domain.AjaxResult;
import com.archive.framework.web.page.TableDataInfo;
import com.archive.project.system.role.domain.Role;
import com.archive.project.system.role.service.IRoleService;
import com.archive.project.system.user.domain.User;
import com.archive.project.system.user.domain.UserRole;
import com.archive.project.system.user.service.IUserService;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping({"/system/role"})
public class RoleController
extends BaseController
{
private String prefix = "system/role";
@Autowired
private IRoleService roleService;
@Autowired
private IUserService userService;
@RequiresPermissions({"system:role:view"})
@GetMapping
public String role() {
return this.prefix + "/role";
}
@RequiresPermissions({"system:role:list"})
@PostMapping({"/list"})
@ResponseBody
public TableDataInfo list(Role role) {
startPage();
List<Role> list = this.roleService.selectRoleList(role);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@RequiresPermissions({"system:role:export"})
@PostMapping({"/export"})
@ResponseBody
public AjaxResult export(Role role) {
List<Role> list = this.roleService.selectRoleList(role);
ExcelUtil<Role> util = new ExcelUtil(Role.class);
return util.exportExcel(list, "角色数据");
}
@GetMapping({"/add"})
public String add() {
return this.prefix + "/add";
}
@RequiresPermissions({"system:role:add"})
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping({"/add"})
@ResponseBody
public AjaxResult addSave(@Validated Role role) {
if ("1".equals(this.roleService.checkRoleNameUnique(role)))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
if ("1".equals(this.roleService.checkRoleKeyUnique(role)))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(this.roleService.insertRole(role));
}
@GetMapping({"/edit/{roleId}"})
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", this.roleService.selectRoleById(roleId));
return this.prefix + "/edit";
}
@RequiresPermissions({"system:role:edit"})
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping({"/edit"})
@ResponseBody
public AjaxResult editSave(@Validated Role role) {
this.roleService.checkRoleAllowed(role);
if ("1".equals(this.roleService.checkRoleNameUnique(role)))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
if ("1".equals(this.roleService.checkRoleKeyUnique(role)))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
AuthorizationUtils.clearAllCachedAuthorizationInfo();
return toAjax(this.roleService.updateRole(role));
}
@GetMapping({"/authDataScope/{roleId}"})
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", this.roleService.selectRoleById(roleId));
return this.prefix + "/dataScope";
}
@RequiresPermissions({"system:role:edit"})
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping({"/authDataScope"})
@ResponseBody
public AjaxResult authDataScopeSave(Role role) {
this.roleService.checkRoleAllowed(role);
if (this.roleService.authDataScope(role) > 0) {
setSysUser(this.userService.selectUserById(getSysUser().getUserId()));
return success();
}
return error();
}
@RequiresPermissions({"system:role:remove"})
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@PostMapping({"/remove"})
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(this.roleService.deleteRoleByIds(ids));
}
@PostMapping({"/checkRoleNameUnique"})
@ResponseBody
public String checkRoleNameUnique(Role role) {
return this.roleService.checkRoleNameUnique(role);
}
@PostMapping({"/checkRoleKeyUnique"})
@ResponseBody
public String checkRoleKeyUnique(Role role) {
return this.roleService.checkRoleKeyUnique(role);
}
@GetMapping({"/selectMenuTree"})
public String selectMenuTree() {
return this.prefix + "/tree";
}
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@RequiresPermissions({"system:role:edit"})
@PostMapping({"/changeStatus"})
@ResponseBody
public AjaxResult changeStatus(Role role) {
this.roleService.checkRoleAllowed(role);
return toAjax(this.roleService.changeStatus(role));
}
@RequiresPermissions({"system:role:edit"})
@GetMapping({"/authUser/{roleId}"})
public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", this.roleService.selectRoleById(roleId));
return this.prefix + "/authUser";
}
@RequiresPermissions({"system:role:list"})
@PostMapping({"/authUser/allocatedList"})
@ResponseBody
public TableDataInfo allocatedList(User user) {
startPage();
List<User> list = this.userService.selectAllocatedList(user);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping({"/authUser/cancel"})
@ResponseBody
public AjaxResult cancelAuthUser(UserRole userRole) {
return toAjax(this.roleService.deleteAuthUser(userRole));
}
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping({"/authUser/cancelAll"})
@ResponseBody
public AjaxResult cancelAuthUserAll(Long roleId, String userIds) {
return toAjax(this.roleService.deleteAuthUsers(roleId, userIds));
}
@GetMapping({"/authUser/selectUser/{roleId}"})
public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap) {
mmap.put("role", this.roleService.selectRoleById(roleId));
return this.prefix + "/selectUser";
}
@RequiresPermissions({"system:role:list"})
@PostMapping({"/authUser/unallocatedList"})
@ResponseBody
public TableDataInfo unallocatedList(User user) {
startPage();
List<User> list = this.userService.selectUnallocatedList(user);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping({"/authUser/selectAll"})
@ResponseBody
public AjaxResult selectAuthUserAll(Long roleId, String userIds) {
return toAjax(this.roleService.insertAuthUsers(roleId, userIds));
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\role\controller\RoleController.class

@ -1,203 +1,203 @@
/* */ package com.archive.project.system.role.domain
package com.archive.project.system.role.domain
;
/* */
/* */ import com.archive.framework.aspectj.lang.annotation.ColumnType;
import com.archive.framework.aspectj.lang.annotation.ColumnType;
import com.archive.framework.aspectj.lang.annotation.Excel;
/* */ import com.archive.framework.web.domain.BaseEntity;
/* */ import javax.validation.constraints.NotBlank;
/* */ import javax.validation.constraints.Size;
/* */ import org.apache.commons.lang3.builder.ToStringBuilder;
/* */ import org.apache.commons.lang3.builder.ToStringStyle;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Role
/* */ extends BaseEntity
/* */ {
/* */ private static final long serialVersionUID = 1L;
/* */ @Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
/* */ private Long roleId;
/* */ @Excel(name = "角色名称")
/* */ private String roleName;
/* */ @Excel(name = "角色权限")
/* */ private String roleKey;
/* */ @Excel(name = "角色排序")
/* */ private String roleSort;
/* */ @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
/* */ private String dataScope;
/* */ @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
/* */ private String status;
/* */ private String delFlag;
/* */ private boolean flag = false;
/* */ private Long[] menuIds;
/* */ private Long[] deptIds;
/* */
/* */ public Role() {}
/* */
/* */ public Role(Long roleId) {
/* 62 */ this.roleId = roleId;
/* */ }
/* */
/* */
/* */ public Long getRoleId() {
/* 67 */ return this.roleId;
/* */ }
/* */
/* */
/* */ public void setRoleId(Long roleId) {
/* 72 */ this.roleId = roleId;
/* */ }
/* */
/* */
/* */ public boolean isAdmin() {
/* 77 */ return isAdmin(this.roleId);
/* */ }
/* */
/* */
/* */ public static boolean isAdmin(Long roleId) {
/* 82 */ return (roleId != null && 1L == roleId.longValue());
/* */ }
/* */
/* */
/* */ public String getDataScope() {
/* 87 */ return this.dataScope;
/* */ }
/* */
/* */
/* */ public void setDataScope(String dataScope) {
/* 92 */ this.dataScope = dataScope;
/* */ }
/* */
/* */
/* */ @NotBlank(message = "角色名称不能为空")
/* */ @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
/* */ public String getRoleName() {
/* 99 */ return this.roleName;
/* */ }
/* */
/* */
/* */ public void setRoleName(String roleName) {
/* 104 */ this.roleName = roleName;
/* */ }
/* */
/* */
/* */ @NotBlank(message = "权限字符不能为空")
/* */ @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
/* */ public String getRoleKey() {
/* 111 */ return this.roleKey;
/* */ }
/* */
/* */
/* */ public void setRoleKey(String roleKey) {
/* 116 */ this.roleKey = roleKey;
/* */ }
/* */
/* */
/* */ @NotBlank(message = "显示顺序不能为空")
/* */ public String getRoleSort() {
/* 122 */ return this.roleSort;
/* */ }
/* */
/* */
/* */ public void setRoleSort(String roleSort) {
/* 127 */ this.roleSort = roleSort;
/* */ }
/* */
/* */
/* */ public String getStatus() {
/* 132 */ return this.status;
/* */ }
/* */
/* */
/* */ public String getDelFlag() {
/* 137 */ return this.delFlag;
/* */ }
/* */
/* */
/* */ public void setDelFlag(String delFlag) {
/* 142 */ this.delFlag = delFlag;
/* */ }
/* */
/* */
/* */ public void setStatus(String status) {
/* 147 */ this.status = status;
/* */ }
/* */
/* */
/* */ public boolean isFlag() {
/* 152 */ return this.flag;
/* */ }
/* */
/* */
/* */ public void setFlag(boolean flag) {
/* 157 */ this.flag = flag;
/* */ }
/* */
/* */
/* */ public Long[] getMenuIds() {
/* 162 */ return this.menuIds;
/* */ }
/* */
/* */
/* */ public void setMenuIds(Long[] menuIds) {
/* 167 */ this.menuIds = menuIds;
/* */ }
/* */
/* */
/* */ public Long[] getDeptIds() {
/* 172 */ return this.deptIds;
/* */ }
/* */
/* */
/* */ public void setDeptIds(Long[] deptIds) {
/* 177 */ this.deptIds = deptIds;
/* */ }
/* */
/* */
/* */ public String toString() {
/* 182 */ return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE))
/* 183 */ .append("roleId", getRoleId())
/* 184 */ .append("roleName", getRoleName())
/* 185 */ .append("roleKey", getRoleKey())
/* 186 */ .append("roleSort", getRoleSort())
/* 187 */ .append("dataScope", getDataScope())
/* 188 */ .append("status", getStatus())
/* 189 */ .append("delFlag", getDelFlag())
/* 190 */ .append("createBy", getCreateBy())
/* 191 */ .append("createTime", getCreateTime())
/* 192 */ .append("updateBy", getUpdateBy())
/* 193 */ .append("updateTime", getUpdateTime())
/* 194 */ .append("remark", getRemark())
/* 195 */ .toString();
/* */ }
/* */ }
import com.archive.framework.web.domain.BaseEntity;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class Role
extends BaseEntity
{
private static final long serialVersionUID = 1L;
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
private Long roleId;
@Excel(name = "角色名称")
private String roleName;
@Excel(name = "角色权限")
private String roleKey;
@Excel(name = "角色排序")
private String roleSort;
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
private String dataScope;
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
private String status;
private String delFlag;
private boolean flag = false;
private Long[] menuIds;
private Long[] deptIds;
public Role() {}
public Role(Long roleId) {
this.roleId = roleId;
}
public Long getRoleId() {
return this.roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public boolean isAdmin() {
return isAdmin(this.roleId);
}
public static boolean isAdmin(Long roleId) {
return (roleId != null && 1L == roleId.longValue());
}
public String getDataScope() {
return this.dataScope;
}
public void setDataScope(String dataScope) {
this.dataScope = dataScope;
}
@NotBlank(message = "角色名称不能为空")
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
public String getRoleName() {
return this.roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
@NotBlank(message = "权限字符不能为空")
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
public String getRoleKey() {
return this.roleKey;
}
public void setRoleKey(String roleKey) {
this.roleKey = roleKey;
}
@NotBlank(message = "显示顺序不能为空")
public String getRoleSort() {
return this.roleSort;
}
public void setRoleSort(String roleSort) {
this.roleSort = roleSort;
}
public String getStatus() {
return this.status;
}
public String getDelFlag() {
return this.delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public void setStatus(String status) {
this.status = status;
}
public boolean isFlag() {
return this.flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public Long[] getMenuIds() {
return this.menuIds;
}
public void setMenuIds(Long[] menuIds) {
this.menuIds = menuIds;
}
public Long[] getDeptIds() {
return this.deptIds;
}
public void setDeptIds(Long[] deptIds) {
this.deptIds = deptIds;
}
public String toString() {
return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE))
.append("roleId", getRoleId())
.append("roleName", getRoleName())
.append("roleKey", getRoleKey())
.append("roleSort", getRoleSort())
.append("dataScope", getDataScope())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\role\domain\Role.class

@ -1,51 +1,51 @@
/* */ package com.archive.project.system.role.domain
package com.archive.project.system.role.domain
;
/* */
/* */ import org.apache.commons.lang3.builder.ToStringBuilder;
/* */ import org.apache.commons.lang3.builder.ToStringStyle;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class RoleDept
/* */ {
/* */ private Long roleId;
/* */ private Long deptId;
/* */
/* */ public Long getRoleId() {
/* 21 */ return this.roleId;
/* */ }
/* */
/* */
/* */ public void setRoleId(Long roleId) {
/* 26 */ this.roleId = roleId;
/* */ }
/* */
/* */
/* */ public Long getDeptId() {
/* 31 */ return this.deptId;
/* */ }
/* */
/* */
/* */ public void setDeptId(Long deptId) {
/* 36 */ this.deptId = deptId;
/* */ }
/* */
/* */
/* */ public String toString() {
/* 41 */ return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE))
/* 42 */ .append("roleId", getRoleId())
/* 43 */ .append("deptId", getDeptId())
/* 44 */ .toString();
/* */ }
/* */ }
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class RoleDept
{
private Long roleId;
private Long deptId;
public Long getRoleId() {
return this.roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Long getDeptId() {
return this.deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String toString() {
return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE))
.append("roleId", getRoleId())
.append("deptId", getDeptId())
.toString();
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\role\domain\RoleDept.class

@ -1,51 +1,51 @@
/* */ package com.archive.project.system.role.domain
package com.archive.project.system.role.domain
;
/* */
/* */ import org.apache.commons.lang3.builder.ToStringBuilder;
/* */ import org.apache.commons.lang3.builder.ToStringStyle;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class RoleMenu
/* */ {
/* */ private Long roleId;
/* */ private Long menuId;
/* */
/* */ public Long getRoleId() {
/* 21 */ return this.roleId;
/* */ }
/* */
/* */
/* */ public void setRoleId(Long roleId) {
/* 26 */ this.roleId = roleId;
/* */ }
/* */
/* */
/* */ public Long getMenuId() {
/* 31 */ return this.menuId;
/* */ }
/* */
/* */
/* */ public void setMenuId(Long menuId) {
/* 36 */ this.menuId = menuId;
/* */ }
/* */
/* */
/* */ public String toString() {
/* 41 */ return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE))
/* 42 */ .append("roleId", getRoleId())
/* 43 */ .append("menuId", getMenuId())
/* 44 */ .toString();
/* */ }
/* */ }
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class RoleMenu
{
private Long roleId;
private Long menuId;
public Long getRoleId() {
return this.roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Long getMenuId() {
return this.menuId;
}
public void setMenuId(Long menuId) {
this.menuId = menuId;
}
public String toString() {
return (new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE))
.append("roleId", getRoleId())
.append("menuId", getMenuId())
.toString();
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\role\domain\RoleMenu.class

@ -1,436 +1,436 @@
/* */ package com.archive.project.system.role.service
package com.archive.project.system.role.service
;
/* */
/* */ import com.archive.common.exception.BusinessException;
/* */ import com.archive.common.utils.StringUtils;
/* */ import com.archive.common.utils.security.ShiroUtils;
/* */ import com.archive.common.utils.spring.SpringUtils;
/* */ import com.archive.common.utils.text.Convert;
/* */ import com.archive.framework.aspectj.lang.annotation.DataScope;
/* */ import com.archive.framework.config.ArchiveConfig;
/* */ import com.archive.project.system.role.domain.Role;
/* */ import com.archive.project.system.role.domain.RoleDept;
/* */ import com.archive.project.system.role.domain.RoleMenu;
/* */ import com.archive.project.system.role.mapper.RoleDeptMapper;
/* */ import com.archive.project.system.role.mapper.RoleMapper;
/* */ import com.archive.project.system.role.mapper.RoleMenuMapper;
/* */ import com.archive.project.system.role.service.IRoleService;
/* */ import com.archive.project.system.user.domain.UserRole;
/* */ import com.archive.project.system.user.mapper.UserRoleMapper;
/* */ import java.util.ArrayList;
/* */ import java.util.Arrays;
/* */ import java.util.HashSet;
/* */ import java.util.List;
/* */ import java.util.Set;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Service;
/* */ import org.springframework.transaction.annotation.Transactional;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Service
/* */ public class RoleServiceImpl
/* */ implements IRoleService
/* */ {
/* */ @Autowired
/* */ private RoleMapper roleMapper;
/* */ @Autowired
/* */ private RoleMenuMapper roleMenuMapper;
/* */ @Autowired
/* */ private UserRoleMapper userRoleMapper;
/* */ @Autowired
/* */ private RoleDeptMapper roleDeptMapper;
/* */ @Autowired
/* */ private ArchiveConfig archiveConfig;
/* */
/* */ @DataScope(deptAlias = "d")
/* */ public List<Role> selectRoleList(Role role) {
/* 63 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
/* 64 */ return this.roleMapper.selectRoleList(role);
/* */ }
/* 66 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
/* 67 */ return this.roleMapper.selectRoleListSqlite(role);
/* */ }
/* 69 */ return this.roleMapper.selectRoleList(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public Set<String> selectRoleKeys(Long userId) {
/* 86 */ List<Role> perms = this.roleMapper.selectRolesByUserId(userId);
/* 87 */ Set<String> permsSet = new HashSet<>();
/* 88 */ for (Role perm : perms) {
/* */
/* 90 */ if (StringUtils.isNotNull(perm))
/* */ {
/* 92 */ permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
/* */ }
/* */ }
/* 95 */ return permsSet;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public List<Role> selectRolesByUserId(Long userId) {
/* 107 */ List<Role> userRoles = this.roleMapper.selectRolesByUserId(userId);
/* 108 */ List<Role> roles = selectRoleAll();
/* 109 */ for (Role role : roles) {
/* */
/* 111 */ for (Role userRole : userRoles) {
/* */
/* 113 */ if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
/* */ {
/* 115 */ role.setFlag(true);
/* */ }
/* */ }
/* */ }
/* */
/* 120 */ return roles;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public List<Role> selectRoleAll() {
/* 131 */ return ((com.archive.project.system.role.service.RoleServiceImpl)SpringUtils.getAopProxy(this)).selectRoleList(new Role());
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public Role selectRoleById(Long roleId) {
/* 143 */ return this.roleMapper.selectRoleById(roleId);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Transactional
/* */ public boolean deleteRoleById(Long roleId) {
/* 157 */ this.roleMenuMapper.deleteRoleMenuByRoleId(roleId);
/* */
/* 159 */ this.roleDeptMapper.deleteRoleDeptByRoleId(roleId);
/* 160 */ return (this.roleMapper.deleteRoleById(roleId) > 0);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Transactional
/* */ public int deleteRoleByIds(String ids) {
/* 173 */ Long[] roleIds = Convert.toLongArray(ids);
/* 174 */ for (Long roleId : roleIds) {
/* */
/* 176 */ checkRoleAllowed(new Role(roleId));
/* 177 */ Role role = selectRoleById(roleId);
/* 178 */ if (countUserRoleByRoleId(roleId) > 0)
/* */ {
/* 180 */ throw new BusinessException(String.format("%1$s已分配,不能删除", new Object[] { role.getRoleName() }));
/* */ }
/* */ }
/* */
/* 184 */ this.roleMenuMapper.deleteRoleMenu(roleIds);
/* */
/* 186 */ this.roleDeptMapper.deleteRoleDept(roleIds);
/* 187 */ return this.roleMapper.deleteRoleByIds(roleIds);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Transactional
/* */ public int insertRole(Role role) {
/* 200 */ role.setCreateBy(ShiroUtils.getLoginName());
/* */
/* 202 */ this.roleMapper.insertRole(role);
/* 203 */ return insertRoleMenu(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Transactional
/* */ public int updateRole(Role role) {
/* 216 */ role.setUpdateBy(ShiroUtils.getLoginName());
/* */
/* 218 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
/* 219 */ this.roleMapper.updateRole(role);
/* */ }
/* 221 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
/* 222 */ this.roleMapper.updateRoleSqlite(role);
/* */ }
/* */
/* */
/* 226 */ this.roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
/* 227 */ return insertRoleMenu(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Transactional
/* */ public int authDataScope(Role role) {
/* 240 */ role.setUpdateBy(ShiroUtils.getLoginName());
/* */
/* 242 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
/* 243 */ this.roleMapper.updateRole(role);
/* */ }
/* 245 */ else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
/* 246 */ this.roleMapper.updateRoleSqlite(role);
/* */ }
/* */
/* 249 */ this.roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
/* */
/* 251 */ return insertRoleDept(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int insertRoleMenu(Role role) {
/* 261 */ int rows = 1;
/* */
/* 263 */ List<RoleMenu> list = new ArrayList<>();
/* 264 */ for (Long menuId : role.getMenuIds()) {
/* */
/* 266 */ RoleMenu rm = new RoleMenu();
/* 267 */ rm.setRoleId(role.getRoleId());
/* 268 */ rm.setMenuId(menuId);
/* 269 */ list.add(rm);
/* */ }
/* 271 */ if (list.size() > 0)
/* */ {
/* 273 */ rows = this.roleMenuMapper.batchRoleMenu(list);
/* */ }
/* 275 */ return rows;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int insertRoleDept(Role role) {
/* 285 */ int rows = 1;
/* */
/* 287 */ List<RoleDept> list = new ArrayList<>();
/* 288 */ for (Long deptId : role.getDeptIds()) {
/* */
/* 290 */ RoleDept rd = new RoleDept();
/* 291 */ rd.setRoleId(role.getRoleId());
/* 292 */ rd.setDeptId(deptId);
/* 293 */ list.add(rd);
/* */ }
/* 295 */ if (list.size() > 0)
/* */ {
/* 297 */ rows = this.roleDeptMapper.batchRoleDept(list);
/* */ }
/* 299 */ return rows;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public String checkRoleNameUnique(Role role) {
/* 311 */ Long roleId = Long.valueOf(StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId().longValue());
/* 312 */ Role info = this.roleMapper.checkRoleNameUnique(role.getRoleName());
/* 313 */ if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
/* */ {
/* 315 */ return "1";
/* */ }
/* 317 */ return "0";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public String checkRoleKeyUnique(Role role) {
/* 329 */ Long roleId = Long.valueOf(StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId().longValue());
/* 330 */ Role info = this.roleMapper.checkRoleKeyUnique(role.getRoleKey());
/* 331 */ if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
/* */ {
/* 333 */ return "1";
/* */ }
/* 335 */ return "0";
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void checkRoleAllowed(Role role) {
/* 346 */ if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
/* */ {
/* 348 */ throw new BusinessException("不允许操作超级管理员角色");
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int countUserRoleByRoleId(Long roleId) {
/* 361 */ return this.userRoleMapper.countUserRoleByRoleId(roleId);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int changeStatus(Role role) {
/* 373 */ if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
/* 374 */ return this.roleMapper.updateRole(role);
/* */ }
/* 376 */ if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
/* 377 */ return this.roleMapper.updateRoleSqlite(role);
/* */ }
/* 379 */ return this.roleMapper.updateRole(role);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int deleteAuthUser(UserRole userRole) {
/* 393 */ return this.userRoleMapper.deleteUserRoleInfo(userRole);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int deleteAuthUsers(Long roleId, String userIds) {
/* 406 */ return this.userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int insertAuthUsers(Long roleId, String userIds) {
/* 419 */ Long[] users = Convert.toLongArray(userIds);
/* */
/* 421 */ List<UserRole> list = new ArrayList<>();
/* 422 */ for (Long userId : users) {
/* */
/* 424 */ UserRole ur = new UserRole();
/* 425 */ ur.setUserId(userId);
/* 426 */ ur.setRoleId(roleId);
/* 427 */ list.add(ur);
/* */ }
/* 429 */ return this.userRoleMapper.batchUserRole(list);
/* */ }
/* */ }
import com.archive.common.exception.BusinessException;
import com.archive.common.utils.StringUtils;
import com.archive.common.utils.security.ShiroUtils;
import com.archive.common.utils.spring.SpringUtils;
import com.archive.common.utils.text.Convert;
import com.archive.framework.aspectj.lang.annotation.DataScope;
import com.archive.framework.config.ArchiveConfig;
import com.archive.project.system.role.domain.Role;
import com.archive.project.system.role.domain.RoleDept;
import com.archive.project.system.role.domain.RoleMenu;
import com.archive.project.system.role.mapper.RoleDeptMapper;
import com.archive.project.system.role.mapper.RoleMapper;
import com.archive.project.system.role.mapper.RoleMenuMapper;
import com.archive.project.system.role.service.IRoleService;
import com.archive.project.system.user.domain.UserRole;
import com.archive.project.system.user.mapper.UserRoleMapper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class RoleServiceImpl
implements IRoleService
{
@Autowired
private RoleMapper roleMapper;
@Autowired
private RoleMenuMapper roleMenuMapper;
@Autowired
private UserRoleMapper userRoleMapper;
@Autowired
private RoleDeptMapper roleDeptMapper;
@Autowired
private ArchiveConfig archiveConfig;
@DataScope(deptAlias = "d")
public List<Role> selectRoleList(Role role) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
return this.roleMapper.selectRoleList(role);
}
if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
return this.roleMapper.selectRoleListSqlite(role);
}
return this.roleMapper.selectRoleList(role);
}
public Set<String> selectRoleKeys(Long userId) {
List<Role> perms = this.roleMapper.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (Role perm : perms) {
if (StringUtils.isNotNull(perm))
{
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
public List<Role> selectRolesByUserId(Long userId) {
List<Role> userRoles = this.roleMapper.selectRolesByUserId(userId);
List<Role> roles = selectRoleAll();
for (Role role : roles) {
for (Role userRole : userRoles) {
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
{
role.setFlag(true);
}
}
}
return roles;
}
public List<Role> selectRoleAll() {
return ((com.archive.project.system.role.service.RoleServiceImpl)SpringUtils.getAopProxy(this)).selectRoleList(new Role());
}
public Role selectRoleById(Long roleId) {
return this.roleMapper.selectRoleById(roleId);
}
@Transactional
public boolean deleteRoleById(Long roleId) {
this.roleMenuMapper.deleteRoleMenuByRoleId(roleId);
this.roleDeptMapper.deleteRoleDeptByRoleId(roleId);
return (this.roleMapper.deleteRoleById(roleId) > 0);
}
@Transactional
public int deleteRoleByIds(String ids) {
Long[] roleIds = Convert.toLongArray(ids);
for (Long roleId : roleIds) {
checkRoleAllowed(new Role(roleId));
Role role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0)
{
throw new BusinessException(String.format("%1$s已分配,不能删除", new Object[] { role.getRoleName() }));
}
}
this.roleMenuMapper.deleteRoleMenu(roleIds);
this.roleDeptMapper.deleteRoleDept(roleIds);
return this.roleMapper.deleteRoleByIds(roleIds);
}
@Transactional
public int insertRole(Role role) {
role.setCreateBy(ShiroUtils.getLoginName());
this.roleMapper.insertRole(role);
return insertRoleMenu(role);
}
@Transactional
public int updateRole(Role role) {
role.setUpdateBy(ShiroUtils.getLoginName());
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
this.roleMapper.updateRole(role);
}
else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
this.roleMapper.updateRoleSqlite(role);
}
this.roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
return insertRoleMenu(role);
}
@Transactional
public int authDataScope(Role role) {
role.setUpdateBy(ShiroUtils.getLoginName());
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
this.roleMapper.updateRole(role);
}
else if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
this.roleMapper.updateRoleSqlite(role);
}
this.roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId());
return insertRoleDept(role);
}
public int insertRoleMenu(Role role) {
int rows = 1;
List<RoleMenu> list = new ArrayList<>();
for (Long menuId : role.getMenuIds()) {
RoleMenu rm = new RoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0)
{
rows = this.roleMenuMapper.batchRoleMenu(list);
}
return rows;
}
public int insertRoleDept(Role role) {
int rows = 1;
List<RoleDept> list = new ArrayList<>();
for (Long deptId : role.getDeptIds()) {
RoleDept rd = new RoleDept();
rd.setRoleId(role.getRoleId());
rd.setDeptId(deptId);
list.add(rd);
}
if (list.size() > 0)
{
rows = this.roleDeptMapper.batchRoleDept(list);
}
return rows;
}
public String checkRoleNameUnique(Role role) {
Long roleId = Long.valueOf(StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId().longValue());
Role info = this.roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return "1";
}
return "0";
}
public String checkRoleKeyUnique(Role role) {
Long roleId = Long.valueOf(StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId().longValue());
Role info = this.roleMapper.checkRoleKeyUnique(role.getRoleKey());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return "1";
}
return "0";
}
public void checkRoleAllowed(Role role) {
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
{
throw new BusinessException("不允许操作超级管理员角色");
}
}
public int countUserRoleByRoleId(Long roleId) {
return this.userRoleMapper.countUserRoleByRoleId(roleId);
}
public int changeStatus(Role role) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
return this.roleMapper.updateRole(role);
}
if ("sqlite".equals(this.archiveConfig.getDatabaseType())) {
return this.roleMapper.updateRoleSqlite(role);
}
return this.roleMapper.updateRole(role);
}
public int deleteAuthUser(UserRole userRole) {
return this.userRoleMapper.deleteUserRoleInfo(userRole);
}
public int deleteAuthUsers(Long roleId, String userIds) {
return this.userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds));
}
public int insertAuthUsers(Long roleId, String userIds) {
Long[] users = Convert.toLongArray(userIds);
List<UserRole> list = new ArrayList<>();
for (Long userId : users) {
UserRole ur = new UserRole();
ur.setUserId(userId);
ur.setRoleId(roleId);
list.add(ur);
}
return this.userRoleMapper.batchUserRole(list);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\role\service\RoleServiceImpl.class

@ -1,51 +1,51 @@
/* */ package com.archive.project.system.user.controller
package com.archive.project.system.user.controller
;
/* */
/* */ import com.archive.framework.shiro.service.RegisterService;
/* */ import com.archive.framework.web.controller.BaseController;
/* */ import com.archive.framework.web.domain.AjaxResult;
/* */ import com.archive.project.system.config.service.IConfigService;
/* */ import com.archive.project.system.user.domain.User;
/* */ import org.springframework.beans.factory.annotation.Autowired;
/* */ import org.springframework.stereotype.Controller;
/* */ import org.springframework.util.StringUtils;
/* */ import org.springframework.web.bind.annotation.GetMapping;
/* */ import org.springframework.web.bind.annotation.PostMapping;
/* */ import org.springframework.web.bind.annotation.ResponseBody;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ @Controller
/* */ public class RegisterController
/* */ extends BaseController
/* */ {
/* */ @Autowired
/* */ private RegisterService registerService;
/* */ @Autowired
/* */ private IConfigService configService;
/* */
/* */ @GetMapping({"/register"})
/* */ public String register() {
/* 32 */ return "register";
/* */ }
/* */
/* */
/* */ @PostMapping({"/register"})
/* */ @ResponseBody
/* */ public AjaxResult ajaxRegister(User user) {
/* 39 */ if (!"true".equals(this.configService.selectConfigByKey("sys.account.registerUser")))
/* */ {
/* 41 */ return error("当前系统没有开启注册功能!");
/* */ }
/* 43 */ String msg = this.registerService.register(user);
/* 44 */ return StringUtils.isEmpty(msg) ? success() : error(msg);
/* */ }
/* */ }
import com.archive.framework.shiro.service.RegisterService;
import com.archive.framework.web.controller.BaseController;
import com.archive.framework.web.domain.AjaxResult;
import com.archive.project.system.config.service.IConfigService;
import com.archive.project.system.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class RegisterController
extends BaseController
{
@Autowired
private RegisterService registerService;
@Autowired
private IConfigService configService;
@GetMapping({"/register"})
public String register() {
return "register";
}
@PostMapping({"/register"})
@ResponseBody
public AjaxResult ajaxRegister(User user) {
if (!"true".equals(this.configService.selectConfigByKey("sys.account.registerUser")))
{
return error("当前系统没有开启注册功能!");
}
String msg = this.registerService.register(user);
return StringUtils.isEmpty(msg) ? success() : error(msg);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\syste\\user\controller\RegisterController.class

Loading…
Cancel
Save