mappings = new HashMap<>(16);
+
+ static
+ {
+ for (HttpMethod httpMethod : values())
+ {
+ mappings.put(httpMethod.name(), httpMethod);
+ }
+ }
+
+ @Nullable
+ public static HttpMethod resolve(@Nullable String method)
+ {
+ return (method != null ? mappings.get(method) : null);
+ }
+
+ public boolean matches(String method)
+ {
+ return (this == resolve(method));
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java
new file mode 100644
index 0000000..c609fd8
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java
@@ -0,0 +1,20 @@
+package com.ruoyi.common.enums;
+
+/**
+ * 限流类型
+ *
+ * @author ruoyi
+ */
+
+public enum LimitType
+{
+ /**
+ * 默认策略全局限流
+ */
+ DEFAULT,
+
+ /**
+ * 根据请求者IP进行限流
+ */
+ IP
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java
new file mode 100644
index 0000000..bdd143c
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java
@@ -0,0 +1,24 @@
+package com.ruoyi.common.enums;
+
+/**
+ * 操作人类别
+ *
+ * @author ruoyi
+ */
+public enum OperatorType
+{
+ /**
+ * 其它
+ */
+ OTHER,
+
+ /**
+ * 后台用户
+ */
+ MANAGE,
+
+ /**
+ * 手机端用户
+ */
+ MOBILE
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java
new file mode 100644
index 0000000..d7ff44a
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java
@@ -0,0 +1,30 @@
+package com.ruoyi.common.enums;
+
+/**
+ * 用户状态
+ *
+ * @author ruoyi
+ */
+public enum UserStatus
+{
+ OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
+
+ private final String code;
+ private final String info;
+
+ UserStatus(String code, String info)
+ {
+ this.code = code;
+ this.info = info;
+ }
+
+ public String getCode()
+ {
+ return code;
+ }
+
+ public String getInfo()
+ {
+ return info;
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java
new file mode 100644
index 0000000..1a51de4
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java
@@ -0,0 +1,53 @@
+
+package com.ruoyi.common.exception;
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 业务异常
+ *
+ * @author xuyuxiang
+ * @date 2020/4/8 15:54
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class CustomException extends RuntimeException {
+
+ private Integer code;
+
+ private String errorMessage;
+
+
+ private List objectList = new ArrayList();
+
+ public CustomException(Integer code, String errorMessage) {
+ super(errorMessage);
+ this.code = code;
+ this.errorMessage = errorMessage;
+ }
+
+ public CustomException(String errorMessage) {
+ super(errorMessage);
+ this.code = 500;
+ this.errorMessage = errorMessage;
+ }
+
+ public CustomException(AbstractBaseExceptionEnum exception) {
+ super(exception.getMessage());
+ this.code = exception.getCode();
+ this.errorMessage = exception.getMessage();
+ }
+
+ public CustomException(AbstractBaseExceptionEnum exception, List objectList) {
+ super(exception.getMessage());
+ this.code = exception.getCode();
+ this.errorMessage = exception.getMessage();
+ this.objectList = objectList;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java
new file mode 100644
index 0000000..f6ad2ab
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java
@@ -0,0 +1,15 @@
+package com.ruoyi.common.exception;
+
+/**
+ * 演示模式异常
+ *
+ * @author ruoyi
+ */
+public class DemoModeException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public DemoModeException()
+ {
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java
new file mode 100644
index 0000000..0bb6768
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java
@@ -0,0 +1,59 @@
+package com.ruoyi.common.exception;
+
+/**
+ * 全局异常
+ *
+ * @author ruoyi
+ */
+public class GlobalException extends RuntimeException
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 错误提示
+ */
+ private String message;
+
+ /**
+ * 错误明细,内部调试错误
+ *
+ * 和 {@link CommonResult#getDetailMessage()} 一致的设计
+ */
+ private String detailMessage;
+
+ /**
+ * 空构造方法,避免反序列化问题
+ */
+ public GlobalException()
+ {
+ }
+
+ public GlobalException(String message)
+ {
+ this.message = message;
+ }
+
+ public String getDetailMessage()
+ {
+ return detailMessage;
+ }
+
+ public GlobalException setDetailMessage(String detailMessage)
+ {
+ this.detailMessage = detailMessage;
+ return this;
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public GlobalException setMessage(String message)
+ {
+ this.message = message;
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java
new file mode 100644
index 0000000..ac53760
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java
@@ -0,0 +1,84 @@
+package com.ruoyi.common.exception;
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 业务异常
+ *
+ * @author ruoyi
+ */
+public final class ServiceException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 错误码
+ */
+ private Integer code;
+
+ /**
+ * 错误提示
+ */
+ private String message;
+
+ /**
+ * 错误明细,内部调试错误
+ *
+ * 和 {@link CommonResult#getDetailMessage()} 一致的设计
+ */
+ private String detailMessage;
+
+ /**
+ * 空构造方法,避免反序列化问题
+ */
+ public ServiceException()
+ {
+ }
+
+ public ServiceException(String message)
+ {
+ this.message = message;
+ }
+
+ public ServiceException(String message, Integer code)
+ {
+ this.message = message;
+ this.code = code;
+ }
+
+ public String getDetailMessage()
+ {
+ return detailMessage;
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public Integer getCode()
+ {
+ return code;
+ }
+
+ public ServiceException setMessage(String message)
+ {
+
+ this.message = message;
+ return this;
+ }
+
+ public ServiceException setDetailMessage(String detailMessage)
+ {
+ this.detailMessage = detailMessage;
+ return this;
+ }
+
+
+ public ServiceException(AbstractBaseExceptionEnum exception) {
+ super(exception.getMessage());
+ this.code = exception.getCode();
+ this.message = exception.getMessage();
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java
new file mode 100644
index 0000000..980fa46
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java
@@ -0,0 +1,26 @@
+package com.ruoyi.common.exception;
+
+/**
+ * 工具类异常
+ *
+ * @author ruoyi
+ */
+public class UtilException extends RuntimeException
+{
+ private static final long serialVersionUID = 8247610319171014183L;
+
+ public UtilException(Throwable e)
+ {
+ super(e.getMessage(), e);
+ }
+
+ public UtilException(String message)
+ {
+ super(message);
+ }
+
+ public UtilException(String message, Throwable throwable)
+ {
+ super(message, throwable);
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java
new file mode 100644
index 0000000..b55d72e
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java
@@ -0,0 +1,97 @@
+package com.ruoyi.common.exception.base;
+
+import com.ruoyi.common.utils.MessageUtils;
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * 基础异常
+ *
+ * @author ruoyi
+ */
+public class BaseException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 所属模块
+ */
+ private String module;
+
+ /**
+ * 错误码
+ */
+ private String code;
+
+ /**
+ * 错误码对应的参数
+ */
+ private Object[] args;
+
+ /**
+ * 错误消息
+ */
+ private String defaultMessage;
+
+ public BaseException(String module, String code, Object[] args, String defaultMessage)
+ {
+ this.module = module;
+ this.code = code;
+ this.args = args;
+ this.defaultMessage = defaultMessage;
+ }
+
+ public BaseException(String module, String code, Object[] args)
+ {
+ this(module, code, args, null);
+ }
+
+ public BaseException(String module, String defaultMessage)
+ {
+ this(module, null, null, defaultMessage);
+ }
+
+ public BaseException(String code, Object[] args)
+ {
+ this(null, code, args, null);
+ }
+
+ public BaseException(String defaultMessage)
+ {
+ this(null, null, null, defaultMessage);
+ }
+
+ @Override
+ public String getMessage()
+ {
+ String message = null;
+ if (!StringUtils.isEmpty(code))
+ {
+ message = MessageUtils.message(code, args);
+ }
+ if (message == null)
+ {
+ message = defaultMessage;
+ }
+ return message;
+ }
+
+ public String getModule()
+ {
+ return module;
+ }
+
+ public String getCode()
+ {
+ return code;
+ }
+
+ public Object[] getArgs()
+ {
+ return args;
+ }
+
+ public String getDefaultMessage()
+ {
+ return defaultMessage;
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/AuthExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/AuthExceptionEnum.java
new file mode 100644
index 0000000..45eb4b8
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/AuthExceptionEnum.java
@@ -0,0 +1,109 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 认证相关的异常的枚举
+ *
+ * 认证和鉴权的区别:
+ *
+ * 认证可以证明你能登录系统,认证的过程是校验token的过程
+ * 鉴权可以证明你有系统的哪些权限,鉴权的过程是校验角色是否包含某些接口的权限
+ *
+ * @author stylefeng
+ * @date 2019/7/18 22:22
+ */
+public enum AuthExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 账号或密码为空
+ */
+ ACCOUNT_PWD_EMPTY(1, "账号或密码为空"),
+
+ /**
+ * 账号密码错误
+ */
+ ACCOUNT_PWD_ERROR(2, "账号或密码错误"),
+
+ /**
+ * 验证码错误
+ */
+ VALID_CODE_ERROR(3, "验证码错误,请检查captcha参数"),
+
+ /**
+ * 请求token为空
+ */
+ REQUEST_TOKEN_EMPTY(700, "请求token为空"),
+
+ /**
+ * token格式不正确,token请以Bearer开头
+ */
+ NOT_VALID_TOKEN_TYPE(700, "token格式不正确,token请以Bearer开头,并且Bearer后边带一个空格"),
+
+ /**
+ * 请求token错误
+ */
+ REQUEST_TOKEN_ERROR(700, "请求token错误"),
+
+ /**
+ * 账号被冻结
+ */
+ ACCOUNT_FREEZE_ERROR(7, "账号被冻结,请联系管理员"),
+
+ /**
+ * 登录已过期
+ */
+ LOGIN_EXPIRED(8, "登录已过期,请重新登录"),
+
+ /**
+ * 无登录用户
+ */
+ NO_LOGIN_USER(9, "无登录用户");
+
+
+
+ private final Integer code;
+
+ private final String message;
+
+ AuthExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/CoreExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/CoreExceptionEnum.java
new file mode 100644
index 0000000..268471f
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/CoreExceptionEnum.java
@@ -0,0 +1,138 @@
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * @author liwenlong
+ * @date 2021/11/1 19:34
+ */
+
+
+public enum CoreExceptionEnum implements AbstractBaseExceptionEnum {
+
+
+ /**
+ * 用户相关
+ */
+ REGISTER_FAIL( "注册失败"),
+ PWD_ERROR( "密码错误"),
+ ACCOUNT_NOT_EXIST( "账号不存在"),
+ ACCOUNT_DISABLE( "账号被冻结"),
+
+ PHONE_NOT_EXIST( "手机号不存在"),
+
+ MOBILE_BIND_MAKE( "请使用绑定的手机号码"),
+ ACCOUNT_HAS_EXIST( "账号已存在,请重新输入"),
+
+ PHONE_HAS_EXIST( "手机号已存在,请重新输入"),
+
+
+
+ /**
+ * 邀请码
+ */
+ REFEREE_CODE_ERROR( "邀请码错误"),
+
+
+ FIGURE_CODE_ERROR( "图形验证码错误"),
+
+ FIGURE_CODE_NOT_EXIST( "请先获取图形验证码"),
+
+
+ /**
+ * 短信
+ */
+ SMS_SEND_FAIL( "短信发送失败"),
+
+
+ /**
+ * 参数
+ */
+ ERROR_PARAM("参数错误"),
+ NOT_NULL_PARAM("参数不能为空"),
+ ERROR_DATA("数据错误"),
+
+ ERROR_FIELD_NAME("字段名称错误"),
+
+ /**
+ * 余额
+ */
+
+ PRICE_ZERO(210, "支付金额为零"),
+ BALANCE_INSUFFICIENT (220, "余额不足"),
+
+ INTEGRAL_INSUFFICIENT (230, "积分不足"),
+
+ PAY_BALANCE_ERROR (240, "支付价格错误"),
+
+ EDIT_BALANCE_ERROR (250, "余额修改错误"),
+
+
+ /**
+ * 字典
+ */
+ NO_DICTIONARIES( "未配置字典值"),
+ DICTIONARIES_ERROR( "字典值格式错误"),
+
+
+ /**
+ * 渲染
+ */
+ WRITE_ERROR( "渲染界面错误"),
+
+ RESOURCES_NOT_EXIST("资源不存在"),
+ IO_ERROR("流读取异常"),
+
+ INVLIDE_DATE_STRING(400, "输入日期格式不对"),
+ FILE_READING_ERROR(400, "FILE_READING_ERROR!"),
+ FILE_NOT_FOUND(400, "FILE_NOT_FOUND!"),
+ PAGE_NULL(404, "请求页面不存在"),
+ REMOTE_SERVICE_NULL(404, "远程服务不存在"),
+
+
+ ERROR_TOKEN(520,"token异常"),
+ INPUT_PWD(530, "请输入支付密码"),
+ NO_PWD(540, "密码为空"),
+ UPDATE_PWD_ERROR("编辑密码错误"),
+ UPDATE_MOBILE_ERROR("编辑手机号错误"),
+ UPDATE_DATA(570, "数据更新错误"),
+ INSERT_DATA(580, "数据保存错误"),
+ ERROR_DICT_LACK(590,"字典表配置缺失"),
+
+
+ ENCRYPT_ERROR(600, "加解密错误"),
+
+
+ NO_CURRENT_USER(700, "当前没有登录的用户"),
+ FIELD_VALIDATE_ERROR(700, "数据库字段与实体字段不一致!"),
+ INIT_TABLE_EMPTY_PARAMS(701, "初始化数据库,存在为空的字段"),
+
+
+ ASYNC_ERROR(5000, "数据在被别人修改,请稍后重试"),
+
+ ;
+
+ private Integer code;
+ private String message;
+
+ private CoreExceptionEnum(int code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ private CoreExceptionEnum(String message) {
+ this.code = 500;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return this.code;
+ }
+
+ @Override
+ public String getMessage() {
+ return this.message;
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ParamExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ParamExceptionEnum.java
new file mode 100644
index 0000000..d77528a
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ParamExceptionEnum.java
@@ -0,0 +1,61 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 参数校验异常枚举
+ *
+ * @author xuyuxiang
+ * @date 2020/3/25 20:11
+ */
+public enum ParamExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 参数错误
+ */
+ PARAM_ERROR(1, "参数错误");
+
+ private final Integer code;
+
+ private final String message;
+
+ ParamExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/PermissionExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/PermissionExceptionEnum.java
new file mode 100644
index 0000000..52def99
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/PermissionExceptionEnum.java
@@ -0,0 +1,92 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 授权和鉴权异常的枚举
+ *
+ * 认证和鉴权的区别:
+ *
+ * 认证可以证明你能登录系统,认证的过程是校验token的过程
+ * 鉴权可以证明你有系统的哪些权限,鉴权的过程是校验角色是否包含某些接口的权限
+ *
+ * @author xuyuxiang
+ * @date 2020/3/12 10:14
+ */
+public enum PermissionExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 资源路径不存在
+ */
+ URL_NOT_EXIST(1, "资源路径不存在,请检查请求地址"),
+
+ /**
+ * 没有权限访问资源
+ */
+ NO_PERMISSION(2, "没有权限访问资源,请联系管理员"),
+
+ /**
+ * 没有权限操作该数据
+ */
+ NO_PERMISSION_OPERATE(3, "没有权限操作该数据,请联系管理员"),
+
+ /**
+ * 手机号已存在
+ */
+ MOBILE_REPEAT(4, "手机号已存在"),
+
+ /**
+ * 账号已存在
+ */
+ ACCOUNT_REPEAT(5, "账号已存在"),
+
+ /**
+ * 请指定接收数据的操作员
+ */
+ NO_CHOOSE_OPERATOR(7, "请指定接收数据的操作员");
+
+ private final Integer code;
+
+ private final String message;
+
+ PermissionExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestMethodExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestMethodExceptionEnum.java
new file mode 100644
index 0000000..bee388d
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestMethodExceptionEnum.java
@@ -0,0 +1,67 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 请求方法相关异常枚举
+ *
+ * @author xuyuxiang
+ * @date 2020/3/11 15:33
+ */
+public enum RequestMethodExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 不支持该请求方法,请求方法应为POST
+ */
+ REQUEST_METHOD_IS_POST(1, "不支持该请求方法,请求方法应为POST"),
+
+ /**
+ * 不支持该请求方法,请求方法应为GET
+ */
+ REQUEST_METHOD_IS_GET(2, "不支持该请求方法,请求方法应为GET");
+
+ private final Integer code;
+
+ private final String message;
+
+ RequestMethodExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestTypeExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestTypeExceptionEnum.java
new file mode 100644
index 0000000..702fcda
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RequestTypeExceptionEnum.java
@@ -0,0 +1,67 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 请求类型相关异常枚举
+ *
+ * @author xuyuxiang
+ * @date 2020/4/2 15:42
+ */
+public enum RequestTypeExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 参数传递格式不支持
+ */
+ REQUEST_TYPE_IS_JSON(1, "参数传递格式不支持,请使用JSON格式传参"),
+
+ /**
+ * 请求JSON参数格式不正确
+ */
+ REQUEST_JSON_ERROR(2, "请求JSON参数格式不正确,请检查参数格式");
+
+ private final Integer code;
+
+ private final String message;
+
+ RequestTypeExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RestExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RestExceptionEnum.java
new file mode 100644
index 0000000..8ebdbe5
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/RestExceptionEnum.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * rest异常
+ *
+ * @author administrator
+ * @date 2016年11月12日 下午5:04:51
+ */
+public enum RestExceptionEnum implements AbstractBaseExceptionEnum {
+
+
+ /**
+ * token异常
+ */
+ TOKEN_EXPIRED(700, "token过期"),
+ TOKEN_ERROR(700, "token验证失败"),
+
+ AUTH_EXCEPTION(700, "token过期");
+
+
+ RestExceptionEnum(int code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ private Integer code;
+
+ private String message;
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ServerExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ServerExceptionEnum.java
new file mode 100644
index 0000000..ce9491d
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/ServerExceptionEnum.java
@@ -0,0 +1,82 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 服务器内部相关异常枚举
+ *
+ * @author xuyuxiang
+ * @date 2020/3/18 19:19
+ */
+public enum ServerExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 当前请求参数为空或数据缺失
+ */
+ REQUEST_EMPTY(1, "当前请求参数为空或数据缺失,请联系管理员"),
+
+ /**
+ * 加载中,请稍后……
+ */
+ SERVER_ERROR(2, "程序异常,请联系管理员"),
+
+ /**
+ * 常量获取存在空值
+ */
+ CONSTANT_EMPTY(3, "常量获取存在空值,请检查sys_config中是否配置"),
+ /**
+ *
+ */
+ COMMON_EXCEPTION(4, "编译异常"),
+
+
+ /**
+ * 请勿重复提交
+ */
+ NO_REPEAT_REQUEST(5, "请勿重复提交");
+
+ private final Integer code;
+
+ private final String message;
+
+ ServerExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/StatusExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/StatusExceptionEnum.java
new file mode 100644
index 0000000..f0ba013
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/StatusExceptionEnum.java
@@ -0,0 +1,81 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 状态枚举
+ *
+ * @author stylefeng
+ * @date 2020/4/30 22:45
+ */
+public enum StatusExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 请求状态值为空
+ */
+ REQUEST_EMPTY(1, "请求状态值为空"),
+
+ /**
+ * 请求状值为非正确状态值
+ */
+ NOT_WRITE_STATUS(2, "请求状态值不合法"),
+
+ /**
+ * 更新状态失败,试图更新被删除的记录
+ */
+ UPDATE_STATUS_ERROR(3, "更新状态失败,您试图更新被删除的记录"),
+
+ /**
+ * 操作失败
+ */
+ OPERATOR_FAIL(500, "操作失败"),;
+
+ private final Integer code;
+
+ private final String message;
+
+ StatusExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(StatusExceptionEnum.NOT_WRITE_STATUS.getCode());
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/WrapperExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/WrapperExceptionEnum.java
new file mode 100644
index 0000000..4d383f2
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/WrapperExceptionEnum.java
@@ -0,0 +1,72 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums;
+
+
+import com.ruoyi.common.exception.enums.abs.AbstractBaseExceptionEnum;
+
+/**
+ * 对象包装异常
+ *
+ * @author fengshuonan
+ * @date 2020/7/24 14:36
+ */
+public enum WrapperExceptionEnum implements AbstractBaseExceptionEnum {
+
+ /**
+ * 被包装的值不能是基本类型
+ */
+ BASIC_TYPE_ERROR(1, "被包装的值不能是基本类型"),
+
+ /**
+ * 获取转化字段的值异常
+ */
+ TRANSFER_FILED_VALUE_ERROR(2, "获取转化字段的值异常"),
+
+ /**
+ * 字段包装转化异常
+ */
+ TRANSFER_ERROR(3, "字段包装转化异常");
+
+ private final Integer code;
+
+ private final String message;
+
+ WrapperExceptionEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ public Integer getCode() {
+ return code;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/abs/AbstractBaseExceptionEnum.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/abs/AbstractBaseExceptionEnum.java
new file mode 100644
index 0000000..fba3a60
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/enums/abs/AbstractBaseExceptionEnum.java
@@ -0,0 +1,53 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.exception.enums.abs;
+
+/**
+ * 异常枚举格式规范
+ *
+ * @author stylefeng
+ * @date 2017/12/17 22:22
+ */
+public interface AbstractBaseExceptionEnum {
+
+ /**
+ * 获取异常的状态码
+ *
+ * @return 状态码
+ * @author stylefeng
+ * @date 2020/7/9 14:28
+ */
+ Integer getCode();
+
+ /**
+ * 获取异常的提示信息
+ *
+ * @return 提示信息
+ * @author stylefeng
+ * @date 2020/7/9 14:28
+ */
+ String getMessage();
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java
new file mode 100644
index 0000000..871f09b
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java
@@ -0,0 +1,19 @@
+package com.ruoyi.common.exception.file;
+
+import com.ruoyi.common.exception.base.BaseException;
+
+/**
+ * 文件信息异常类
+ *
+ * @author ruoyi
+ */
+public class FileException extends BaseException
+{
+ private static final long serialVersionUID = 1L;
+
+ public FileException(String code, Object[] args)
+ {
+ super("file", code, args, null);
+ }
+
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java
new file mode 100644
index 0000000..70e0ec9
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java
@@ -0,0 +1,16 @@
+package com.ruoyi.common.exception.file;
+
+/**
+ * 文件名称超长限制异常类
+ *
+ * @author ruoyi
+ */
+public class FileNameLengthLimitExceededException extends FileException
+{
+ private static final long serialVersionUID = 1L;
+
+ public FileNameLengthLimitExceededException(int defaultFileNameLength)
+ {
+ super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java
new file mode 100644
index 0000000..ec6ab05
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java
@@ -0,0 +1,16 @@
+package com.ruoyi.common.exception.file;
+
+/**
+ * 文件名大小限制异常类
+ *
+ * @author ruoyi
+ */
+public class FileSizeLimitExceededException extends FileException
+{
+ private static final long serialVersionUID = 1L;
+
+ public FileSizeLimitExceededException(long defaultMaxSize)
+ {
+ super("upload.exceed.maxSize", new Object[] { defaultMaxSize });
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
new file mode 100644
index 0000000..f1c8e83
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
@@ -0,0 +1,81 @@
+package com.ruoyi.common.exception.file;
+
+import java.util.Arrays;
+import org.apache.commons.fileupload.FileUploadException;
+
+/**
+ * 文件上传 误异常类
+ *
+ * @author ruoyi
+ */
+public class InvalidExtensionException extends FileUploadException
+{
+ private static final long serialVersionUID = 1L;
+
+ private String[] allowedExtension;
+ private String extension;
+ private String filename;
+
+ public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
+ {
+ super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
+ this.allowedExtension = allowedExtension;
+ this.extension = extension;
+ this.filename = filename;
+ }
+
+ public String[] getAllowedExtension()
+ {
+ return allowedExtension;
+ }
+
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ public String getFilename()
+ {
+ return filename;
+ }
+
+ public static class InvalidImageExtensionException extends InvalidExtensionException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
+ {
+ super(allowedExtension, extension, filename);
+ }
+ }
+
+ public static class InvalidFlashExtensionException extends InvalidExtensionException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
+ {
+ super(allowedExtension, extension, filename);
+ }
+ }
+
+ public static class InvalidMediaExtensionException extends InvalidExtensionException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
+ {
+ super(allowedExtension, extension, filename);
+ }
+ }
+
+ public static class InvalidVideoExtensionException extends InvalidExtensionException
+ {
+ private static final long serialVersionUID = 1L;
+
+ public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
+ {
+ super(allowedExtension, extension, filename);
+ }
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java
new file mode 100644
index 0000000..a567b40
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java
@@ -0,0 +1,34 @@
+package com.ruoyi.common.exception.job;
+
+/**
+ * 计划策略异常
+ *
+ * @author ruoyi
+ */
+public class TaskException extends Exception
+{
+ private static final long serialVersionUID = 1L;
+
+ private Code code;
+
+ public TaskException(String msg, Code code)
+ {
+ this(msg, code, null);
+ }
+
+ public TaskException(String msg, Code code, Exception nestedEx)
+ {
+ super(msg, nestedEx);
+ this.code = code;
+ }
+
+ public Code getCode()
+ {
+ return code;
+ }
+
+ public enum Code
+ {
+ TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java
new file mode 100644
index 0000000..389dbc7
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java
@@ -0,0 +1,16 @@
+package com.ruoyi.common.exception.user;
+
+/**
+ * 验证码错误异常类
+ *
+ * @author ruoyi
+ */
+public class CaptchaException extends UserException
+{
+ private static final long serialVersionUID = 1L;
+
+ public CaptchaException()
+ {
+ super("user.jcaptcha.error", null);
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java
new file mode 100644
index 0000000..85f9486
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java
@@ -0,0 +1,16 @@
+package com.ruoyi.common.exception.user;
+
+/**
+ * 验证码失效异常类
+ *
+ * @author ruoyi
+ */
+public class CaptchaExpireException extends UserException
+{
+ private static final long serialVersionUID = 1L;
+
+ public CaptchaExpireException()
+ {
+ super("user.jcaptcha.expire", null);
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java
new file mode 100644
index 0000000..c292d70
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java
@@ -0,0 +1,18 @@
+package com.ruoyi.common.exception.user;
+
+import com.ruoyi.common.exception.base.BaseException;
+
+/**
+ * 用户信息异常类
+ *
+ * @author ruoyi
+ */
+public class UserException extends BaseException
+{
+ private static final long serialVersionUID = 1L;
+
+ public UserException(String code, Object[] args)
+ {
+ super("user", code, args, null);
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java
new file mode 100644
index 0000000..a7f3e5f
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java
@@ -0,0 +1,16 @@
+package com.ruoyi.common.exception.user;
+
+/**
+ * 用户密码不正确或不符合规范异常类
+ *
+ * @author ruoyi
+ */
+public class UserPasswordNotMatchException extends UserException
+{
+ private static final long serialVersionUID = 1L;
+
+ public UserPasswordNotMatchException()
+ {
+ super("user.password.not.match", null);
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/CustomInterceptor.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/CustomInterceptor.java
new file mode 100644
index 0000000..530cd05
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/CustomInterceptor.java
@@ -0,0 +1,113 @@
+package com.ruoyi.common.filter;
+
+import com.ruoyi.common.annotation.CreateBy;
+import com.ruoyi.common.annotation.CreateTime;
+import com.ruoyi.common.annotation.UpdateBy;
+import com.ruoyi.common.annotation.UpdateTime;
+import com.ruoyi.common.core.domain.BaseEntity;
+import com.ruoyi.common.utils.SecurityUtils;
+import org.apache.ibatis.binding.MapperMethod;
+import org.apache.ibatis.executor.Executor;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.SqlCommandType;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Signature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Field;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+/**
+ * 自定义 Mybatis 插件,自动设置 createTime 和 updatTime 的值。
+ * 拦截 update 操作(添加和修改)
+ */
+@Component
+@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
+public class CustomInterceptor implements Interceptor {
+ private static final Logger logger = LoggerFactory.getLogger(CustomInterceptor.class);
+
+ @Override
+ public Object intercept(Invocation invocation) throws Throwable {
+ MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
+
+ // 获取 SQL 命令
+ SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
+ //只判断新增和修改
+ if (SqlCommandType.INSERT.equals(sqlCommandType) || SqlCommandType.UPDATE.equals(sqlCommandType)) {
+ // 获取参数
+ Object parameter = invocation.getArgs()[1];
+ //批量操作时
+ if (parameter instanceof MapperMethod.ParamMap) {
+ MapperMethod.ParamMap map = (MapperMethod.ParamMap) parameter;
+ if (map.containsKey("list")) {
+ Object obj = map.get("list");
+ List> list = (List>) obj;
+ if (list != null) {
+ for (Object o : list) {
+ setParameter(o, sqlCommandType);
+ }
+ }
+ }
+ } else {
+ setParameter(parameter, sqlCommandType);
+ }
+ }
+ return invocation.proceed();
+ }
+
+ public void setParameter(Object parameter, SqlCommandType sqlCommandType) throws Throwable {
+ Class> aClass = parameter.getClass();
+ Field[] declaredFields;
+ //如果常用字段提取了公共类 BaseEntity
+ //判断BaseEntity是否是父类
+ if (BaseEntity.class.isAssignableFrom(aClass)) {
+ // 获取父类私有成员变量
+ declaredFields = aClass.getSuperclass().getDeclaredFields();
+ } else {
+ // 获取私有成员变量
+ declaredFields = aClass.getDeclaredFields();
+ }
+ for (Field field : declaredFields) {
+ if (SqlCommandType.INSERT.equals(sqlCommandType)) { // insert 语句插入 createBy
+ if (field.getAnnotation(CreateBy.class) != null) {
+ field.setAccessible(true);
+
+ try {
+ field.set(parameter, SecurityUtils.getUserId().toString());
+ }catch (Exception e){
+ field.set(parameter, "0");
+ continue;
+ }
+ }
+
+ if (field.getAnnotation(CreateTime.class) != null) { // insert 语句插入 createTime
+ field.setAccessible(true);
+ field.set(parameter, new Timestamp(System.currentTimeMillis()));
+ }
+ }
+
+ if (SqlCommandType.UPDATE.equals(sqlCommandType)) {
+ if (field.getAnnotation(UpdateTime.class) != null) { // update 语句插入 updateTime
+ field.setAccessible(true);
+ field.set(parameter, new Timestamp(System.currentTimeMillis()));
+ }
+ if (field.getAnnotation(UpdateBy.class) != null) { // update 语句插入 updateBy
+ field.setAccessible(true);
+
+ try {
+ field.set(parameter, SecurityUtils.getUserId().toString());
+ }catch (Exception e){
+ continue;
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java
new file mode 100644
index 0000000..a1bcfe2
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java
@@ -0,0 +1,52 @@
+package com.ruoyi.common.filter;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import org.springframework.http.MediaType;
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * Repeatable 过滤器
+ *
+ * @author ruoyi
+ */
+public class RepeatableFilter implements Filter
+{
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+ ServletRequest requestWrapper = null;
+ if (request instanceof HttpServletRequest
+ && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
+ {
+ requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
+ }
+ if (null == requestWrapper)
+ {
+ chain.doFilter(request, response);
+ }
+ else
+ {
+ chain.doFilter(requestWrapper, response);
+ }
+ }
+
+ @Override
+ public void destroy()
+ {
+
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java
new file mode 100644
index 0000000..614c24c
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java
@@ -0,0 +1,75 @@
+package com.ruoyi.common.filter;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import com.ruoyi.common.utils.http.HttpHelper;
+
+/**
+ * 构建可重复读取inputStream的request
+ *
+ * @author ruoyi
+ */
+public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
+{
+ private final byte[] body;
+
+ public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
+ {
+ super(request);
+ request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding("UTF-8");
+
+ body = HttpHelper.getBodyString(request).getBytes("UTF-8");
+ }
+
+ @Override
+ public BufferedReader getReader() throws IOException
+ {
+ return new BufferedReader(new InputStreamReader(getInputStream()));
+ }
+
+ @Override
+ public ServletInputStream getInputStream() throws IOException
+ {
+ final ByteArrayInputStream bais = new ByteArrayInputStream(body);
+ return new ServletInputStream()
+ {
+ @Override
+ public int read() throws IOException
+ {
+ return bais.read();
+ }
+
+ @Override
+ public int available() throws IOException
+ {
+ return body.length;
+ }
+
+ @Override
+ public boolean isFinished()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isReady()
+ {
+ return false;
+ }
+
+ @Override
+ public void setReadListener(ReadListener readListener)
+ {
+
+ }
+ };
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java
new file mode 100644
index 0000000..99323ed
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java
@@ -0,0 +1,74 @@
+package com.ruoyi.common.filter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * 防止XSS攻击的过滤器
+ *
+ * @author ruoyi
+ */
+public class XssFilter implements Filter
+{
+ /**
+ * 排除链接
+ */
+ public List excludes = new ArrayList<>();
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ String tempExcludes = filterConfig.getInitParameter("excludes");
+ if (StringUtils.isNotEmpty(tempExcludes))
+ {
+ String[] url = tempExcludes.split(",");
+ for (int i = 0; url != null && i < url.length; i++)
+ {
+ excludes.add(url[i]);
+ }
+ }
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException
+ {
+ HttpServletRequest req = (HttpServletRequest) request;
+ HttpServletResponse resp = (HttpServletResponse) response;
+ if (handleExcludeURL(req, resp))
+ {
+ chain.doFilter(request, response);
+ return;
+ }
+ XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request);
+ chain.doFilter(xssRequest, response);
+ }
+
+ private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
+ {
+ String url = request.getServletPath();
+ String method = request.getMethod();
+ // GET DELETE 不过滤
+ if (method == null || method.matches("GET") || method.matches("DELETE"))
+ {
+ return true;
+ }
+ return StringUtils.matches(url, excludes);
+ }
+
+ @Override
+ public void destroy()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
new file mode 100644
index 0000000..b1eeb65
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
@@ -0,0 +1,111 @@
+package com.ruoyi.common.filter;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import org.apache.commons.io.IOUtils;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.html.EscapeUtil;
+
+/**
+ * XSS过滤处理
+ *
+ * @author ruoyi
+ */
+public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
+{
+ /**
+ * @param request
+ */
+ public XssHttpServletRequestWrapper(HttpServletRequest request)
+ {
+ super(request);
+ }
+
+ @Override
+ public String[] getParameterValues(String name)
+ {
+ String[] values = super.getParameterValues(name);
+ if (values != null)
+ {
+ int length = values.length;
+ String[] escapseValues = new String[length];
+ for (int i = 0; i < length; i++)
+ {
+ // 防xss攻击和过滤前后空格
+ escapseValues[i] = EscapeUtil.clean(values[i]).trim();
+ }
+ return escapseValues;
+ }
+ return super.getParameterValues(name);
+ }
+
+ @Override
+ public ServletInputStream getInputStream() throws IOException
+ {
+ // 非json类型,直接返回
+ if (!isJsonRequest())
+ {
+ return super.getInputStream();
+ }
+
+ // 为空,直接返回
+ String json = IOUtils.toString(super.getInputStream(), "utf-8");
+ if (StringUtils.isEmpty(json))
+ {
+ return super.getInputStream();
+ }
+
+ // xss过滤
+ json = EscapeUtil.clean(json).trim();
+ byte[] jsonBytes = json.getBytes("utf-8");
+ final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
+ return new ServletInputStream()
+ {
+ @Override
+ public boolean isFinished()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isReady()
+ {
+ return true;
+ }
+
+ @Override
+ public int available() throws IOException
+ {
+ return jsonBytes.length;
+ }
+
+ @Override
+ public void setReadListener(ReadListener readListener)
+ {
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ return bis.read();
+ }
+ };
+ }
+
+ /**
+ * 是否是Json请求
+ *
+ * @param request
+ */
+ public boolean isJsonRequest()
+ {
+ String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
+ return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/ManualPagination.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/ManualPagination.java
new file mode 100644
index 0000000..dedb26b
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/ManualPagination.java
@@ -0,0 +1,28 @@
+
+package com.ruoyi.common.page;
+
+import com.ruoyi.common.core.page.PageDomain;
+import com.ruoyi.common.core.page.TableSupport;
+
+import java.util.List;
+
+/**
+ * 手动分页
+ */
+public class ManualPagination {
+
+ public static List getPage(List dataList) {
+
+ PageDomain pageDomain = TableSupport.buildPageRequest();
+ Integer pageNum = pageDomain.getPageNum();
+ Integer pageSize = pageDomain.getPageSize();
+ int startIndex = (pageNum - 1) * pageSize;
+ int endIndex = Math.min(startIndex + pageSize, dataList.size());
+ List pageData = dataList.subList(startIndex, endIndex);
+ return pageData;
+ }
+
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageResult.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageResult.java
new file mode 100644
index 0000000..049772d
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageResult.java
@@ -0,0 +1,119 @@
+/*
+Copyright [2020] [https://www.stylefeng.cn]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+
+1.请不要删除和修改根目录下的LICENSE文件。
+2.请不要删除和修改Guns源码头部的版权声明。
+3.请保留源码和相关描述文件的项目出处,作者声明等。
+4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns-separation
+6.若您的项目无法满足以上几点,可申请商业授权,获取Guns商业授权许可,请在官网购买授权,地址为 https://www.stylefeng.cn
+ */
+package com.ruoyi.common.page;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.PageUtil;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 分页结果集
+ *
+ * @author xuyuxiang
+ * @date 2020/3/30 15:44
+ */
+@Data
+public class PageResult implements Serializable {
+
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * 默认分页彩虹展示数量
+ */
+ public static final int RAINBOW_NUM = 5;
+
+ /**
+ * 第几页
+ */
+ private Integer pageNo = 1;
+
+ /**
+ * 每页条数
+ */
+ private Integer pageSize = 20;
+
+ /**
+ * 总页数
+ */
+ private Integer totalPage = 0;
+
+ /**
+ * 总记录数
+ */
+ private Integer totalRows = 0;
+
+ /**
+ * 结果集
+ */
+ private List rows;
+
+ /**
+ * 分页彩虹
+ */
+ private int[] rainbow;
+
+ public PageResult() {
+ }
+
+ /**
+ * 将mybatis-plus的page转成自定义的PageResult,扩展了totalPage总页数,和rainBow彩虹条
+ *
+ * @author xuyuxiang
+ * @date 2020/4/8 19:20
+ */
+ public PageResult(IPage page) {
+ this.setRows(page.getRecords());
+ this.setTotalRows(Convert.toInt(page.getTotal()));
+ this.setPageNo(Convert.toInt(page.getCurrent()));
+ this.setPageSize(Convert.toInt(page.getSize()));
+ this.setTotalPage(PageUtil.totalPage(Convert.toInt(page.getTotal()),
+ Convert.toInt(page.getSize())));
+ this.setRainbow(PageUtil.rainbow(Convert.toInt(page.getCurrent()),
+ Convert.toInt(this.getTotalPage()), RAINBOW_NUM));
+ }
+
+ /**
+ * 将mybatis-plus的page转成自定义的PageResult,扩展了totalPage总页数,和rainBow彩虹条
+ * 可单独设置rows
+ *
+ * @author xuyuxiang
+ * @date 2020/4/14 20:55
+ */
+ public PageResult(Page page, List t) {
+ this.setRows(t);
+ this.setTotalRows(Convert.toInt(page.getTotal()));
+ this.setPageNo(Convert.toInt(page.getCurrent()));
+ this.setPageSize(Convert.toInt(page.getSize()));
+ this.setTotalPage(PageUtil.totalPage(Convert.toInt(page.getTotal()),
+ Convert.toInt(page.getSize())));
+ this.setRainbow(PageUtil.rainbow(Convert.toInt(page.getCurrent()),
+ Convert.toInt(this.getTotalPage()), RAINBOW_NUM));
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageUtil.java
new file mode 100644
index 0000000..93031ce
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/page/PageUtil.java
@@ -0,0 +1,30 @@
+package com.ruoyi.common.page;
+
+
+import com.github.pagehelper.PageInfo;
+import com.ruoyi.common.constant.HttpStatus;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+import java.util.List;
+
+public class PageUtil {
+
+ /**
+ *
+ * @param list 返回数据
+ * @param totalList 计算总数据量的数据
+ * @return
+ */
+ public static TableDataInfo getTableDataInfo(List list, List totalList){
+ TableDataInfo rspData = new TableDataInfo();
+ rspData.setCode(HttpStatus.SUCCESS);
+ rspData.setRows(list);
+ rspData.setMsg("查询成功");
+ if(totalList==null){
+ rspData.setTotal(Integer.valueOf(new PageInfo(list).getTotal() + ""));
+ }else {
+ rspData.setTotal(Integer.valueOf(new PageInfo(totalList).getTotal()+""));
+ }
+ return rspData;
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/AESUtil.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/AESUtil.java
new file mode 100644
index 0000000..5945753
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/AESUtil.java
@@ -0,0 +1,234 @@
+package com.ruoyi.common.utils;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Base64Utils;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * AES加密工具类
+ *
+ * @author ACGkaka
+ * @since 2021-06-18 19:11:03
+ */
+public class AESUtil {
+ /**
+ * 日志相关
+ */
+ private static final Logger LOGGER = LoggerFactory.getLogger(AESUtil.class);
+ /**
+ * 编码
+ */
+ private static final String ENCODING = "UTF-8";
+ /**
+ * 算法定义
+ */
+ private static final String AES_ALGORITHM = "AES";
+ /**
+ * 指定填充方式
+ */
+ private static final String CIPHER_PADDING = "AES/ECB/PKCS5Padding";
+ private static final String CIPHER_CBC_PADDING = "AES/CBC/PKCS5Padding";
+ /**
+ * 偏移量(CBC中使用,增强加密算法强度)
+ */
+ private static final String IV_SEED = "1234567812345678";
+
+ /**
+ * AES加密
+ * @param content 待加密内容
+ * @param aesKey 密码
+ * @return
+ */
+ public static String encrypt(String content, String aesKey){
+ if(StringUtils.isBlank(content)){
+ LOGGER.info("AES encrypt: the content is null!");
+ return null;
+ }
+ //判断秘钥是否为16位
+ if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){
+ try {
+ //对密码进行编码
+ byte[] bytes = aesKey.getBytes(ENCODING);
+ //设置加密算法,生成秘钥
+ SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM);
+ // "算法/模式/补码方式"
+ Cipher cipher = Cipher.getInstance(CIPHER_PADDING);
+ //选择加密
+ cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
+ //根据待加密内容生成字节数组
+ byte[] encrypted = cipher.doFinal(content.getBytes(ENCODING));
+ //返回base64字符串
+ return Base64Utils.encodeToString(encrypted);
+ } catch (Exception e) {
+ LOGGER.info("AES encrypt exception:" + e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ }else {
+ LOGGER.info("AES encrypt: the aesKey is null or error!");
+ return null;
+ }
+ }
+
+ /**
+ * 解密
+ *
+ * @param content 待解密内容
+ * @param aesKey 密码
+ * @return
+ */
+ public static String decrypt(String content, String aesKey){
+ if(StringUtils.isBlank(content)){
+ LOGGER.info("AES decrypt: the content is null!");
+ return null;
+ }
+ //判断秘钥是否为16位
+ if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){
+ try {
+ //对密码进行编码
+ byte[] bytes = aesKey.getBytes(ENCODING);
+ //设置解密算法,生成秘钥
+ SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM);
+ // "算法/模式/补码方式"
+ Cipher cipher = Cipher.getInstance(CIPHER_PADDING);
+ //选择解密
+ cipher.init(Cipher.DECRYPT_MODE, skeySpec);
+
+ //先进行Base64解码
+ byte[] decodeBase64 = Base64Utils.decodeFromString(content);
+
+ //根据待解密内容进行解密
+ byte[] decrypted = cipher.doFinal(decodeBase64);
+
+ //将字节数组转成字符串
+ return new String(decrypted, ENCODING);
+ } catch (Exception e) {
+ LOGGER.info("AES decrypt exception:" + e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ }else {
+ LOGGER.info("AES decrypt: the aesKey is null or error!");
+ return null;
+ }
+ }
+
+ /**
+ * AES_CBC加密
+ *
+ * @param content 待加密内容
+ * @param aesKey 密码
+ * @return
+ */
+ public static String encryptCBC(String content, String aesKey){
+ if(StringUtils.isBlank(content)){
+ LOGGER.info("AES_CBC encrypt: the content is null!");
+ return null;
+ }
+ //判断秘钥是否为16位
+ if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){
+ try {
+ //对密码进行编码
+ byte[] bytes = aesKey.getBytes(ENCODING);
+ //设置加密算法,生成秘钥
+ SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM);
+ // "算法/模式/补码方式"
+ Cipher cipher = Cipher.getInstance(CIPHER_CBC_PADDING);
+ //偏移
+ IvParameterSpec iv = new IvParameterSpec(IV_SEED.getBytes(ENCODING));
+ //选择加密
+ cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
+ //根据待加密内容生成字节数组
+ byte[] encrypted = cipher.doFinal(content.getBytes(ENCODING));
+ //返回base64字符串
+ return Base64Utils.encodeToString(encrypted);
+ } catch (Exception e) {
+ LOGGER.info("AES_CBC encrypt exception:" + e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ }else {
+ LOGGER.info("AES_CBC encrypt: the aesKey is null or error!");
+ return null;
+ }
+ }
+
+ /**
+ * AES_CBC解密
+ *
+ * @param content 待解密内容
+ * @param aesKey 密码
+ * @return
+ */
+ public static String decryptCBC(String content, String aesKey){
+ if(StringUtils.isBlank(content)){
+ LOGGER.info("AES_CBC decrypt: the content is null!");
+ return null;
+ }
+ //判断秘钥是否为16位
+ if(StringUtils.isNotBlank(aesKey) && aesKey.length() == 16){
+ try {
+ //对密码进行编码
+ byte[] bytes = aesKey.getBytes(ENCODING);
+ //设置解密算法,生成秘钥
+ SecretKeySpec skeySpec = new SecretKeySpec(bytes, AES_ALGORITHM);
+ //偏移
+ IvParameterSpec iv = new IvParameterSpec(IV_SEED.getBytes(ENCODING));
+ // "算法/模式/补码方式"
+ Cipher cipher = Cipher.getInstance(CIPHER_CBC_PADDING);
+ //选择解密
+ cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+
+ //先进行Base64解码
+ byte[] decodeBase64 = Base64Utils.decodeFromString(content);
+
+ //根据待解密内容进行解密
+ byte[] decrypted = cipher.doFinal(decodeBase64);
+ //将字节数组转成字符串
+ return new String(decrypted, ENCODING);
+ } catch (Exception e) {
+ LOGGER.info("AES_CBC decrypt exception:" + e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ }else {
+ LOGGER.info("AES_CBC decrypt: the aesKey is null or error!");
+ return null;
+ }
+ }
+
+ public static void main(String[] args) {
+ // AES支持三种长度的密钥:128位、192位、256位。
+ // 代码中这种就是128位的加密密钥,16字节 * 8位/字节 = 128位。
+ String random = RandomStringUtils.random(16, "abcdefghijklmnopqrstuvwxyz1234567890");
+ System.out.println("随机key:" + random);
+ System.out.println();
+
+ System.out.println("---------加密---------");
+ String aesResult = encrypt("测试AES加密12", "huitu@77387.uurh");
+ System.out.println("aes加密结果:" + aesResult);
+ System.out.println();
+
+ System.out.println("---------解密---------");
+ String decrypt = decrypt(aesResult, "huitu@77387.uurh");
+ System.out.println("aes解密结果:" + decrypt);
+ System.out.println();
+
+
+ System.out.println("--------AES_CBC加密解密---------");
+ String cbcResult = encryptCBC("测试AES加密12456", random);
+ System.out.println("aes_cbc加密结果:" + cbcResult);
+ System.out.println();
+
+ System.out.println("---------解密CBC---------");
+ String cbcDecrypt = decryptCBC(cbcResult, random);
+ System.out.println("aes解密结果:" + cbcDecrypt);
+ System.out.println();
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java
new file mode 100644
index 0000000..b6326c2
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java
@@ -0,0 +1,114 @@
+package com.ruoyi.common.utils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * 精确的浮点数运算
+ *
+ * @author ruoyi
+ */
+public class Arith
+{
+
+ /** 默认除法运算精度 */
+ private static final int DEF_DIV_SCALE = 10;
+
+ /** 这个类不能实例化 */
+ private Arith()
+ {
+ }
+
+ /**
+ * 提供精确的加法运算。
+ * @param v1 被加数
+ * @param v2 加数
+ * @return 两个参数的和
+ */
+ public static double add(double v1, double v2)
+ {
+ BigDecimal b1 = new BigDecimal(Double.toString(v1));
+ BigDecimal b2 = new BigDecimal(Double.toString(v2));
+ return b1.add(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的减法运算。
+ * @param v1 被减数
+ * @param v2 减数
+ * @return 两个参数的差
+ */
+ public static double sub(double v1, double v2)
+ {
+ BigDecimal b1 = new BigDecimal(Double.toString(v1));
+ BigDecimal b2 = new BigDecimal(Double.toString(v2));
+ return b1.subtract(b2).doubleValue();
+ }
+
+ /**
+ * 提供精确的乘法运算。
+ * @param v1 被乘数
+ * @param v2 乘数
+ * @return 两个参数的积
+ */
+ public static double mul(double v1, double v2)
+ {
+ BigDecimal b1 = new BigDecimal(Double.toString(v1));
+ BigDecimal b2 = new BigDecimal(Double.toString(v2));
+ return b1.multiply(b2).doubleValue();
+ }
+
+ /**
+ * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
+ * 小数点以后10位,以后的数字四舍五入。
+ * @param v1 被除数
+ * @param v2 除数
+ * @return 两个参数的商
+ */
+ public static double div(double v1, double v2)
+ {
+ return div(v1, v2, DEF_DIV_SCALE);
+ }
+
+ /**
+ * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
+ * 定精度,以后的数字四舍五入。
+ * @param v1 被除数
+ * @param v2 除数
+ * @param scale 表示表示需要精确到小数点以后几位。
+ * @return 两个参数的商
+ */
+ public static double div(double v1, double v2, int scale)
+ {
+ if (scale < 0)
+ {
+ throw new IllegalArgumentException(
+ "The scale must be a positive integer or zero");
+ }
+ BigDecimal b1 = new BigDecimal(Double.toString(v1));
+ BigDecimal b2 = new BigDecimal(Double.toString(v2));
+ if (b1.compareTo(BigDecimal.ZERO) == 0)
+ {
+ return BigDecimal.ZERO.doubleValue();
+ }
+ return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
+ }
+
+ /**
+ * 提供精确的小数位四舍五入处理。
+ * @param v 需要四舍五入的数字
+ * @param scale 小数点后保留几位
+ * @return 四舍五入后的结果
+ */
+ public static double round(double v, int scale)
+ {
+ if (scale < 0)
+ {
+ throw new IllegalArgumentException(
+ "The scale must be a positive integer or zero");
+ }
+ BigDecimal b = new BigDecimal(Double.toString(v));
+ BigDecimal one = BigDecimal.ONE;
+ return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
new file mode 100644
index 0000000..536cb3c
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
@@ -0,0 +1,155 @@
+package com.ruoyi.common.utils;
+
+import java.lang.management.ManagementFactory;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+/**
+ * 时间工具类
+ *
+ * @author ruoyi
+ */
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils
+{
+ public static String YYYY = "yyyy";
+
+ public static String YYYY_MM = "yyyy-MM";
+
+ public static String YYYY_MM_DD = "yyyy-MM-dd";
+
+ public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+
+ public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+
+ private static String[] parsePatterns = {
+ "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
+ "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
+ "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
+
+ /**
+ * 获取当前Date型日期
+ *
+ * @return Date() 当前日期
+ */
+ public static Date getNowDate()
+ {
+ return new Date();
+ }
+
+ /**
+ * 获取当前日期, 默认格式为yyyy-MM-dd
+ *
+ * @return String
+ */
+ public static String getDate()
+ {
+ return dateTimeNow(YYYY_MM_DD);
+ }
+
+ public static final String getTime()
+ {
+ return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
+ }
+
+ public static final String dateTimeNow()
+ {
+ return dateTimeNow(YYYYMMDDHHMMSS);
+ }
+
+ public static final String dateTimeNow(final String format)
+ {
+ return parseDateToStr(format, new Date());
+ }
+
+ public static final String dateTime(final Date date)
+ {
+ return parseDateToStr(YYYY_MM_DD, date);
+ }
+
+ public static final String parseDateToStr(final String format, final Date date)
+ {
+ return new SimpleDateFormat(format).format(date);
+ }
+
+ public static final Date dateTime(final String format, final String ts)
+ {
+ try
+ {
+ return new SimpleDateFormat(format).parse(ts);
+ }
+ catch (ParseException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 日期路径 即年/月/日 如2018/08/08
+ */
+ public static final String datePath()
+ {
+ Date now = new Date();
+ return DateFormatUtils.format(now, "yyyy/MM/dd");
+ }
+
+ /**
+ * 日期路径 即年/月/日 如20180808
+ */
+ public static final String dateTime()
+ {
+ Date now = new Date();
+ return DateFormatUtils.format(now, "yyyyMMdd");
+ }
+
+ /**
+ * 日期型字符串转化为日期 格式
+ */
+ public static Date parseDate(Object str)
+ {
+ if (str == null)
+ {
+ return null;
+ }
+ try
+ {
+ return parseDate(str.toString(), parsePatterns);
+ }
+ catch (ParseException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * 获取服务器启动时间
+ */
+ public static Date getServerStartDate()
+ {
+ long time = ManagementFactory.getRuntimeMXBean().getStartTime();
+ return new Date(time);
+ }
+
+ /**
+ * 计算两个时间差
+ */
+ public static String getDatePoor(Date endDate, Date nowDate)
+ {
+ long nd = 1000 * 24 * 60 * 60;
+ long nh = 1000 * 60 * 60;
+ long nm = 1000 * 60;
+ // long ns = 1000;
+ // 获得两个时间的毫秒时间差异
+ long diff = endDate.getTime() - nowDate.getTime();
+ // 计算差多少天
+ long day = diff / nd;
+ // 计算差多少小时
+ long hour = diff % nd / nh;
+ // 计算差多少分钟
+ long min = diff % nd % nh / nm;
+ // 计算差多少秒//输出结果
+ // long sec = diff % nd % nh % nm / ns;
+ return day + "天" + hour + "小时" + min + "分钟";
+ }
+}
diff --git a/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
new file mode 100644
index 0000000..4c90a6c
--- /dev/null
+++ b/ruoyi-base-support/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
@@ -0,0 +1,183 @@
+package com.ruoyi.common.utils;
+
+import java.util.Collection;
+import java.util.List;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.entity.SysDictData;
+import com.ruoyi.common.core.redis.RedisService;
+import com.ruoyi.common.utils.spring.SpringUtils;
+
+/**
+ * 字典工具类
+ *
+ * @author ruoyi
+ */
+public class DictUtils
+{
+ /**
+ * 分隔符
+ */
+ public static final String SEPARATOR = ",";
+
+ /**
+ * 设置字典缓存
+ *
+ * @param key 参数键
+ * @param dictDatas 字典数据列表
+ */
+ public static void setDictCache(String key, List