This commit is contained in:
ls
2024-11-05 11:00:34 +08:00
parent 83fa274068
commit 639d0ee799
541 changed files with 29300 additions and 26585 deletions

View File

@@ -8,12 +8,14 @@ import java.util.Set;
/** /**
* 通用api * 通用api
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public interface CommonAPI { public interface CommonAPI {
/** /**
* 1查询用户角色信息 * 1查询用户角色信息
*
* @param username * @param username
* @return * @return
*/ */
@@ -21,6 +23,7 @@ public interface CommonAPI {
/** /**
* 1查询用户角色信息 * 1查询用户角色信息
*
* @param userId * @param userId
* @return * @return
*/ */
@@ -29,6 +32,7 @@ public interface CommonAPI {
/** /**
* 2查询用户权限信息 * 2查询用户权限信息
*
* @param userId * @param userId
* @return * @return
*/ */
@@ -52,6 +56,7 @@ public interface CommonAPI {
/** /**
* 5根据用户账号查询用户信息 * 5根据用户账号查询用户信息
*
* @param username * @param username
* @return * @return
*/ */
@@ -59,6 +64,7 @@ public interface CommonAPI {
/** /**
* 5根据用户账号查询用户Id * 5根据用户账号查询用户Id
*
* @param username * @param username
* @return * @return
*/ */
@@ -67,6 +73,7 @@ public interface CommonAPI {
/** /**
* 6字典表的 翻译 * 6字典表的 翻译
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
@@ -77,6 +84,7 @@ public interface CommonAPI {
/** /**
* 7普通字典的翻译 * 7普通字典的翻译
*
* @param code * @param code
* @param key * @param key
* @return * @return
@@ -85,8 +93,9 @@ public interface CommonAPI {
/** /**
* 8查询数据权限 * 8查询数据权限
* @param component 组件 *
* @param username 用户名 * @param component 组件
* @param username 用户名
* @param requestPath 前段请求地址 * @param requestPath 前段请求地址
* @return * @return
*/ */
@@ -95,6 +104,7 @@ public interface CommonAPI {
/** /**
* 9查询用户信息 * 9查询用户信息
*
* @param username * @param username
* @return * @return
*/ */
@@ -102,6 +112,7 @@ public interface CommonAPI {
/** /**
* 10获取数据字典 * 10获取数据字典
*
* @param code * @param code
* @return * @return
*/ */
@@ -109,6 +120,7 @@ public interface CommonAPI {
/** /**
* 获取有效的数据字典项 * 获取有效的数据字典项
*
* @param code * @param code
* @return * @return
*/ */
@@ -116,6 +128,7 @@ public interface CommonAPI {
/** /**
* 13获取表数据字典 * 13获取表数据字典
*
* @param tableFilterSql * @param tableFilterSql
* @param text * @param text
* @param code * @param code
@@ -125,19 +138,22 @@ public interface CommonAPI {
/** /**
* 14 普通字典的翻译根据多个dictCode和多条数据多个以逗号分割 * 14 普通字典的翻译根据多个dictCode和多条数据多个以逗号分割
*
* @param dictCodes 例如user_status,sex * @param dictCodes 例如user_status,sex
* @param keys 例如1,2,0 * @param keys 例如1,2,0
* @return * @return
*/ */
Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys); Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys);
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------ //update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/** /**
* 15 字典表的 翻译,可批量 * 15 字典表的 翻译,可批量
*
* @param table * @param table
* @param text * @param text
* @param code * @param code
* @param keys 多个用逗号分割 * @param keys 多个用逗号分割
* @param dataSource 数据源 * @param dataSource 数据源
* @return * @return
*/ */

View File

@@ -19,7 +19,7 @@ public class DataLogDTO {
private String createName; private String createName;
public DataLogDTO(){ public DataLogDTO() {
} }

View File

@@ -1,13 +1,14 @@
package org.jeecg.common.api.dto; package org.jeecg.common.api.dto;
import jakarta.servlet.http.HttpServletResponse;
import lombok.Data; import lombok.Data;
import jakarta.servlet.http.HttpServletResponse;
import java.io.Serializable; import java.io.Serializable;
/** /**
* 文件下载 * 文件下载
* cloud api 用到的接口传输对象 * cloud api 用到的接口传输对象
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -20,9 +21,10 @@ public class FileDownDTO implements Serializable {
private String uploadType; private String uploadType;
private HttpServletResponse response; private HttpServletResponse response;
public FileDownDTO(){} public FileDownDTO() {
}
public FileDownDTO(String filePath, String uploadpath, String uploadType,HttpServletResponse response){ public FileDownDTO(String filePath, String uploadpath, String uploadType, HttpServletResponse response) {
this.filePath = filePath; this.filePath = filePath;
this.uploadpath = uploadpath; this.uploadpath = uploadpath;
this.uploadType = uploadType; this.uploadType = uploadType;

View File

@@ -8,6 +8,7 @@ import java.io.Serializable;
/** /**
* 文件上传 * 文件上传
* cloud api 用到的接口传输对象 * cloud api 用到的接口传输对象
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -23,17 +24,18 @@ public class FileUploadDTO implements Serializable {
private String customBucket; private String customBucket;
public FileUploadDTO(){ public FileUploadDTO() {
} }
/** /**
* 简单上传 构造器1 * 简单上传 构造器1
*
* @param file * @param file
* @param bizPath * @param bizPath
* @param uploadType * @param uploadType
*/ */
public FileUploadDTO(MultipartFile file,String bizPath,String uploadType){ public FileUploadDTO(MultipartFile file, String bizPath, String uploadType) {
this.file = file; this.file = file;
this.bizPath = bizPath; this.bizPath = bizPath;
this.uploadType = uploadType; this.uploadType = uploadType;
@@ -41,12 +43,13 @@ public class FileUploadDTO implements Serializable {
/** /**
* 申明桶 文件上传 构造器2 * 申明桶 文件上传 构造器2
*
* @param file * @param file
* @param bizPath * @param bizPath
* @param uploadType * @param uploadType
* @param customBucket * @param customBucket
*/ */
public FileUploadDTO(MultipartFile file,String bizPath,String uploadType,String customBucket){ public FileUploadDTO(MultipartFile file, String bizPath, String uploadType, String customBucket) {
this.file = file; this.file = file;
this.bizPath = bizPath; this.bizPath = bizPath;
this.uploadType = uploadType; this.uploadType = uploadType;

View File

@@ -1,13 +1,15 @@
package org.jeecg.common.api.dto; package org.jeecg.common.api.dto;
import lombok.Data; import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
* 日志对象 * 日志对象
* cloud api 用到的接口传输对象 * cloud api 用到的接口传输对象
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -15,16 +17,24 @@ public class LogDTO implements Serializable {
private static final long serialVersionUID = 8482720462943906924L; private static final long serialVersionUID = 8482720462943906924L;
/**内容*/ /**
* 内容
*/
private String logContent; private String logContent;
/**日志类型(0:操作日志;1:登录日志;2:定时任务) */ /**
* 日志类型(0:操作日志;1:登录日志;2:定时任务)
*/
private Integer logType; private Integer logType;
/**操作类型(1:添加;2:修改;3:删除;) */ /**
* 操作类型(1:添加;2:修改;3:删除;)
*/
private Integer operateType; private Integer operateType;
/**登录用户 */ /**
* 登录用户
*/
private LoginUser loginUser; private LoginUser loginUser;
private String id; private String id;
@@ -33,22 +43,34 @@ public class LogDTO implements Serializable {
private Long costTime; private Long costTime;
private String ip; private String ip;
/**请求参数 */ /**
* 请求参数
*/
private String requestParam; private String requestParam;
/**请求类型*/ /**
* 请求类型
*/
private String requestType; private String requestType;
/**请求路径*/ /**
* 请求路径
*/
private String requestUrl; private String requestUrl;
/**请求方法 */ /**
* 请求方法
*/
private String method; private String method;
/**操作人用户名称*/ /**
* 操作人用户名称
*/
private String username; private String username;
/**操作人用户账户*/ /**
* 操作人用户账户
*/
private String userid; private String userid;
/** /**
@@ -61,17 +83,17 @@ public class LogDTO implements Serializable {
*/ */
private String clientType; private String clientType;
public LogDTO(){ public LogDTO() {
} }
public LogDTO(String logContent, Integer logType, Integer operatetype){ public LogDTO(String logContent, Integer logType, Integer operatetype) {
this.logContent = logContent; this.logContent = logContent;
this.logType = logType; this.logType = logType;
this.operateType = operatetype; this.operateType = operatetype;
} }
public LogDTO(String logContent, Integer logType, Integer operatetype, LoginUser loginUser){ public LogDTO(String logContent, Integer logType, Integer operatetype, LoginUser loginUser) {
this.logContent = logContent; this.logContent = logContent;
this.logType = logType; this.logType = logType;
this.operateType = operatetype; this.operateType = operatetype;

View File

@@ -8,6 +8,7 @@ import java.util.List;
/** /**
* online 拦截器权限判断 * online 拦截器权限判断
* cloud api 用到的接口传输对象 * cloud api 用到的接口传输对象
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -37,11 +38,11 @@ public class OnlineAuthDTO implements Serializable {
private String onlineWorkOrderUrl; private String onlineWorkOrderUrl;
//update-end---author:chenrui ---date:20240123 for[QQYUN-7992]【online】工单申请下的online表单未配置online表单开发菜单操作报错无权限------------ //update-end---author:chenrui ---date:20240123 for[QQYUN-7992]【online】工单申请下的online表单未配置online表单开发菜单操作报错无权限------------
public OnlineAuthDTO(){ public OnlineAuthDTO() {
} }
public OnlineAuthDTO(String username, List<String> possibleUrl, String onlineFormUrl){ public OnlineAuthDTO(String username, List<String> possibleUrl, String onlineFormUrl) {
this.username = username; this.username = username;
this.possibleUrl = possibleUrl; this.possibleUrl = possibleUrl;
this.onlineFormUrl = onlineFormUrl; this.onlineFormUrl = onlineFormUrl;

View File

@@ -6,10 +6,10 @@ import java.io.Serializable;
/** /**
* 带业务参数的消息 * 带业务参数的消息
* *
* @author: taoyan * @author: taoyan
* @date: 2022/8/17 * @date: 2022/8/17
*/ */
@Data @Data
public class BusMessageDTO extends MessageDTO implements Serializable { public class BusMessageDTO extends MessageDTO implements Serializable {
@@ -24,12 +24,13 @@ public class BusMessageDTO extends MessageDTO implements Serializable {
*/ */
private String busId; private String busId;
public BusMessageDTO(){ public BusMessageDTO() {
} }
/** /**
* 构造 带业务参数的消息 * 构造 带业务参数的消息
*
* @param fromUser * @param fromUser
* @param toUser * @param toUser
* @param title * @param title
@@ -38,7 +39,7 @@ public class BusMessageDTO extends MessageDTO implements Serializable {
* @param busType * @param busType
* @param busId * @param busId
*/ */
public BusMessageDTO(String fromUser, String toUser, String title, String msgContent, String msgCategory, String busType, String busId){ public BusMessageDTO(String fromUser, String toUser, String title, String msgContent, String msgCategory, String busType, String busId) {
super(fromUser, toUser, title, msgContent, msgCategory); super(fromUser, toUser, title, msgContent, msgCategory);
this.busId = busId; this.busId = busId;
this.busType = busType; this.busType = busType;

View File

@@ -7,6 +7,7 @@ import java.util.Map;
/** /**
* 带业务参数的模板消息 * 带业务参数的模板消息
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -24,12 +25,13 @@ public class BusTemplateMessageDTO extends TemplateMessageDTO implements Seriali
*/ */
private String busId; private String busId;
public BusTemplateMessageDTO(){ public BusTemplateMessageDTO() {
} }
/** /**
* 构造 带业务参数的模板消息 * 构造 带业务参数的模板消息
*
* @param fromUser * @param fromUser
* @param toUser * @param toUser
* @param title * @param title
@@ -38,7 +40,7 @@ public class BusTemplateMessageDTO extends TemplateMessageDTO implements Seriali
* @param busType * @param busType
* @param busId * @param busId
*/ */
public BusTemplateMessageDTO(String fromUser, String toUser, String title, Map<String, String> templateParam, String templateCode, String busType, String busId){ public BusTemplateMessageDTO(String fromUser, String toUser, String title, Map<String, String> templateParam, String templateCode, String busType, String busId) {
super(fromUser, toUser, title, templateParam, templateCode); super(fromUser, toUser, title, templateParam, templateCode);
this.busId = busId; this.busId = busId;
this.busType = busType; this.busType = busType;

View File

@@ -4,10 +4,12 @@ import lombok.Data;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.Map;
import java.util.Set;
/** /**
* 普通消息 * 普通消息
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -46,10 +48,10 @@ public class MessageDTO implements Serializable {
/** /**
* 消息类型org.jeecg.common.constant.enums.MessageTypeEnum * 消息类型org.jeecg.common.constant.enums.MessageTypeEnum
* XT("system", "系统消息") * XT("system", "系统消息")
* YJ("email", "邮件消息") * YJ("email", "邮件消息")
* DD("dingtalk", "钉钉消息") * DD("dingtalk", "钉钉消息")
* QYWX("wechat_enterprise", "企业微信") * QYWX("wechat_enterprise", "企业微信")
*/ */
protected String type; protected String type;
@@ -86,13 +88,13 @@ public class MessageDTO implements Serializable {
protected Set<String> ccEmailList; protected Set<String> ccEmailList;
//---【邮件相关参数】------------------------------------------------------------- //---【邮件相关参数】-------------------------------------------------------------
public MessageDTO(){ public MessageDTO() {
} }
/** /**
* 构造器1 系统消息 * 构造器1 系统消息
*/ */
public MessageDTO(String fromUser,String toUser,String title, String content){ public MessageDTO(String fromUser, String toUser, String title, String content) {
this.fromUser = fromUser; this.fromUser = fromUser;
this.toUser = toUser; this.toUser = toUser;
this.title = title; this.title = title;
@@ -104,7 +106,7 @@ public class MessageDTO implements Serializable {
/** /**
* 构造器2 支持设置category 1:消息 2:系统消息 * 构造器2 支持设置category 1:消息 2:系统消息
*/ */
public MessageDTO(String fromUser,String toUser,String title, String content, String category){ public MessageDTO(String fromUser, String toUser, String title, String content, String category) {
this.fromUser = fromUser; this.fromUser = fromUser;
this.toUser = toUser; this.toUser = toUser;
this.title = title; this.title = title;

View File

@@ -7,6 +7,7 @@ import java.util.Map;
/** /**
* 消息模板dto * 消息模板dto
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -27,12 +28,12 @@ public class TemplateDTO implements Serializable {
/** /**
* 构造器 通过设置模板参数和模板编码 作为参数获取消息内容 * 构造器 通过设置模板参数和模板编码 作为参数获取消息内容
*/ */
public TemplateDTO(String templateCode, Map<String, String> templateParam){ public TemplateDTO(String templateCode, Map<String, String> templateParam) {
this.templateCode = templateCode; this.templateCode = templateCode;
this.templateParam = templateParam; this.templateParam = templateParam;
} }
public TemplateDTO(){ public TemplateDTO() {
} }
} }

View File

@@ -1,11 +1,13 @@
package org.jeecg.common.api.dto.message; package org.jeecg.common.api.dto.message;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map; import java.util.Map;
/** /**
* 模板消息 * 模板消息
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data
@@ -30,14 +32,14 @@ public class TemplateMessageDTO extends TemplateDTO implements Serializable {
protected String title; protected String title;
public TemplateMessageDTO(){ public TemplateMessageDTO() {
} }
/** /**
* 构造器1 发模板消息用 * 构造器1 发模板消息用
*/ */
public TemplateMessageDTO(String fromUser, String toUser,String title, Map<String, String> templateParam, String templateCode){ public TemplateMessageDTO(String fromUser, String toUser, String title, Map<String, String> templateParam, String templateCode) {
super(templateCode, templateParam); super(templateCode, templateParam);
this.fromUser = fromUser; this.fromUser = fromUser;
this.toUser = toUser; this.toUser = toUser;
@@ -45,5 +47,4 @@ public class TemplateMessageDTO extends TemplateDTO implements Serializable {
} }
} }

View File

@@ -8,169 +8,171 @@ import org.jeecg.common.constant.CommonConstant;
import java.io.Serializable; import java.io.Serializable;
/** /**
* 接口返回数据格式 * 接口返回数据格式
*
* @author scott * @author scott
* @email jeecgos@163.com * @email jeecgos@163.com
* @date 2019年1月19日 * @date 2019年1月19日
*/ */
@Data @Data
@Schema(description="接口返回对象") @Schema(description = "接口返回对象")
public class Result<T> implements Serializable { public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 成功标志 * 成功标志
*/ */
@Schema(description = "成功标志") @Schema(description = "成功标志")
private boolean success = true; private boolean success = true;
/** /**
* 返回处理消息 * 返回处理消息
*/ */
@Schema(description = "返回处理消息") @Schema(description = "返回处理消息")
private String message = ""; private String message = "";
/** /**
* 返回代码 * 返回代码
*/ */
@Schema(description = "返回代码") @Schema(description = "返回代码")
private Integer code = 0; private Integer code = 0;
/** /**
* 返回数据对象 data * 返回数据对象 data
*/ */
@Schema(description = "返回数据对象") @Schema(description = "返回数据对象")
private T result; private T result;
/** /**
* 时间戳 * 时间戳
*/ */
@Schema(description = "时间戳") @Schema(description = "时间戳")
private long timestamp = System.currentTimeMillis(); private long timestamp = System.currentTimeMillis();
public Result() { public Result() {
} }
/** /**
* 兼容VUE3版token失效不跳转登录页面 * 兼容VUE3版token失效不跳转登录页面
*
* @param code * @param code
* @param message * @param message
*/ */
public Result(Integer code, String message) { public Result(Integer code, String message) {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
public Result<T> success(String message) { public Result<T> success(String message) {
this.message = message; this.message = message;
this.code = CommonConstant.SC_OK_200; this.code = CommonConstant.SC_OK_200;
this.success = true; this.success = true;
return this; return this;
} }
public static<T> Result<T> ok() { public static <T> Result<T> ok() {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
return r; return r;
} }
public static<T> Result<T> ok(String msg) { public static <T> Result<T> ok(String msg) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
//Result OK(String msg)方法会造成兼容性问题 issues/I4IP3D //Result OK(String msg)方法会造成兼容性问题 issues/I4IP3D
r.setResult((T) msg); r.setResult((T) msg);
r.setMessage(msg); r.setMessage(msg);
return r; return r;
} }
public static<T> Result<T> ok(T data) { public static <T> Result<T> ok(T data) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
r.setResult(data); r.setResult(data);
return r; return r;
} }
public static<T> Result<T> OK() { public static <T> Result<T> OK() {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
return r; return r;
} }
/** /**
* 此方法是为了兼容升级所创建 * 此方法是为了兼容升级所创建
* *
* @param msg * @param msg
* @param <T> * @param <T>
* @return * @return
*/ */
public static<T> Result<T> OK(String msg) { public static <T> Result<T> OK(String msg) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
r.setMessage(msg); r.setMessage(msg);
//Result OK(String msg)方法会造成兼容性问题 issues/I4IP3D //Result OK(String msg)方法会造成兼容性问题 issues/I4IP3D
r.setResult((T) msg); r.setResult((T) msg);
return r; return r;
} }
public static<T> Result<T> OK(T data) { public static <T> Result<T> OK(T data) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
r.setResult(data); r.setResult(data);
return r; return r;
} }
public static<T> Result<T> OK(String msg, T data) { public static <T> Result<T> OK(String msg, T data) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(true); r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200); r.setCode(CommonConstant.SC_OK_200);
r.setMessage(msg); r.setMessage(msg);
r.setResult(data); r.setResult(data);
return r; return r;
} }
public static<T> Result<T> error(String msg, T data) { public static <T> Result<T> error(String msg, T data) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setSuccess(false); r.setSuccess(false);
r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500); r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
r.setMessage(msg); r.setMessage(msg);
r.setResult(data); r.setResult(data);
return r; return r;
} }
public static<T> Result<T> error(String msg) { public static <T> Result<T> error(String msg) {
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg); return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
} }
public static<T> Result<T> error(int code, String msg) { public static <T> Result<T> error(int code, String msg) {
Result<T> r = new Result<T>(); Result<T> r = new Result<T>();
r.setCode(code); r.setCode(code);
r.setMessage(msg); r.setMessage(msg);
r.setSuccess(false); r.setSuccess(false);
return r; return r;
} }
public Result<T> error500(String message) { public Result<T> error500(String message) {
this.message = message; this.message = message;
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
this.success = false; this.success = false;
return this; return this;
} }
/** /**
* 无权限访问返回结果 * 无权限访问返回结果
*/ */
public static<T> Result<T> noauth(String msg) { public static <T> Result<T> noauth(String msg) {
return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg); return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg);
} }
@JsonIgnore @JsonIgnore
private String onlTable; private String onlTable;
} }

View File

@@ -2,6 +2,10 @@ package org.jeecg.common.aspect;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.PropertyFilter; import com.alibaba.fastjson.serializer.PropertyFilter;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
@@ -15,20 +19,16 @@ import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.enums.ModuleType; import org.jeecg.common.constant.enums.ModuleType;
import org.jeecg.common.constant.enums.OperateTypeEnum; import org.jeecg.common.constant.enums.OperateTypeEnum;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.IpUtils; import org.jeecg.common.util.IpUtils;
import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.jeecg.modules.base.service.BaseCommonService;
import org.springframework.core.StandardReflectionParameterNameDiscoverer; import org.springframework.core.StandardReflectionParameterNameDiscoverer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Date; import java.util.Date;
@@ -72,10 +72,10 @@ public class AutoLogAspect {
LogDTO dto = new LogDTO(); LogDTO dto = new LogDTO();
AutoLog syslog = method.getAnnotation(AutoLog.class); AutoLog syslog = method.getAnnotation(AutoLog.class);
if(syslog != null){ if (syslog != null) {
//update-begin-author:taoyan date: //update-begin-author:taoyan date:
String content = syslog.value(); String content = syslog.value();
if(syslog.module()== ModuleType.ONLINE){ if (syslog.module() == ModuleType.ONLINE) {
content = getOnlineLogContent(obj, content); content = getOnlineLogContent(obj, content);
} }
//注解上的描述,操作日志内容 //注解上的描述,操作日志内容
@@ -97,12 +97,12 @@ public class AutoLogAspect {
//获取request //获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//请求的参数 //请求的参数
dto.setRequestParam(getReqestParams(request,joinPoint)); dto.setRequestParam(getReqestParams(request, joinPoint));
//设置IP地址 //设置IP地址
dto.setIp(IpUtils.getIpAddr(request)); dto.setIp(IpUtils.getIpAddr(request));
//获取登录用户信息 //获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(sysUser!=null){ if (sysUser != null) {
dto.setUserid(sysUser.getUsername()); dto.setUserid(sysUser.getUsername());
dto.setUsername(sysUser.getRealname()); dto.setUsername(sysUser.getRealname());
@@ -118,7 +118,7 @@ public class AutoLogAspect {
/** /**
* 获取操作类型 * 获取操作类型
*/ */
private int getOperateType(String methodName,int operateType) { private int getOperateType(String methodName, int operateType) {
if (operateType > 0) { if (operateType > 0) {
return operateType; return operateType;
} }
@@ -128,11 +128,11 @@ public class AutoLogAspect {
} }
/** /**
* @param request: request
* @param joinPoint: joinPoint
* @Description: 获取请求参数 * @Description: 获取请求参数
* @author: scott * @author: scott
* @date: 2020/4/16 0:10 * @date: 2020/4/16 0:10
* @param request: request
* @param joinPoint: joinPoint
* @Return: java.lang.String * @Return: java.lang.String
*/ */
private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) { private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) {
@@ -142,7 +142,7 @@ public class AutoLogAspect {
Object[] paramsArray = joinPoint.getArgs(); Object[] paramsArray = joinPoint.getArgs();
// java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) // java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
// https://my.oschina.net/mengzhang6/blog/2395893 // https://my.oschina.net/mengzhang6/blog/2395893
Object[] arguments = new Object[paramsArray.length]; Object[] arguments = new Object[paramsArray.length];
for (int i = 0; i < paramsArray.length; i++) { for (int i = 0; i < paramsArray.length; i++) {
if (paramsArray[i] instanceof BindingResult || paramsArray[i] instanceof ServletRequest || paramsArray[i] instanceof ServletResponse || paramsArray[i] instanceof MultipartFile) { if (paramsArray[i] instanceof BindingResult || paramsArray[i] instanceof ServletRequest || paramsArray[i] instanceof ServletResponse || paramsArray[i] instanceof MultipartFile) {
//ServletRequest不能序列化从入参里排除否则报异常java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) //ServletRequest不能序列化从入参里排除否则报异常java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
@@ -156,10 +156,10 @@ public class AutoLogAspect {
@Override @Override
public boolean apply(Object o, String name, Object value) { public boolean apply(Object o, String name, Object value) {
int length = 500; int length = 500;
if(value!=null && value.toString().length()>length){ if (value != null && value.toString().length() > length) {
return false; return false;
} }
if(value instanceof MultipartFile){ if (value instanceof MultipartFile) {
return false; return false;
} }
return true; return true;
@@ -173,7 +173,7 @@ public class AutoLogAspect {
// 请求的方法参数值 // 请求的方法参数值
Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
// 请求的方法参数名称 // 请求的方法参数名称
StandardReflectionParameterNameDiscoverer u=new StandardReflectionParameterNameDiscoverer(); StandardReflectionParameterNameDiscoverer u = new StandardReflectionParameterNameDiscoverer();
String[] paramNames = u.getParameterNames(method); String[] paramNames = u.getParameterNames(method);
if (args != null && paramNames != null) { if (args != null && paramNames != null) {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
@@ -186,22 +186,23 @@ public class AutoLogAspect {
/** /**
* online日志内容拼接 * online日志内容拼接
*
* @param obj * @param obj
* @param content * @param content
* @return * @return
*/ */
private String getOnlineLogContent(Object obj, String content){ private String getOnlineLogContent(Object obj, String content) {
if (Result.class.isInstance(obj)){ if (Result.class.isInstance(obj)) {
Result res = (Result)obj; Result res = (Result) obj;
String msg = res.getMessage(); String msg = res.getMessage();
String tableName = res.getOnlTable(); String tableName = res.getOnlTable();
if(oConvertUtils.isNotEmpty(tableName)){ if (oConvertUtils.isNotEmpty(tableName)) {
content+=",表名:"+tableName; content += ",表名:" + tableName;
} }
if(res.isSuccess()){ if (res.isSuccess()) {
content+= ","+(oConvertUtils.isEmpty(msg)?"操作成功":msg); content += "," + (oConvertUtils.isEmpty(msg) ? "操作成功" : msg);
}else{ } else {
content+= ","+(oConvertUtils.isEmpty(msg)?"操作失败":msg); content += "," + (oConvertUtils.isEmpty(msg) ? "操作失败" : msg);
} }
} }
return content; return content;

View File

@@ -60,14 +60,14 @@ public class DictAspect {
@Around("excudeService()") @Around("excudeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable { public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long time1=System.currentTimeMillis(); long time1 = System.currentTimeMillis();
Object result = pjp.proceed(); Object result = pjp.proceed();
long time2=System.currentTimeMillis(); long time2 = System.currentTimeMillis();
log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms"); log.debug("获取JSON数据 耗时:" + (time2 - time1) + "ms");
long start=System.currentTimeMillis(); long start = System.currentTimeMillis();
result=this.parseDictText(result); result = this.parseDictText(result);
long end=System.currentTimeMillis(); long end = System.currentTimeMillis();
log.debug("注入字典到JSON数据 耗时"+(end-start)+"ms"); log.debug("注入字典到JSON数据 耗时" + (end - start) + "ms");
return result; return result;
} }
@@ -77,20 +77,21 @@ public class DictAspect {
* 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text已字段名称加_dictText形式返回到前端 * 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text已字段名称加_dictText形式返回到前端
* 例输入当前返回值的就会多出一个sex_dictText字段 * 例输入当前返回值的就会多出一个sex_dictText字段
* { * {
* sex:1, * sex:1,
* sex_dictText:"男" * sex_dictText:"男"
* } * }
* 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了 * 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
* customRender:function (text) { * customRender:function (text) {
* if(text==1){ * if(text==1){
* return "男"; * return "男";
* }else if(text==2){ * }else if(text==2){
* return "女"; * return "女";
* }else{ * }else{
* return text; * return text;
* } * }
* } * }
* 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用 * 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
*
* @param result * @param result
*/ */
private Object parseDictText(Object result) { private Object parseDictText(Object result) {
@@ -104,24 +105,24 @@ public class DictAspect {
// 字典数据列表, key = 字典codevalue=数据列表 // 字典数据列表, key = 字典codevalue=数据列表
Map<String, List<String>> dataListMap = new HashMap<>(5); Map<String, List<String>> dataListMap = new HashMap<>(5);
//取出结果集 //取出结果集
List<Object> records=((IPage) ((Result) result).getResult()).getRecords(); List<Object> records = ((IPage) ((Result) result).getResult()).getRecords();
//update-begin--Author:zyf -- Date:20220606 ----for【VUEN-1230】 判断是否含有字典注解,没有注解返回----- //update-begin--Author:zyf -- Date:20220606 ----for【VUEN-1230】 判断是否含有字典注解,没有注解返回-----
Boolean hasDict= checkHasDict(records); Boolean hasDict = checkHasDict(records);
if(!hasDict){ if (!hasDict) {
return result; return result;
} }
log.debug(" __ 进入字典翻译切面 DictAspect —— " ); log.debug(" __ 进入字典翻译切面 DictAspect —— ");
//update-end--Author:zyf -- Date:20220606 ----for【VUEN-1230】 判断是否含有字典注解,没有注解返回----- //update-end--Author:zyf -- Date:20220606 ----for【VUEN-1230】 判断是否含有字典注解,没有注解返回-----
for (Object record : records) { for (Object record : records) {
String json="{}"; String json = "{}";
try { try {
//update-begin--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错----- //update-begin--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错-----
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat //解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = objectMapper.writeValueAsString(record); json = objectMapper.writeValueAsString(record);
//update-end--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错----- //update-end--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错-----
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
log.error("json解析失败"+e.getMessage(),e); log.error("json解析失败" + e.getMessage(), e);
} }
//update-begin--Author:scott -- Date:20211223 ----for【issues/3303】restcontroller返回json数据后key顺序错乱 ----- //update-begin--Author:scott -- Date:20211223 ----for【issues/3303】restcontroller返回json数据后key顺序错乱 -----
JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
@@ -135,7 +136,7 @@ public class DictAspect {
if (oConvertUtils.isEmpty(value)) { if (oConvertUtils.isEmpty(value)) {
continue; continue;
} }
//update-end--Author:scott -- Date:20190603 ----for解决继承实体字段无法翻译问题------ //update-end--Author:scott -- Date:20190603 ----for解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) { if (field.getAnnotation(Dict.class) != null) {
if (!dictFieldList.contains(field)) { if (!dictFieldList.contains(field)) {
dictFieldList.add(field); dictFieldList.add(field);
@@ -159,8 +160,8 @@ public class DictAspect {
//date类型默认转换string格式化日期 //date类型默认转换string格式化日期
//update-begin--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错----- //update-begin--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错-----
//if (JAVA_UTIL_DATE.equals(field.getType().getName())&&field.getAnnotation(JsonFormat.class)==null&&item.get(field.getName())!=null){ //if (JAVA_UTIL_DATE.equals(field.getType().getName())&&field.getAnnotation(JsonFormat.class)==null&&item.get(field.getName())!=null){
//SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName())))); // item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
//} //}
//update-end--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错----- //update-end--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错-----
} }
@@ -190,7 +191,7 @@ public class DictAspect {
String value = record.getString(field.getName()); String value = record.getString(field.getName());
if (oConvertUtils.isNotEmpty(value)) { if (oConvertUtils.isNotEmpty(value)) {
List<DictModel> dictModels = translText.get(fieldDictCode); List<DictModel> dictModels = translText.get(fieldDictCode);
if(dictModels==null || dictModels.size()==0){ if (dictModels == null || dictModels.size() == 0) {
continue; continue;
} }
@@ -229,6 +230,7 @@ public class DictAspect {
* 一次性把所有的字典都翻译了 * 一次性把所有的字典都翻译了
* 1. 所有的普通数据字典的所有数据只执行一次SQL * 1. 所有的普通数据字典的所有数据只执行一次SQL
* 2. 表字典相同的所有数据只执行一次SQL * 2. 表字典相同的所有数据只执行一次SQL
*
* @param dataListMap * @param dataListMap
* @return * @return
*/ */
@@ -298,7 +300,7 @@ public class DictAspect {
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------ //update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
//update-begin---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串--- //update-begin---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串---
if(null == dataSource){ if (null == dataSource) {
dataSource = ""; dataSource = "";
} }
//update-end---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串--- //update-end---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串---
@@ -380,7 +382,8 @@ public class DictAspect {
} }
/** /**
* 翻译字典文本 * 翻译字典文本
*
* @param code * @param code
* @param text * @param text
* @param table * @param table
@@ -389,39 +392,39 @@ public class DictAspect {
*/ */
@Deprecated @Deprecated
private String translateDictValue(String code, String text, String table, String key) { private String translateDictValue(String code, String text, String table, String key) {
if(oConvertUtils.isEmpty(key)) { if (oConvertUtils.isEmpty(key)) {
return null; return null;
} }
StringBuffer textValue=new StringBuffer(); StringBuffer textValue = new StringBuffer();
String[] keys = key.split(","); String[] keys = key.split(",");
for (String k : keys) { for (String k : keys) {
String tmpValue = null; String tmpValue = null;
log.debug(" 字典 key : "+ k); log.debug(" 字典 key : " + k);
if (k.trim().length() == 0) { if (k.trim().length() == 0) {
continue; //跳过循环 continue; //跳过循环
} }
//update-begin--Author:scott -- Date:20210531 ----for !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题----- //update-begin--Author:scott -- Date:20210531 ----for !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
if (!StringUtils.isEmpty(table)){ if (!StringUtils.isEmpty(table)) {
log.debug("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code); log.debug("--DictAspect------dicTable=" + table + " ,dicText= " + text + " ,dicCode=" + code);
String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]",table,text,code,k.trim()); String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]", table, text, code, k.trim());
if (redisTemplate.hasKey(keyString)){ if (redisTemplate.hasKey(keyString)) {
try { try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString)); tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) { } catch (Exception e) {
log.warn(e.getMessage()); log.warn(e.getMessage());
} }
}else { } else {
tmpValue= commonApi.translateDictFromTable(table,text,code,k.trim()); tmpValue = commonApi.translateDictFromTable(table, text, code, k.trim());
} }
}else { } else {
String keyString = String.format("sys:cache:dict::%s:%s",code,k.trim()); String keyString = String.format("sys:cache:dict::%s:%s", code, k.trim());
if (redisTemplate.hasKey(keyString)){ if (redisTemplate.hasKey(keyString)) {
try { try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString)); tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) { } catch (Exception e) {
log.warn(e.getMessage()); log.warn(e.getMessage());
} }
}else { } else {
tmpValue = commonApi.translateDict(code, k.trim()); tmpValue = commonApi.translateDict(code, k.trim());
} }
} }
@@ -440,11 +443,12 @@ public class DictAspect {
/** /**
* 检测返回结果集中是否包含Dict注解 * 检测返回结果集中是否包含Dict注解
*
* @param records * @param records
* @return * @return
*/ */
private Boolean checkHasDict(List<Object> records){ private Boolean checkHasDict(List<Object> records) {
if(oConvertUtils.isNotEmpty(records) && records.size()>0){ if (oConvertUtils.isNotEmpty(records) && records.size() > 0) {
for (Field field : oConvertUtils.getAllFields(records.get(0))) { for (Field field : oConvertUtils.getAllFields(records.get(0))) {
if (oConvertUtils.isNotEmpty(field.getAnnotation(Dict.class))) { if (oConvertUtils.isNotEmpty(field.getAnnotation(Dict.class))) {
return true; return true;

View File

@@ -1,5 +1,6 @@
package org.jeecg.common.aspect; package org.jeecg.common.aspect;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
@@ -21,13 +22,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import jakarta.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
/** /**
* 数据权限切面处理类 * 数据权限切面处理类
* 当被请求的方法有注解PermissionData时,会在往当前request中写入数据权限信息 * 当被请求的方法有注解PermissionData时,会在往当前request中写入数据权限信息
*
* @Date 2019年4月10日 * @Date 2019年4月10日
* @Version: 1.0 * @Version: 1.0
* @author: jeecg-boot * @author: jeecg-boot
@@ -48,7 +49,7 @@ public class PermissionDataAspect {
} }
@Around("pointCut()") @Around("pointCut()")
public Object arround(ProceedingJoinPoint point) throws Throwable{ public Object arround(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
MethodSignature signature = (MethodSignature) point.getSignature(); MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod(); Method method = signature.getMethod();
@@ -59,11 +60,11 @@ public class PermissionDataAspect {
requestPath = filterUrl(requestPath); requestPath = filterUrl(requestPath);
//update-begin-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效 //update-begin-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效
//先判断是否online报表请求 //先判断是否online报表请求
if(requestPath.indexOf(UrlMatchEnum.CGREPORT_DATA.getMatchUrl())>=0 || requestPath.indexOf(UrlMatchEnum.CGREPORT_ONLY_DATA.getMatchUrl())>=0){ if (requestPath.indexOf(UrlMatchEnum.CGREPORT_DATA.getMatchUrl()) >= 0 || requestPath.indexOf(UrlMatchEnum.CGREPORT_ONLY_DATA.getMatchUrl()) >= 0) {
// 获取地址栏参数 // 获取地址栏参数
String urlParamString = request.getParameter(CommonConstant.ONL_REP_URL_PARAM_STR); String urlParamString = request.getParameter(CommonConstant.ONL_REP_URL_PARAM_STR);
if(oConvertUtils.isNotEmpty(urlParamString)){ if (oConvertUtils.isNotEmpty(urlParamString)) {
requestPath+="?"+urlParamString; requestPath += "?" + urlParamString;
} }
} }
//update-end-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效 //update-end-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效
@@ -72,22 +73,22 @@ public class PermissionDataAspect {
//查询数据权限信息 //查询数据权限信息
//TODO 微服务情况下也得支持缓存机制 //TODO 微服务情况下也得支持缓存机制
List<SysPermissionDataRuleModel> dataRules = commonApi.queryPermissionDataRule(component, requestPath, username); List<SysPermissionDataRuleModel> dataRules = commonApi.queryPermissionDataRule(component, requestPath, username);
if(dataRules!=null && dataRules.size()>0) { if (dataRules != null && dataRules.size() > 0) {
//临时存储 //临时存储
JeecgDataAutorUtils.installDataSearchConditon(request, dataRules); JeecgDataAutorUtils.installDataSearchConditon(request, dataRules);
//TODO 微服务情况下也得支持缓存机制 //TODO 微服务情况下也得支持缓存机制
SysUserCacheInfo userinfo = commonApi.getCacheUser(username); SysUserCacheInfo userinfo = commonApi.getCacheUser(username);
JeecgDataAutorUtils.installUserInfo(request, userinfo); JeecgDataAutorUtils.installUserInfo(request, userinfo);
} }
return point.proceed(); return point.proceed();
} }
private String filterUrl(String requestPath){ private String filterUrl(String requestPath) {
String url = ""; String url = "";
if(oConvertUtils.isNotEmpty(requestPath)){ if (oConvertUtils.isNotEmpty(requestPath)) {
url = requestPath.replace("\\", "/"); url = requestPath.replace("\\", "/");
url = url.replace("//", "/"); url = url.replace("//", "/");
if(url.indexOf(SymbolConstant.DOUBLE_SLASH)>=0){ if (url.indexOf(SymbolConstant.DOUBLE_SLASH) >= 0) {
url = filterUrl(url); url = filterUrl(url);
} }
/*if(url.startsWith("/")){ /*if(url.startsWith("/")){
@@ -99,6 +100,7 @@ public class PermissionDataAspect {
/** /**
* 获取请求地址 * 获取请求地址
*
* @param request * @param request
* @return * @return
*/ */
@@ -106,18 +108,18 @@ public class PermissionDataAspect {
private String getJgAuthRequsetPath(HttpServletRequest request) { private String getJgAuthRequsetPath(HttpServletRequest request) {
String queryString = request.getQueryString(); String queryString = request.getQueryString();
String requestPath = request.getRequestURI(); String requestPath = request.getRequestURI();
if(oConvertUtils.isNotEmpty(queryString)){ if (oConvertUtils.isNotEmpty(queryString)) {
requestPath += "?" + queryString; requestPath += "?" + queryString;
} }
// 去掉其他参数(保留一个参数) 例如loginController.do?login // 去掉其他参数(保留一个参数) 例如loginController.do?login
if (requestPath.indexOf(SymbolConstant.AND) > -1) { if (requestPath.indexOf(SymbolConstant.AND) > -1) {
requestPath = requestPath.substring(0, requestPath.indexOf("&")); requestPath = requestPath.substring(0, requestPath.indexOf("&"));
} }
if(requestPath.indexOf(QueryRuleEnum.EQ.getValue())!=-1){ if (requestPath.indexOf(QueryRuleEnum.EQ.getValue()) != -1) {
if(requestPath.indexOf(SPOT_DO)!=-1){ if (requestPath.indexOf(SPOT_DO) != -1) {
requestPath = requestPath.substring(0,requestPath.indexOf(".do")+3); requestPath = requestPath.substring(0, requestPath.indexOf(".do") + 3);
}else{ } else {
requestPath = requestPath.substring(0,requestPath.indexOf("?")); requestPath = requestPath.substring(0, requestPath.indexOf("?"));
} }
} }
// 去掉项目路径 // 去掉项目路径
@@ -126,9 +128,9 @@ public class PermissionDataAspect {
} }
@Deprecated @Deprecated
private boolean moHuContain(List<String> list,String key){ private boolean moHuContain(List<String> list, String key) {
for(String str : list){ for (String str : list) {
if(key.contains(str)){ if (key.contains(str)) {
return true; return true;
} }
} }

View File

@@ -6,19 +6,33 @@ package org.jeecg.common.aspect;
* @Description: 请求URL与菜单路由URL转换规则方便于采用菜单路由URL来配置数据权限规则 * @Description: 请求URL与菜单路由URL转换规则方便于采用菜单路由URL来配置数据权限规则
*/ */
public enum UrlMatchEnum { public enum UrlMatchEnum {
/**求URL与菜单路由URL转换规则 /online/cgform/api/getData/ */ /**
* 求URL与菜单路由URL转换规则 /online/cgform/api/getData/
*/
CGFORM_DATA("/online/cgform/api/getData/", "/online/cgformList/"), CGFORM_DATA("/online/cgform/api/getData/", "/online/cgformList/"),
/**求URL与菜单路由URL转换规则 /online/cgform/api/exportXls/ */ /**
* 求URL与菜单路由URL转换规则 /online/cgform/api/exportXls/
*/
CGFORM_EXCEL_DATA("/online/cgform/api/exportXls/", "/online/cgformList/"), CGFORM_EXCEL_DATA("/online/cgform/api/exportXls/", "/online/cgformList/"),
/**求URL与菜单路由URL转换规则 /online/cgform/api/getTreeData/ */ /**
* 求URL与菜单路由URL转换规则 /online/cgform/api/getTreeData/
*/
CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", "/online/cgformList/"), CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", "/online/cgformList/"),
/**求URL与菜单路由URL转换规则 /online/cgreport/api/getColumnsAndData/ */ /**
* 求URL与菜单路由URL转换规则 /online/cgreport/api/getColumnsAndData/
*/
CGREPORT_DATA("/online/cgreport/api/getColumnsAndData/", "/online/cgreport/"), CGREPORT_DATA("/online/cgreport/api/getColumnsAndData/", "/online/cgreport/"),
/** 求URL与菜单路由URL转换规则/online/cgreport/api/getData/ 【vue3报表数据请求地址】 */ /**
* 求URL与菜单路由URL转换规则/online/cgreport/api/getData/ 【vue3报表数据请求地址】
*/
CGREPORT_ONLY_DATA("/online/cgreport/api/getData/", "/online/cgreport/"), CGREPORT_ONLY_DATA("/online/cgreport/api/getData/", "/online/cgreport/"),
/**求URL与菜单路由URL转换规则 /online/cgreport/api/exportXls/ */ /**
* 求URL与菜单路由URL转换规则 /online/cgreport/api/exportXls/
*/
CGREPORT_EXCEL_DATA("/online/cgreport/api/exportXls/", "/online/cgreport/"), CGREPORT_EXCEL_DATA("/online/cgreport/api/exportXls/", "/online/cgreport/"),
/**求URL与菜单路由URL转换规则 /online/cgreport/api/exportManySheetXls/ */ /**
* 求URL与菜单路由URL转换规则 /online/cgreport/api/exportManySheetXls/
*/
CGREPORT_EXCEL_DATA2("/online/cgreport/api/exportManySheetXls/", "/online/cgreport/"); CGREPORT_EXCEL_DATA2("/online/cgreport/api/exportManySheetXls/", "/online/cgreport/");
UrlMatchEnum(String url, String matchUrl) { UrlMatchEnum(String url, String matchUrl) {

View File

@@ -14,10 +14,11 @@ import java.lang.annotation.*;
@Documented @Documented
public @interface AutoDict { public @interface AutoDict {
/** /**
* 暂时无用 * 暂时无用
* @return *
*/ * @return
String value() default ""; */
String value() default "";
} }

View File

@@ -17,30 +17,31 @@ import java.lang.annotation.*;
@Documented @Documented
public @interface AutoLog { public @interface AutoLog {
/** /**
* 日志内容 * 日志内容
* *
* @return * @return
*/ */
String value() default ""; String value() default "";
/** /**
* 日志类型 * 日志类型
* *
* @return 0:操作日志;1:登录日志;2:定时任务; * @return 0:操作日志;1:登录日志;2:定时任务;
*/ */
int logType() default CommonConstant.LOG_TYPE_2; int logType() default CommonConstant.LOG_TYPE_2;
/** /**
* 操作日志类型 * 操作日志类型
* *
* @return 1查询2添加3修改4删除 * @return 1查询2添加3修改4删除
*/ */
int operateType() default 0; int operateType() default 0;
/** /**
* 模块类型 默认为common * 模块类型 默认为common
* @return *
*/ * @return
ModuleType module() default ModuleType.COMMON; */
ModuleType module() default ModuleType.COMMON;
} }

View File

@@ -7,6 +7,7 @@ import java.lang.annotation.Target;
/** /**
* 字典注解 * 字典注解
*
* @author: dangzhenghui * @author: dangzhenghui
* @date: 2019年03月17日-下午9:37:16 * @date: 2019年03月17日-下午9:37:16
*/ */
@@ -42,6 +43,7 @@ public @interface Dict {
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------ //update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
/** /**
* 方法描述: 数据字典表所在数据源名称 * 方法描述: 数据字典表所在数据源名称
* 作 者: chenrui * 作 者: chenrui

View File

@@ -14,6 +14,7 @@ import java.lang.annotation.*;
public @interface DynamicTable { public @interface DynamicTable {
/** /**
* 需要动态解析的表名 * 需要动态解析的表名
*
* @return * @return
*/ */
String value(); String value();

View File

@@ -4,15 +4,17 @@ import java.lang.annotation.*;
/** /**
* online请求拦截专用注解 * online请求拦截专用注解
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD}) @Target({ElementType.TYPE, ElementType.METHOD})
@Documented @Documented
public @interface OnlineAuth { public @interface OnlineAuth {
/** /**
* 请求关键字在xxx/code之前的字符串 * 请求关键字在xxx/code之前的字符串
*
* @return * @return
*/ */
String value(); String value();

View File

@@ -1,29 +1,27 @@
package org.jeecg.common.aspect.annotation; package org.jeecg.common.aspect.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**
* 数据权限注解 * 数据权限注解
*
* @Author taoyan * @Author taoyan
* @Date 2019年4月11日 * @Date 2019年4月11日
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD}) @Target({ElementType.TYPE, ElementType.METHOD})
@Documented @Documented
public @interface PermissionData { public @interface PermissionData {
/** /**
* 暂时没用 * 暂时没用
* @return *
*/ * @return
String value() default ""; */
String value() default "";
/** /**
* 配置菜单的组件路径,用于数据权限 * 配置菜单的组件路径,用于数据权限
*/ */
String pageComponent() default ""; String pageComponent() default "";
} }

View File

@@ -6,35 +6,35 @@ package org.jeecg.common.constant;
*/ */
public interface CommonConstant { public interface CommonConstant {
/** /**
* 正常状态 * 正常状态
*/ */
Integer STATUS_NORMAL = 0; Integer STATUS_NORMAL = 0;
/** /**
* 禁用状态 * 禁用状态
*/ */
Integer STATUS_DISABLE = -1; Integer STATUS_DISABLE = -1;
/** /**
* 删除标志 * 删除标志
*/ */
Integer DEL_FLAG_1 = 1; Integer DEL_FLAG_1 = 1;
/** /**
* 未删除 * 未删除
*/ */
Integer DEL_FLAG_0 = 0; Integer DEL_FLAG_0 = 0;
/** /**
* 系统日志类型: 登录 * 系统日志类型: 登录
*/ */
int LOG_TYPE_1 = 1; int LOG_TYPE_1 = 1;
/** /**
* 系统日志类型: 操作 * 系统日志类型: 操作
*/ */
int LOG_TYPE_2 = 2; int LOG_TYPE_2 = 2;
/** /**
* 系统日志类型: 租户操作日志 * 系统日志类型: 租户操作日志
@@ -46,98 +46,122 @@ public interface CommonConstant {
*/ */
int LOG_TYPE_4 = 4; int LOG_TYPE_4 = 4;
/** /**
* 操作日志类型: 查询 * 操作日志类型: 查询
*/ */
int OPERATE_TYPE_1 = 1; int OPERATE_TYPE_1 = 1;
/** /**
* 操作日志类型: 添加 * 操作日志类型: 添加
*/ */
int OPERATE_TYPE_2 = 2; int OPERATE_TYPE_2 = 2;
/** /**
* 操作日志类型: 更新 * 操作日志类型: 更新
*/ */
int OPERATE_TYPE_3 = 3; int OPERATE_TYPE_3 = 3;
/** /**
* 操作日志类型: 删除 * 操作日志类型: 删除
*/ */
int OPERATE_TYPE_4 = 4; int OPERATE_TYPE_4 = 4;
/** /**
* 操作日志类型: 倒入 * 操作日志类型: 倒入
*/ */
int OPERATE_TYPE_5 = 5; int OPERATE_TYPE_5 = 5;
/** /**
* 操作日志类型: 导出 * 操作日志类型: 导出
*/ */
int OPERATE_TYPE_6 = 6; int OPERATE_TYPE_6 = 6;
/** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ /**
* {@code 500 Server Error} (HTTP/1.0 - RFC 1945)
*/
Integer SC_INTERNAL_SERVER_ERROR_500 = 500; Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
/** {@code 404 Not Found} (HTTP/1.0 - RFC 1945) */ /**
* {@code 404 Not Found} (HTTP/1.0 - RFC 1945)
*/
Integer SC_INTERNAL_NOT_FOUND_404 = 404; Integer SC_INTERNAL_NOT_FOUND_404 = 404;
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ /**
* {@code 200 OK} (HTTP/1.0 - RFC 1945)
*/
Integer SC_OK_200 = 200; Integer SC_OK_200 = 200;
/**访问权限认证未通过 510*/ /**
Integer SC_JEECG_NO_AUTHZ=510; * 访问权限认证未通过 510
*/
Integer SC_JEECG_NO_AUTHZ = 510;
/** 登录用户Shiro权限缓存KEY前缀 */ /**
public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; * 登录用户Shiro权限缓存KEY前缀
/** 登录用户Token令牌缓存KEY前缀 */ */
String PREFIX_USER_TOKEN = "prefix_user_token:"; public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
/**
* 登录用户Token令牌缓存KEY前缀
*/
String PREFIX_USER_TOKEN = "prefix_user_token:";
// /** Token缓存时间3600秒即一小时 */ // /** Token缓存时间3600秒即一小时 */
// int TOKEN_EXPIRE_TIME = 3600; // int TOKEN_EXPIRE_TIME = 3600;
/** 登录二维码 */ /**
String LOGIN_QRCODE_PRE = "QRCODELOGIN:"; * 登录二维码
String LOGIN_QRCODE = "LQ:"; */
/** 登录二维码token */ String LOGIN_QRCODE_PRE = "QRCODELOGIN:";
String LOGIN_QRCODE_TOKEN = "LQT:"; String LOGIN_QRCODE = "LQ:";
/**
* 登录二维码token
*/
String LOGIN_QRCODE_TOKEN = "LQT:";
/** /**
* 0一级菜单 * 0一级菜单
*/ */
Integer MENU_TYPE_0 = 0; Integer MENU_TYPE_0 = 0;
/**
* 1子菜单
*/
Integer MENU_TYPE_1 = 1;
/** /**
* 2按钮权限 * 1子菜单
*/ */
Integer MENU_TYPE_2 = 2; Integer MENU_TYPE_1 = 1;
/**
* 2按钮权限
*/
Integer MENU_TYPE_2 = 2;
/**通告对象类型USER:指定用户ALL:全体用户)*/ /**
String MSG_TYPE_UESR = "USER"; * 通告对象类型USER:指定用户ALL:全体用户)
String MSG_TYPE_ALL = "ALL"; */
String MSG_TYPE_UESR = "USER";
String MSG_TYPE_ALL = "ALL";
/**发布状态0未发布1已发布2已撤销*/ /**
String NO_SEND = "0"; * 发布状态0未发布1已发布2已撤销
String HAS_SEND = "1"; */
String HAS_CANCLE = "2"; String NO_SEND = "0";
String HAS_SEND = "1";
String HAS_CANCLE = "2";
/**阅读状态0未读1已读*/ /**
Integer HAS_READ_FLAG = 1; * 阅读状态0未读1已读
Integer NO_READ_FLAG = 0; */
Integer HAS_READ_FLAG = 1;
Integer NO_READ_FLAG = 0;
/**优先级L低M中H高*/ /**
String PRIORITY_L = "L"; * 优先级L低M中H高
String PRIORITY_M = "M"; */
String PRIORITY_H = "H"; String PRIORITY_L = "L";
String PRIORITY_M = "M";
String PRIORITY_H = "H";
/** /**
* 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板
*/ */
String SMS_TPL_TYPE_0 = "0"; String SMS_TPL_TYPE_0 = "0";
String SMS_TPL_TYPE_1 = "1"; String SMS_TPL_TYPE_1 = "1";
String SMS_TPL_TYPE_2 = "2"; String SMS_TPL_TYPE_2 = "2";
/** /**
* 状态(0无效1有效) * 状态(0无效1有效)
@@ -170,9 +194,13 @@ public interface CommonConstant {
Integer USER_FREEZE = 2; Integer USER_FREEZE = 2;
Integer USER_QUIT = 3; Integer USER_QUIT = 3;
/**字典翻译文本后缀*/ /**
* 字典翻译文本后缀
*/
String DICT_TEXT_SUFFIX = "_dictText"; String DICT_TEXT_SUFFIX = "_dictText";
/**字典翻译颜色后缀*/ /**
* 字典翻译颜色后缀
*/
String DICT_COLOR_SUFFIX = "_dictColor"; String DICT_COLOR_SUFFIX = "_dictColor";
/** /**
@@ -248,26 +276,46 @@ public interface CommonConstant {
Integer USER_IDENTITY_1 = 1; Integer USER_IDENTITY_1 = 1;
Integer USER_IDENTITY_2 = 2; Integer USER_IDENTITY_2 = 2;
/** sys_user 表 username 唯一键索引 */ /**
* sys_user 表 username 唯一键索引
*/
String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username"; String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username";
/** sys_user 表 work_no 唯一键索引 */ /**
* sys_user 表 work_no 唯一键索引
*/
String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no"; String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no";
/** sys_user 表 phone 唯一键索引 */ /**
* sys_user 表 phone 唯一键索引
*/
String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone"; String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone";
/** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */ /**
* 达梦数据库升提示。违反表[SYS_USER]唯一性约束
*/
String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束"; String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束";
/** sys_user 表 email 唯一键索引 */ /**
* sys_user 表 email 唯一键索引
*/
String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email"; String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email";
/** sys_quartz_job 表 job_class_name 唯一键索引 */ /**
* sys_quartz_job 表 job_class_name 唯一键索引
*/
String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name"; String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name";
/** sys_position 表 code 唯一键索引 */ /**
* sys_position 表 code 唯一键索引
*/
String SQL_INDEX_UNIQ_CODE = "uniq_code"; String SQL_INDEX_UNIQ_CODE = "uniq_code";
/** sys_role 表 code 唯一键索引 */ /**
* sys_role 表 code 唯一键索引
*/
String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code"; String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
/** sys_depart 表 code 唯一键索引 */ /**
* sys_depart 表 code 唯一键索引
*/
String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code"; String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
/** sys_category 表 code 唯一键索引 */ /**
* sys_category 表 code 唯一键索引
*/
String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code"; String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code";
/** /**
* 在线聊天 是否为默认分组 * 在线聊天 是否为默认分组
@@ -311,7 +359,7 @@ public interface CommonConstant {
* 公文文档上传自定义路径 * 公文文档上传自定义路径
*/ */
String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc"; String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc";
/** /**
* 公文文档下载自定义路径 * 公文文档下载自定义路径
*/ */
String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown"; String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown";
@@ -319,8 +367,8 @@ public interface CommonConstant {
/** /**
* WPS存储值类别(1 code文号 2 textWPS模板还是公文发文模板) * WPS存储值类别(1 code文号 2 textWPS模板还是公文发文模板)
*/ */
String WPS_TYPE_1="1"; String WPS_TYPE_1 = "1";
String WPS_TYPE_2="2"; String WPS_TYPE_2 = "2";
/**===============================================================================================*/ /**===============================================================================================*/
@@ -331,11 +379,17 @@ public interface CommonConstant {
String X_ACCESS_TOKEN = "X-Access-Token"; String X_ACCESS_TOKEN = "X-Access-Token";
String X_SIGN = "X-Sign"; String X_SIGN = "X-Sign";
String X_TIMESTAMP = "X-TIMESTAMP"; String X_TIMESTAMP = "X-TIMESTAMP";
/** 租户请求头 更名为X-Tenant-Id */ /**
* 租户请求头 更名为X-Tenant-Id
*/
String TENANT_ID = "X-Tenant-Id"; String TENANT_ID = "X-Tenant-Id";
/** 简流接口请求头,用于排除不支持的控件字段 */ /**
* 简流接口请求头,用于排除不支持的控件字段
*/
String X_MiniFlowExclusionFieldMode = "X-Miniflowexclusionfieldmode"; String X_MiniFlowExclusionFieldMode = "X-Miniflowexclusionfieldmode";
/**===============================================================================================*/ /**
* ===============================================================================================
*/
String TOKEN_IS_INVALID_MSG = "Token失效请重新登录!"; String TOKEN_IS_INVALID_MSG = "Token失效请重新登录!";
String X_FORWARDED_SCHEME = "X-Forwarded-Scheme"; String X_FORWARDED_SCHEME = "X-Forwarded-Scheme";
@@ -360,41 +414,65 @@ public interface CommonConstant {
*/ */
String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL"; String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL";
/** 系统通告消息状态0=未发布 */ /**
* 系统通告消息状态0=未发布
*/
String ANNOUNCEMENT_SEND_STATUS_0 = "0"; String ANNOUNCEMENT_SEND_STATUS_0 = "0";
/** 系统通告消息状态1=已发布 */ /**
* 系统通告消息状态1=已发布
*/
String ANNOUNCEMENT_SEND_STATUS_1 = "1"; String ANNOUNCEMENT_SEND_STATUS_1 = "1";
/** 系统通告消息状态2=已撤销 */ /**
* 系统通告消息状态2=已撤销
*/
String ANNOUNCEMENT_SEND_STATUS_2 = "2"; String ANNOUNCEMENT_SEND_STATUS_2 = "2";
/**ONLINE 报表权限用 从request中获取地址栏后的参数*/ /**
String ONL_REP_URL_PARAM_STR="onlRepUrlParamStr"; * ONLINE 报表权限用 从request中获取地址栏后的参数
*/
String ONL_REP_URL_PARAM_STR = "onlRepUrlParamStr";
/**POST请求*/ /**
* POST请求
*/
String HTTP_POST = "POST"; String HTTP_POST = "POST";
/**PUT请求*/ /**
* PUT请求
*/
String HTTP_PUT = "PUT"; String HTTP_PUT = "PUT";
/**PATCH请求*/ /**
* PATCH请求
*/
String HTTP_PATCH = "PATCH"; String HTTP_PATCH = "PATCH";
/**未知的*/ /**
* 未知的
*/
String UNKNOWN = "unknown"; String UNKNOWN = "unknown";
/**字符串http*/ /**
* 字符串http
*/
String STR_HTTP = "http"; String STR_HTTP = "http";
/**String 类型的空值*/ /**
* String 类型的空值
*/
String STRING_NULL = "null"; String STRING_NULL = "null";
/**前端vue3版本Header参数名*/ /**
String VERSION="X-Version"; * 前端vue3版本Header参数名
*/
String VERSION = "X-Version";
String VERSION_V3 = "v3"; String VERSION_V3 = "v3";
/**存储在线程变量里的动态表名*/ /**
String DYNAMIC_TABLE_NAME="DYNAMIC_TABLE_NAME"; * 存储在线程变量里的动态表名
*/
String DYNAMIC_TABLE_NAME = "DYNAMIC_TABLE_NAME";
/** /**
* http:// http协议 * http:// http协议
*/ */
@@ -405,9 +483,13 @@ public interface CommonConstant {
*/ */
String HTTPS_PROTOCOL = "https://"; String HTTPS_PROTOCOL = "https://";
/** 部门表唯一keyid */ /**
* 部门表唯一keyid
*/
String DEPART_KEY_ID = "id"; String DEPART_KEY_ID = "id";
/** 部门表唯一keyorgCode */ /**
* 部门表唯一keyorgCode
*/
String DEPART_KEY_ORG_CODE = "orgCode"; String DEPART_KEY_ORG_CODE = "orgCode";
/**======【消息推送相关】==============================================================================*/ /**======【消息推送相关】==============================================================================*/
@@ -421,10 +503,10 @@ public interface CommonConstant {
*/ */
String NOTICE_MSG_BUS_ID = "NOTICE_MSG_BUS_ID"; String NOTICE_MSG_BUS_ID = "NOTICE_MSG_BUS_ID";
/** /**
* 发消息 消息业务类型 * 发消息 消息业务类型
*/ */
String NOTICE_MSG_BUS_TYPE = "NOTICE_MSG_BUS_TYPE"; String NOTICE_MSG_BUS_TYPE = "NOTICE_MSG_BUS_TYPE";
/** /**
* 邮箱消息中地址登录时地址后携带的token,需要替换成真实的token值 * 邮箱消息中地址登录时地址后携带的token,需要替换成真实的token值
@@ -446,7 +528,9 @@ public interface CommonConstant {
*/ */
String DATA_LOG_TYPE_JSON = "json"; String DATA_LOG_TYPE_JSON = "json";
/** 消息模板markdown */ /**
* 消息模板markdown
*/
String MSG_TEMPLATE_TYPE_MD = "5"; String MSG_TEMPLATE_TYPE_MD = "5";
/**========【消息推送相关】==========================================================================*/ /**========【消息推送相关】==========================================================================*/
@@ -485,84 +569,86 @@ public interface CommonConstant {
*/ */
Integer BPM_USER_EVENT_ADD = 1; Integer BPM_USER_EVENT_ADD = 1;
/** /**
* 离职事件 * 离职事件
*/ */
Integer BPM_USER_EVENT_LEVEL = 2; Integer BPM_USER_EVENT_LEVEL = 2;
/** /**
* 用户租户状态(正常/已通过审核的) * 用户租户状态(正常/已通过审核的)
*/ */
String USER_TENANT_NORMAL = "1"; String USER_TENANT_NORMAL = "1";
/** /**
* 用户租户状态(离职) * 用户租户状态(离职)
*/ */
String USER_TENANT_QUIT = "2"; String USER_TENANT_QUIT = "2";
/** /**
* 用户租户状态(审核中) * 用户租户状态(审核中)
*/ */
String USER_TENANT_UNDER_REVIEW = "3"; String USER_TENANT_UNDER_REVIEW = "3";
/** /**
* 用户租户状态(拒绝) * 用户租户状态(拒绝)
*/ */
String USER_TENANT_REFUSE = "4"; String USER_TENANT_REFUSE = "4";
/** /**
* 用户租户状态(邀请) * 用户租户状态(邀请)
*/ */
String USER_TENANT_INVITE = "5"; String USER_TENANT_INVITE = "5";
/** /**
* 不是叶子节点 * 不是叶子节点
*/ */
Integer NOT_LEAF = 0; Integer NOT_LEAF = 0;
/** /**
* 是叶子节点 * 是叶子节点
*/ */
Integer IS_LEAF = 1; Integer IS_LEAF = 1;
/** /**
* 钉钉 * 钉钉
*/ */
String DINGTALK = "DINGTALK"; String DINGTALK = "DINGTALK";
/** /**
* 企业微信 * 企业微信
*/ */
String WECHAT_ENTERPRISE = "WECHAT_ENTERPRISE"; String WECHAT_ENTERPRISE = "WECHAT_ENTERPRISE";
/** /**
* 系统默认租户id 0 * 系统默认租户id 0
*/ */
Integer TENANT_ID_DEFAULT_VALUE = 0; Integer TENANT_ID_DEFAULT_VALUE = 0;
/** /**
* 【low-app用】 应用级别的复制 * 【low-app用】 应用级别的复制
*/ */
String COPY_LEVEL_APP = "app"; String COPY_LEVEL_APP = "app";
/** /**
* 【low-app用】 菜单级别的复制 * 【low-app用】 菜单级别的复制
*/ */
String COPY_LEVEL_MENU = "menu"; String COPY_LEVEL_MENU = "menu";
/** /**
* 【low-app用】 应用备份 * 【low-app用】 应用备份
*/ */
String COPY_LEVEL_BAK = "backup"; String COPY_LEVEL_BAK = "backup";
/** /**
* 【low-app用】 从备份还原 * 【low-app用】 从备份还原
*/ */
String COPY_LEVEL_COVER = "cover"; String COPY_LEVEL_COVER = "cover";
/** 【QQYUN-6034】关联字段变更历史值缓存半个小时 */ /**
String CACHE_REL_FIELD_OLD_VAL = "sys:cache:desform:relFieldOldVal:"; * 【QQYUN-6034】关联字段变更历史值缓存半个小时
*/
String CACHE_REL_FIELD_OLD_VAL = "sys:cache:desform:relFieldOldVal:";
/** /**
* 排序类型:升序 * 排序类型:升序
@@ -574,47 +660,47 @@ public interface CommonConstant {
String ORDER_TYPE_DESC = "DESC"; String ORDER_TYPE_DESC = "DESC";
//update-begin---author:scott ---date:2023-09-10 for积木报表常量---- //update-begin---author:scott ---date:2023-09-10 for积木报表常量----
/** /**
* 报表允许设计开发的角色 * 报表允许设计开发的角色
*/ */
public static String[] allowDevRoles = new String[]{"lowdeveloper", "admin"}; public static String[] allowDevRoles = new String[]{"lowdeveloper", "admin"};
/** /**
* 【对应积木报表的常量】 * 【对应积木报表的常量】
* 数据隔离模式: 按照创建人隔离 * 数据隔离模式: 按照创建人隔离
*/ */
public static final String SAAS_MODE_CREATED = "created"; public static final String SAAS_MODE_CREATED = "created";
/** /**
* 【对应积木报表的常量】 * 【对应积木报表的常量】
* 数据隔离模式: 按照租户隔离 * 数据隔离模式: 按照租户隔离
*/ */
public static final String SAAS_MODE_TENANT = "tenant"; public static final String SAAS_MODE_TENANT = "tenant";
//update-end---author:scott ---date::2023-09-10 for积木报表常量---- //update-end---author:scott ---date::2023-09-10 for积木报表常量----
//update-begin---author:wangshuai---date:2024-04-07---for:修改手机号常量--- //update-begin---author:wangshuai---date:2024-04-07---for:修改手机号常量---
/** /**
* 修改手机号短信验证码redis-key的前缀 * 修改手机号短信验证码redis-key的前缀
*/ */
String CHANGE_PHONE_REDIS_KEY_PRE = "sys:cache:phone:change_phone_msg:"; String CHANGE_PHONE_REDIS_KEY_PRE = "sys:cache:phone:change_phone_msg:";
/** /**
* 缓存用户最后一次收到消息通知的时间 KEY * 缓存用户最后一次收到消息通知的时间 KEY
*/ */
String CACHE_KEY_USER_LAST_ANNOUNT_TIME_1HOUR = "sys:cache:userinfo:user_last_annount_time::%s"; String CACHE_KEY_USER_LAST_ANNOUNT_TIME_1HOUR = "sys:cache:userinfo:user_last_annount_time::%s";
/** /**
* 验证原手机号 * 验证原手机号
*/ */
String VERIFY_ORIGINAL_PHONE = "verifyOriginalPhone"; String VERIFY_ORIGINAL_PHONE = "verifyOriginalPhone";
/** /**
* 修改手机号 * 修改手机号
*/ */
String UPDATE_PHONE = "updatePhone"; String UPDATE_PHONE = "updatePhone";
//update-end---author:wangshuai---date:2024-04-07---for:修改手机号常量--- //update-end---author:wangshuai---date:2024-04-07---for:修改手机号常量---
/** /**
* 修改手机号验证码请求次数超出 * 修改手机号验证码请求次数超出
*/ */
Integer PHONE_SMS_FAIL_CODE = 40002; Integer PHONE_SMS_FAIL_CODE = 40002;
} }

View File

@@ -1,9 +1,9 @@
package org.jeecg.common.constant; package org.jeecg.common.constant;
/** /**
* 系统通告 - 发布状态 * 系统通告 - 发布状态
* @Author LeeShaoQing
* *
* @Author LeeShaoQing
*/ */
public interface CommonSendStatus { public interface CommonSendStatus {
@@ -15,34 +15,44 @@ public interface CommonSendStatus {
/** /**
* 已发布 * 已发布
*/ */
public static final String PUBLISHED_STATUS_1 = "1"; public static final String PUBLISHED_STATUS_1 = "1";
/** /**
* 撤销 * 撤销
*/ */
public static final String REVOKE_STATUS_2 = "2"; public static final String REVOKE_STATUS_2 = "2";
/** /**
* app端推送会话标识后缀 * app端推送会话标识后缀
*/ */
public static final String APP_SESSION_SUFFIX = "_app"; public static final String APP_SESSION_SUFFIX = "_app";
/**-----【流程相关通知模板code】------------------------------------------------------------*/ /**-----【流程相关通知模板code】------------------------------------------------------------*/
/**流程催办——系统通知消息模板*/ /**
public static final String TZMB_BPM_CUIBAN = "bpm_cuiban"; * 流程催办——系统通知消息模板
/**流程抄送——系统通知消息模板*/ */
public static final String TZMB_BPM_CC = "bpm_cc"; public static final String TZMB_BPM_CUIBAN = "bpm_cuiban";
/**流程催办——邮件通知消息模板*/ /**
public static final String TZMB_BPM_CUIBAN_EMAIL = "bpm_cuiban_email"; * 流程抄送——系统通知消息模板
/**标准模板—系统消息通知*/ */
public static final String TZMB_SYS_TS_NOTE = "sys_ts_note"; public static final String TZMB_BPM_CC = "bpm_cc";
/**流程超时提醒——系统通知消息模板*/ /**
public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip"; * 流程催办——邮件通知消息模板
/**-----【流程相关通知模板code】-----------------------------------------------------------*/ */
public static final String TZMB_BPM_CUIBAN_EMAIL = "bpm_cuiban_email";
/**
* 标准模板—系统消息通知
*/
public static final String TZMB_SYS_TS_NOTE = "sys_ts_note";
/**
* 流程超时提醒——系统通知消息模板
*/
public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip";
/**-----【流程相关通知模板code】-----------------------------------------------------------*/
/** /**
* 系统通知拓展参数(比如:用于流程抄送和催办通知,这里额外传递流程跳转页面所需要的路由参数) * 系统通知拓展参数(比如:用于流程抄送和催办通知,这里额外传递流程跳转页面所需要的路由参数)
*/ */
public static final String MSG_ABSTRACT_JSON = "msg_abstract"; public static final String MSG_ABSTRACT_JSON = "msg_abstract";
} }

View File

@@ -1,37 +1,57 @@
package org.jeecg.common.constant; package org.jeecg.common.constant;
/** /**
* 数据库上下文常量 * 数据库上下文常量
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public interface DataBaseConstant { public interface DataBaseConstant {
//*********数据库类型**************************************** //*********数据库类型****************************************
/**MYSQL数据库*/ /**
public static final String DB_TYPE_MYSQL = "MYSQL"; * MYSQL数据库
*/
public static final String DB_TYPE_MYSQL = "MYSQL";
/** ORACLE*/ /**
public static final String DB_TYPE_ORACLE = "ORACLE"; * ORACLE
*/
public static final String DB_TYPE_ORACLE = "ORACLE";
/**达梦数据库*/ /**
public static final String DB_TYPE_DM = "DM"; * 达梦数据库
*/
public static final String DB_TYPE_DM = "DM";
/**postgreSQL达梦数据库*/ /**
public static final String DB_TYPE_POSTGRESQL = "POSTGRESQL"; * postgreSQL达梦数据库
*/
public static final String DB_TYPE_POSTGRESQL = "POSTGRESQL";
/**人大金仓数据库*/ /**
public static final String DB_TYPE_KINGBASEES = "KINGBASEES"; * 人大金仓数据库
*/
public static final String DB_TYPE_KINGBASEES = "KINGBASEES";
/**sqlserver数据库*/ /**
public static final String DB_TYPE_SQLSERVER = "SQLSERVER"; * sqlserver数据库
*/
public static final String DB_TYPE_SQLSERVER = "SQLSERVER";
/**mariadb 数据库*/ /**
public static final String DB_TYPE_MARIADB = "MARIADB"; * mariadb 数据库
*/
public static final String DB_TYPE_MARIADB = "MARIADB";
/**DB2 数据库*/ /**
public static final String DB_TYPE_DB2 = "DB2"; * DB2 数据库
*/
public static final String DB_TYPE_DB2 = "DB2";
/**HSQL 数据库*/ /**
public static final String DB_TYPE_HSQL = "HSQL"; * HSQL 数据库
*/
public static final String DB_TYPE_HSQL = "HSQL";
// // 数据库类型,对应 database_type 字典 // // 数据库类型,对应 database_type 字典
// public static final String DB_TYPE_MYSQL_NUM = "1"; // public static final String DB_TYPE_MYSQL_NUM = "1";
@@ -41,129 +61,129 @@ public interface DataBaseConstant {
// public static final String DB_TYPE_POSTGRESQL_NUM = "4"; // public static final String DB_TYPE_POSTGRESQL_NUM = "4";
// public static final String DB_TYPE_MARIADB_NUM = "5"; // public static final String DB_TYPE_MARIADB_NUM = "5";
//*********系统上下文变量**************************************** //*********系统上下文变量****************************************
/** /**
* 数据-所属机构编码 * 数据-所属机构编码
*/ */
public static final String SYS_ORG_CODE = "sysOrgCode"; public static final String SYS_ORG_CODE = "sysOrgCode";
/** /**
* 数据-所属机构编码 * 数据-所属机构编码
*/ */
public static final String SYS_ORG_CODE_TABLE = "sys_org_code"; public static final String SYS_ORG_CODE_TABLE = "sys_org_code";
/** /**
* 数据-所属机构编码 * 数据-所属机构编码
*/ */
public static final String SYS_MULTI_ORG_CODE = "sysMultiOrgCode"; public static final String SYS_MULTI_ORG_CODE = "sysMultiOrgCode";
/** /**
* 数据-所属机构编码 * 数据-所属机构编码
*/ */
public static final String SYS_MULTI_ORG_CODE_TABLE = "sys_multi_org_code"; public static final String SYS_MULTI_ORG_CODE_TABLE = "sys_multi_org_code";
/** /**
* 数据-所属机构ID * 数据-所属机构ID
*/ */
public static final String SYS_ORG_ID = "sysOrgId"; public static final String SYS_ORG_ID = "sysOrgId";
/** /**
* 数据-所属机构ID * 数据-所属机构ID
*/ */
public static final String SYS_ORG_ID_TABLE = "sys_org_id"; public static final String SYS_ORG_ID_TABLE = "sys_org_id";
/** /**
* 数据-所属角色code多个逗号分割 * 数据-所属角色code多个逗号分割
*/ */
public static final String SYS_ROLE_CODE = "sysRoleCode"; public static final String SYS_ROLE_CODE = "sysRoleCode";
/** /**
* 数据-所属角色code多个逗号分割 * 数据-所属角色code多个逗号分割
*/ */
public static final String SYS_ROLE_CODE_TABLE = "sys_role_code"; public static final String SYS_ROLE_CODE_TABLE = "sys_role_code";
/** /**
* 数据-系统用户编码(对应登录用户账号) * 数据-系统用户编码(对应登录用户账号)
*/ */
public static final String SYS_USER_CODE = "sysUserCode"; public static final String SYS_USER_CODE = "sysUserCode";
/** /**
* 数据-系统用户编码(对应登录用户账号) * 数据-系统用户编码(对应登录用户账号)
*/ */
public static final String SYS_USER_CODE_TABLE = "sys_user_code"; public static final String SYS_USER_CODE_TABLE = "sys_user_code";
/** /**
* 登录用户ID * 登录用户ID
*/ */
public static final String SYS_USER_ID = "sysUserId"; public static final String SYS_USER_ID = "sysUserId";
/** /**
* 登录用户ID * 登录用户ID
*/ */
public static final String SYS_USER_ID_TABLE = "sys_user_id"; public static final String SYS_USER_ID_TABLE = "sys_user_id";
/** /**
* 登录用户真实姓名 * 登录用户真实姓名
*/ */
public static final String SYS_USER_NAME = "sysUserName"; public static final String SYS_USER_NAME = "sysUserName";
/** /**
* 登录用户真实姓名 * 登录用户真实姓名
*/ */
public static final String SYS_USER_NAME_TABLE = "sys_user_name"; public static final String SYS_USER_NAME_TABLE = "sys_user_name";
/** /**
* 系统日期"yyyy-MM-dd" * 系统日期"yyyy-MM-dd"
*/ */
public static final String SYS_DATE = "sysDate"; public static final String SYS_DATE = "sysDate";
/** /**
* 系统日期"yyyy-MM-dd" * 系统日期"yyyy-MM-dd"
*/ */
public static final String SYS_DATE_TABLE = "sys_date"; public static final String SYS_DATE_TABLE = "sys_date";
/** /**
* 系统时间"yyyy-MM-dd HH:mm" * 系统时间"yyyy-MM-dd HH:mm"
*/ */
public static final String SYS_TIME = "sysTime"; public static final String SYS_TIME = "sysTime";
/** /**
* 系统时间"yyyy-MM-dd HH:mm" * 系统时间"yyyy-MM-dd HH:mm"
*/ */
public static final String SYS_TIME_TABLE = "sys_time"; public static final String SYS_TIME_TABLE = "sys_time";
/** /**
* 数据-所属机构编码 * 数据-所属机构编码
*/ */
public static final String SYS_BASE_PATH = "sys_base_path"; public static final String SYS_BASE_PATH = "sys_base_path";
//*********系统上下文变量**************************************** //*********系统上下文变量****************************************
//*********系统建表标准字段**************************************** //*********系统建表标准字段****************************************
/** /**
* 创建者登录名称 * 创建者登录名称
*/ */
public static final String CREATE_BY_TABLE = "create_by"; public static final String CREATE_BY_TABLE = "create_by";
/** /**
* 创建者登录名称 * 创建者登录名称
*/ */
public static final String CREATE_BY = "createBy"; public static final String CREATE_BY = "createBy";
/** /**
* 创建日期时间 * 创建日期时间
*/ */
public static final String CREATE_TIME_TABLE = "create_time"; public static final String CREATE_TIME_TABLE = "create_time";
/** /**
* 创建日期时间 * 创建日期时间
*/ */
public static final String CREATE_TIME = "createTime"; public static final String CREATE_TIME = "createTime";
/** /**
* 更新用户登录名称 * 更新用户登录名称
*/ */
public static final String UPDATE_BY_TABLE = "update_by"; public static final String UPDATE_BY_TABLE = "update_by";
/** /**
* 更新用户登录名称 * 更新用户登录名称
*/ */
public static final String UPDATE_BY = "updateBy"; public static final String UPDATE_BY = "updateBy";
/** /**
* 更新日期时间 * 更新日期时间
*/ */
public static final String UPDATE_TIME = "updateTime"; public static final String UPDATE_TIME = "updateTime";
/** /**
* 更新日期时间 * 更新日期时间
*/ */
public static final String UPDATE_TIME_TABLE = "update_time"; public static final String UPDATE_TIME_TABLE = "update_time";
/** /**
* 业务流程状态 * 业务流程状态
*/ */
public static final String BPM_STATUS = "bpmStatus"; public static final String BPM_STATUS = "bpmStatus";
/** /**
* 业务流程状态 * 业务流程状态
*/ */
public static final String BPM_STATUS_TABLE = "bpm_status"; public static final String BPM_STATUS_TABLE = "bpm_status";
//*********系统建表标准字段**************************************** //*********系统建表标准字段****************************************
/** /**
* sql语句 where * sql语句 where

View File

@@ -2,6 +2,7 @@ package org.jeecg.common.constant;
/** /**
* 规则值生成 编码常量类 * 规则值生成 编码常量类
*
* @author: taoyan * @author: taoyan
* @date: 2020年04月02日 * @date: 2020年04月02日
*/ */

View File

@@ -2,16 +2,12 @@ package org.jeecg.common.constant;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Scanner;
import java.util.Set;
import java.util.List; import java.util.List;
import java.util.Scanner;
/** /**
* @Description: 省市区 * @Description: 省市区
@@ -21,24 +17,24 @@ import java.util.List;
public class ProvinceCityArea { public class ProvinceCityArea {
List<Area> areaList; List<Area> areaList;
public String getText(String code){ public String getText(String code) {
this.initAreaList(); this.initAreaList();
if(this.areaList!=null || this.areaList.size()>0){ if (this.areaList != null || this.areaList.size() > 0) {
List<String> ls = new ArrayList<String>(); List<String> ls = new ArrayList<String>();
getAreaByCode(code,ls); getAreaByCode(code, ls);
return String.join("/",ls); return String.join("/", ls);
} }
return ""; return "";
} }
public String getCode(String text){ public String getCode(String text) {
this.initAreaList(); this.initAreaList();
if(areaList!=null && areaList.size()>0){ if (areaList != null && areaList.size() > 0) {
for(int i=areaList.size()-1;i>=0;i--){ for (int i = areaList.size() - 1; i >= 0; i--) {
//update-begin-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区 //update-begin-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区
String areaText = areaList.get(i).getText(); String areaText = areaList.get(i).getText();
String cityText = areaList.get(i).getAheadText(); String cityText = areaList.get(i).getAheadText();
if(text.indexOf(areaText)>=0 && (cityText!=null && text.indexOf(cityText)>=0)){ if (text.indexOf(areaText) >= 0 && (cityText != null && text.indexOf(cityText) >= 0)) {
return areaList.get(i).getId(); return areaList.get(i).getId();
} }
//update-end-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区 //update-end-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区
@@ -48,8 +44,10 @@ public class ProvinceCityArea {
} }
// update-begin-author:sunjianlei date:20220121 for:【JTC-704】数据导入错误 省市区组件,文件中为北京市,导入后,导为了山西省 // update-begin-author:sunjianlei date:20220121 for:【JTC-704】数据导入错误 省市区组件,文件中为北京市,导入后,导为了山西省
/** /**
* 获取省市区code精准匹配 * 获取省市区code精准匹配
*
* @param texts 文本数组,省,市,区 * @param texts 文本数组,省,市,区
* @return 返回 省市区的code * @return 返回 省市区的code
*/ */
@@ -83,6 +81,7 @@ public class ProvinceCityArea {
/** /**
* 根据text获取area * 根据text获取area
*
* @param text * @param text
* @return * @return
*/ */
@@ -97,6 +96,7 @@ public class ProvinceCityArea {
/** /**
* 通过pid获取 area 对象 * 通过pid获取 area 对象
*
* @param pCode 父级编码 * @param pCode 父级编码
* @param text * @param text
* @return * @return
@@ -114,41 +114,41 @@ public class ProvinceCityArea {
} }
// update-end-author:sunjianlei date:20220121 for:【JTC-704】数据导入错误 省市区组件,文件中为北京市,导入后,导为了山西省 // update-end-author:sunjianlei date:20220121 for:【JTC-704】数据导入错误 省市区组件,文件中为北京市,导入后,导为了山西省
public void getAreaByCode(String code,List<String> ls){ public void getAreaByCode(String code, List<String> ls) {
for(Area area: areaList){ for (Area area : areaList) {
if(area.getId().equals(code)){ if (area.getId().equals(code)) {
String pid = area.getPid(); String pid = area.getPid();
ls.add(0,area.getText()); ls.add(0, area.getText());
getAreaByCode(pid,ls); getAreaByCode(pid, ls);
} }
} }
} }
private void initAreaList(){ private void initAreaList() {
//System.out.println("====================="); //System.out.println("=====================");
if(this.areaList==null || this.areaList.size()==0){ if (this.areaList == null || this.areaList.size() == 0) {
this.areaList = new ArrayList<Area>(); this.areaList = new ArrayList<Area>();
try { try {
String jsonData = oConvertUtils.readStatic("classpath:static/pca.json"); String jsonData = oConvertUtils.readStatic("classpath:static/pca.json");
JSONObject baseJson = JSONObject.parseObject(jsonData); JSONObject baseJson = JSONObject.parseObject(jsonData);
//第一层 省 //第一层 省
JSONObject provinceJson = baseJson.getJSONObject("86"); JSONObject provinceJson = baseJson.getJSONObject("86");
for(String provinceKey: provinceJson.keySet()){ for (String provinceKey : provinceJson.keySet()) {
//System.out.println("===="+provinceKey); //System.out.println("===="+provinceKey);
Area province = new Area(provinceKey,provinceJson.getString(provinceKey),"86"); Area province = new Area(provinceKey, provinceJson.getString(provinceKey), "86");
this.areaList.add(province); this.areaList.add(province);
//第二层 市 //第二层 市
JSONObject cityJson = baseJson.getJSONObject(provinceKey); JSONObject cityJson = baseJson.getJSONObject(provinceKey);
for(String cityKey:cityJson.keySet()){ for (String cityKey : cityJson.keySet()) {
//System.out.println("-----"+cityKey); //System.out.println("-----"+cityKey);
Area city = new Area(cityKey,cityJson.getString(cityKey),provinceKey); Area city = new Area(cityKey, cityJson.getString(cityKey), provinceKey);
this.areaList.add(city); this.areaList.add(city);
//第三层 区 //第三层 区
JSONObject areaJson = baseJson.getJSONObject(cityKey); JSONObject areaJson = baseJson.getJSONObject(cityKey);
if(areaJson!=null){ if (areaJson != null) {
for(String areaKey:areaJson.keySet()){ for (String areaKey : areaJson.keySet()) {
//System.out.println("········"+areaKey); //System.out.println("········"+areaKey);
Area area = new Area(areaKey,areaJson.getString(areaKey),cityKey); Area area = new Area(areaKey, areaJson.getString(areaKey), cityKey);
//update-begin-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区 //update-begin-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区
area.setAheadText(cityJson.getString(cityKey)); area.setAheadText(cityJson.getString(cityKey));
//update-end-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区 //update-end-author:taoyan date:2022-5-24 for:VUEN-1088 online 导入 省市区导入后 导入数据错乱 北京市/市辖区/西城区-->山西省/晋城市/城区
@@ -165,7 +165,7 @@ public class ProvinceCityArea {
} }
private String jsonRead(File file){ private String jsonRead(File file) {
Scanner scanner = null; Scanner scanner = null;
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
try { try {
@@ -183,14 +183,14 @@ public class ProvinceCityArea {
return buffer.toString(); return buffer.toString();
} }
class Area{ class Area {
String id; String id;
String text; String text;
String pid; String pid;
// 用于存储上级文本数据,区的上级文本 是市的数据 // 用于存储上级文本数据,区的上级文本 是市的数据
String aheadText; String aheadText;
public Area(String id,String text,String pid){ public Area(String id, String text, String pid) {
this.id = id; this.id = id;
this.text = text; this.text = text;
this.pid = pid; this.pid = pid;
@@ -211,6 +211,7 @@ public class ProvinceCityArea {
public String getAheadText() { public String getAheadText() {
return aheadText; return aheadText;
} }
public void setAheadText(String aheadText) { public void setAheadText(String aheadText) {
this.aheadText = aheadText; this.aheadText = aheadText;
} }

View File

@@ -25,18 +25,18 @@ package org.jeecg.common.constant;
*/ */
public interface ServiceNameConstants { public interface ServiceNameConstants {
/** /**
* 微服务名:系统管理模块 * 微服务名:系统管理模块
*/ */
String SERVICE_SYSTEM = "jeecg-system"; String SERVICE_SYSTEM = "jeecg-system";
/** /**
* 微服务名: demo模块 * 微服务名: demo模块
*/ */
String SERVICE_DEMO = "jeecg-demo"; String SERVICE_DEMO = "jeecg-demo";
/** /**
* 微服务名joa模块 * 微服务名joa模块
*/ */
String SERVICE_JOA = "jeecg-joa"; String SERVICE_JOA = "jeecg-joa";
// /** // /**
// * 微服务名online在线模块 // * 微服务名online在线模块
@@ -51,9 +51,9 @@ public interface ServiceNameConstants {
// */ // */
// String SERVICE_FORM = "jeecg-desform"; // String SERVICE_FORM = "jeecg-desform";
/** /**
* gateway通过header传递根路径 basePath * gateway通过header传递根路径 basePath
*/ */
String X_GATEWAY_BASE_PATH = "X_GATEWAY_BASE_PATH"; String X_GATEWAY_BASE_PATH = "X_GATEWAY_BASE_PATH";
} }

View File

@@ -2,6 +2,7 @@ package org.jeecg.common.constant;
/** /**
* VXESocket 常量 * VXESocket 常量
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class VxeSocketConst { public class VxeSocketConst {

View File

@@ -7,6 +7,7 @@ import java.util.Map;
/** /**
* online表单枚举 代码生成器用到 * online表单枚举 代码生成器用到
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public enum CgformEnum { public enum CgformEnum {
@@ -14,33 +15,33 @@ public enum CgformEnum {
/** /**
* 单表 * 单表
*/ */
ONE(1, "one", "/jeecg/code-template-online", "default.one", "经典风格", new String[]{"vue3","vue","vue3Native"}), ONE(1, "one", "/jeecg/code-template-online", "default.one", "经典风格", new String[]{"vue3", "vue", "vue3Native"}),
/** /**
* 多表 * 多表
*/ */
MANY(2, "many", "/jeecg/code-template-online", "default.onetomany", "经典风格" ,new String[]{"vue"}), MANY(2, "many", "/jeecg/code-template-online", "default.onetomany", "经典风格", new String[]{"vue"}),
/** /**
* 多表jvxe风格 * 多表jvxe风格
* */ */
JVXE_TABLE(2, "jvxe", "/jeecg/code-template-online", "jvxe.onetomany", "默认风格" ,new String[]{"vue3","vue","vue3Native"}), JVXE_TABLE(2, "jvxe", "/jeecg/code-template-online", "jvxe.onetomany", "默认风格", new String[]{"vue3", "vue", "vue3Native"}),
/** /**
* 多表 (erp风格) * 多表 (erp风格)
*/ */
ERP(2, "erp", "/jeecg/code-template-online", "erp.onetomany", "ERP风格" ,new String[]{"vue3","vue","vue3Native"}), ERP(2, "erp", "/jeecg/code-template-online", "erp.onetomany", "ERP风格", new String[]{"vue3", "vue", "vue3Native"}),
/** /**
* 多表(内嵌子表风格) * 多表(内嵌子表风格)
*/ */
INNER_TABLE(2, "innerTable", "/jeecg/code-template-online", "inner-table.onetomany", "内嵌子表风格" ,new String[]{"vue3","vue"}), INNER_TABLE(2, "innerTable", "/jeecg/code-template-online", "inner-table.onetomany", "内嵌子表风格", new String[]{"vue3", "vue"}),
/** /**
* 多表tab风格 * 多表tab风格
* */ */
TAB(2, "tab", "/jeecg/code-template-online", "tab.onetomany", "Tab风格" ,new String[]{"vue3","vue"}), TAB(2, "tab", "/jeecg/code-template-online", "tab.onetomany", "Tab风格", new String[]{"vue3", "vue"}),
/** /**
* 树形列表 * 树形列表
*/ */
TREE(3, "tree", "/jeecg/code-template-online", "default.tree", "树形列表" ,new String[]{"vue3","vue","vue3Native"}); TREE(3, "tree", "/jeecg/code-template-online", "default.tree", "树形列表", new String[]{"vue3", "vue", "vue3Native"});
/** /**
* 类型 1/单表 2/一对多 3/树 * 类型 1/单表 2/一对多 3/树
@@ -70,12 +71,12 @@ public enum CgformEnum {
/** /**
* 构造器 * 构造器
* *
* @param type 类型 1/单表 2/一对多 3/树 * @param type 类型 1/单表 2/一对多 3/树
* @param code 模板编码 * @param code 模板编码
* @param templatePath 模板路径 * @param templatePath 模板路径
* @param stylePath 模板子路径 * @param stylePath 模板子路径
* @param note * @param note
* @param vueStyle 支持代码风格 * @param vueStyle 支持代码风格
*/ */
CgformEnum(int type, String code, String templatePath, String stylePath, String note, String[] vueStyle) { CgformEnum(int type, String code, String templatePath, String stylePath, String note, String[] vueStyle) {
this.type = type; this.type = type;

View File

@@ -8,76 +8,92 @@ import org.apache.commons.lang3.StringUtils;
*/ */
public enum DySmsEnum { public enum DySmsEnum {
/**登录短信模板编码*/ /**
LOGIN_TEMPLATE_CODE("SMS_175435174","敲敲云","code"), * 登录短信模板编码
/**忘记密码短信模板编码*/ */
FORGET_PASSWORD_TEMPLATE_CODE("SMS_175435174","敲敲云","code"), LOGIN_TEMPLATE_CODE("SMS_175435174", "敲敲云", "code"),
/**修改密码短信模板编码*/ /**
CHANGE_PASSWORD_TEMPLATE_CODE("SMS_465391221","敲敲云","code"), * 忘记密码短信模板编码
/**注册账号短信模板编码*/ */
REGISTER_TEMPLATE_CODE("SMS_175430166","敲敲云","code"), FORGET_PASSWORD_TEMPLATE_CODE("SMS_175435174", "敲敲云", "code"),
/**会议通知*/ /**
MEET_NOTICE_TEMPLATE_CODE("SMS_201480469","JEECG","username,title,minute,time"), * 修改密码短信模板编码
/**我的计划通知*/ */
PLAN_NOTICE_TEMPLATE_CODE("SMS_201470515","JEECG","username,title,time"), CHANGE_PASSWORD_TEMPLATE_CODE("SMS_465391221", "敲敲云", "code"),
/**支付成功短信通知*/ /**
PAY_SUCCESS_NOTICE_CODE("SMS_461735163","敲敲云","realname,money,endTime"), * 注册账号短信模板编码
/**会员到期通知提醒*/ */
VIP_EXPIRE_NOTICE_CODE("SMS_461885023","敲敲云","realname,endTime"); REGISTER_TEMPLATE_CODE("SMS_175430166", "敲敲云", "code"),
/**
* 会议通知
*/
MEET_NOTICE_TEMPLATE_CODE("SMS_201480469", "JEECG", "username,title,minute,time"),
/**
* 我的计划通知
*/
PLAN_NOTICE_TEMPLATE_CODE("SMS_201470515", "JEECG", "username,title,time"),
/**
* 支付成功短信通知
*/
PAY_SUCCESS_NOTICE_CODE("SMS_461735163", "敲敲云", "realname,money,endTime"),
/**
* 会员到期通知提醒
*/
VIP_EXPIRE_NOTICE_CODE("SMS_461885023", "敲敲云", "realname,endTime");
/** /**
* 短信模板编码 * 短信模板编码
*/ */
private String templateCode; private String templateCode;
/** /**
* 签名 * 签名
*/ */
private String signName; private String signName;
/** /**
* 短信模板必需的数据名称多个key以逗号分隔此处配置作为校验 * 短信模板必需的数据名称多个key以逗号分隔此处配置作为校验
*/ */
private String keys; private String keys;
private DySmsEnum(String templateCode,String signName,String keys) { private DySmsEnum(String templateCode, String signName, String keys) {
this.templateCode = templateCode; this.templateCode = templateCode;
this.signName = signName; this.signName = signName;
this.keys = keys; this.keys = keys;
} }
public String getTemplateCode() { public String getTemplateCode() {
return templateCode; return templateCode;
} }
public void setTemplateCode(String templateCode) { public void setTemplateCode(String templateCode) {
this.templateCode = templateCode; this.templateCode = templateCode;
} }
public String getSignName() { public String getSignName() {
return signName; return signName;
} }
public void setSignName(String signName) { public void setSignName(String signName) {
this.signName = signName; this.signName = signName;
} }
public String getKeys() { public String getKeys() {
return keys; return keys;
} }
public void setKeys(String keys) { public void setKeys(String keys) {
this.keys = keys; this.keys = keys;
} }
public static DySmsEnum toEnum(String templateCode) { public static DySmsEnum toEnum(String templateCode) {
if(StringUtils.isEmpty(templateCode)){ if (StringUtils.isEmpty(templateCode)) {
return null; return null;
} }
for(DySmsEnum item : DySmsEnum.values()) { for (DySmsEnum item : DySmsEnum.values()) {
if(item.getTemplateCode().equals(templateCode)) { if (item.getTemplateCode().equals(templateCode)) {
return item; return item;
} }
} }
return null; return null;
} }
} }

View File

@@ -8,35 +8,37 @@ import org.jeecg.common.util.oConvertUtils;
public enum FileTypeEnum { public enum FileTypeEnum {
// 文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频 voice:语音) // 文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频 voice:语音)
// FOLDER // FOLDER
xls(".xls","excel","excel"), xls(".xls", "excel", "excel"),
xlsx(".xlsx","excel","excel"), xlsx(".xlsx", "excel", "excel"),
doc(".doc","doc","word"), doc(".doc", "doc", "word"),
docx(".docx","doc","word"), docx(".docx", "doc", "word"),
ppt(".ppt","pp","ppt"), ppt(".ppt", "pp", "ppt"),
pptx(".pptx","pp","ppt"), pptx(".pptx", "pp", "ppt"),
gif(".gif","image","图片"), gif(".gif", "image", "图片"),
jpg(".jpg","image","图片"), jpg(".jpg", "image", "图片"),
jpeg(".jpeg","image","图片"), jpeg(".jpeg", "image", "图片"),
png(".png","image","图片"), png(".png", "image", "图片"),
txt(".txt","text","文本"), txt(".txt", "text", "文本"),
avi(".avi","video","视频"), avi(".avi", "video", "视频"),
mov(".mov","video","视频"), mov(".mov", "video", "视频"),
rmvb(".rmvb","video","视频"), rmvb(".rmvb", "video", "视频"),
rm(".rm","video","视频"), rm(".rm", "video", "视频"),
flv(".flv","video","视频"), flv(".flv", "video", "视频"),
mp4(".mp4","video","视频"), mp4(".mp4", "video", "视频"),
zip(".zip","zip","压缩包"), zip(".zip", "zip", "压缩包"),
pdf(".pdf","pdf","pdf"), pdf(".pdf", "pdf", "pdf"),
mp3(".mp3","mp3","语音"); mp3(".mp3", "mp3", "语音");
private String type; private String type;
private String value; private String value;
private String text; private String text;
private FileTypeEnum(String type,String value,String text){
private FileTypeEnum(String type, String value, String text) {
this.type = type; this.type = type;
this.value = value; this.value = value;
this.text = text; this.text = text;
} }
public String getType() { public String getType() {
return type; return type;
} }
@@ -61,7 +63,7 @@ public enum FileTypeEnum {
this.text = text; this.text = text;
} }
public static FileTypeEnum getByType(String type){ public static FileTypeEnum getByType(String type) {
if (oConvertUtils.isEmpty(type)) { if (oConvertUtils.isEmpty(type)) {
return null; return null;
} }

View File

@@ -8,21 +8,30 @@ import java.util.List;
/** /**
* 消息类型 * 消息类型
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@EnumDict("messageType") @EnumDict("messageType")
public enum MessageTypeEnum { public enum MessageTypeEnum {
/** 系统消息 */ /**
XT("system", "系统消息"), * 系统消息
/** 邮件消息 */ */
YJ("email", "邮件消息"), XT("system", "系统消息"),
/** 钉钉消息 */ /**
* 邮件消息
*/
YJ("email", "邮件消息"),
/**
* 钉钉消息
*/
DD("dingtalk", "钉钉消息"), DD("dingtalk", "钉钉消息"),
/** 企业微信 */ /**
* 企业微信
*/
QYWX("wechat_enterprise", "企业微信"); QYWX("wechat_enterprise", "企业微信");
MessageTypeEnum(String type, String note){ MessageTypeEnum(String type, String note) {
this.type = type; this.type = type;
this.note = note; this.note = note;
} }
@@ -56,12 +65,13 @@ public enum MessageTypeEnum {
/** /**
* 获取字典数据 * 获取字典数据
*
* @return * @return
*/ */
public static List<DictModel> getDictList(){ public static List<DictModel> getDictList() {
List<DictModel> list = new ArrayList<>(); List<DictModel> list = new ArrayList<>();
DictModel dictModel = null; DictModel dictModel = null;
for(MessageTypeEnum e: MessageTypeEnum.values()){ for (MessageTypeEnum e : MessageTypeEnum.values()) {
dictModel = new DictModel(); dictModel = new DictModel();
dictModel.setValue(e.getType()); dictModel.setValue(e.getType());
dictModel.setText(e.getNote()); dictModel.setText(e.getNote());

View File

@@ -2,6 +2,7 @@ package org.jeecg.common.constant.enums;
/** /**
* 日志按模块分类 * 日志按模块分类
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public enum ModuleType { public enum ModuleType {

View File

@@ -8,6 +8,7 @@ import java.util.List;
* 首页自定义 * 首页自定义
* 通过角色编码与首页组件路径配置 * 通过角色编码与首页组件路径配置
* 枚举的顺序有权限高低权重作用(也就是配置多个角色,在前面的角色首页,会优先生效) * 枚举的顺序有权限高低权重作用(也就是配置多个角色,在前面的角色首页,会优先生效)
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public enum RoleIndexConfigEnum { public enum RoleIndexConfigEnum {
@@ -15,7 +16,9 @@ public enum RoleIndexConfigEnum {
/**首页自定义 admin*/ /**首页自定义 admin*/
// ADMIN("admin", "dashboard/Analysis"), // ADMIN("admin", "dashboard/Analysis"),
//TEST("test", "dashboard/IndexChart"), //TEST("test", "dashboard/IndexChart"),
/**首页自定义 hr*/ /**
* 首页自定义 hr
*/
// HR("hr", "dashboard/IndexBdc"); // HR("hr", "dashboard/IndexBdc");
//DM("dm", "dashboard/IndexTask"), //DM("dm", "dashboard/IndexTask"),
@@ -35,15 +38,17 @@ public enum RoleIndexConfigEnum {
/** /**
* 构造器 * 构造器
* *
* @param roleCode 角色编码 * @param roleCode 角色编码
* @param componentUrl 首页组件路径(规则跟菜单配置一样) * @param componentUrl 首页组件路径(规则跟菜单配置一样)
*/ */
RoleIndexConfigEnum(String roleCode, String componentUrl) { RoleIndexConfigEnum(String roleCode, String componentUrl) {
this.roleCode = roleCode; this.roleCode = roleCode;
this.componentUrl = componentUrl; this.componentUrl = componentUrl;
} }
/** /**
* 根据code找枚举 * 根据code找枚举
*
* @param roleCode 角色编码 * @param roleCode 角色编码
* @return * @return
*/ */
@@ -55,8 +60,10 @@ public enum RoleIndexConfigEnum {
} }
return null; return null;
} }
/** /**
* 根据code找index * 根据code找index
*
* @param roleCode 角色编码 * @param roleCode 角色编码
* @return * @return
*/ */
@@ -72,7 +79,7 @@ public enum RoleIndexConfigEnum {
public static String getIndexByRoles(List<String> roles) { public static String getIndexByRoles(List<String> roles) {
String[] rolesArray = roles.toArray(new String[roles.size()]); String[] rolesArray = roles.toArray(new String[roles.size()]);
for (RoleIndexConfigEnum e : RoleIndexConfigEnum.values()) { for (RoleIndexConfigEnum e : RoleIndexConfigEnum.values()) {
if (oConvertUtils.isIn(e.roleCode,rolesArray)){ if (oConvertUtils.isIn(e.roleCode, rolesArray)) {
return e.componentUrl; return e.componentUrl;
} }
} }

View File

@@ -4,6 +4,7 @@ import org.jeecg.common.util.oConvertUtils;
/** /**
* 系统公告自定义跳转方式 * 系统公告自定义跳转方式
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public enum SysAnnmentTypeEnum { public enum SysAnnmentTypeEnum {

View File

@@ -8,6 +8,7 @@ import java.util.List;
/** /**
* 消息跳转【vue3】 * 消息跳转【vue3】
*
* @Author taoYan * @Author taoYan
* @Date 2022/8/19 20:41 * @Date 2022/8/19 20:41
**/ **/
@@ -58,12 +59,13 @@ public enum Vue3MessageHrefEnum {
/** /**
* 获取字典数据 * 获取字典数据
*
* @return * @return
*/ */
public static List<DictModel> getDictList(){ public static List<DictModel> getDictList() {
List<DictModel> list = new ArrayList<>(); List<DictModel> list = new ArrayList<>();
DictModel dictModel = null; DictModel dictModel = null;
for(Vue3MessageHrefEnum e: Vue3MessageHrefEnum.values()){ for (Vue3MessageHrefEnum e : Vue3MessageHrefEnum.values()) {
dictModel = new DictModel(); dictModel = new DictModel();
dictModel.setValue(e.getBusType()); dictModel.setValue(e.getBusType());
dictModel.setText(e.getPath()); dictModel.setText(e.getPath());

View File

@@ -30,7 +30,7 @@ public class SensitiveSerialize extends JsonSerializer<String> implements Contex
@Override @Override
public void serialize(String data, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { public void serialize(String data, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
switch (type){ switch (type) {
case ENCODE: case ENCODE:
try { try {
jsonGenerator.writeString(AesEncryptUtil.encrypt(data)); jsonGenerator.writeString(AesEncryptUtil.encrypt(data));

View File

@@ -20,6 +20,7 @@ public @interface Sensitive {
/** /**
* 不同类型处理不同 * 不同类型处理不同
*
* @return * @return
*/ */
SensitiveEnum type() default SensitiveEnum.ENCODE; SensitiveEnum type() default SensitiveEnum.ENCODE;

View File

@@ -4,7 +4,7 @@ import java.lang.annotation.*;
/** /**
* 解密注解 * 解密注解
* * <p>
* 在方法上定义 将方法返回对象中的敏感字段 解密,需要注意的是,如果没有加密过,解密会出问题,返回原字符串 * 在方法上定义 将方法返回对象中的敏感字段 解密,需要注意的是,如果没有加密过,解密会出问题,返回原字符串
*/ */
@Documented @Documented
@@ -14,6 +14,7 @@ public @interface SensitiveDecode {
/** /**
* 指明需要脱敏的实体类class * 指明需要脱敏的实体类class
*
* @return * @return
*/ */
Class entity() default Object.class; Class entity() default Object.class;

View File

@@ -4,7 +4,7 @@ import java.lang.annotation.*;
/** /**
* 加密注解 * 加密注解
* * <p>
* 在方法上声明 将方法返回对象中的敏感字段 加密/格式化 * 在方法上声明 将方法返回对象中的敏感字段 加密/格式化
*/ */
@Documented @Documented
@@ -14,6 +14,7 @@ public @interface SensitiveEncode {
/** /**
* 指明需要脱敏的实体类class * 指明需要脱敏的实体类class
*
* @return * @return
*/ */
Class entity() default Object.class; Class entity() default Object.class;

View File

@@ -15,6 +15,7 @@ public @interface SensitiveField {
/** /**
* 不同类型处理不同 * 不同类型处理不同
*
* @return * @return
*/ */
SensitiveEnum type() default SensitiveEnum.ENCODE; SensitiveEnum type() default SensitiveEnum.ENCODE;

View File

@@ -16,6 +16,7 @@ import java.util.List;
/** /**
* 敏感数据切面处理类 * 敏感数据切面处理类
*
* @Author taoYan * @Author taoYan
* @Date 2022/4/20 17:45 * @Date 2022/4/20 17:45
**/ **/
@@ -35,13 +36,13 @@ public class SensitiveDataAspect {
public Object around(ProceedingJoinPoint point) throws Throwable { public Object around(ProceedingJoinPoint point) throws Throwable {
// 处理结果 // 处理结果
Object result = point.proceed(); Object result = point.proceed();
if(result == null){ if (result == null) {
return result; return result;
} }
Class resultClass = result.getClass(); Class resultClass = result.getClass();
log.debug(" resultClass = {}" , resultClass); log.debug(" resultClass = {}", resultClass);
if(resultClass.isPrimitive()){ if (resultClass.isPrimitive()) {
//是基本类型 直接返回 不需要处理 //是基本类型 直接返回 不需要处理
return result; return result;
} }
@@ -51,28 +52,28 @@ public class SensitiveDataAspect {
MethodSignature methodSignature = (MethodSignature) point.getSignature(); MethodSignature methodSignature = (MethodSignature) point.getSignature();
Method method = methodSignature.getMethod(); Method method = methodSignature.getMethod();
SensitiveEncode encode = method.getAnnotation(SensitiveEncode.class); SensitiveEncode encode = method.getAnnotation(SensitiveEncode.class);
if(encode==null){ if (encode == null) {
SensitiveDecode decode = method.getAnnotation(SensitiveDecode.class); SensitiveDecode decode = method.getAnnotation(SensitiveDecode.class);
if(decode!=null){ if (decode != null) {
entity = decode.entity(); entity = decode.entity();
isEncode = false; isEncode = false;
} }
}else{ } else {
entity = encode.entity(); entity = encode.entity();
} }
long startTime=System.currentTimeMillis(); long startTime = System.currentTimeMillis();
if(resultClass.equals(entity) || entity.equals(Object.class)){ if (resultClass.equals(entity) || entity.equals(Object.class)) {
// 方法返回实体和注解的entity一样如果注解没有申明entity属性则认为是(方法返回实体和注解的entity一样) // 方法返回实体和注解的entity一样如果注解没有申明entity属性则认为是(方法返回实体和注解的entity一样)
SensitiveInfoUtil.handlerObject(result, isEncode); SensitiveInfoUtil.handlerObject(result, isEncode);
} else if(result instanceof List){ } else if (result instanceof List) {
// 方法返回List<实体> // 方法返回List<实体>
SensitiveInfoUtil.handleList(result, entity, isEncode); SensitiveInfoUtil.handleList(result, entity, isEncode);
}else{ } else {
// 方法返回一个对象 // 方法返回一个对象
SensitiveInfoUtil.handleNestedObject(result, entity, isEncode); SensitiveInfoUtil.handleNestedObject(result, entity, isEncode);
} }
long endTime=System.currentTimeMillis(); long endTime = System.currentTimeMillis();
log.info((isEncode ? "加密操作," : "解密操作,") + "Aspect程序耗时" + (endTime - startTime) + "ms"); log.info((isEncode ? "加密操作," : "解密操作,") + "Aspect程序耗时" + (endTime - startTime) + "ms");
return result; return result;

View File

@@ -13,6 +13,7 @@ import java.util.List;
/** /**
* 敏感信息处理工具类 * 敏感信息处理工具类
*
* @author taoYan * @author taoYan
* @date 2022/4/20 18:01 * @date 2022/4/20 18:01
**/ **/
@@ -21,29 +22,30 @@ public class SensitiveInfoUtil {
/** /**
* 处理嵌套对象 * 处理嵌套对象
* @param obj 方法返回值 *
* @param entity 实体class * @param obj 方法返回值
* @param entity 实体class
* @param isEncode 是否加密true: 加密操作 / false:解密操作) * @param isEncode 是否加密true: 加密操作 / false:解密操作)
* @throws IllegalAccessException * @throws IllegalAccessException
*/ */
public static void handleNestedObject(Object obj, Class entity, boolean isEncode) throws IllegalAccessException { public static void handleNestedObject(Object obj, Class entity, boolean isEncode) throws IllegalAccessException {
Field[] fields = obj.getClass().getDeclaredFields(); Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
if(field.getType().isPrimitive()){ if (field.getType().isPrimitive()) {
continue; continue;
} }
if(field.getType().equals(entity)){ if (field.getType().equals(entity)) {
// 对象里面是实体 // 对象里面是实体
field.setAccessible(true); field.setAccessible(true);
Object nestedObject = field.get(obj); Object nestedObject = field.get(obj);
handlerObject(nestedObject, isEncode); handlerObject(nestedObject, isEncode);
break; break;
}else{ } else {
// 对象里面是List<实体> // 对象里面是List<实体>
if(field.getGenericType() instanceof ParameterizedType){ if (field.getGenericType() instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType)field.getGenericType(); ParameterizedType pt = (ParameterizedType) field.getGenericType();
if(pt.getRawType().equals(List.class)){ if (pt.getRawType().equals(List.class)) {
if(pt.getActualTypeArguments()[0].equals(entity)){ if (pt.getActualTypeArguments()[0].equals(entity)) {
field.setAccessible(true); field.setAccessible(true);
Object nestedObject = field.get(obj); Object nestedObject = field.get(obj);
handleList(nestedObject, entity, isEncode); handleList(nestedObject, entity, isEncode);
@@ -57,7 +59,8 @@ public class SensitiveInfoUtil {
/** /**
* 处理Object * 处理Object
* @param obj 方法返回值 *
* @param obj 方法返回值
* @param isEncode 是否加密true: 加密操作 / false:解密操作) * @param isEncode 是否加密true: 加密操作 / false:解密操作)
* @return * @return
* @throws IllegalAccessException * @throws IllegalAccessException
@@ -66,30 +69,30 @@ public class SensitiveInfoUtil {
if (oConvertUtils.isEmpty(obj)) { if (oConvertUtils.isEmpty(obj)) {
return obj; return obj;
} }
long startTime=System.currentTimeMillis(); long startTime = System.currentTimeMillis();
log.debug(" obj --> "+ obj.toString()); log.debug(" obj --> " + obj.toString());
// 判断是不是一个对象 // 判断是不是一个对象
Field[] fields = obj.getClass().getDeclaredFields(); Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
boolean isSensitiveField = field.isAnnotationPresent(SensitiveField.class); boolean isSensitiveField = field.isAnnotationPresent(SensitiveField.class);
if(isSensitiveField){ if (isSensitiveField) {
// 必须有SensitiveField注解 才作处理 // 必须有SensitiveField注解 才作处理
if(field.getType().isAssignableFrom(String.class)){ if (field.getType().isAssignableFrom(String.class)) {
//必须是字符串类型 才作处理 //必须是字符串类型 才作处理
field.setAccessible(true); field.setAccessible(true);
String realValue = (String) field.get(obj); String realValue = (String) field.get(obj);
if(realValue==null || "".equals(realValue)){ if (realValue == null || "".equals(realValue)) {
continue; continue;
} }
SensitiveField sf = field.getAnnotation(SensitiveField.class); SensitiveField sf = field.getAnnotation(SensitiveField.class);
if(isEncode==true){ if (isEncode == true) {
//加密 //加密
String value = SensitiveInfoUtil.getEncodeData(realValue, sf.type()); String value = SensitiveInfoUtil.getEncodeData(realValue, sf.type());
field.set(obj, value); field.set(obj, value);
}else{ } else {
//解密只处理 encode类型的 //解密只处理 encode类型的
if(sf.type().equals(SensitiveEnum.ENCODE)){ if (sf.type().equals(SensitiveEnum.ENCODE)) {
String value = SensitiveInfoUtil.getDecodeData(realValue); String value = SensitiveInfoUtil.getDecodeData(realValue);
field.set(obj, value); field.set(obj, value);
} }
@@ -104,16 +107,17 @@ public class SensitiveInfoUtil {
/** /**
* 处理 List<实体> * 处理 List<实体>
*
* @param obj * @param obj
* @param entity * @param entity
* @param isEncodetrue: 加密操作 / false:解密操作) * @param isEncodetrue: 加密操作 / false:解密操作)
*/ */
public static void handleList(Object obj, Class entity, boolean isEncode){ public static void handleList(Object obj, Class entity, boolean isEncode) {
List list = (List)obj; List list = (List) obj;
if(list.size()>0){ if (list.size() > 0) {
Object first = list.get(0); Object first = list.get(0);
if(first.getClass().equals(entity)){ if (first.getClass().equals(entity)) {
for(int i=0; i<list.size(); i++){ for (int i = 0; i < list.size(); i++) {
Object temp = list.get(i); Object temp = list.get(i);
try { try {
handlerObject(temp, isEncode); handlerObject(temp, isEncode);
@@ -128,18 +132,19 @@ public class SensitiveInfoUtil {
/** /**
* 处理数据 获取解密后的数据 * 处理数据 获取解密后的数据
*
* @param data * @param data
* @return * @return
*/ */
public static String getDecodeData(String data){ public static String getDecodeData(String data) {
String result = null; String result = null;
try { try {
result = AesEncryptUtil.desEncrypt(data); result = AesEncryptUtil.desEncrypt(data);
} catch (Exception exception) { } catch (Exception exception) {
log.debug("数据解密错误,原数据:"+data); log.debug("数据解密错误,原数据:" + data);
} }
//解决debug模式下加解密失效导致中文被解密变成空的问题 //解决debug模式下加解密失效导致中文被解密变成空的问题
if(oConvertUtils.isEmpty(result) && oConvertUtils.isNotEmpty(data)){ if (oConvertUtils.isEmpty(result) && oConvertUtils.isNotEmpty(data)) {
result = data; result = data;
} }
return result; return result;
@@ -147,13 +152,14 @@ public class SensitiveInfoUtil {
/** /**
* 处理数据 获取加密后的数据 或是格式化后的数据 * 处理数据 获取加密后的数据 或是格式化后的数据
* @param data 字符串 *
* @param data 字符串
* @param sensitiveEnum 类型 * @param sensitiveEnum 类型
* @return 处理后的字符串 * @return 处理后的字符串
*/ */
public static String getEncodeData(String data, SensitiveEnum sensitiveEnum){ public static String getEncodeData(String data, SensitiveEnum sensitiveEnum) {
String result; String result;
switch (sensitiveEnum){ switch (sensitiveEnum) {
case ENCODE: case ENCODE:
try { try {
result = AesEncryptUtil.encrypt(data); result = AesEncryptUtil.encrypt(data);
@@ -195,6 +201,7 @@ public class SensitiveInfoUtil {
/** /**
* [中文姓名] 只显示第一个汉字其他隐藏为2个星号 * [中文姓名] 只显示第一个汉字其他隐藏为2个星号
*
* @param fullName 全名 * @param fullName 全名
* @return <例子:李**> * @return <例子:李**>
*/ */
@@ -207,8 +214,9 @@ public class SensitiveInfoUtil {
/** /**
* [中文姓名] 只显示第一个汉字其他隐藏为2个星号 * [中文姓名] 只显示第一个汉字其他隐藏为2个星号
*
* @param familyName 姓 * @param familyName 姓
* @param firstName 名 * @param firstName
* @return <例子:李**> * @return <例子:李**>
*/ */
public static String chineseName(String familyName, String firstName) { public static String chineseName(String familyName, String firstName) {
@@ -220,6 +228,7 @@ public class SensitiveInfoUtil {
/** /**
* [身份证号] 显示最后四位其他隐藏。共计18位或者15位。 * [身份证号] 显示最后四位其他隐藏。共计18位或者15位。
*
* @param id 身份证号 * @param id 身份证号
* @return <例子:*************5762> * @return <例子:*************5762>
*/ */
@@ -233,6 +242,7 @@ public class SensitiveInfoUtil {
/** /**
* [固定电话] 后四位,其他隐藏 * [固定电话] 后四位,其他隐藏
*
* @param num 固定电话 * @param num 固定电话
* @return <例子:****1234> * @return <例子:****1234>
*/ */
@@ -245,6 +255,7 @@ public class SensitiveInfoUtil {
/** /**
* [手机号码] 前三位,后四位,其他隐藏 * [手机号码] 前三位,后四位,其他隐藏
*
* @param num 手机号码 * @param num 手机号码
* @return <例子:138******1234> * @return <例子:138******1234>
*/ */
@@ -253,7 +264,7 @@ public class SensitiveInfoUtil {
return ""; return "";
} }
int len = num.length(); int len = num.length();
if(len<11){ if (len < 11) {
return num; return num;
} }
return formatBetween(num, 3, 4); return formatBetween(num, 3, 4);
@@ -261,7 +272,8 @@ public class SensitiveInfoUtil {
/** /**
* [地址] 只显示到地区,不显示详细地址;我们要对个人信息增强保护 * [地址] 只显示到地区,不显示详细地址;我们要对个人信息增强保护
* @param address 地址 *
* @param address 地址
* @param sensitiveSize 敏感信息长度 * @param sensitiveSize 敏感信息长度
* @return <例子:北京市海淀区****> * @return <例子:北京市海淀区****>
*/ */
@@ -270,7 +282,7 @@ public class SensitiveInfoUtil {
return ""; return "";
} }
int len = address.length(); int len = address.length();
if(len<sensitiveSize){ if (len < sensitiveSize) {
return address; return address;
} }
return formatRight(address, sensitiveSize); return formatRight(address, sensitiveSize);
@@ -278,6 +290,7 @@ public class SensitiveInfoUtil {
/** /**
* [电子邮箱] 邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示 * [电子邮箱] 邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示
*
* @param email 电子邮箱 * @param email 电子邮箱
* @return <例子:g**@163.com> * @return <例子:g**@163.com>
*/ */
@@ -286,7 +299,7 @@ public class SensitiveInfoUtil {
return ""; return "";
} }
int index = email.indexOf("@"); int index = email.indexOf("@");
if (index <= 1){ if (index <= 1) {
return email; return email;
} }
String begin = email.substring(0, 1); String begin = email.substring(0, 1);
@@ -297,6 +310,7 @@ public class SensitiveInfoUtil {
/** /**
* [银行卡号] 前六位后四位其他用星号隐藏每位1个星号 * [银行卡号] 前六位后四位其他用星号隐藏每位1个星号
*
* @param cardNum 银行卡号 * @param cardNum 银行卡号
* @return <例子:6222600**********1234> * @return <例子:6222600**********1234>
*/ */
@@ -309,6 +323,7 @@ public class SensitiveInfoUtil {
/** /**
* [公司开户银行联号] 公司开户银行联行号,显示前两位其他用星号隐藏每位1个星号 * [公司开户银行联号] 公司开户银行联行号,显示前两位其他用星号隐藏每位1个星号
*
* @param code 公司开户银行联号 * @param code 公司开户银行联号
* @return <例子:12********> * @return <例子:12********>
*/ */
@@ -322,41 +337,44 @@ public class SensitiveInfoUtil {
/** /**
* 将右边的格式化成* * 将右边的格式化成*
* @param str 字符串 *
* @param str 字符串
* @param reservedLength 保留长度 * @param reservedLength 保留长度
* @return 格式化后的字符串 * @return 格式化后的字符串
*/ */
public static String formatRight(String str, int reservedLength){ public static String formatRight(String str, int reservedLength) {
String name = str.substring(0, reservedLength); String name = str.substring(0, reservedLength);
String stars = String.join("", Collections.nCopies(str.length()-reservedLength, "*")); String stars = String.join("", Collections.nCopies(str.length() - reservedLength, "*"));
return name + stars; return name + stars;
} }
/** /**
* 将左边的格式化成* * 将左边的格式化成*
* @param str 字符串 *
* @param str 字符串
* @param reservedLength 保留长度 * @param reservedLength 保留长度
* @return 格式化后的字符串 * @return 格式化后的字符串
*/ */
public static String formatLeft(String str, int reservedLength){ public static String formatLeft(String str, int reservedLength) {
int len = str.length(); int len = str.length();
String show = str.substring(len-reservedLength); String show = str.substring(len - reservedLength);
String stars = String.join("", Collections.nCopies(len-reservedLength, "*")); String stars = String.join("", Collections.nCopies(len - reservedLength, "*"));
return stars + show; return stars + show;
} }
/** /**
* 将中间的格式化成* * 将中间的格式化成*
* @param str 字符串 *
* @param str 字符串
* @param beginLen 开始保留长度 * @param beginLen 开始保留长度
* @param endLen 结尾保留长度 * @param endLen 结尾保留长度
* @return 格式化后的字符串 * @return 格式化后的字符串
*/ */
public static String formatBetween(String str, int beginLen, int endLen){ public static String formatBetween(String str, int beginLen, int endLen) {
int len = str.length(); int len = str.length();
String begin = str.substring(0, beginLen); String begin = str.substring(0, beginLen);
String end = str.substring(len-endLen); String end = str.substring(len - endLen);
String stars = String.join("", Collections.nCopies(len-beginLen-endLen, "*")); String stars = String.join("", Collections.nCopies(len - beginLen - endLen, "*"));
return begin + stars + end; return begin + stars + end;
} }

View File

@@ -25,19 +25,29 @@ import java.util.*;
@Component @Component
@ConditionalOnProperty(prefix = "jeecg.elasticsearch", name = "cluster-nodes") @ConditionalOnProperty(prefix = "jeecg.elasticsearch", name = "cluster-nodes")
public class JeecgElasticsearchTemplate { public class JeecgElasticsearchTemplate {
/** es服务地址 */ /**
* es服务地址
*/
private String baseUrl; private String baseUrl;
private final String FORMAT_JSON = "format=json"; private final String FORMAT_JSON = "format=json";
/** Elasticsearch 的版本号 */ /**
* Elasticsearch 的版本号
*/
private String version = null; private String version = null;
/**ElasticSearch 最大可返回条目数*/ /**
* ElasticSearch 最大可返回条目数
*/
public static final int ES_MAX_SIZE = 10000; public static final int ES_MAX_SIZE = 10000;
/**es7*/ /**
* es7
*/
public static final String IE_SEVEN = "7"; public static final String IE_SEVEN = "7";
/**url not found 404*/ /**
* url not found 404
*/
public static final String URL_NOT_FOUND = "404 Not Found"; public static final String URL_NOT_FOUND = "404 Not Found";
public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl, @Value("${jeecg.elasticsearch.check-enabled}") boolean checkEnabled) { public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl, @Value("${jeecg.elasticsearch.check-enabled}") boolean checkEnabled) {
@@ -339,9 +349,9 @@ public class JeecgElasticsearchTemplate {
emptyKeys.add(key); emptyKeys.add(key);
} }
//2、剔除上传控件值(会导致ES同步失败报异常failed to parse field [ge_pic] of type [text] ) //2、剔除上传控件值(会导致ES同步失败报异常failed to parse field [ge_pic] of type [text] )
if (oConvertUtils.isNotEmpty(value) && value.indexOf("[{")!=-1) { if (oConvertUtils.isNotEmpty(value) && value.indexOf("[{") != -1) {
emptyKeys.add(key); emptyKeys.add(key);
log.info("-------剔除上传控件字段------------key: "+ key); log.info("-------剔除上传控件字段------------key: " + key);
} }
} }
for (String key : emptyKeys) { for (String key : emptyKeys) {
@@ -447,8 +457,8 @@ public class JeecgElasticsearchTemplate {
/** /**
* @param source 源滤波器指定返回的字段传null返回所有字段 * @param source 源滤波器指定返回的字段传null返回所有字段
* @param query * @param query
* @param from 从第几条数据开始 * @param from 从第几条数据开始
* @param size 返回条目数 * @param size 返回条目数
* @return { "query": query } * @return { "query": query }
*/ */
public JSONObject buildQuery(List<String> source, JSONObject query, int from, int size) { public JSONObject buildQuery(List<String> source, JSONObject query, int from, int size) {

View File

@@ -66,14 +66,15 @@ public class QueryStringBuilder {
} }
/** /**
* 添加双引号(模糊查询,不能加双引号) * 添加双引号(模糊查询,不能加双引号)
*/ */
private QueryStringBuilder addQuot(String str, boolean addQuot) { private QueryStringBuilder addQuot(String str, boolean addQuot) {
return this.addQuotEffect(this.builder, str, addQuot); return this.addQuotEffect(this.builder, str, addQuot);
} }
/** /**
* 是否在两边加上双引号 * 是否在两边加上双引号
*
* @param builder * @param builder
* @param str * @param str
* @param addQuot * @param addQuot

View File

@@ -5,19 +5,17 @@ package org.jeecg.common.exception;
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class JeecgBoot401Exception extends RuntimeException { public class JeecgBoot401Exception extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public JeecgBoot401Exception(String message){ public JeecgBoot401Exception(String message) {
super(message); super(message);
} }
public JeecgBoot401Exception(Throwable cause) public JeecgBoot401Exception(Throwable cause) {
{ super(cause);
super(cause); }
}
public JeecgBoot401Exception(String message, Throwable cause) public JeecgBoot401Exception(String message, Throwable cause) {
{ super(message, cause);
super(message,cause); }
}
} }

View File

@@ -8,33 +8,31 @@ import org.jeecg.common.constant.CommonConstant;
* @author: scott * @author: scott
*/ */
public class JeecgBootBizTipException extends RuntimeException { public class JeecgBootBizTipException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 返回给前端的错误code * 返回给前端的错误code
*/ */
private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
public JeecgBootBizTipException(String message){ public JeecgBootBizTipException(String message) {
super(message); super(message);
} }
public JeecgBootBizTipException(String message, int errCode){ public JeecgBootBizTipException(String message, int errCode) {
super(message); super(message);
this.errCode = errCode; this.errCode = errCode;
} }
public int getErrCode() { public int getErrCode() {
return errCode; return errCode;
} }
public JeecgBootBizTipException(Throwable cause) public JeecgBootBizTipException(Throwable cause) {
{ super(cause);
super(cause); }
}
public JeecgBootBizTipException(String message, Throwable cause) public JeecgBootBizTipException(String message, Throwable cause) {
{ super(message, cause);
super(message,cause); }
}
} }

View File

@@ -7,33 +7,31 @@ import org.jeecg.common.constant.CommonConstant;
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class JeecgBootException extends RuntimeException { public class JeecgBootException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 返回给前端的错误code * 返回给前端的错误code
*/ */
private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
public JeecgBootException(String message){ public JeecgBootException(String message) {
super(message); super(message);
} }
public JeecgBootException(String message, int errCode){ public JeecgBootException(String message, int errCode) {
super(message); super(message);
this.errCode = errCode; this.errCode = errCode;
} }
public int getErrCode() { public int getErrCode() {
return errCode; return errCode;
} }
public JeecgBootException(Throwable cause) public JeecgBootException(Throwable cause) {
{ super(cause);
super(cause); }
}
public JeecgBootException(String message,Throwable cause) public JeecgBootException(String message, Throwable cause) {
{ super(message, cause);
super(message,cause); }
}
} }

View File

@@ -44,166 +44,168 @@ import java.util.Map;
@Slf4j @Slf4j
public class JeecgBootExceptionHandler { public class JeecgBootExceptionHandler {
@Resource @Resource
BaseCommonService baseCommonService; BaseCommonService baseCommonService;
/** /**
* 处理自定义异常 * 处理自定义异常
*/ */
@ExceptionHandler(JeecgBootException.class) @ExceptionHandler(JeecgBootException.class)
public Result<?> handleJeecgBootException(JeecgBootException e){ public Result<?> handleJeecgBootException(JeecgBootException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return Result.error(e.getErrCode(), e.getMessage()); return Result.error(e.getErrCode(), e.getMessage());
} }
/** /**
* 处理自定义异常 * 处理自定义异常
*/ */
@ExceptionHandler(JeecgBootBizTipException.class) @ExceptionHandler(JeecgBootBizTipException.class)
public Result<?> handleJeecgBootBizTipException(JeecgBootBizTipException e){ public Result<?> handleJeecgBootBizTipException(JeecgBootBizTipException e) {
log.error(e.getMessage()); log.error(e.getMessage());
return Result.error(e.getErrCode(), e.getMessage()); return Result.error(e.getErrCode(), e.getMessage());
} }
/** /**
* 处理自定义微服务异常 * 处理自定义微服务异常
*/ */
@ExceptionHandler(JeecgCloudException.class) @ExceptionHandler(JeecgCloudException.class)
public Result<?> handleJeecgCloudException(JeecgCloudException e){ public Result<?> handleJeecgCloudException(JeecgCloudException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return Result.error(e.getMessage()); return Result.error(e.getMessage());
} }
/** /**
* 处理自定义异常 * 处理自定义异常
*/ */
@ExceptionHandler(JeecgBoot401Exception.class) @ExceptionHandler(JeecgBoot401Exception.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseStatus(HttpStatus.UNAUTHORIZED)
public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e){ public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return new Result(401,e.getMessage()); return new Result(401, e.getMessage());
} }
@ExceptionHandler(NoHandlerFoundException.class) @ExceptionHandler(NoHandlerFoundException.class)
public Result<?> handlerNoFoundException(Exception e) { public Result<?> handlerNoFoundException(Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return Result.error(404, "路径不存在,请检查路径是否正确"); return Result.error(404, "路径不存在,请检查路径是否正确");
} }
@ExceptionHandler(DuplicateKeyException.class) @ExceptionHandler(DuplicateKeyException.class)
public Result<?> handleDuplicateKeyException(DuplicateKeyException e){ public Result<?> handleDuplicateKeyException(DuplicateKeyException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return Result.error("数据库中已存在该记录"); return Result.error("数据库中已存在该记录");
} }
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class}) @ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
public Result<?> handleAuthorizationException(AuthorizationException e){ public Result<?> handleAuthorizationException(AuthorizationException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return Result.noauth("没有权限,请联系管理员授权,后刷新缓存!"); return Result.noauth("没有权限,请联系管理员授权,后刷新缓存!");
} }
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public Result<?> handleException(Exception e){ public Result<?> handleException(Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
//update-begin---author:zyf ---date:20220411 for处理Sentinel限流自定义异常 //update-begin---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
Throwable throwable = e.getCause(); Throwable throwable = e.getCause();
SentinelErrorInfoEnum errorInfoEnum = SentinelErrorInfoEnum.getErrorByException(throwable); SentinelErrorInfoEnum errorInfoEnum = SentinelErrorInfoEnum.getErrorByException(throwable);
if (ObjectUtil.isNotEmpty(errorInfoEnum)) { if (ObjectUtil.isNotEmpty(errorInfoEnum)) {
return Result.error(errorInfoEnum.getError()); return Result.error(errorInfoEnum.getError());
} }
//update-end---author:zyf ---date:20220411 for处理Sentinel限流自定义异常 //update-end---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
addSysLog(e); addSysLog(e);
return Result.error("操作失败,"+e.getMessage()); return Result.error("操作失败," + e.getMessage());
} }
/** /**
* @Author 政辉 * @param e
* @param e * @return
* @return * @Author 政辉
*/ */
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){ public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("不支持"); sb.append("不支持");
sb.append(e.getMethod()); sb.append(e.getMethod());
sb.append("请求方法,"); sb.append("请求方法,");
sb.append("支持以下"); sb.append("支持以下");
String [] methods = e.getSupportedMethods(); String[] methods = e.getSupportedMethods();
if(methods!=null){ if (methods != null) {
for(String str:methods){ for (String str : methods) {
sb.append(str); sb.append(str);
sb.append(""); sb.append("");
} }
} }
log.error(sb.toString(), e); log.error(sb.toString(), e);
//return Result.error("没有权限,请联系管理员授权"); //return Result.error("没有权限,请联系管理员授权");
addSysLog(e); addSysLog(e);
return Result.error(405,sb.toString()); return Result.error(405, sb.toString());
} }
/** /**
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException * spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
*/ */
@ExceptionHandler(MaxUploadSizeExceededException.class) @ExceptionHandler(MaxUploadSizeExceededException.class)
public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) { public Result<?> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return Result.error("文件大小超出10MB限制, 请压缩或降低文件质量! "); return Result.error("文件大小超出10MB限制, 请压缩或降低文件质量! ");
} }
@ExceptionHandler(DataIntegrityViolationException.class) @ExceptionHandler(DataIntegrityViolationException.class)
public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) { public Result<?> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
//【issues/3624】数据库执行异常handleDataIntegrityViolationException提示有误 #3624 //【issues/3624】数据库执行异常handleDataIntegrityViolationException提示有误 #3624
return Result.error("执行数据库异常,违反了完整性例如:违反惟一约束、违反非空限制、字段内容超出长度等"); return Result.error("执行数据库异常,违反了完整性例如:违反惟一约束、违反非空限制、字段内容超出长度等");
} }
@ExceptionHandler(PoolException.class) @ExceptionHandler(PoolException.class)
public Result<?> handlePoolException(PoolException e) { public Result<?> handlePoolException(PoolException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
addSysLog(e); addSysLog(e);
return Result.error("Redis 连接异常!"); return Result.error("Redis 连接异常!");
} }
/** /**
* SQL注入风险全局异常处理 * SQL注入风险全局异常处理
* *
* @param exception * @param exception
* @return * @return
*/ */
@ExceptionHandler(JeecgSqlInjectionException.class) @ExceptionHandler(JeecgSqlInjectionException.class)
public Result<?> handleSQLException(Exception exception) { public Result<?> handleSQLException(Exception exception) {
String msg = exception.getMessage().toLowerCase(); String msg = exception.getMessage().toLowerCase();
final String extractvalue = "extractvalue"; final String extractvalue = "extractvalue";
final String updatexml = "updatexml"; final String updatexml = "updatexml";
boolean hasSensitiveInformation = msg.indexOf(extractvalue) >= 0 || msg.indexOf(updatexml) >= 0; boolean hasSensitiveInformation = msg.indexOf(extractvalue) >= 0 || msg.indexOf(updatexml) >= 0;
if (msg != null && hasSensitiveInformation) { if (msg != null && hasSensitiveInformation) {
log.error("校验失败存在SQL注入风险{}", msg); log.error("校验失败存在SQL注入风险{}", msg);
return Result.error("校验失败存在SQL注入风险"); return Result.error("校验失败存在SQL注入风险");
} }
addSysLog(exception); addSysLog(exception);
return Result.error("校验失败存在SQL注入风险" + msg); return Result.error("校验失败存在SQL注入风险" + msg);
} }
//update-begin---author:chenrui ---date:20240423 for[QQYUN-8732]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------ //update-begin---author:chenrui ---date:20240423 for[QQYUN-8732]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------
/**
* 添加异常新系统日志 /**
* @param e 异常 * 添加异常新系统日志
* @author chenrui *
* @date 2024/4/22 17:16 * @param e 异常
*/ * @author chenrui
* @date 2024/4/22 17:16
*/
private void addSysLog(Throwable e) { private void addSysLog(Throwable e) {
LogDTO log = new LogDTO(); LogDTO log = new LogDTO();
log.setLogType(CommonConstant.LOG_TYPE_4); log.setLogType(CommonConstant.LOG_TYPE_4);
log.setLogContent(e.getClass().getName()+":"+e.getMessage()); log.setLogContent(e.getClass().getName() + ":" + e.getMessage());
log.setRequestParam(ExceptionUtils.getStackTrace(e)); log.setRequestParam(ExceptionUtils.getStackTrace(e));
//获取request //获取request
HttpServletRequest request = null; HttpServletRequest request = null;
try { try {
@@ -211,34 +213,34 @@ public class JeecgBootExceptionHandler {
} catch (NullPointerException | BeansException ignored) { } catch (NullPointerException | BeansException ignored) {
} }
if (null != request) { if (null != request) {
//请求的参数 //请求的参数
Map<String, String[]> parameterMap = request.getParameterMap(); Map<String, String[]> parameterMap = request.getParameterMap();
if(!CollectionUtils.isEmpty(parameterMap)){ if (!CollectionUtils.isEmpty(parameterMap)) {
log.setMethod(oConvertUtils.mapToString(request.getParameterMap())); log.setMethod(oConvertUtils.mapToString(request.getParameterMap()));
} }
// 请求地址 // 请求地址
log.setRequestUrl(request.getRequestURI()); log.setRequestUrl(request.getRequestURI());
//设置IP地址 //设置IP地址
log.setIp(IpUtils.getIpAddr(request)); log.setIp(IpUtils.getIpAddr(request));
//设置客户端 //设置客户端
if(BrowserUtils.isDesktop(request)){ if (BrowserUtils.isDesktop(request)) {
log.setClientType(ClientTerminalTypeEnum.PC.getKey()); log.setClientType(ClientTerminalTypeEnum.PC.getKey());
}else{ } else {
log.setClientType(ClientTerminalTypeEnum.APP.getKey()); log.setClientType(ClientTerminalTypeEnum.APP.getKey());
} }
} }
//获取登录用户信息 //获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(sysUser!=null){ if (sysUser != null) {
log.setUserid(sysUser.getUsername()); log.setUserid(sysUser.getUsername());
log.setUsername(sysUser.getRealname()); log.setUsername(sysUser.getRealname());
} }
baseCommonService.addLog(log); baseCommonService.addLog(log);
} }
//update-end---author:chenrui ---date:20240423 for[QQYUN-8732]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------ //update-end---author:chenrui ---date:20240423 for[QQYUN-8732]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------
} }

View File

@@ -5,19 +5,17 @@ package org.jeecg.common.exception;
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class JeecgSqlInjectionException extends RuntimeException { public class JeecgSqlInjectionException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public JeecgSqlInjectionException(String message){ public JeecgSqlInjectionException(String message) {
super(message); super(message);
} }
public JeecgSqlInjectionException(Throwable cause) public JeecgSqlInjectionException(Throwable cause) {
{ super(cause);
super(cause); }
}
public JeecgSqlInjectionException(String message, Throwable cause) public JeecgSqlInjectionException(String message, Throwable cause) {
{ super(message, cause);
super(message,cause); }
}
} }

View File

@@ -12,8 +12,9 @@ public interface IFillRuleHandler {
/** /**
* 填值规则 * 填值规则
* @param params 页面配置固定参数 *
* @param formData 动态表单参数 * @param params 页面配置固定参数
* @param formData 动态表单参数
* @return * @return
*/ */
public Object execute(JSONObject params, JSONObject formData); public Object execute(JSONObject params, JSONObject formData);

View File

@@ -4,6 +4,7 @@ import java.lang.annotation.*;
/** /**
* 将枚举类转化成字典数据 * 将枚举类转化成字典数据
*
* @Author taoYan * @Author taoYan
* @Date 2022/7/8 10:34 * @Date 2022/7/8 10:34
**/ **/

View File

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
@@ -23,9 +26,6 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@@ -37,7 +37,9 @@ import java.util.*;
*/ */
@Slf4j @Slf4j
public class JeecgController<T, S extends IService<T>> { public class JeecgController<T, S extends IService<T>> {
/**issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service*/ /**
* issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service
*/
@Autowired @Autowired
protected S service; protected S service;
@Resource @Resource
@@ -57,7 +59,7 @@ public class JeecgController<T, S extends IService<T>> {
String selections = request.getParameter("selections"); String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) { if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(",")); List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList); queryWrapper.in("id", selectionList);
} }
// Step.2 获取导出数据 // Step.2 获取导出数据
List<T> exportList = service.list(queryWrapper); List<T> exportList = service.list(queryWrapper);
@@ -68,53 +70,54 @@ public class JeecgController<T, S extends IService<T>> {
mv.addObject(NormalExcelConstants.FILE_NAME, title); mv.addObject(NormalExcelConstants.FILE_NAME, title);
mv.addObject(NormalExcelConstants.CLASS, clazz); mv.addObject(NormalExcelConstants.CLASS, clazz);
//update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置-------------------- //update-begin--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload()); exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置---------------------- //update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams); mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList); mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv; return mv;
} }
/** /**
* 根据每页sheet数量导出多sheet * 根据每页sheet数量导出多sheet
* *
* @param request * @param request
* @param object 实体类 * @param object 实体类
* @param clazz 实体类class * @param clazz 实体类class
* @param title 标题 * @param title 标题
* @param exportFields 导出字段自定义 * @param exportFields 导出字段自定义
* @param pageNum 每个sheet的数据条数 * @param pageNum 每个sheet的数据条数
* @param request * @param request
*/ */
protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields,Integer pageNum) { protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title, String exportFields, Integer pageNum) {
// Step.1 组装查询条件 // Step.1 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 计算分页sheet数据 // Step.2 计算分页sheet数据
double total = service.count(); double total = service.count();
int count = (int)Math.ceil(total/pageNum); int count = (int) Math.ceil(total / pageNum);
//update-begin-author:liusq---date:20220629--for: 多sheet导出根据选择导出写法调整 --- //update-begin-author:liusq---date:20220629--for: 多sheet导出根据选择导出写法调整 ---
// Step.3 过滤选中数据 // Step.3 过滤选中数据
String selections = request.getParameter("selections"); String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) { if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(",")); List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList); queryWrapper.in("id", selectionList);
} }
//update-end-author:liusq---date:20220629--for: 多sheet导出根据选择导出写法调整 --- //update-end-author:liusq---date:20220629--for: 多sheet导出根据选择导出写法调整 ---
// Step.4 多sheet处理 // Step.4 多sheet处理
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
for (int i = 1; i <=count ; i++) { for (int i = 1; i <= count; i++) {
Page<T> page = new Page<T>(i, pageNum); Page<T> page = new Page<T>(i, pageNum);
IPage<T> pageList = service.page(page, queryWrapper); IPage<T> pageList = service.page(page, queryWrapper);
List<T> exportList = pageList.getRecords(); List<T> exportList = pageList.getRecords();
Map<String, Object> map = new HashMap<>(5); Map<String, Object> map = new HashMap<>(5);
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,jeecgBaseConfig.getPath().getUpload()); ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title + i, jeecgBaseConfig.getPath().getUpload());
exportParams.setType(ExcelType.XSSF); exportParams.setType(ExcelType.XSSF);
//map.put("title",exportParams); //map.put("title",exportParams);
//表格Title //表格Title
map.put(NormalExcelConstants.PARAMS,exportParams); map.put(NormalExcelConstants.PARAMS, exportParams);
//表格对应实体 //表格对应实体
map.put(NormalExcelConstants.CLASS,clazz); map.put(NormalExcelConstants.CLASS, clazz);
//数据集合 //数据集合
map.put(NormalExcelConstants.DATA_LIST, exportList); map.put(NormalExcelConstants.DATA_LIST, exportList);
listMap.add(map); listMap.add(map);
@@ -133,9 +136,9 @@ public class JeecgController<T, S extends IService<T>> {
* *
* @param request * @param request
*/ */
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields) { protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title, String exportFields) {
ModelAndView mv = this.exportXls(request,object,clazz,title); ModelAndView mv = this.exportXls(request, object, clazz, title);
mv.addObject(NormalExcelConstants.EXPORT_FIELDS,exportFields); mv.addObject(NormalExcelConstants.EXPORT_FIELDS, exportFields);
return mv; return mv;
} }
@@ -184,9 +187,9 @@ public class JeecgController<T, S extends IService<T>> {
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage(); String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);
if(msg!=null && msg.indexOf("Duplicate entry")>=0){ if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
return Result.error("文件导入失败:有重复数据!"); return Result.error("文件导入失败:有重复数据!");
}else{ } else {
return Result.error("文件导入失败:" + e.getMessage()); return Result.error("文件导入失败:" + e.getMessage());
} }
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示

View File

@@ -1,18 +1,16 @@
package org.jeecg.common.system.base.entity; package org.jeecg.common.system.base.entity;
import java.io.Serializable;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema; import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/** /**
* @Description: Entity基类 * @Description: Entity基类

View File

@@ -1,11 +1,10 @@
package org.jeecg.common.system.base.service.impl; package org.jeecg.common.system.base.service.impl;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecg.common.system.base.service.JeecgService;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecg.common.system.base.service.JeecgService;
/** /**
* @Description: ServiceImpl基类 * @Description: ServiceImpl基类

View File

@@ -9,8 +9,8 @@ public interface UserFilterEnhance {
/** /**
* 获取用户id * 获取用户id
* @param loginUserId 当前登录的用户id
* *
* @param loginUserId 当前登录的用户id
* @return List<String> 返回多个用户id * @return List<String> 返回多个用户id
*/ */
default List<String> getUserIds(String loginUserId) { default List<String> getUserIds(String loginUserId) {

View File

@@ -9,9 +9,13 @@ import org.jeecg.common.util.oConvertUtils;
*/ */
public enum MatchTypeEnum { public enum MatchTypeEnum {
/**查询链接规则 AND*/ /**
* 查询链接规则 AND
*/
AND("AND"), AND("AND"),
/**查询链接规则 OR*/ /**
* 查询链接规则 OR
*/
OR("OR"); OR("OR");
private String value; private String value;

View File

@@ -8,74 +8,76 @@ import java.io.Serializable;
*/ */
public class QueryCondition implements Serializable { public class QueryCondition implements Serializable {
private static final long serialVersionUID = 4740166316629191651L; private static final long serialVersionUID = 4740166316629191651L;
private String field; private String field;
/** 组件的类型例如input、select、radio */ /**
private String type; * 组件的类型例如input、select、radio
/** */
* 对应的数据库字段的类型 private String type;
* 支持int、bigDecimal、short、long、float、double、boolean /**
*/ * 对应的数据库字段的类型
private String dbType; * 支持int、bigDecimal、short、long、float、double、boolean
private String rule; */
private String val; private String dbType;
private String rule;
private String val;
public QueryCondition(String field, String type, String dbType, String rule, String val) { public QueryCondition(String field, String type, String dbType, String rule, String val) {
this.field = field; this.field = field;
this.type = type; this.type = type;
this.dbType = dbType; this.dbType = dbType;
this.rule = rule; this.rule = rule;
this.val = val; this.val = val;
} }
public String getField() { public String getField() {
return field; return field;
} }
public void setField(String field) { public void setField(String field) {
this.field = field; this.field = field;
} }
public String getType() { public String getType() {
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getDbType() { public String getDbType() {
return dbType; return dbType;
} }
public void setDbType(String dbType) { public void setDbType(String dbType) {
this.dbType = dbType; this.dbType = dbType;
} }
public String getRule() { public String getRule() {
return rule; return rule;
} }
public void setRule(String rule) { public void setRule(String rule) {
this.rule = rule; this.rule = rule;
} }
public String getVal() { public String getVal() {
return val; return val;
} }
public void setVal(String val) { public void setVal(String val) {
this.val = val; this.val = val;
} }
@Override @Override
public String toString(){ public String toString() {
StringBuffer sb =new StringBuffer(); StringBuffer sb = new StringBuffer();
if(field == null || "".equals(field)){ if (field == null || "".equals(field)) {
return ""; return "";
} }
sb.append(this.field).append(" ").append(this.rule).append(" ").append(this.type).append(" ").append(this.dbType).append(" ").append(this.val); sb.append(this.field).append(" ").append(this.rule).append(" ").append(this.type).append(" ").append(this.dbType).append(" ").append(this.val);
return sb.toString(); return sb.toString();
} }
} }

View File

@@ -4,64 +4,115 @@ import org.jeecg.common.util.oConvertUtils;
/** /**
* Query 规则 常量 * Query 规则 常量
*
* @Author Scott * @Author Scott
* @Date 2019年02月14日 * @Date 2019年02月14日
*/ */
public enum QueryRuleEnum { public enum QueryRuleEnum {
/**查询规则 大于*/ /**
GT(">","gt","大于"), * 查询规则 大于
/**查询规则 大于等于*/ */
GE(">=","ge","大于等于"), GT(">", "gt", "大于"),
/**查询规则 小于*/ /**
LT("<","lt","小于"), * 查询规则 大于等于
/**查询规则 小于等于*/ */
LE("<=","le","于等于"), GE(">=", "ge", "于等于"),
/**查询规则 等于*/ /**
EQ("=","eq","等于"), * 查询规则 小于
/**查询规则 不等于*/ */
NE("!=","ne","不等"), LT("<", "lt", ""),
/**查询规则 包含*/ /**
IN("IN","in","包含"), * 查询规则 小于等于
/**查询规则 全模糊*/ */
LIKE("LIKE","like","全模糊"), LE("<=", "le", "小于等于"),
/**查询规则 不模糊包含*/ /**
NOT_LIKE("NOT_LIKE","not_like","不模糊包含"), * 查询规则 等于
/**查询规则 左模糊*/ */
LEFT_LIKE("LEFT_LIKE","left_like","左模糊"), EQ("=", "eq", "等于"),
/**查询规则 右模糊*/ /**
RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"), * 查询规则 不等于
/**查询规则 带加号等于*/ */
EQ_WITH_ADD("EQWITHADD","eq_with_add","带加号等于"), NE("!=", "ne", "等于"),
/**查询规则 多词模糊匹配(and)*/ /**
LIKE_WITH_AND("LIKEWITHAND","like_with_and","多词模糊匹配————暂时未用上"), * 查询规则 包含
/**查询规则 多词模糊匹配(or)*/ */
LIKE_WITH_OR("LIKEWITHOR","like_with_or","多词模糊匹配(or)"), IN("IN", "in", "包含"),
/**查询规则 自定义SQL片段*/ /**
SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段"), * 查询规则 全模糊
*/
LIKE("LIKE", "like", "全模糊"),
/**
* 查询规则 不模糊包含
*/
NOT_LIKE("NOT_LIKE", "not_like", "不模糊包含"),
/**
* 查询规则 左模糊
*/
LEFT_LIKE("LEFT_LIKE", "left_like", "左模糊"),
/**
* 查询规则 右模糊
*/
RIGHT_LIKE("RIGHT_LIKE", "right_like", "右模糊"),
/**
* 查询规则 带加号等于
*/
EQ_WITH_ADD("EQWITHADD", "eq_with_add", "带加号等于"),
/**
* 查询规则 多词模糊匹配(and)
*/
LIKE_WITH_AND("LIKEWITHAND", "like_with_and", "多词模糊匹配————暂时未用上"),
/**
* 查询规则 多词模糊匹配(or)
*/
LIKE_WITH_OR("LIKEWITHOR", "like_with_or", "多词模糊匹配(or)"),
/**
* 查询规则 自定义SQL片段
*/
SQL_RULES("USE_SQL_RULES", "ext", "自定义SQL片段"),
/** 查询工作表 */ /**
LINKAGE("LINKAGE","linkage","查询工作表"), * 查询工作表
*/
LINKAGE("LINKAGE", "linkage", "查询工作表"),
// ------- 当前表单设计器内专用 ------- // ------- 当前表单设计器内专用 -------
/**查询规则 不以…结尾*/ /**
NOT_LEFT_LIKE("NOT_LEFT_LIKE","not_left_like","不以…结尾"), * 查询规则 不以…结尾
/**查询规则 不以…开头*/ */
NOT_RIGHT_LIKE("NOT_RIGHT_LIKE","not_right_like","不以…开头"), NOT_LEFT_LIKE("NOT_LEFT_LIKE", "not_left_like", "不以…结尾"),
/** 值为空 */ /**
EMPTY("EMPTY","empty","值为空"), * 查询规则 不以…开头
/** 值不为空 */ */
NOT_EMPTY("NOT_EMPTY","not_empty","值不为空"), NOT_RIGHT_LIKE("NOT_RIGHT_LIKE", "not_right_like", "不以…开头"),
/**查询规则 不包含*/ /**
NOT_IN("NOT_IN","not_in","不包含"), * 值为空
/**查询规则 多词匹配*/ */
ELE_MATCH("ELE_MATCH","elemMatch","多词匹配"), EMPTY("EMPTY", "empty", "值为空"),
/**查询规则 范围查询*/ /**
RANGE("RANGE","range","范围查询"), * 值不为空
/**查询规则 不在范围内查询*/ */
NOT_RANGE("NOT_RANGE","not_range","不在范围查询"), NOT_EMPTY("NOT_EMPTY", "not_empty", "值不为空"),
/** 自定义mongodb查询语句 */ /**
CUSTOM_MONGODB("CUSTOM_MONGODB","custom_mongodb","自定义mongodb查询语句"); * 查询规则 不包含
*/
NOT_IN("NOT_IN", "not_in", "不包含"),
/**
* 查询规则 多词匹配
*/
ELE_MATCH("ELE_MATCH", "elemMatch", "多词匹配"),
/**
* 查询规则 范围查询
*/
RANGE("RANGE", "range", "范围查询"),
/**
* 查询规则 不在范围内查询
*/
NOT_RANGE("NOT_RANGE", "not_range", "不在范围查询"),
/**
* 自定义mongodb查询语句
*/
CUSTOM_MONGODB("CUSTOM_MONGODB", "custom_mongodb", "自定义mongodb查询语句");
// ------- 当前表单设计器内专用 ------- // ------- 当前表单设计器内专用 -------
private String value; private String value;
@@ -70,7 +121,7 @@ public enum QueryRuleEnum {
private String msg; private String msg;
QueryRuleEnum(String value, String condition, String msg){ QueryRuleEnum(String value, String condition, String msg) {
this.value = value; this.value = value;
this.condition = condition; this.condition = condition;
this.msg = msg; this.msg = msg;
@@ -93,22 +144,22 @@ public enum QueryRuleEnum {
} }
public String getCondition() { public String getCondition() {
return condition; return condition;
} }
public void setCondition(String condition) { public void setCondition(String condition) {
this.condition = condition; this.condition = condition;
} }
public static QueryRuleEnum getByValue(String value){ public static QueryRuleEnum getByValue(String value) {
if(oConvertUtils.isEmpty(value)) { if (oConvertUtils.isEmpty(value)) {
return null; return null;
} }
for(QueryRuleEnum val :values()){ for (QueryRuleEnum val : values()) {
if (val.getValue().equals(value) || val.getCondition().equalsIgnoreCase(value)){ if (val.getValue().equals(value) || val.getCondition().equalsIgnoreCase(value)) {
return val; return val;
} }
} }
return null; return null;
} }
} }

View File

@@ -1,11 +1,11 @@
package org.jeecg.common.system.util; package org.jeecg.common.system.util;
import jakarta.servlet.http.HttpServletRequest;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel; import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.system.vo.SysUserCacheInfo; import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.SpringContextUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -14,93 +14,95 @@ import java.util.List;
* @Description: 数据权限查询规则容器工具类 * @Description: 数据权限查询规则容器工具类
* @Author: 张代浩 * @Author: 张代浩
* @Date: 2012-12-15 下午11:27:39 * @Date: 2012-12-15 下午11:27:39
*
*/ */
public class JeecgDataAutorUtils { public class JeecgDataAutorUtils {
public static final String MENU_DATA_AUTHOR_RULES = "MENU_DATA_AUTHOR_RULES"; public static final String MENU_DATA_AUTHOR_RULES = "MENU_DATA_AUTHOR_RULES";
public static final String MENU_DATA_AUTHOR_RULE_SQL = "MENU_DATA_AUTHOR_RULE_SQL"; public static final String MENU_DATA_AUTHOR_RULE_SQL = "MENU_DATA_AUTHOR_RULE_SQL";
public static final String SYS_USER_INFO = "SYS_USER_INFO"; public static final String SYS_USER_INFO = "SYS_USER_INFO";
/** /**
* 往链接请求里面,传入数据查询条件 * 往链接请求里面,传入数据查询条件
* *
* @param request * @param request
* @param dataRules * @param dataRules
*/ */
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) { public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// 1.先从request获取MENU_DATA_AUTHOR_RULES如果存则获取到LIST // 1.先从request获取MENU_DATA_AUTHOR_RULES如果存则获取到LIST
List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon(); List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>) loadDataSearchConditon();
if (list==null) { if (list == null) {
// 2.如果不存在则new一个list // 2.如果不存在则new一个list
list = new ArrayList<SysPermissionDataRuleModel>(); list = new ArrayList<SysPermissionDataRuleModel>();
} }
for (SysPermissionDataRuleModel tsDataRule : dataRules) { for (SysPermissionDataRuleModel tsDataRule : dataRules) {
list.add(tsDataRule); list.add(tsDataRule);
} }
// 3.往list里面增量存指 // 3.往list里面增量存指
request.setAttribute(MENU_DATA_AUTHOR_RULES, list); request.setAttribute(MENU_DATA_AUTHOR_RULES, list);
} }
/** /**
* 获取请求对应的数据权限规则 * 获取请求对应的数据权限规则
* *
* @return * @return
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() { public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() {
return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES); return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES);
} }
/** /**
* 获取请求对应的数据权限SQL * 获取请求对应的数据权限SQL
* *
* @return * @return
*/ */
public static synchronized String loadDataSearchConditonSqlString() { public static synchronized String loadDataSearchConditonSqlString() {
return (String) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULE_SQL); return (String) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULE_SQL);
} }
/** /**
* 往链接请求里面,传入数据查询条件 * 往链接请求里面,传入数据查询条件
* *
* @param request * @param request
* @param sql * @param sql
*/ */
public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) { public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) {
String ruleSql = (String) loadDataSearchConditonSqlString(); String ruleSql = (String) loadDataSearchConditonSqlString();
if (!StringUtils.hasText(ruleSql)) { if (!StringUtils.hasText(ruleSql)) {
request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL,sql); request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL, sql);
} }
} }
/** /**
* 将用户信息存到request * 将用户信息存到request
* @param request *
* @param userinfo * @param request
*/ * @param userinfo
public static synchronized void installUserInfo(HttpServletRequest request, SysUserCacheInfo userinfo) { */
request.setAttribute(SYS_USER_INFO, userinfo); public static synchronized void installUserInfo(HttpServletRequest request, SysUserCacheInfo userinfo) {
} request.setAttribute(SYS_USER_INFO, userinfo);
}
/** /**
* 将用户信息存到request * 将用户信息存到request
* @param userinfo *
*/ * @param userinfo
public static synchronized void installUserInfo(SysUserCacheInfo userinfo) { */
SpringContextUtils.getHttpServletRequest().setAttribute(SYS_USER_INFO, userinfo); public static synchronized void installUserInfo(SysUserCacheInfo userinfo) {
} SpringContextUtils.getHttpServletRequest().setAttribute(SYS_USER_INFO, userinfo);
}
/** /**
* 从request获取用户信息 * 从request获取用户信息
* @return *
*/ * @return
public static synchronized SysUserCacheInfo loadUserInfo() { */
return (SysUserCacheInfo) SpringContextUtils.getHttpServletRequest().getAttribute(SYS_USER_INFO); public static synchronized SysUserCacheInfo loadUserInfo() {
return (SysUserCacheInfo) SpringContextUtils.getHttpServletRequest().getAttribute(SYS_USER_INFO);
} }
} }

View File

@@ -7,15 +7,10 @@ import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT; import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import jakarta.servlet.ServletResponse; import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
@@ -30,6 +25,10 @@ import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
/** /**
* @Author Scott * @Author Scott
* @Date 2018-07-12 14:23 * @Date 2018-07-12 14:23
@@ -38,27 +37,28 @@ import org.jeecg.common.util.oConvertUtils;
@Slf4j @Slf4j
public class JwtUtil { public class JwtUtil {
/**Token有效期为7天Token在reids中缓存时间为两倍*/ /**
public static final long EXPIRE_TIME = (7 * 12) * 60 * 60 * 1000; * Token有效期为7天Token在reids中缓存时间为两倍
static final String WELL_NUMBER = SymbolConstant.WELL_NUMBER + SymbolConstant.LEFT_CURLY_BRACKET; */
public static final long EXPIRE_TIME = (7 * 12) * 60 * 60 * 1000;
static final String WELL_NUMBER = SymbolConstant.WELL_NUMBER + SymbolConstant.LEFT_CURLY_BRACKET;
/** /**
*
* @param response * @param response
* @param code * @param code
* @param errorMsg * @param errorMsg
*/ */
public static void responseError(ServletResponse response, Integer code, String errorMsg) { public static void responseError(ServletResponse response, Integer code, String errorMsg) {
HttpServletResponse httpServletResponse = (HttpServletResponse) response; HttpServletResponse httpServletResponse = (HttpServletResponse) response;
// issues/I4YH95浏览器显示乱码问题 // issues/I4YH95浏览器显示乱码问题
httpServletResponse.setHeader("Content-type", "text/html;charset=UTF-8"); httpServletResponse.setHeader("Content-type", "text/html;charset=UTF-8");
Result jsonResult = new Result(code, errorMsg); Result jsonResult = new Result(code, errorMsg);
jsonResult.setSuccess(false); jsonResult.setSuccess(false);
OutputStream os = null; OutputStream os = null;
try { try {
os = httpServletResponse.getOutputStream(); os = httpServletResponse.getOutputStream();
httpServletResponse.setCharacterEncoding("UTF-8"); httpServletResponse.setCharacterEncoding("UTF-8");
httpServletResponse.setStatus(code); httpServletResponse.setStatus(code);
os.write(new ObjectMapper().writeValueAsString(jsonResult).getBytes("UTF-8")); os.write(new ObjectMapper().writeValueAsString(jsonResult).getBytes("UTF-8"));
os.flush(); os.flush();
os.close(); os.close();
@@ -67,232 +67,238 @@ public class JwtUtil {
} }
} }
/** /**
* 校验token是否正确 * 校验token是否正确
* *
* @param token 密钥 * @param token 密钥
* @param secret 用户的密码 * @param secret 用户的密码
* @return 是否正确 * @return 是否正确
*/ */
public static boolean verify(String token, String username, String secret) { public static boolean verify(String token, String username, String secret) {
try { try {
// 根据密码生成JWT效验器 // 根据密码生成JWT效验器
Algorithm algorithm = Algorithm.HMAC256(secret); Algorithm algorithm = Algorithm.HMAC256(secret);
JWTVerifier verifier = JWT.require(algorithm).withClaim("username", username).build(); JWTVerifier verifier = JWT.require(algorithm).withClaim("username", username).build();
// 效验TOKEN // 效验TOKEN
DecodedJWT jwt = verifier.verify(token); DecodedJWT jwt = verifier.verify(token);
return true; return true;
} catch (Exception exception) { } catch (Exception exception) {
return false; return false;
} }
} }
/** /**
* 获得token中的信息无需secret解密也能获得 * 获得token中的信息无需secret解密也能获得
* *
* @return token中包含的用户名 * @return token中包含的用户名
*/ */
public static String getUsername(String token) { public static String getUsername(String token) {
try { try {
DecodedJWT jwt = JWT.decode(token); DecodedJWT jwt = JWT.decode(token);
return jwt.getClaim("username").asString(); return jwt.getClaim("username").asString();
} catch (JWTDecodeException e) { } catch (JWTDecodeException e) {
return null; return null;
} }
} }
/** /**
* 生成签名,5min后过期 * 生成签名,5min后过期
* *
* @param username 用户名 * @param username 用户名
* @param secret 用户的密码 * @param secret 用户的密码
* @return 加密的token * @return 加密的token
*/ */
public static String sign(String username, String secret) { public static String sign(String username, String secret) {
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME); Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
Algorithm algorithm = Algorithm.HMAC256(secret); Algorithm algorithm = Algorithm.HMAC256(secret);
// 附带username信息 // 附带username信息
return JWT.create().withClaim("username", username).withExpiresAt(date).sign(algorithm); return JWT.create().withClaim("username", username).withExpiresAt(date).sign(algorithm);
} }
/** /**
* 根据request中的token获取用户账号 * 根据request中的token获取用户账号
* *
* @param request * @param request
* @return * @return
* @throws JeecgBootException * @throws JeecgBootException
*/ */
public static String getUserNameByToken(HttpServletRequest request) throws JeecgBootException { public static String getUserNameByToken(HttpServletRequest request) throws JeecgBootException {
String accessToken = request.getHeader("X-Access-Token"); String accessToken = request.getHeader("X-Access-Token");
String username = getUsername(accessToken); String username = getUsername(accessToken);
if (oConvertUtils.isEmpty(username)) { if (oConvertUtils.isEmpty(username)) {
throw new JeecgBootException("未获取到用户"); throw new JeecgBootException("未获取到用户");
} }
return username; return username;
} }
/** /**
* 从session中获取变量 * 从session中获取变量
* @param key *
* @return * @param key
*/ * @return
public static String getSessionData(String key) { */
//${myVar}% public static String getSessionData(String key) {
//得到${} 后面的值 //${myVar}%
String moshi = ""; //得到${} 后面的值
String wellNumber = WELL_NUMBER; String moshi = "";
if(key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET)!=-1){
moshi = key.substring(key.indexOf("}")+1);
}
String returnValue = null;
if (key.contains(wellNumber)) {
key = key.substring(2,key.indexOf("}"));
}
if (oConvertUtils.isNotEmpty(key)) {
HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
returnValue = (String) session.getAttribute(key);
}
//结果加上${} 后面的值
if(returnValue!=null){returnValue = returnValue + moshi;}
return returnValue;
}
/**
* 从当前用户中获取变量
* @param key
* @param user
* @return
*/
public static String getUserSystemData(String key, SysUserCacheInfo user) {
//1.优先获取 SysUserCacheInfo
if(user==null) {
try {
user = JeecgDataAutorUtils.loadUserInfo();
} catch (Exception e) {
log.warn("获取用户信息异常:" + e.getMessage());
}
}
//2.通过shiro获取登录用户信息
LoginUser sysUser = null;
try {
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
} catch (Exception e) {
log.warn("SecurityUtils.getSubject() 获取用户信息异常:" + e.getMessage());
}
//#{sys_user_code}%
String moshi = "";
String wellNumber = WELL_NUMBER; String wellNumber = WELL_NUMBER;
if(key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET)!=-1){
moshi = key.substring(key.indexOf("}")+1);
}
String returnValue = null;
//针对特殊标示处理#{sysOrgCode},判断替换
if (key.contains(wellNumber)) {
key = key.substring(2,key.indexOf("}"));
} else {
key = key;
}
//替换为当前系统时间(年月日)
if (key.equals(DataBaseConstant.SYS_DATE)|| key.toLowerCase().equals(DataBaseConstant.SYS_DATE_TABLE)) {
returnValue = DateUtils.formatDate();
}
//替换为当前系统时间(年月日时分秒)
else if (key.equals(DataBaseConstant.SYS_TIME)|| key.toLowerCase().equals(DataBaseConstant.SYS_TIME_TABLE)) {
returnValue = DateUtils.now();
}
//流程状态默认值(默认未发起)
else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) {
returnValue = "1";
}
//后台任务获取用户信息异常,导致程序中断 if (key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET) != -1) {
if(sysUser==null && user==null){ moshi = key.substring(key.indexOf("}") + 1);
return null; }
} String returnValue = null;
if (key.contains(wellNumber)) {
key = key.substring(2, key.indexOf("}"));
}
if (oConvertUtils.isNotEmpty(key)) {
HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
returnValue = (String) session.getAttribute(key);
}
//结果加上${} 后面的值
if (returnValue != null) {
returnValue = returnValue + moshi;
}
return returnValue;
}
//替换为系统登录用户帐号 /**
if (key.equals(DataBaseConstant.SYS_USER_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_CODE_TABLE)) { * 从当前用户中获取变量
if(user==null) { *
returnValue = sysUser.getUsername(); * @param key
}else { * @param user
returnValue = user.getSysUserCode(); * @return
} */
} public static String getUserSystemData(String key, SysUserCacheInfo user) {
//1.优先获取 SysUserCacheInfo
if (user == null) {
try {
user = JeecgDataAutorUtils.loadUserInfo();
} catch (Exception e) {
log.warn("获取用户信息异常:" + e.getMessage());
}
}
//2.通过shiro获取登录用户信息
LoginUser sysUser = null;
try {
sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
} catch (Exception e) {
log.warn("SecurityUtils.getSubject() 获取用户信息异常:" + e.getMessage());
}
// 替换为系统登录用户ID //#{sys_user_code}%
else if (key.equals(DataBaseConstant.SYS_USER_ID) || key.equalsIgnoreCase(DataBaseConstant.SYS_USER_ID_TABLE)) { String moshi = "";
if(user==null) { String wellNumber = WELL_NUMBER;
returnValue = sysUser.getId(); if (key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET) != -1) {
}else { moshi = key.substring(key.indexOf("}") + 1);
returnValue = user.getSysUserId(); }
} String returnValue = null;
} //针对特殊标示处理#{sysOrgCode},判断替换
if (key.contains(wellNumber)) {
key = key.substring(2, key.indexOf("}"));
} else {
key = key;
}
//替换为当前系统时间(年月日)
if (key.equals(DataBaseConstant.SYS_DATE) || key.toLowerCase().equals(DataBaseConstant.SYS_DATE_TABLE)) {
returnValue = DateUtils.formatDate();
}
//替换为当前系统时间(年月日时分秒)
else if (key.equals(DataBaseConstant.SYS_TIME) || key.toLowerCase().equals(DataBaseConstant.SYS_TIME_TABLE)) {
returnValue = DateUtils.now();
}
//流程状态默认值(默认未发起)
else if (key.equals(DataBaseConstant.BPM_STATUS) || key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) {
returnValue = "1";
}
//替换为系统登录用户真实名字 //后台任务获取用户信息异常,导致程序中断
else if (key.equals(DataBaseConstant.SYS_USER_NAME)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) { if (sysUser == null && user == null) {
if(user==null) { return null;
returnValue = sysUser.getRealname(); }
}else {
returnValue = user.getSysUserName();
}
}
//替换为系统用户登录所使用的机构编码 //替换为系统登录用户帐号
else if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) { if (key.equals(DataBaseConstant.SYS_USER_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
if(user==null) { if (user == null) {
returnValue = sysUser.getOrgCode(); returnValue = sysUser.getUsername();
}else { } else {
returnValue = user.getSysOrgCode(); returnValue = user.getSysUserCode();
} }
} }
// 替换为系统用户登录所使用的机构ID // 替换为系统登录用户ID
else if (key.equals(DataBaseConstant.SYS_ORG_ID) || key.equalsIgnoreCase(DataBaseConstant.SYS_ORG_ID_TABLE)) { else if (key.equals(DataBaseConstant.SYS_USER_ID) || key.equalsIgnoreCase(DataBaseConstant.SYS_USER_ID_TABLE)) {
if (user == null) { if (user == null) {
returnValue = sysUser.getOrgId(); returnValue = sysUser.getId();
} else { } else {
returnValue = user.getSysOrgId(); returnValue = user.getSysUserId();
} }
} }
//替换为系统用户所拥有的所有机构编码 //替换为系统登录用户真实名字
else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) { else if (key.equals(DataBaseConstant.SYS_USER_NAME) || key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
if(user==null){ if (user == null) {
//TODO 暂时使用用户登录部门,存在逻辑缺陷,不是用户所拥有的部门 returnValue = sysUser.getRealname();
returnValue = sysUser.getOrgCode(); } else {
}else{ returnValue = user.getSysUserName();
if(user.isOneDepart()) { }
returnValue = user.getSysMultiOrgCode().get(0); }
}else {
returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
}
}
}
// 替换为当前登录用户的角色code多个逗号分割 //替换为系统用户登录所使用的机构编码
else if (key.equals(DataBaseConstant.SYS_ROLE_CODE) || key.equalsIgnoreCase(DataBaseConstant.SYS_ROLE_CODE_TABLE)) { else if (key.equals(DataBaseConstant.SYS_ORG_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
if (user == null) { if (user == null) {
returnValue = sysUser.getRoleCode(); returnValue = sysUser.getOrgCode();
} else { } else {
returnValue = user.getSysRoleCode(); returnValue = user.getSysOrgCode();
} }
} }
//update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量 // 替换为系统用户登录所使用的机构ID
else if (key.equals(TenantConstant.TENANT_ID) || key.toLowerCase().equals(TenantConstant.TENANT_ID_TABLE)){ else if (key.equals(DataBaseConstant.SYS_ORG_ID) || key.equalsIgnoreCase(DataBaseConstant.SYS_ORG_ID_TABLE)) {
try { if (user == null) {
returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID); returnValue = sysUser.getOrgId();
} catch (Exception e) { } else {
log.warn("获取系统租户异常:" + e.getMessage()); returnValue = user.getSysOrgId();
} }
} }
//update-end-author:taoyan date:20210330 for:多租户ID作为系统变量
if(returnValue!=null){returnValue = returnValue + moshi;} //替换为系统用户所拥有的所有机构编码
return returnValue; else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) {
} if (user == null) {
//TODO 暂时使用用户登录部门,存在逻辑缺陷,不是用户所拥有的部门
returnValue = sysUser.getOrgCode();
} else {
if (user.isOneDepart()) {
returnValue = user.getSysMultiOrgCode().get(0);
} else {
returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
}
}
}
// 替换为当前登录用户的角色code多个逗号分割
else if (key.equals(DataBaseConstant.SYS_ROLE_CODE) || key.equalsIgnoreCase(DataBaseConstant.SYS_ROLE_CODE_TABLE)) {
if (user == null) {
returnValue = sysUser.getRoleCode();
} else {
returnValue = user.getSysRoleCode();
}
}
//update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量
else if (key.equals(TenantConstant.TENANT_ID) || key.toLowerCase().equals(TenantConstant.TENANT_ID_TABLE)) {
try {
returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID);
} catch (Exception e) {
log.warn("获取系统租户异常:" + e.getMessage());
}
}
//update-end-author:taoyan date:20210330 for:多租户ID作为系统变量
if (returnValue != null) {
returnValue = returnValue + moshi;
}
return returnValue;
}
// public static void main(String[] args) { // public static void main(String[] args) {
// String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjUzMzY1MTMsInVzZXJuYW1lIjoiYWRtaW4ifQ.xjhud_tWCNYBOg_aRlMgOdlZoWFFKB_givNElHNw3X0"; // String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjUzMzY1MTMsInVzZXJuYW1lIjoiYWRtaW4ifQ.xjhud_tWCNYBOg_aRlMgOdlZoWFFKB_givNElHNw3X0";

View File

@@ -21,6 +21,7 @@ import java.util.Map;
/** /**
* 资源加载工具类 * 资源加载工具类
*
* @Author taoYan * @Author taoYan
* @Date 2022/7/8 10:40 * @Date 2022/7/8 10:40
**/ **/
@@ -36,13 +37,13 @@ public class ResourceUtil {
/** /**
* 所有java类 * 所有java类
*/ */
private final static String CLASS_PATTERN="/**/*.class"; private final static String CLASS_PATTERN = "/**/*.class";
/** /**
* 所有枚举java类 * 所有枚举java类
*/ */
private final static String CLASS_ENUM_PATTERN="/**/*Enum.class"; private final static String CLASS_ENUM_PATTERN = "/**/*Enum.class";
/** /**
* 包路径 org.jeecg * 包路径 org.jeecg
@@ -56,10 +57,11 @@ public class ResourceUtil {
/** /**
* 获取枚举类对应的字典数据 SysDictServiceImpl#queryAllDictItems() * 获取枚举类对应的字典数据 SysDictServiceImpl#queryAllDictItems()
*
* @return * @return
*/ */
public static Map<String, List<DictModel>> getEnumDictData(){ public static Map<String, List<DictModel>> getEnumDictData() {
if(enumDictData.keySet().size()>0){ if (enumDictData.keySet().size() > 0) {
return enumDictData; return enumDictData;
} }
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
@@ -75,13 +77,13 @@ public class ResourceUtil {
if (enumDict != null) { if (enumDict != null) {
EnumDict annotation = clazz.getAnnotation(EnumDict.class); EnumDict annotation = clazz.getAnnotation(EnumDict.class);
String key = annotation.value(); String key = annotation.value();
if(oConvertUtils.isNotEmpty(key)){ if (oConvertUtils.isNotEmpty(key)) {
List<DictModel> list = (List<DictModel>) clazz.getDeclaredMethod(METHOD_NAME).invoke(null); List<DictModel> list = (List<DictModel>) clazz.getDeclaredMethod(METHOD_NAME).invoke(null);
enumDictData.put(key, list); enumDictData.put(key, list);
} }
} }
} }
}catch (Exception e){ } catch (Exception e) {
log.error("获取枚举类字典数据异常", e.getMessage()); log.error("获取枚举类字典数据异常", e.getMessage());
// e.printStackTrace(); // e.printStackTrace();
} }
@@ -90,24 +92,25 @@ public class ResourceUtil {
/** /**
* 用于后端字典翻译 SysDictServiceImpl#queryManyDictByKeys(java.util.List, java.util.List) * 用于后端字典翻译 SysDictServiceImpl#queryManyDictByKeys(java.util.List, java.util.List)
*
* @param dictCodeList * @param dictCodeList
* @param keys * @param keys
* @return * @return
*/ */
public static Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys){ public static Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys) {
if(enumDictData.keySet().size()==0){ if (enumDictData.keySet().size() == 0) {
getEnumDictData(); getEnumDictData();
} }
Map<String, List<DictModel>> map = new HashMap<>(); Map<String, List<DictModel>> map = new HashMap<>();
for (String code : enumDictData.keySet()) { for (String code : enumDictData.keySet()) {
if(dictCodeList.indexOf(code)>=0){ if (dictCodeList.indexOf(code) >= 0) {
List<DictModel> dictItemList = enumDictData.get(code); List<DictModel> dictItemList = enumDictData.get(code);
for(DictModel dm: dictItemList){ for (DictModel dm : dictItemList) {
String value = dm.getValue(); String value = dm.getValue();
if(keys.indexOf(value)>=0){ if (keys.indexOf(value) >= 0) {
List<DictModel> list = new ArrayList<>(); List<DictModel> list = new ArrayList<>();
list.add(new DictModel(value, dm.getText())); list.add(new DictModel(value, dm.getText()));
map.put(code,list); map.put(code, list);
break; break;
} }
} }
@@ -121,15 +124,15 @@ public class ResourceUtil {
* *
* @param classPath * @param classPath
*/ */
public static Object getImplementationClass(String classPath){ public static Object getImplementationClass(String classPath) {
try { try {
Class<?> aClass = Class.forName(classPath); Class<?> aClass = Class.forName(classPath);
return SpringContextUtils.getBean(aClass); return SpringContextUtils.getBean(aClass);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.error("类没有找到",e); log.error("类没有找到", e);
return null; return null;
} catch (NoSuchBeanDefinitionException e){ } catch (NoSuchBeanDefinitionException e) {
log.error(classPath + "没有实现",e); log.error(classPath + "没有实现", e);
return null; return null;
} }
} }

View File

@@ -7,6 +7,7 @@ import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum; import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.CommonUtils; import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -20,18 +21,20 @@ public class SqlConcatUtil {
/** /**
* 获取单个查询条件的值 * 获取单个查询条件的值
*
* @param rule * @param rule
* @param field * @param field
* @param value * @param value
* @param isString * @param isString
* @return * @return
*/ */
public static String getSingleSqlByRule(QueryRuleEnum rule,String field,Object value,boolean isString) { public static String getSingleSqlByRule(QueryRuleEnum rule, String field, Object value, boolean isString) {
return getSingleSqlByRule(rule, field, value, isString, null); return getSingleSqlByRule(rule, field, value, isString, null);
} }
/** /**
* 报表获取查询条件 支持多数据源 * 报表获取查询条件 支持多数据源
*
* @param field * @param field
* @param alias * @param alias
* @param value * @param value
@@ -39,17 +42,18 @@ public class SqlConcatUtil {
* @param dataBaseType * @param dataBaseType
* @return * @return
*/ */
public static String getSingleQueryConditionSql(String field,String alias,Object value,boolean isString, String dataBaseType) { public static String getSingleQueryConditionSql(String field, String alias, Object value, boolean isString, String dataBaseType) {
if (value == null) { if (value == null) {
return ""; return "";
} }
field = alias+oConvertUtils.camelToUnderline(field); field = alias + oConvertUtils.camelToUnderline(field);
QueryRuleEnum rule = QueryGenerator.convert2Rule(value); QueryRuleEnum rule = QueryGenerator.convert2Rule(value);
return getSingleSqlByRule(rule, field, value, isString, dataBaseType); return getSingleSqlByRule(rule, field, value, isString, dataBaseType);
} }
/** /**
* 获取单个查询条件的值 * 获取单个查询条件的值
*
* @param rule * @param rule
* @param field * @param field
* @param value * @param value
@@ -57,44 +61,44 @@ public class SqlConcatUtil {
* @param dataBaseType * @param dataBaseType
* @return * @return
*/ */
private static String getSingleSqlByRule(QueryRuleEnum rule,String field,Object value,boolean isString, String dataBaseType) { private static String getSingleSqlByRule(QueryRuleEnum rule, String field, Object value, boolean isString, String dataBaseType) {
String res = ""; String res = "";
switch (rule) { switch (rule) {
case GT: case GT:
res =field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType); res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case GE: case GE:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType); res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case LT: case LT:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType); res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case LE: case LE:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType); res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case EQ: case EQ:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType); res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case EQ_WITH_ADD: case EQ_WITH_ADD:
res = field+" = "+getFieldConditionValue(value, isString, dataBaseType); res = field + " = " + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case NE: case NE:
res = field+" <> "+getFieldConditionValue(value, isString, dataBaseType); res = field + " <> " + getFieldConditionValue(value, isString, dataBaseType);
break; break;
case IN: case IN:
res = field + " in "+getInConditionValue(value, isString); res = field + " in " + getInConditionValue(value, isString);
break; break;
case LIKE: case LIKE:
res = field + " like "+getLikeConditionValue(value, QueryRuleEnum.LIKE); res = field + " like " + getLikeConditionValue(value, QueryRuleEnum.LIKE);
break; break;
case LEFT_LIKE: case LEFT_LIKE:
res = field + " like "+getLikeConditionValue(value, QueryRuleEnum.LEFT_LIKE); res = field + " like " + getLikeConditionValue(value, QueryRuleEnum.LEFT_LIKE);
break; break;
case RIGHT_LIKE: case RIGHT_LIKE:
res = field + " like "+getLikeConditionValue(value, QueryRuleEnum.RIGHT_LIKE); res = field + " like " + getLikeConditionValue(value, QueryRuleEnum.RIGHT_LIKE);
break; break;
default: default:
res = field+" = "+getFieldConditionValue(value, isString, dataBaseType); res = field + " = " + getFieldConditionValue(value, isString, dataBaseType);
break; break;
} }
return res; return res;
@@ -102,62 +106,63 @@ public class SqlConcatUtil {
/** /**
* 获取查询条件的值 * 获取查询条件的值
*
* @param value * @param value
* @param isString * @param isString
* @param dataBaseType * @param dataBaseType
* @return * @return
*/ */
private static String getFieldConditionValue(Object value,boolean isString, String dataBaseType) { private static String getFieldConditionValue(Object value, boolean isString, String dataBaseType) {
String str = value.toString().trim(); String str = value.toString().trim();
if(str.startsWith(SymbolConstant.EXCLAMATORY_MARK)) { if (str.startsWith(SymbolConstant.EXCLAMATORY_MARK)) {
str = str.substring(1); str = str.substring(1);
}else if(str.startsWith(QueryRuleEnum.GE.getValue())) { } else if (str.startsWith(QueryRuleEnum.GE.getValue())) {
str = str.substring(2); str = str.substring(2);
}else if(str.startsWith(QueryRuleEnum.LE.getValue())) { } else if (str.startsWith(QueryRuleEnum.LE.getValue())) {
str = str.substring(2); str = str.substring(2);
}else if(str.startsWith(QueryRuleEnum.GT.getValue())) { } else if (str.startsWith(QueryRuleEnum.GT.getValue())) {
str = str.substring(1); str = str.substring(1);
}else if(str.startsWith(QueryRuleEnum.LT.getValue())) { } else if (str.startsWith(QueryRuleEnum.LT.getValue())) {
str = str.substring(1); str = str.substring(1);
}else if(str.indexOf(QueryGenerator.QUERY_COMMA_ESCAPE)>0) { } else if (str.indexOf(QueryGenerator.QUERY_COMMA_ESCAPE) > 0) {
str = str.replaceAll("\\+\\+", SymbolConstant.COMMA); str = str.replaceAll("\\+\\+", SymbolConstant.COMMA);
} }
if(dataBaseType==null){ if (dataBaseType == null) {
dataBaseType = getDbType(); dataBaseType = getDbType();
} }
if(isString) { if (isString) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType)){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType)) {
return " N'"+str+"' "; return " N'" + str + "' ";
}else{ } else {
return " '"+str+"' "; return " '" + str + "' ";
} }
}else { } else {
// 如果不是字符串 有一种特殊情况 popup调用都走这个逻辑 参数传递的可能是“admin”这种格式的 // 如果不是字符串 有一种特殊情况 popup调用都走这个逻辑 参数传递的可能是“admin”这种格式的
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK)){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK)) {
return " N"+str; return " N" + str;
} }
return value.toString(); return value.toString();
} }
} }
private static String getInConditionValue(Object value,boolean isString) { private static String getInConditionValue(Object value, boolean isString) {
//update-begin-author:taoyan date:20210628 for: 查询条件如果输入,导致sql报错 //update-begin-author:taoyan date:20210628 for: 查询条件如果输入,导致sql报错
String[] temp = value.toString().split(","); String[] temp = value.toString().split(",");
if(temp.length==0){ if (temp.length == 0) {
return "('')"; return "('')";
} }
if(isString) { if (isString) {
List<String> res = new ArrayList<>(); List<String> res = new ArrayList<>();
for (String string : temp) { for (String string : temp) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
res.add("N'"+string+"'"); res.add("N'" + string + "'");
}else{ } else {
res.add("'"+string+"'"); res.add("'" + string + "'");
} }
} }
return "("+String.join("," ,res)+")"; return "(" + String.join(",", res) + ")";
}else { } else {
return "("+value.toString()+")"; return "(" + value.toString() + ")";
} }
//update-end-author:taoyan date:20210628 for: 查询条件如果输入,导致sql报错 //update-end-author:taoyan date:20210628 for: 查询条件如果输入,导致sql报错
} }
@@ -165,46 +170,47 @@ public class SqlConcatUtil {
/** /**
* 先根据值判断 走左模糊还是右模糊 * 先根据值判断 走左模糊还是右模糊
* 最后如果值不带任何标识(*或者%)则再根据ruleEnum判断 * 最后如果值不带任何标识(*或者%)则再根据ruleEnum判断
*
* @param value * @param value
* @param ruleEnum * @param ruleEnum
* @return * @return
*/ */
private static String getLikeConditionValue(Object value, QueryRuleEnum ruleEnum) { private static String getLikeConditionValue(Object value, QueryRuleEnum ruleEnum) {
String str = value.toString().trim(); String str = value.toString().trim();
if(str.startsWith(SymbolConstant.ASTERISK) && str.endsWith(SymbolConstant.ASTERISK)) { if (str.startsWith(SymbolConstant.ASTERISK) && str.endsWith(SymbolConstant.ASTERISK)) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
return "N'%"+str.substring(1,str.length()-1)+"%'"; return "N'%" + str.substring(1, str.length() - 1) + "%'";
}else{ } else {
return "'%"+str.substring(1,str.length()-1)+"%'"; return "'%" + str.substring(1, str.length() - 1) + "%'";
} }
}else if(str.startsWith(SymbolConstant.ASTERISK)) { } else if (str.startsWith(SymbolConstant.ASTERISK)) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
return "N'%"+str.substring(1)+"'"; return "N'%" + str.substring(1) + "'";
}else{ } else {
return "'%"+str.substring(1)+"'"; return "'%" + str.substring(1) + "'";
} }
}else if(str.endsWith(SymbolConstant.ASTERISK)) { } else if (str.endsWith(SymbolConstant.ASTERISK)) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
return "N'"+str.substring(0,str.length()-1)+"%'"; return "N'" + str.substring(0, str.length() - 1) + "%'";
}else{ } else {
return "'"+str.substring(0,str.length()-1)+"%'"; return "'" + str.substring(0, str.length() - 1) + "%'";
} }
}else { } else {
if(str.indexOf(SymbolConstant.PERCENT_SIGN)>=0) { if (str.indexOf(SymbolConstant.PERCENT_SIGN) >= 0) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){ if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
if(str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)){ if (str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)) {
return "N"+str; return "N" + str;
}else{ } else {
return "N"+"'"+str+"'"; return "N" + "'" + str + "'";
} }
}else{ } else {
if(str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)){ if (str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)) {
return str; return str;
}else{ } else {
return "'"+str+"'"; return "'" + str + "'";
} }
} }
}else { } else {
//update-begin-author:taoyan date:2022-6-30 for: issues/3810 数据权限规则问题 //update-begin-author:taoyan date:2022-6-30 for: issues/3810 数据权限规则问题
// 走到这里说明 value不带有任何模糊查询的标识(*或者%) // 走到这里说明 value不带有任何模糊查询的标识(*或者%)

View File

@@ -18,23 +18,35 @@ import java.io.Serializable;
public class ComboModel implements Serializable { public class ComboModel implements Serializable {
private String id; private String id;
private String title; private String title;
/**文档管理 表单table默认选中*/ /**
* 文档管理 表单table默认选中
*/
private boolean checked; private boolean checked;
/**文档管理 表单table 用户账号*/ /**
* 文档管理 表单table 用户账号
*/
private String username; private String username;
/**文档管理 表单table 用户邮箱*/ /**
* 文档管理 表单table 用户邮箱
*/
private String email; private String email;
/**文档管理 表单table 角色编码*/ /**
* 文档管理 表单table 角色编码
*/
private String roleCode; private String roleCode;
public ComboModel(){ public ComboModel() {
}; }
public ComboModel(String id,String title,boolean checked,String username){ ;
public ComboModel(String id, String title, boolean checked, String username) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.checked = false; this.checked = false;
this.username = username; this.username = username;
}; }
;
} }

View File

@@ -1,14 +1,13 @@
package org.jeecg.common.system.vo; package org.jeecg.common.system.vo;
import java.io.Serializable;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
/** /**
* @Description: 字典类 * @Description: 字典类
* @author: jeecg-boot * @author: jeecg-boot
@@ -17,55 +16,57 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Accessors(chain = true) @Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DictModel implements Serializable{ public class DictModel implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public DictModel() { public DictModel() {
} }
public DictModel(String value, String text) { public DictModel(String value, String text) {
this.value = value; this.value = value;
this.text = text; this.text = text;
} }
public DictModel(String value, String text, String color) { public DictModel(String value, String text, String color) {
this.value = value; this.value = value;
this.text = text; this.text = text;
this.color = color; this.color = color;
} }
/** /**
* 字典value * 字典value
*/ */
private String value; private String value;
/** /**
* 字典文本 * 字典文本
*/ */
private String text; private String text;
/** /**
* 字典颜色 * 字典颜色
*/ */
private String color; private String color;
/** /**
* 特殊用途: JgEditableTable * 特殊用途: JgEditableTable
* @return *
*/ * @return
public String getTitle() { */
return this.text; public String getTitle() {
} return this.text;
/** }
* 特殊用途: vue3 Select组件
*/ /**
public String getLabel() { * 特殊用途: vue3 Select组件
return this.text; */
} public String getLabel() {
return this.text;
}
/** /**
* 用于表单设计器 关联记录表数据存储 * 用于表单设计器 关联记录表数据存储
* QQYUN-5595【表单设计器】他表字段 导入没有翻译 * QQYUN-5595【表单设计器】他表字段 导入没有翻译
*/ */
private JSONObject jsonObject; private JSONObject jsonObject;
} }

View File

@@ -5,6 +5,7 @@ import lombok.EqualsAndHashCode;
/** /**
* 查询多个字典时用到 * 查询多个字典时用到
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data

View File

@@ -4,6 +4,7 @@ import lombok.Data;
/** /**
* 字典查询参数实体 * 字典查询参数实体
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Data @Data

View File

@@ -22,120 +22,124 @@ import java.util.Date;
@Accessors(chain = true) @Accessors(chain = true)
public class LoginUser { public class LoginUser {
/** /**
* 登录人id * 登录人id
*/ */
@SensitiveField @SensitiveField
private String id; private String id;
/** /**
* 登录人账号 * 登录人账号
*/ */
@SensitiveField @SensitiveField
private String username; private String username;
/** /**
* 登录人名字 * 登录人名字
*/ */
@SensitiveField @SensitiveField
private String realname; private String realname;
/** /**
* 登录人密码 * 登录人密码
*/ */
@SensitiveField @SensitiveField
private String password; private String password;
/** /**
* 当前登录部门code * 当前登录部门code
*/ */
@SensitiveField @SensitiveField
private String orgCode; private String orgCode;
/** /**
* 当前登录部门id * 当前登录部门id
*/ */
@SensitiveField @SensitiveField
private String orgId; private String orgId;
/** /**
* 当前登录角色code多个逗号分割 * 当前登录角色code多个逗号分割
*/ */
@SensitiveField @SensitiveField
private String roleCode; private String roleCode;
/** /**
* 头像 * 头像
*/ */
@SensitiveField @SensitiveField
private String avatar; private String avatar;
/** /**
* 生日 * 生日
*/ */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birthday; private Date birthday;
/** /**
* 性别1男 2 * 性别1男 2
*/ */
private Integer sex; private Integer sex;
/** /**
* 电子邮件 * 电子邮件
*/ */
@SensitiveField @SensitiveField
private String email; private String email;
/** /**
* 电话 * 电话
*/ */
@SensitiveField @SensitiveField
private String phone; private String phone;
/** /**
* 状态(1正常 2冻结 * 状态(1正常 2冻结
*/ */
private Integer status; private Integer status;
private Integer delFlag; private Integer delFlag;
/** /**
* 同步工作流引擎1同步0不同步 * 同步工作流引擎1同步0不同步
*/ */
private Integer activitiSync; private Integer activitiSync;
/** /**
* 创建时间 * 创建时间
*/ */
private Date createTime; private Date createTime;
/** /**
* 身份1 普通员工 2 上级) * 身份1 普通员工 2 上级)
*/ */
private Integer userIdentity; private Integer userIdentity;
/** /**
* 管理部门ids * 管理部门ids
*/ */
@SensitiveField @SensitiveField
private String departIds; private String departIds;
/** /**
* 职务,关联职务表 * 职务,关联职务表
*/ */
@SensitiveField @SensitiveField
private String post; private String post;
/** /**
* 座机号 * 座机号
*/ */
@SensitiveField @SensitiveField
private String telephone; private String telephone;
/** 多租户ids临时用不持久化数据库(数据库字段不存在) */ /**
@SensitiveField * 多租户ids临时用不持久化数据库(数据库字段不存在)
private String relTenantIds; */
@SensitiveField
private String relTenantIds;
/**设备id uniapp推送用*/ /**
private String clientId; * 设备id uniapp推送用
*/
private String clientId;
} }

View File

@@ -1,7 +1,5 @@
package org.jeecg.common.system.vo; package org.jeecg.common.system.vo;
import org.jeecgframework.poi.excel.annotation.Excel;
/** /**
* @Author qinfeng * @Author qinfeng
* @Date 2020/2/19 12:01 * @Date 2020/2/19 12:01
@@ -9,13 +7,21 @@ import org.jeecgframework.poi.excel.annotation.Excel;
* @Version 1.0 * @Version 1.0
*/ */
public class SysCategoryModel { public class SysCategoryModel {
/**主键*/ /**
* 主键
*/
private java.lang.String id; private java.lang.String id;
/**父级节点*/ /**
* 父级节点
*/
private java.lang.String pid; private java.lang.String pid;
/**类型名称*/ /**
* 类型名称
*/
private java.lang.String name; private java.lang.String name;
/**类型编码*/ /**
* 类型编码
*/
private java.lang.String code; private java.lang.String code;
public String getId() { public String getId() {

View File

@@ -2,36 +2,65 @@ package org.jeecg.common.system.vo;
/** /**
* 部门机构model * 部门机构model
*
* @author: lvdandan * @author: lvdandan
*/ */
public class SysDepartModel { public class SysDepartModel {
/**ID*/ /**
* ID
*/
private String id; private String id;
/**父机构ID*/ /**
* 父机构ID
*/
private String parentId; private String parentId;
/**机构/部门名称*/ /**
* 机构/部门名称
*/
private String departName; private String departName;
/**英文名*/ /**
* 英文名
*/
private String departNameEn; private String departNameEn;
/**缩写*/ /**
* 缩写
*/
private String departNameAbbr; private String departNameAbbr;
/**排序*/ /**
* 排序
*/
private Integer departOrder; private Integer departOrder;
/**描述*/ /**
* 描述
*/
private String description; private String description;
/**机构类别 1组织机构2岗位*/ /**
* 机构类别 1组织机构2岗位
*/
private String orgCategory; private String orgCategory;
/**机构类型*/ /**
* 机构类型
*/
private String orgType; private String orgType;
/**机构编码*/ /**
* 机构编码
*/
private String orgCode; private String orgCode;
/**手机号*/ /**
* 手机号
*/
private String mobile; private String mobile;
/**传真*/ /**
* 传真
*/
private String fax; private String fax;
/**地址*/ /**
* 地址
*/
private String address; private String address;
/**备注*/ /**
* 备注
*/
private String memo; private String memo;
public String getId() { public String getId() {

View File

@@ -7,19 +7,33 @@ package org.jeecg.common.system.vo;
* @date: 2022年08月11日 9:48 * @date: 2022年08月11日 9:48
*/ */
public class SysFilesModel { public class SysFilesModel {
/**主键id*/ /**
* 主键id
*/
private String id; private String id;
/**文件名称*/ /**
* 文件名称
*/
private String fileName; private String fileName;
/**文件地址*/ /**
* 文件地址
*/
private String url; private String url;
/**文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频)*/ /**
* 文档类型folder:文件夹 excel:excel doc:word pp:ppt image:图片 archive:其他文档 video:视频)
*/
private String fileType; private String fileType;
/**文件上传类型(temp/本地上传(临时文件) manage/知识库)*/ /**
* 文件上传类型(temp/本地上传(临时文件) manage/知识库)
*/
private String storeType; private String storeType;
/**文件大小kb*/ /**
* 文件大小kb
*/
private Double fileSize; private Double fileSize;
/**租户id*/ /**
* 租户id
*/
private String tenantId; private String tenantId;
public String getId() { public String getId() {

View File

@@ -1,12 +1,5 @@
package org.jeecg.common.system.vo; package org.jeecg.common.system.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**

View File

@@ -1,106 +1,106 @@
package org.jeecg.common.system.vo; package org.jeecg.common.system.vo;
import java.util.List;
import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.DateUtils;
import java.util.List;
/** /**
* @Description: 用户缓存信息 * @Description: 用户缓存信息
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class SysUserCacheInfo { public class SysUserCacheInfo {
private String sysUserId; private String sysUserId;
private String sysUserCode; private String sysUserCode;
private String sysUserName; private String sysUserName;
private String sysOrgCode; private String sysOrgCode;
/** /**
* 当前用户部门ID * 当前用户部门ID
*/ */
private String sysOrgId; private String sysOrgId;
private List<String> sysMultiOrgCode; private List<String> sysMultiOrgCode;
private boolean oneDepart; private boolean oneDepart;
/** /**
* 当前用户角色code多个逗号分割 * 当前用户角色code多个逗号分割
*/ */
private String sysRoleCode; private String sysRoleCode;
public boolean isOneDepart() { public boolean isOneDepart() {
return oneDepart; return oneDepart;
} }
public void setOneDepart(boolean oneDepart) { public void setOneDepart(boolean oneDepart) {
this.oneDepart = oneDepart; this.oneDepart = oneDepart;
} }
public String getSysDate() { public String getSysDate() {
return DateUtils.formatDate(); return DateUtils.formatDate();
} }
public String getSysTime() { public String getSysTime() {
return DateUtils.now(); return DateUtils.now();
} }
public String getSysUserCode() { public String getSysUserCode() {
return sysUserCode; return sysUserCode;
} }
public void setSysUserCode(String sysUserCode) { public void setSysUserCode(String sysUserCode) {
this.sysUserCode = sysUserCode; this.sysUserCode = sysUserCode;
} }
public String getSysUserName() { public String getSysUserName() {
return sysUserName; return sysUserName;
} }
public void setSysUserName(String sysUserName) { public void setSysUserName(String sysUserName) {
this.sysUserName = sysUserName; this.sysUserName = sysUserName;
} }
public String getSysOrgCode() { public String getSysOrgCode() {
return sysOrgCode; return sysOrgCode;
} }
public void setSysOrgCode(String sysOrgCode) { public void setSysOrgCode(String sysOrgCode) {
this.sysOrgCode = sysOrgCode; this.sysOrgCode = sysOrgCode;
} }
public List<String> getSysMultiOrgCode() { public List<String> getSysMultiOrgCode() {
return sysMultiOrgCode; return sysMultiOrgCode;
} }
public void setSysMultiOrgCode(List<String> sysMultiOrgCode) { public void setSysMultiOrgCode(List<String> sysMultiOrgCode) {
this.sysMultiOrgCode = sysMultiOrgCode; this.sysMultiOrgCode = sysMultiOrgCode;
} }
public String getSysUserId() { public String getSysUserId() {
return sysUserId; return sysUserId;
} }
public void setSysUserId(String sysUserId) { public void setSysUserId(String sysUserId) {
this.sysUserId = sysUserId; this.sysUserId = sysUserId;
} }
public String getSysOrgId() { public String getSysOrgId() {
return sysOrgId; return sysOrgId;
} }
public void setSysOrgId(String sysOrgId) { public void setSysOrgId(String sysOrgId) {
this.sysOrgId = sysOrgId; this.sysOrgId = sysOrgId;
} }
public String getSysRoleCode() { public String getSysRoleCode() {
return sysRoleCode; return sysRoleCode;
} }
public void setSysRoleCode(String sysRoleCode) { public void setSysRoleCode(String sysRoleCode) {
this.sysRoleCode = sysRoleCode; this.sysRoleCode = sysRoleCode;
} }
} }

View File

@@ -1,13 +1,9 @@
package org.jeecg.common.system.vo; package org.jeecg.common.system.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.jeecg.common.desensitization.annotation.SensitiveField; import org.jeecg.common.desensitization.annotation.SensitiveField;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/** /**
* <p> * <p>

View File

@@ -1,13 +1,11 @@
package org.jeecg.common.util; package org.jeecg.common.util;
/** /**
* * @Author 张代浩
* @Author 张代浩
*
*/ */
public enum BrowserType { public enum BrowserType {
/** /**
* 浏览类型 IE11,IE10,IE9,IE8,IE7,IE6,Firefox,Safari,Chrome,Opera,Camino,Gecko * 浏览类型 IE11,IE10,IE9,IE8,IE7,IE6,Firefox,Safari,Chrome,Opera,Camino,Gecko
*/ */
IE11,IE10,IE9,IE8,IE7,IE6,Firefox,Safari,Chrome,Opera,Camino,Gecko IE11, IE10, IE9, IE8, IE7, IE6, Firefox, Safari, Chrome, Opera, Camino, Gecko
} }

View File

@@ -1,207 +1,208 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import jakarta.servlet.http.HttpServletRequest;
/** /**
*
* @Author 张代浩 * @Author 张代浩
*
*/ */
public class BrowserUtils { public class BrowserUtils {
/** /**
* 判断是否是IE * 判断是否是IE
*
* @param request * @param request
* @return * @return
*/ */
public static boolean isIe(HttpServletRequest request) { public static boolean isIe(HttpServletRequest request) {
return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request
.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0) ? true .getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0) ? true
: false; : false;
} }
/** /**
* 获取IE版本 * 获取IE版本
* *
* @param request * @param request
* @return * @return
*/ */
public static Double getIeVersion(HttpServletRequest request) { public static Double getIeVersion(HttpServletRequest request) {
Double version = 0.0; Double version = 0.0;
if (getBrowserType(request, IE11)) { if (getBrowserType(request, IE11)) {
version = 11.0; version = 11.0;
} else if (getBrowserType(request, IE10)) { } else if (getBrowserType(request, IE10)) {
version = 10.0; version = 10.0;
} else if (getBrowserType(request, IE9)) { } else if (getBrowserType(request, IE9)) {
version = 9.0; version = 9.0;
} else if (getBrowserType(request, IE8)) { } else if (getBrowserType(request, IE8)) {
version = 8.0; version = 8.0;
} else if (getBrowserType(request, IE7)) { } else if (getBrowserType(request, IE7)) {
version = 7.0; version = 7.0;
} else if (getBrowserType(request, IE6)) { } else if (getBrowserType(request, IE6)) {
version = 6.0; version = 6.0;
} }
return version; return version;
} }
/** /**
* 获取浏览器类型 * 获取浏览器类型
* *
* @param request * @param request
* @return * @return
*/ */
public static BrowserType getBrowserType(HttpServletRequest request) { public static BrowserType getBrowserType(HttpServletRequest request) {
BrowserType browserType = null; BrowserType browserType = null;
if (getBrowserType(request, IE11)) { if (getBrowserType(request, IE11)) {
browserType = BrowserType.IE11; browserType = BrowserType.IE11;
} }
if (getBrowserType(request, IE10)) { if (getBrowserType(request, IE10)) {
browserType = BrowserType.IE10; browserType = BrowserType.IE10;
} }
if (getBrowserType(request, IE9)) { if (getBrowserType(request, IE9)) {
browserType = BrowserType.IE9; browserType = BrowserType.IE9;
} }
if (getBrowserType(request, IE8)) { if (getBrowserType(request, IE8)) {
browserType = BrowserType.IE8; browserType = BrowserType.IE8;
} }
if (getBrowserType(request, IE7)) { if (getBrowserType(request, IE7)) {
browserType = BrowserType.IE7; browserType = BrowserType.IE7;
} }
if (getBrowserType(request, IE6)) { if (getBrowserType(request, IE6)) {
browserType = BrowserType.IE6; browserType = BrowserType.IE6;
} }
if (getBrowserType(request, FIREFOX)) { if (getBrowserType(request, FIREFOX)) {
browserType = BrowserType.Firefox; browserType = BrowserType.Firefox;
} }
if (getBrowserType(request, SAFARI)) { if (getBrowserType(request, SAFARI)) {
browserType = BrowserType.Safari; browserType = BrowserType.Safari;
} }
if (getBrowserType(request, CHROME)) { if (getBrowserType(request, CHROME)) {
browserType = BrowserType.Chrome; browserType = BrowserType.Chrome;
} }
if (getBrowserType(request, OPERA)) { if (getBrowserType(request, OPERA)) {
browserType = BrowserType.Opera; browserType = BrowserType.Opera;
} }
if (getBrowserType(request, CAMINO)) { if (getBrowserType(request, CAMINO)) {
browserType = BrowserType.Camino; browserType = BrowserType.Camino;
} }
return browserType; return browserType;
} }
private static boolean getBrowserType(HttpServletRequest request, private static boolean getBrowserType(HttpServletRequest request,
String brosertype) { String brosertype) {
return request.getHeader("USER-AGENT").toLowerCase() return request.getHeader("USER-AGENT").toLowerCase()
.indexOf(brosertype) > 0 ? true : false; .indexOf(brosertype) > 0 ? true : false;
} }
private final static String IE11 = "rv:11.0"; private final static String IE11 = "rv:11.0";
private final static String IE10 = "MSIE 10.0"; private final static String IE10 = "MSIE 10.0";
private final static String IE9 = "MSIE 9.0"; private final static String IE9 = "MSIE 9.0";
private final static String IE8 = "MSIE 8.0"; private final static String IE8 = "MSIE 8.0";
private final static String IE7 = "MSIE 7.0"; private final static String IE7 = "MSIE 7.0";
private final static String IE6 = "MSIE 6.0"; private final static String IE6 = "MSIE 6.0";
private final static String MAXTHON = "Maxthon"; private final static String MAXTHON = "Maxthon";
private final static String QQ = "QQBrowser"; private final static String QQ = "QQBrowser";
private final static String GREEN = "GreenBrowser"; private final static String GREEN = "GreenBrowser";
private final static String SE360 = "360SE"; private final static String SE360 = "360SE";
private final static String FIREFOX = "Firefox"; private final static String FIREFOX = "Firefox";
private final static String OPERA = "Opera"; private final static String OPERA = "Opera";
private final static String CHROME = "Chrome"; private final static String CHROME = "Chrome";
private final static String SAFARI = "Safari"; private final static String SAFARI = "Safari";
private final static String OTHER = "其它"; private final static String OTHER = "其它";
private final static String CAMINO = "Camino"; private final static String CAMINO = "Camino";
public static String checkBrowse(HttpServletRequest request) { public static String checkBrowse(HttpServletRequest request) {
String userAgent = request.getHeader("USER-AGENT"); String userAgent = request.getHeader("USER-AGENT");
if (regex(OPERA, userAgent)) { if (regex(OPERA, userAgent)) {
return OPERA; return OPERA;
} }
if (regex(CHROME, userAgent)) { if (regex(CHROME, userAgent)) {
return CHROME; return CHROME;
} }
if (regex(FIREFOX, userAgent)) { if (regex(FIREFOX, userAgent)) {
return FIREFOX; return FIREFOX;
} }
if (regex(SAFARI, userAgent)) { if (regex(SAFARI, userAgent)) {
return SAFARI; return SAFARI;
} }
if (regex(SE360, userAgent)) { if (regex(SE360, userAgent)) {
return SE360; return SE360;
} }
if (regex(GREEN, userAgent)) { if (regex(GREEN, userAgent)) {
return GREEN; return GREEN;
} }
if (regex(QQ, userAgent)) { if (regex(QQ, userAgent)) {
return QQ; return QQ;
} }
if (regex(MAXTHON, userAgent)) { if (regex(MAXTHON, userAgent)) {
return MAXTHON; return MAXTHON;
} }
if (regex(IE11, userAgent)) { if (regex(IE11, userAgent)) {
return IE11; return IE11;
} }
if (regex(IE10, userAgent)) { if (regex(IE10, userAgent)) {
return IE10; return IE10;
} }
if (regex(IE9, userAgent)) { if (regex(IE9, userAgent)) {
return IE9; return IE9;
} }
if (regex(IE8, userAgent)) { if (regex(IE8, userAgent)) {
return IE8; return IE8;
} }
if (regex(IE7, userAgent)) { if (regex(IE7, userAgent)) {
return IE7; return IE7;
} }
if (regex(IE6, userAgent)) { if (regex(IE6, userAgent)) {
return IE6; return IE6;
} }
return OTHER; return OTHER;
} }
public static boolean regex(String regex, String str) { public static boolean regex(String regex, String str) {
Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
Matcher m = p.matcher(str); Matcher m = p.matcher(str);
return m.find(); return m.find();
} }
private static Map<String, String> langMap = new HashMap<String, String>(); private static Map<String, String> langMap = new HashMap<String, String>();
private final static String ZH = "zh"; private final static String ZH = "zh";
private final static String ZH_CN = "zh-cn"; private final static String ZH_CN = "zh-cn";
private final static String EN = "en"; private final static String EN = "en";
private final static String EN_US = "en"; private final static String EN_US = "en";
static static {
{ langMap.put(ZH, ZH_CN);
langMap.put(ZH, ZH_CN); langMap.put(EN, EN_US);
langMap.put(EN, EN_US); }
}
public static String getBrowserLanguage(HttpServletRequest request) { public static String getBrowserLanguage(HttpServletRequest request) {
String browserLang = request.getLocale().getLanguage(); String browserLang = request.getLocale().getLanguage();
String browserLangCode = (String)langMap.get(browserLang); String browserLangCode = (String) langMap.get(browserLang);
if(browserLangCode == null) if (browserLangCode == null) {
{ browserLangCode = EN_US;
browserLangCode = EN_US; }
} return browserLangCode;
return browserLangCode; }
}
/** 判断请求是否来自电脑端 */ /**
* 判断请求是否来自电脑端
*/
public static boolean isDesktop(HttpServletRequest request) { public static boolean isDesktop(HttpServletRequest request) {
return !isMobile(request); return !isMobile(request);
} }
/** 判断请求是否来自移动端 */ /**
* 判断请求是否来自移动端
*/
public static boolean isMobile(HttpServletRequest request) { public static boolean isMobile(HttpServletRequest request) {
String ua = request.getHeader("User-Agent").toLowerCase(); String ua = request.getHeader("User-Agent").toLowerCase();
String type = "(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)"; String type = "(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)";

View File

@@ -5,6 +5,7 @@ import com.baomidou.dynamic.datasource.creator.DataSourceProperty;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;
import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.toolkit.JdbcUtils; import com.baomidou.mybatisplus.extension.toolkit.JdbcUtils;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
@@ -19,7 +20,6 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import jakarta.servlet.http.HttpServletRequest;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
@@ -52,13 +52,13 @@ public class CommonUtils {
*/ */
private static String FILE_NAME_REGEX = "[^A-Za-z\\.\\(\\)\\-\\_0-9\\u4e00-\\u9fa5]"; private static String FILE_NAME_REGEX = "[^A-Za-z\\.\\(\\)\\-\\_0-9\\u4e00-\\u9fa5]";
public static String uploadOnlineImage(byte[] data,String basePath,String bizPath,String uploadType){ public static String uploadOnlineImage(byte[] data, String basePath, String bizPath, String uploadType) {
String dbPath = null; String dbPath = null;
String fileName = "image" + Math.round(Math.random() * 100000000000L); String fileName = "image" + Math.round(Math.random() * 100000000000L);
fileName += "." + PoiPublicUtil.getFileExtendName(data); fileName += "." + PoiPublicUtil.getFileExtendName(data);
try { try {
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ if (CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) {
File file = new File(basePath + File.separator + bizPath + File.separator ); File file = new File(basePath + File.separator + bizPath + File.separator);
if (!file.exists()) { if (!file.exists()) {
file.mkdirs();// 创建文件根目录 file.mkdirs();// 创建文件根目录
} }
@@ -66,13 +66,13 @@ public class CommonUtils {
File savefile = new File(savePath); File savefile = new File(savePath);
FileCopyUtils.copy(data, savefile); FileCopyUtils.copy(data, savefile);
dbPath = bizPath + File.separator + fileName; dbPath = bizPath + File.separator + fileName;
}else { } else {
InputStream in = new ByteArrayInputStream(data); InputStream in = new ByteArrayInputStream(data);
String relativePath = bizPath+"/"+fileName; String relativePath = bizPath + "/" + fileName;
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)) {
dbPath = MinioUtil.upload(in,relativePath); dbPath = MinioUtil.upload(in, relativePath);
}else if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){ } else if (CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)) {
dbPath = OssBootUtil.upload(in,relativePath); dbPath = OssBootUtil.upload(in, relativePath);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@@ -83,10 +83,11 @@ public class CommonUtils {
/** /**
* 判断文件名是否带盘符,重新处理 * 判断文件名是否带盘符,重新处理
*
* @param fileName * @param fileName
* @return * @return
*/ */
public static String getFileName(String fileName){ public static String getFileName(String fileName) {
//判断是否带有盘符信息 //判断是否带有盘符信息
// Check for Unix-style path // Check for Unix-style path
int unixSep = fileName.lastIndexOf('/'); int unixSep = fileName.lastIndexOf('/');
@@ -94,15 +95,15 @@ public class CommonUtils {
int winSep = fileName.lastIndexOf('\\'); int winSep = fileName.lastIndexOf('\\');
// Cut off at latest possible point // Cut off at latest possible point
int pos = (winSep > unixSep ? winSep : unixSep); int pos = (winSep > unixSep ? winSep : unixSep);
if (pos != -1) { if (pos != -1) {
// Any sort of path separator found... // Any sort of path separator found...
fileName = fileName.substring(pos + 1); fileName = fileName.substring(pos + 1);
} }
//替换上传文件名字的特殊字符 //替换上传文件名字的特殊字符
fileName = fileName.replace("=","").replace(",","").replace("&","") fileName = fileName.replace("=", "").replace(",", "").replace("&", "")
.replace("#", "").replace("", "").replace("", ""); .replace("#", "").replace("", "").replace("", "");
//替换上传文件名字中的空格 //替换上传文件名字中的空格
fileName=fileName.replaceAll("\\s",""); fileName = fileName.replaceAll("\\s", "");
//update-beign-author:taoyan date:20220302 for: /issues/3381 online 在线表单 使用文件组件时,上传文件名中含%,下载异常 //update-beign-author:taoyan date:20220302 for: /issues/3381 online 在线表单 使用文件组件时,上传文件名中含%,下载异常
fileName = fileName.replaceAll(FILE_NAME_REGEX, ""); fileName = fileName.replaceAll(FILE_NAME_REGEX, "");
//update-end-author:taoyan date:20220302 for: /issues/3381 online 在线表单 使用文件组件时,上传文件名中含%,下载异常 //update-end-author:taoyan date:20220302 for: /issues/3381 online 在线表单 使用文件组件时,上传文件名中含%,下载异常
@@ -111,13 +112,14 @@ public class CommonUtils {
/** /**
* java 判断字符串里是否包含中文字符 * java 判断字符串里是否包含中文字符
*
* @param str * @param str
* @return * @return
*/ */
public static boolean ifContainChinese(String str) { public static boolean ifContainChinese(String str) {
if(str.getBytes().length == str.length()){ if (str.getBytes().length == str.length()) {
return false; return false;
}else{ } else {
Matcher m = ZHONGWEN_PATTERN.matcher(str); Matcher m = ZHONGWEN_PATTERN.matcher(str);
if (m.find()) { if (m.find()) {
return true; return true;
@@ -128,6 +130,7 @@ public class CommonUtils {
/** /**
* 统一全局上传 * 统一全局上传
*
* @Return: java.lang.String * @Return: java.lang.String
*/ */
public static String upload(MultipartFile file, String bizPath, String uploadType) { public static String upload(MultipartFile file, String bizPath, String uploadType) {
@@ -144,19 +147,21 @@ public class CommonUtils {
} }
return url; return url;
} }
/** /**
* 本地文件上传 * 本地文件上传
* @param mf 文件 *
* @param bizPath 自定义路径 * @param mf 文件
* @param bizPath 自定义路径
* @return * @return
*/ */
public static String uploadLocal(MultipartFile mf,String bizPath,String uploadpath){ public static String uploadLocal(MultipartFile mf, String bizPath, String uploadpath) {
try { try {
//update-begin-author:liusq date:20210809 for: 过滤上传文件类型 //update-begin-author:liusq date:20210809 for: 过滤上传文件类型
SsrfFileTypeFilter.checkUploadFileType(mf); SsrfFileTypeFilter.checkUploadFileType(mf);
//update-end-author:liusq date:20210809 for: 过滤上传文件类型 //update-end-author:liusq date:20210809 for: 过滤上传文件类型
String fileName = null; String fileName = null;
File file = new File(uploadpath + File.separator + bizPath + File.separator ); File file = new File(uploadpath + File.separator + bizPath + File.separator);
if (!file.exists()) { if (!file.exists()) {
// 创建文件根目录 // 创建文件根目录
file.mkdirs(); file.mkdirs();
@@ -164,18 +169,18 @@ public class CommonUtils {
// 获取文件名 // 获取文件名
String orgName = mf.getOriginalFilename(); String orgName = mf.getOriginalFilename();
orgName = CommonUtils.getFileName(orgName); orgName = CommonUtils.getFileName(orgName);
if(orgName.indexOf(SymbolConstant.SPOT)!=-1){ if (orgName.indexOf(SymbolConstant.SPOT) != -1) {
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
}else{ } else {
fileName = orgName+ "_" + System.currentTimeMillis(); fileName = orgName + "_" + System.currentTimeMillis();
} }
String savePath = file.getPath() + File.separator + fileName; String savePath = file.getPath() + File.separator + fileName;
File savefile = new File(savePath); File savefile = new File(savePath);
FileCopyUtils.copy(mf.getBytes(), savefile); FileCopyUtils.copy(mf.getBytes(), savefile);
String dbpath = null; String dbpath = null;
if(oConvertUtils.isNotEmpty(bizPath)){ if (oConvertUtils.isNotEmpty(bizPath)) {
dbpath = bizPath + File.separator + fileName; dbpath = bizPath + File.separator + fileName;
}else{ } else {
dbpath = fileName; dbpath = fileName;
} }
if (dbpath.contains(SymbolConstant.DOUBLE_BACKSLASH)) { if (dbpath.contains(SymbolConstant.DOUBLE_BACKSLASH)) {
@@ -184,7 +189,7 @@ public class CommonUtils {
return dbpath; return dbpath;
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
}catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
return ""; return "";
@@ -192,6 +197,7 @@ public class CommonUtils {
/** /**
* 统一全局上传 带桶 * 统一全局上传 带桶
*
* @Return: java.lang.String * @Return: java.lang.String
*/ */
public static String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) { public static String upload(MultipartFile file, String bizPath, String uploadType, String customBucket) {
@@ -203,22 +209,25 @@ public class CommonUtils {
url = OssBootUtil.upload(file, bizPath, customBucket); url = OssBootUtil.upload(file, bizPath, customBucket);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e); log.error(e.getMessage(), e);
} }
return url; return url;
} }
/** 当前系统数据库类型 */ /**
* 当前系统数据库类型
*/
private static String DB_TYPE = ""; private static String DB_TYPE = "";
private static DbType dbTypeEnum = null; private static DbType dbTypeEnum = null;
/** /**
* 全局获取平台数据库类型(作废了) * 全局获取平台数据库类型(作废了)
*
* @return * @return
*/ */
@Deprecated @Deprecated
public static String getDatabaseType() { public static String getDatabaseType() {
if(oConvertUtils.isNotEmpty(DB_TYPE)){ if (oConvertUtils.isNotEmpty(DB_TYPE)) {
return DB_TYPE; return DB_TYPE;
} }
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class); DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
@@ -226,13 +235,14 @@ public class CommonUtils {
return getDatabaseTypeByDataSource(dataSource); return getDatabaseTypeByDataSource(dataSource);
} catch (SQLException e) { } catch (SQLException e) {
//e.printStackTrace(); //e.printStackTrace();
log.warn(e.getMessage(),e); log.warn(e.getMessage(), e);
return ""; return "";
} }
} }
/** /**
* 全局获取平台数据库类型对应mybaisPlus枚举 * 全局获取平台数据库类型对应mybaisPlus枚举
*
* @return * @return
*/ */
public static DbType getDatabaseTypeEnum() { public static DbType getDatabaseTypeEnum() {
@@ -251,18 +261,20 @@ public class CommonUtils {
/** /**
* 根据数据源key获取DataSourceProperty * 根据数据源key获取DataSourceProperty
*
* @param sourceKey * @param sourceKey
* @return * @return
*/ */
public static DataSourceProperty getDataSourceProperty(String sourceKey){ public static DataSourceProperty getDataSourceProperty(String sourceKey) {
DynamicDataSourceProperties prop = SpringContextUtils.getApplicationContext().getBean(DynamicDataSourceProperties.class); DynamicDataSourceProperties prop = SpringContextUtils.getApplicationContext().getBean(DynamicDataSourceProperties.class);
Map<String, DataSourceProperty> map = prop.getDatasource(); Map<String, DataSourceProperty> map = prop.getDatasource();
DataSourceProperty db = (DataSourceProperty)map.get(sourceKey); DataSourceProperty db = (DataSourceProperty) map.get(sourceKey);
return db; return db;
} }
/** /**
* 根据sourceKey 获取数据源连接 * 根据sourceKey 获取数据源连接
*
* @param sourceKey * @param sourceKey
* @return * @return
* @throws SQLException * @throws SQLException
@@ -273,11 +285,11 @@ public class CommonUtils {
} }
DynamicDataSourceProperties prop = SpringContextUtils.getApplicationContext().getBean(DynamicDataSourceProperties.class); DynamicDataSourceProperties prop = SpringContextUtils.getApplicationContext().getBean(DynamicDataSourceProperties.class);
Map<String, DataSourceProperty> map = prop.getDatasource(); Map<String, DataSourceProperty> map = prop.getDatasource();
DataSourceProperty db = (DataSourceProperty)map.get(sourceKey); DataSourceProperty db = (DataSourceProperty) map.get(sourceKey);
if(db==null){ if (db == null) {
return null; return null;
} }
DriverManagerDataSource ds = new DriverManagerDataSource (); DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName(db.getDriverClassName()); ds.setDriverClassName(db.getDriverClassName());
ds.setUrl(db.getUrl()); ds.setUrl(db.getUrl());
ds.setUsername(db.getUsername()); ds.setUsername(db.getUsername());
@@ -287,40 +299,42 @@ public class CommonUtils {
/** /**
* 获取数据库类型 * 获取数据库类型
*
* @param dataSource * @param dataSource
* @return * @return
* @throws SQLException * @throws SQLException
*/ */
private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{ private static String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException {
if("".equals(DB_TYPE)) { if ("".equals(DB_TYPE)) {
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
try { try {
DatabaseMetaData md = connection.getMetaData(); DatabaseMetaData md = connection.getMetaData();
String dbType = md.getDatabaseProductName().toUpperCase(); String dbType = md.getDatabaseProductName().toUpperCase();
String sqlserver= "SQL SERVER"; String sqlserver = "SQL SERVER";
if(dbType.indexOf(DataBaseConstant.DB_TYPE_MYSQL)>=0) { if (dbType.indexOf(DataBaseConstant.DB_TYPE_MYSQL) >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL; DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
}else if(dbType.indexOf(DataBaseConstant.DB_TYPE_ORACLE)>=0 ||dbType.indexOf(DataBaseConstant.DB_TYPE_DM)>=0) { } else if (dbType.indexOf(DataBaseConstant.DB_TYPE_ORACLE) >= 0 || dbType.indexOf(DataBaseConstant.DB_TYPE_DM) >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE; DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
}else if(dbType.indexOf(DataBaseConstant.DB_TYPE_SQLSERVER)>=0||dbType.indexOf(sqlserver)>=0) { } else if (dbType.indexOf(DataBaseConstant.DB_TYPE_SQLSERVER) >= 0 || dbType.indexOf(sqlserver) >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER; DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
}else if(dbType.indexOf(DataBaseConstant.DB_TYPE_POSTGRESQL)>=0 || dbType.indexOf(DataBaseConstant.DB_TYPE_KINGBASEES)>=0) { } else if (dbType.indexOf(DataBaseConstant.DB_TYPE_POSTGRESQL) >= 0 || dbType.indexOf(DataBaseConstant.DB_TYPE_KINGBASEES) >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL; DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
}else if(dbType.indexOf(DataBaseConstant.DB_TYPE_MARIADB)>=0) { } else if (dbType.indexOf(DataBaseConstant.DB_TYPE_MARIADB) >= 0) {
DB_TYPE = DataBaseConstant.DB_TYPE_MARIADB; DB_TYPE = DataBaseConstant.DB_TYPE_MARIADB;
}else { } else {
log.error("数据库类型:[" + dbType + "]不识别!"); log.error("数据库类型:[" + dbType + "]不识别!");
//throw new JeecgBootException("数据库类型:["+dbType+"]不识别!"); //throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
}finally { } finally {
connection.close(); connection.close();
} }
} }
return DB_TYPE; return DB_TYPE;
} }
/** /**
* 获取服务器地址 * 获取服务器地址
* *
@@ -330,14 +344,14 @@ public class CommonUtils {
public static String getBaseUrl(HttpServletRequest request) { public static String getBaseUrl(HttpServletRequest request) {
//1.【兼容】兼容微服务下的 base path------- //1.【兼容】兼容微服务下的 base path-------
String xGatewayBasePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH); String xGatewayBasePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH);
if(oConvertUtils.isNotEmpty(xGatewayBasePath)){ if (oConvertUtils.isNotEmpty(xGatewayBasePath)) {
log.info("x_gateway_base_path = "+ xGatewayBasePath); log.info("x_gateway_base_path = " + xGatewayBasePath);
return xGatewayBasePath; return xGatewayBasePath;
} }
//2.【兼容】SSL认证之后request.getScheme()获取不到https的问题 //2.【兼容】SSL认证之后request.getScheme()获取不到https的问题
// https://blog.csdn.net/weixin_34376986/article/details/89767950 // https://blog.csdn.net/weixin_34376986/article/details/89767950
String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME); String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME);
if(oConvertUtils.isEmpty(scheme)){ if (oConvertUtils.isEmpty(scheme)) {
scheme = request.getScheme(); scheme = request.getScheme();
} }
@@ -351,11 +365,11 @@ public class CommonUtils {
//update-begin---author:wangshuai---date:2024-03-15---for:【QQYUN-8561】企业微信登陆请求接口设置上下文不一致导致接口404--- //update-begin---author:wangshuai---date:2024-03-15---for:【QQYUN-8561】企业微信登陆请求接口设置上下文不一致导致接口404---
int httpPort = 80; int httpPort = 80;
int httpsPort = 443; int httpsPort = 443;
if(httpPort == serverPort || httpsPort == serverPort){ if (httpPort == serverPort || httpsPort == serverPort) {
//update-end---author:wangshuai---date:2024-03-15---for:【QQYUN-8561】企业微信登陆请求接口设置上下文不一致导致接口404---~ //update-end---author:wangshuai---date:2024-03-15---for:【QQYUN-8561】企业微信登陆请求接口设置上下文不一致导致接口404---~
baseDomainPath = scheme + "://" + serverName + contextPath ; baseDomainPath = scheme + "://" + serverName + contextPath;
}else{ } else {
baseDomainPath = scheme + "://" + serverName + ":" + serverPort + contextPath ; baseDomainPath = scheme + "://" + serverName + ":" + serverPort + contextPath;
} }
log.debug("-----Common getBaseUrl----- : " + baseDomainPath); log.debug("-----Common getBaseUrl----- : " + baseDomainPath);
return baseDomainPath; return baseDomainPath;
@@ -402,6 +416,7 @@ public class CommonUtils {
/** /**
* 将list集合以分割符的方式进行分割 * 将list集合以分割符的方式进行分割
*
* @param list String类型的集合文本 * @param list String类型的集合文本
* @param separator 分隔符 * @param separator 分隔符
* @return * @return
@@ -420,7 +435,7 @@ public class CommonUtils {
* @return name = '1212' * @return name = '1212'
*/ */
public static String getFilterSqlByTableSql(String tableSql) { public static String getFilterSqlByTableSql(String tableSql) {
if(oConvertUtils.isEmpty(tableSql)){ if (oConvertUtils.isEmpty(tableSql)) {
return null; return null;
} }
@@ -440,7 +455,7 @@ public class CommonUtils {
* @return sys_user * @return sys_user
*/ */
public static String getTableNameByTableSql(String tableSql) { public static String getTableNameByTableSql(String tableSql) {
if(oConvertUtils.isEmpty(tableSql)){ if (oConvertUtils.isEmpty(tableSql)) {
return null; return null;
} }
@@ -454,6 +469,7 @@ public class CommonUtils {
/** /**
* 判断两个数组是否存在交集 * 判断两个数组是否存在交集
*
* @param set1 * @param set1
* @param arr2 * @param arr2
* @return * @return
@@ -463,7 +479,7 @@ public class CommonUtils {
return false; return false;
} }
if(set1.size()>0){ if (set1.size() > 0) {
for (String str : arr2) { for (String str : arr2) {
if (set1.contains(str)) { if (set1.contains(str)) {
return true; return true;

View File

@@ -79,6 +79,7 @@ public class DateUtils extends PropertyEditorSupport {
/** /**
* 指定模式的时间格式 * 指定模式的时间格式
*
* @param pattern * @param pattern
* @return * @return
*/ */
@@ -227,7 +228,7 @@ public class DateUtils extends PropertyEditorSupport {
/** /**
* 日期转换为字符串 * 日期转换为字符串
* *
* @param date 日期 * @param date 日期
* @param dateSdf 日期格式 * @param dateSdf 日期格式
* @return 字符串 * @return 字符串
*/ */
@@ -689,13 +690,14 @@ public class DateUtils extends PropertyEditorSupport {
/** /**
* 将字符串转成时间 * 将字符串转成时间
*
* @param str * @param str
* @return * @return
*/ */
public static Date parseDatetime(String str){ public static Date parseDatetime(String str) {
try { try {
return datetimeFormat.get().parse(str); return datetimeFormat.get().parse(str);
}catch (Exception e){ } catch (Exception e) {
} }
return null; return null;
} }

View File

@@ -20,23 +20,30 @@ import org.slf4j.LoggerFactory;
* 工程依赖了2个jar包(存放在工程的libs目录下) * 工程依赖了2个jar包(存放在工程的libs目录下)
* 1:aliyun-java-sdk-core.jar * 1:aliyun-java-sdk-core.jar
* 2:aliyun-java-sdk-dysmsapi.jar * 2:aliyun-java-sdk-dysmsapi.jar
* * <p>
* 备注:Demo工程编码采用UTF-8 * 备注:Demo工程编码采用UTF-8
* 国际短信发送请勿参照此DEMO * 国际短信发送请勿参照此DEMO
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class DySmsHelper { public class DySmsHelper {
private final static Logger logger=LoggerFactory.getLogger(DySmsHelper.class); private final static Logger logger = LoggerFactory.getLogger(DySmsHelper.class);
/**产品名称:云通信短信API产品,开发者无需替换*/ /**
* 产品名称:云通信短信API产品,开发者无需替换
*/
static final String PRODUCT = "Dysmsapi"; static final String PRODUCT = "Dysmsapi";
/**产品域名,开发者无需替换*/ /**
* 产品域名,开发者无需替换
*/
static final String DOMAIN = "dysmsapi.aliyuncs.com"; static final String DOMAIN = "dysmsapi.aliyuncs.com";
/**TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)*/ /**
static String accessKeyId; * TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
static String accessKeySecret; */
static String accessKeyId;
static String accessKeySecret;
public static void setAccessKeyId(String accessKeyId) { public static void setAccessKeyId(String accessKeyId) {
DySmsHelper.accessKeyId = accessKeyId; DySmsHelper.accessKeyId = accessKeyId;
@@ -56,7 +63,7 @@ public class DySmsHelper {
public static boolean sendSms(String phone, JSONObject templateParamJson, DySmsEnum dySmsEnum) throws ClientException { public static boolean sendSms(String phone, JSONObject templateParamJson, DySmsEnum dySmsEnum) throws ClientException {
//可自助调整超时时间 //可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000"); System.setProperty("sun.net.client.defaultReadTimeout", "10000");
@@ -74,7 +81,7 @@ public class DySmsHelper {
IAcsClient acsClient = new DefaultAcsClient(profile); IAcsClient acsClient = new DefaultAcsClient(profile);
//验证json参数 //验证json参数
validateParam(templateParamJson,dySmsEnum); validateParam(templateParamJson, dySmsEnum);
//组装请求对象-具体描述见控制台-文档部分内容 //组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest(); SendSmsRequest request = new SendSmsRequest();
@@ -98,7 +105,7 @@ public class DySmsHelper {
//hint 此处可能会抛出异常注意catch //hint 此处可能会抛出异常注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
logger.info("短信接口返回的数据----------------"); logger.info("短信接口返回的数据----------------");
logger.info("{Code:" + sendSmsResponse.getCode()+",Message:" + sendSmsResponse.getMessage()+",RequestId:"+ sendSmsResponse.getRequestId()+",BizId:"+sendSmsResponse.getBizId()+"}"); logger.info("{Code:" + sendSmsResponse.getCode() + ",Message:" + sendSmsResponse.getMessage() + ",RequestId:" + sendSmsResponse.getRequestId() + ",BizId:" + sendSmsResponse.getBizId() + "}");
String ok = "OK"; String ok = "OK";
if (ok.equals(sendSmsResponse.getCode())) { if (ok.equals(sendSmsResponse.getCode())) {
result = true; result = true;
@@ -107,14 +114,14 @@ public class DySmsHelper {
} }
private static void validateParam(JSONObject templateParamJson,DySmsEnum dySmsEnum) { private static void validateParam(JSONObject templateParamJson, DySmsEnum dySmsEnum) {
String keys = dySmsEnum.getKeys(); String keys = dySmsEnum.getKeys();
String [] keyArr = keys.split(","); String[] keyArr = keys.split(",");
for(String item :keyArr) { for (String item : keyArr) {
if(!templateParamJson.containsKey(item)) { if (!templateParamJson.containsKey(item)) {
throw new RuntimeException("模板缺少参数:"+item); throw new RuntimeException("模板缺少参数:" + item);
} }
} }
} }

View File

@@ -6,15 +6,15 @@ import java.util.concurrent.ConcurrentHashMap;
/** /**
* 防止刷短信接口只针对绑定手机号模板SMS_175430166 * 防止刷短信接口只针对绑定手机号模板SMS_175430166
* * <p>
* 1、同一IP1分钟内发短信不允许超过5次每一分钟重置每个IP请求次数 * 1、同一IP1分钟内发短信不允许超过5次每一分钟重置每个IP请求次数
* 2、同一IP1分钟内发短信超过20次进入黑名单不让使用短信接口 * 2、同一IP1分钟内发短信超过20次进入黑名单不让使用短信接口
* * <p>
* 3、短信接口加签和时间戳 * 3、短信接口加签和时间戳
* 涉及接口: * 涉及接口:
* /sys/sms * /sys/sms
* /desform/api/sendVerifyCode * /desform/api/sendVerifyCode
* /sys/sendChangePwdSms * /sys/sendChangePwdSms
*/ */
@Slf4j @Slf4j
public class DySmsLimit { public class DySmsLimit {

View File

@@ -6,6 +6,7 @@ import org.springframework.web.util.HtmlUtils;
/** /**
* HTML 工具类 * HTML 工具类
*
* @author: jeecg-boot * @author: jeecg-boot
* @date: 2022/3/30 14:43 * @date: 2022/3/30 14:43
*/ */
@@ -32,6 +33,7 @@ public class HTMLUtils {
/** /**
* 将Markdown解析成Html * 将Markdown解析成Html
*
* @param markdownContent * @param markdownContent
* @return * @return
*/ */

View File

@@ -12,12 +12,13 @@ import java.util.List;
/** /**
* 导出返回信息 * 导出返回信息
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
@Slf4j @Slf4j
public class ImportExcelUtil { public class ImportExcelUtil {
public static Result<?> imporReturnRes(int errorLines,int successLines,List<String> errorMessage) throws IOException { public static Result<?> imporReturnRes(int errorLines, int successLines, List<String> errorMessage) throws IOException {
if (errorLines == 0) { if (errorLines == 0) {
return Result.ok("" + successLines + "行数据全部导入成功!"); return Result.ok("" + successLines + "行数据全部导入成功!");
} else { } else {
@@ -39,12 +40,12 @@ public class ImportExcelUtil {
} }
} }
public static List<String> importDateSave(List<?> list, Class serviceClass, List<String> errorMessage, String errorFlag) { public static List<String> importDateSave(List<?> list, Class serviceClass, List<String> errorMessage, String errorFlag) {
IService bean =(IService) SpringContextUtils.getBean(serviceClass); IService bean = (IService) SpringContextUtils.getBean(serviceClass);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
try { try {
boolean save = bean.save(list.get(i)); boolean save = bean.save(list.get(i));
if(!save){ if (!save) {
throw new Exception(errorFlag); throw new Exception(errorFlag);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -55,11 +56,11 @@ public class ImportExcelUtil {
errorMessage.add("" + lineNumber + " 行:角色编码已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:角色编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) { } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
errorMessage.add("" + lineNumber + " 行:任务类名已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:任务类名已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) { } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
errorMessage.add("" + lineNumber + " 行:职务编码已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:职务编码已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) { } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
errorMessage.add("" + lineNumber + " 行:部门编码已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:部门编码已经存在,忽略导入。");
}else { } else {
errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入"); errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
@@ -68,11 +69,11 @@ public class ImportExcelUtil {
return errorMessage; return errorMessage;
} }
public static List<String> importDateSaveOne(Object obj, Class serviceClass,List<String> errorMessage,int i,String errorFlag) { public static List<String> importDateSaveOne(Object obj, Class serviceClass, List<String> errorMessage, int i, String errorFlag) {
IService bean =(IService) SpringContextUtils.getBean(serviceClass); IService bean = (IService) SpringContextUtils.getBean(serviceClass);
try { try {
boolean save = bean.save(obj); boolean save = bean.save(obj);
if(!save){ if (!save) {
throw new Exception(errorFlag); throw new Exception(errorFlag);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -83,11 +84,11 @@ public class ImportExcelUtil {
errorMessage.add("" + lineNumber + " 行:角色编码已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:角色编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) { } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
errorMessage.add("" + lineNumber + " 行:任务类名已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:任务类名已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) { } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
errorMessage.add("" + lineNumber + " 行:职务编码已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:职务编码已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) { } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
errorMessage.add("" + lineNumber + " 行:部门编码已经存在,忽略导入。"); errorMessage.add("" + lineNumber + " 行:部门编码已经存在,忽略导入。");
}else { } else {
errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入"); errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }

View File

@@ -1,7 +1,6 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -20,22 +19,22 @@ import java.util.regex.Pattern;
* @Date 2019年01月14日 * @Date 2019年01月14日
*/ */
public class IpUtils { public class IpUtils {
private static Logger logger = LoggerFactory.getLogger(IpUtils.class); private static Logger logger = LoggerFactory.getLogger(IpUtils.class);
/** /**
* 获取IP地址 * 获取IP地址
* * <p>
* 使用Nginx等反向代理软件 则不能通过request.getRemoteAddr()获取IP地址 * 使用Nginx等反向代理软件 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话X-Forwarded-For的值并不止一个而是一串IP地址X-Forwarded-For中第一个非unknown的有效IP字符串则为真实IP地址 * 如果使用了多级反向代理的话X-Forwarded-For的值并不止一个而是一串IP地址X-Forwarded-For中第一个非unknown的有效IP字符串则为真实IP地址
*/ */
public static String getIpAddr(HttpServletRequest request) { public static String getIpAddr(HttpServletRequest request) {
String ip = null; String ip = null;
try { try {
ip = request.getHeader("x-forwarded-for"); ip = request.getHeader("x-forwarded-for");
if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) { if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP"); ip = request.getHeader("Proxy-Client-IP");
} }
if (StringUtils.isEmpty(ip) || ip.length() == 0 ||CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) { if (StringUtils.isEmpty(ip) || ip.length() == 0 || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP"); ip = request.getHeader("WL-Proxy-Client-IP");
} }
if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) { if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
@@ -48,7 +47,7 @@ public class IpUtils {
ip = request.getRemoteAddr(); ip = request.getRemoteAddr();
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("IPUtils ERROR ", e); logger.error("IPUtils ERROR ", e);
} }
//logger.info("获取客户端 ip{} ", ip); //logger.info("获取客户端 ip{} ", ip);
@@ -72,6 +71,7 @@ public class IpUtils {
/** /**
* 判断是否是IP格式 * 判断是否是IP格式
*
* @param ipAddress * @param ipAddress
* @return * @return
*/ */
@@ -84,9 +84,10 @@ public class IpUtils {
/** /**
* 获取服务器上的ip * 获取服务器上的ip
*
* @return * @return
*/ */
public static String getServerIp(){ public static String getServerIp() {
InetAddress inetAddress = null; InetAddress inetAddress = null;
try { try {
inetAddress = InetAddress.getLocalHost(); inetAddress = InetAddress.getLocalHost();

View File

@@ -8,40 +8,40 @@ import java.security.MessageDigest;
*/ */
public class Md5Util { public class Md5Util {
private static final String[] HEXDIGITS = { "0", "1", "2", "3", "4", "5", private static final String[] HEXDIGITS = {"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
public static String byteArrayToHexString(byte[] b) { public static String byteArrayToHexString(byte[] b) {
StringBuffer resultSb = new StringBuffer(); StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++){ for (int i = 0; i < b.length; i++) {
resultSb.append(byteToHexString(b[i])); resultSb.append(byteToHexString(b[i]));
} }
return resultSb.toString(); return resultSb.toString();
} }
private static String byteToHexString(byte b) { private static String byteToHexString(byte b) {
int n = b; int n = b;
if (n < 0) { if (n < 0) {
n += 256; n += 256;
} }
int d1 = n / 16; int d1 = n / 16;
int d2 = n % 16; int d2 = n % 16;
return HEXDIGITS[d1] + HEXDIGITS[d2]; return HEXDIGITS[d1] + HEXDIGITS[d2];
} }
public static String md5Encode(String origin, String charsetname) { public static String md5Encode(String origin, String charsetname) {
String resultString = null; String resultString = null;
try { try {
resultString = new String(origin); resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5"); MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetname == null || "".equals(charsetname)) { if (charsetname == null || "".equals(charsetname)) {
resultString = byteArrayToHexString(md.digest(resultString.getBytes())); resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
} else { } else {
resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));
} }
} catch (Exception exception) { } catch (Exception exception) {
} }
return resultString; return resultString;
} }
} }

View File

@@ -3,103 +3,104 @@ package org.jeecg.common.util;
import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.SymbolConstant;
/** /**
* @Author 张代浩 * @Author 张代浩
*/ */
public class MyClassLoader extends ClassLoader { public class MyClassLoader extends ClassLoader {
public static Class getClassByScn(String className) { public static Class getClassByScn(String className) {
Class myclass = null; Class myclass = null;
try { try {
myclass = Class.forName(className); myclass = Class.forName(className);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(className+" not found!"); throw new RuntimeException(className + " not found!");
} }
return myclass; return myclass;
} }
/** /**
* 获得类的全名,包括包名 * 获得类的全名,包括包名
*
* @param object * @param object
* @return * @return
*/ */
public static String getPackPath(Object object) { public static String getPackPath(Object object) {
// 检查用户传入的参数是否为空 // 检查用户传入的参数是否为空
if (object == null) { if (object == null) {
throw new java.lang.IllegalArgumentException("参数不能为空!"); throw new java.lang.IllegalArgumentException("参数不能为空!");
} }
// 获得类的全名,包括包名 // 获得类的全名,包括包名
String clsName = object.getClass().getName(); String clsName = object.getClass().getName();
return clsName; return clsName;
} }
public static String getAppPath(Class cls) { public static String getAppPath(Class cls) {
// 检查用户传入的参数是否为空 // 检查用户传入的参数是否为空
if (cls == null) { if (cls == null) {
throw new java.lang.IllegalArgumentException("参数不能为空!"); throw new java.lang.IllegalArgumentException("参数不能为空!");
} }
ClassLoader loader = cls.getClassLoader(); ClassLoader loader = cls.getClassLoader();
// 获得类的全名,包括包名 // 获得类的全名,包括包名
String clsName = cls.getName() + ".class"; String clsName = cls.getName() + ".class";
// 获得传入参数所在的包 // 获得传入参数所在的包
Package pack = cls.getPackage(); Package pack = cls.getPackage();
String path = ""; String path = "";
// 如果不是匿名包,将包名转化为路径 // 如果不是匿名包,将包名转化为路径
if (pack != null) { if (pack != null) {
String packName = pack.getName(); String packName = pack.getName();
String javaSpot="java."; String javaSpot = "java.";
String javaxSpot="javax."; String javaxSpot = "javax.";
// 此处简单判定是否是Java基础类库防止用户传入JDK内置的类库 // 此处简单判定是否是Java基础类库防止用户传入JDK内置的类库
if (packName.startsWith(javaSpot) || packName.startsWith(javaxSpot)) { if (packName.startsWith(javaSpot) || packName.startsWith(javaxSpot)) {
throw new java.lang.IllegalArgumentException("不要传送系统类!"); throw new java.lang.IllegalArgumentException("不要传送系统类!");
} }
// 在类的名称中,去掉包名的部分,获得类的文件名 // 在类的名称中,去掉包名的部分,获得类的文件名
clsName = clsName.substring(packName.length() + 1); clsName = clsName.substring(packName.length() + 1);
// 判定包名是否是简单包名,如果是,则直接将包名转换为路径, // 判定包名是否是简单包名,如果是,则直接将包名转换为路径,
if (packName.indexOf(SymbolConstant.SPOT) < 0) { if (packName.indexOf(SymbolConstant.SPOT) < 0) {
path = packName + "/"; path = packName + "/";
} else { } else {
// 否则按照包名的组成部分,将包名转换为路径 // 否则按照包名的组成部分,将包名转换为路径
int start = 0, end = 0; int start = 0, end = 0;
end = packName.indexOf("."); end = packName.indexOf(".");
StringBuilder pathBuilder = new StringBuilder(); StringBuilder pathBuilder = new StringBuilder();
while (end != -1) { while (end != -1) {
pathBuilder.append(packName, start, end).append("/"); pathBuilder.append(packName, start, end).append("/");
start = end + 1; start = end + 1;
end = packName.indexOf(".", start); end = packName.indexOf(".", start);
} }
if(oConvertUtils.isNotEmpty(pathBuilder.toString())){ if (oConvertUtils.isNotEmpty(pathBuilder.toString())) {
path = pathBuilder.toString(); path = pathBuilder.toString();
} }
path = path + packName.substring(start) + "/"; path = path + packName.substring(start) + "/";
} }
} }
// 调用ClassLoader的getResource方法传入包含路径信息的类文件名 // 调用ClassLoader的getResource方法传入包含路径信息的类文件名
java.net.URL url = loader.getResource(path + clsName); java.net.URL url = loader.getResource(path + clsName);
// 从URL对象中获取路径信息 // 从URL对象中获取路径信息
String realPath = url.getPath(); String realPath = url.getPath();
// 去掉路径信息中的协议名"file:" // 去掉路径信息中的协议名"file:"
int pos = realPath.indexOf("file:"); int pos = realPath.indexOf("file:");
if (pos > -1) { if (pos > -1) {
realPath = realPath.substring(pos + 5); realPath = realPath.substring(pos + 5);
} }
// 去掉路径信息最后包含类文件信息的部分,得到类所在的路径 // 去掉路径信息最后包含类文件信息的部分,得到类所在的路径
pos = realPath.indexOf(path + clsName); pos = realPath.indexOf(path + clsName);
realPath = realPath.substring(0, pos - 1); realPath = realPath.substring(0, pos - 1);
// 如果类文件被打包到JAR等文件中时去掉对应的JAR等打包文件名 // 如果类文件被打包到JAR等文件中时去掉对应的JAR等打包文件名
if (realPath.endsWith(SymbolConstant.EXCLAMATORY_MARK)) { if (realPath.endsWith(SymbolConstant.EXCLAMATORY_MARK)) {
realPath = realPath.substring(0, realPath.lastIndexOf("/")); realPath = realPath.substring(0, realPath.lastIndexOf("/"));
} }
/*------------------------------------------------------------ /*------------------------------------------------------------
ClassLoader的getResource方法使用了utf-8对路径信息进行了编码当路径 ClassLoader的getResource方法使用了utf-8对路径信息进行了编码当路径
中存在中文和空格时,他会对这些字符进行转换,这样,得到的往往不是我们想要 中存在中文和空格时,他会对这些字符进行转换,这样,得到的往往不是我们想要
的真实路径在此调用了URLDecoder的decode方法进行解码以便得到原始的 的真实路径在此调用了URLDecoder的decode方法进行解码以便得到原始的
中文及空格路径 中文及空格路径
-------------------------------------------------------------*/ -------------------------------------------------------------*/
try { try {
realPath = java.net.URLDecoder.decode(realPath, "utf-8"); realPath = java.net.URLDecoder.decode(realPath, "utf-8");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return realPath; return realPath;
}// getAppPath定义结束 }// getAppPath定义结束
} }

View File

@@ -1,12 +1,12 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec; import javax.crypto.spec.PBEParameterSpec;
import java.security.Key;
import java.security.SecureRandom;
/** /**
* @Description: 密码工具类 * @Description: 密码工具类
@@ -14,178 +14,167 @@ import javax.crypto.spec.PBEParameterSpec;
*/ */
public class PasswordUtil { public class PasswordUtil {
/** /**
* JAVA6支持以下任意一种算法 PBEWITHMD5ANDDES PBEWITHMD5ANDTRIPLEDES * JAVA6支持以下任意一种算法 PBEWITHMD5ANDDES PBEWITHMD5ANDTRIPLEDES
* PBEWITHSHAANDDESEDE PBEWITHSHA1ANDRC2_40 PBKDF2WITHHMACSHA1 * PBEWITHSHAANDDESEDE PBEWITHSHA1ANDRC2_40 PBKDF2WITHHMACSHA1
* */ * */
/** /**
* 定义使用的算法为:PBEWITHMD5andDES算法 * 定义使用的算法为:PBEWITHMD5andDES算法
* 加密算法 * 加密算法
*/ */
public static final String ALGORITHM = "PBEWithMD5AndDES"; public static final String ALGORITHM = "PBEWithMD5AndDES";
/** /**
* 定义使用的算法为:PBEWITHMD5andDES算法 * 定义使用的算法为:PBEWITHMD5andDES算法
* 密钥 * 密钥
*/ */
public static final String SALT = "63293188"; public static final String SALT = "63293188";
/** /**
* 定义迭代次数为1000次 * 定义迭代次数为1000次
*/ */
private static final int ITERATIONCOUNT = 1000; private static final int ITERATIONCOUNT = 1000;
/** /**
* 获取加密算法中使用的盐值,解密中使用的盐值必须与加密中使用的相同才能完成操作. 盐长度必须为8字节 * 获取加密算法中使用的盐值,解密中使用的盐值必须与加密中使用的相同才能完成操作. 盐长度必须为8字节
* *
* @return byte[] 盐值 * @return byte[] 盐值
* */ */
public static byte[] getSalt() throws Exception { public static byte[] getSalt() throws Exception {
// 实例化安全随机数 // 实例化安全随机数
SecureRandom random = new SecureRandom(); SecureRandom random = new SecureRandom();
// 产出盐 // 产出盐
return random.generateSeed(8); return random.generateSeed(8);
} }
public static byte[] getStaticSalt() { public static byte[] getStaticSalt() {
// 产出盐 // 产出盐
return SALT.getBytes(); return SALT.getBytes();
} }
/** /**
* 根据PBE密码生成一把密钥 * 根据PBE密码生成一把密钥
* *
* @param password * @param password 生成密钥时所使用的密码
* 生成密钥时所使用的密码 * @return Key PBE算法密钥
* @return Key PBE算法密钥 */
* */ private static Key getPbeKey(String password) {
private static Key getPbeKey(String password) { // 实例化使用的算法
// 实例化使用的算法 SecretKeyFactory keyFactory;
SecretKeyFactory keyFactory; SecretKey secretKey = null;
SecretKey secretKey = null; try {
try { keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
keyFactory = SecretKeyFactory.getInstance(ALGORITHM); // 设置PBE密钥参数
// 设置PBE密钥参数 PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray()); // 生成密钥
// 生成密钥 secretKey = keyFactory.generateSecret(keySpec);
secretKey = keyFactory.generateSecret(keySpec); } catch (Exception e) {
} catch (Exception e) { // TODO Auto-generated catch block
// TODO Auto-generated catch block e.printStackTrace();
e.printStackTrace(); }
}
return secretKey; return secretKey;
} }
/** /**
* 加密明文字符串 * 加密明文字符串
* *
* @param plaintext * @param plaintext 待加密的明文字符串
* 待加密的明文字符串 * @param password 生成密钥时所使用的密码
* @param password * @param salt 盐值
* 生成密钥时所使用的密码 * @return 加密后的密文字符串
* @param salt * @throws Exception
* 盐值 */
* @return 加密后的密文字符串 public static String encrypt(String plaintext, String password, String salt) {
* @throws Exception
*/
public static String encrypt(String plaintext, String password, String salt) {
Key key = getPbeKey(password); Key key = getPbeKey(password);
byte[] encipheredData = null; byte[] encipheredData = null;
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt.getBytes(), ITERATIONCOUNT); PBEParameterSpec parameterSpec = new PBEParameterSpec(salt.getBytes(), ITERATIONCOUNT);
try { try {
Cipher cipher = Cipher.getInstance(ALGORITHM); Cipher cipher = Cipher.getInstance(ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, key, parameterSpec); cipher.init(Cipher.ENCRYPT_MODE, key, parameterSpec);
//update-begin-author:sccott date:20180815 for:中文作为用户名时加密的密码windows和linux会得到不同的结果 gitee/issues/IZUD7 //update-begin-author:sccott date:20180815 for:中文作为用户名时加密的密码windows和linux会得到不同的结果 gitee/issues/IZUD7
encipheredData = cipher.doFinal(plaintext.getBytes("utf-8")); encipheredData = cipher.doFinal(plaintext.getBytes("utf-8"));
//update-end-author:sccott date:20180815 for:中文作为用户名时加密的密码windows和linux会得到不同的结果 gitee/issues/IZUD7 //update-end-author:sccott date:20180815 for:中文作为用户名时加密的密码windows和linux会得到不同的结果 gitee/issues/IZUD7
} catch (Exception e) { } catch (Exception e) {
} }
return bytesToHexString(encipheredData); return bytesToHexString(encipheredData);
} }
/** /**
* 解密密文字符串 * 解密密文字符串
* *
* @param ciphertext * @param ciphertext 待解密的密文字符串
* 待解密的密文字符串 * @param password 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
* @param password * @param salt 盐值(如需解密,该参数需要与加密时使用的一致)
* 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致) * @return 解密后的明文字符串
* @param salt * @throws Exception
* 盐值(如需解密,该参数需要与加密时使用的一致) */
* @return 解密后的明文字符串 public static String decrypt(String ciphertext, String password, String salt) {
* @throws Exception
*/
public static String decrypt(String ciphertext, String password, String salt) {
Key key = getPbeKey(password); Key key = getPbeKey(password);
byte[] passDec = null; byte[] passDec = null;
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt.getBytes(), ITERATIONCOUNT); PBEParameterSpec parameterSpec = new PBEParameterSpec(salt.getBytes(), ITERATIONCOUNT);
try { try {
Cipher cipher = Cipher.getInstance(ALGORITHM); Cipher cipher = Cipher.getInstance(ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, key, parameterSpec); cipher.init(Cipher.DECRYPT_MODE, key, parameterSpec);
passDec = cipher.doFinal(hexStringToBytes(ciphertext)); passDec = cipher.doFinal(hexStringToBytes(ciphertext));
} } catch (Exception e) {
// TODO: handle exception
}
return new String(passDec);
}
catch (Exception e) { /**
// TODO: handle exception * 将字节数组转换为十六进制字符串
} *
return new String(passDec); * @param src 字节数组
} * @return
*/
public static String bytesToHexString(byte[] src) {
StringBuilder stringBuilder = new StringBuilder("");
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < src.length; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
}
return stringBuilder.toString();
}
/** /**
* 将字节数组转换为十六进制字符串 * 将十六进制字符串转换为字节数组
* *
* @param src * @param hexString 十六进制字符串
* 字节数组 * @return
* @return */
*/ public static byte[] hexStringToBytes(String hexString) {
public static String bytesToHexString(byte[] src) { if (hexString == null || "".equals(hexString)) {
StringBuilder stringBuilder = new StringBuilder(""); return null;
if (src == null || src.length <= 0) { }
return null; hexString = hexString.toUpperCase();
} int length = hexString.length() / 2;
for (int i = 0; i < src.length; i++) { char[] hexChars = hexString.toCharArray();
int v = src[i] & 0xFF; byte[] d = new byte[length];
String hv = Integer.toHexString(v); for (int i = 0; i < length; i++) {
if (hv.length() < 2) { int pos = i * 2;
stringBuilder.append(0); d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
} }
stringBuilder.append(hv); return d;
} }
return stringBuilder.toString();
}
/** private static byte charToByte(char c) {
* 将十六进制字符串转换为字节数组 return (byte) "0123456789ABCDEF".indexOf(c);
* }
* @param hexString
* 十六进制字符串
* @return
*/
public static byte[] hexStringToBytes(String hexString) {
if (hexString == null || "".equals(hexString)) {
return null;
}
hexString = hexString.toUpperCase();
int length = hexString.length() / 2;
char[] hexChars = hexString.toCharArray();
byte[] d = new byte[length];
for (int i = 0; i < length; i++) {
int pos = i * 2;
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
}
return d;
}
private static byte charToByte(char c) {
return (byte) "0123456789ABCDEF".indexOf(c);
}
} }

View File

@@ -256,16 +256,17 @@ public class ReflectHelper {
/** /**
* 判断给定的字段是不是类中的属性 * 判断给定的字段是不是类中的属性
*
* @param field 字段名 * @param field 字段名
* @param clazz 类对象 * @param clazz 类对象
* @return * @return
*/ */
public static boolean isClassField(String field, Class clazz){ public static boolean isClassField(String field, Class clazz) {
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
for(int i=0;i<fields.length;i++){ for (int i = 0; i < fields.length; i++) {
String fieldName = fields[i].getName(); String fieldName = fields[i].getName();
String tableColumnName = oConvertUtils.camelToUnderline(fieldName); String tableColumnName = oConvertUtils.camelToUnderline(fieldName);
if(fieldName.equalsIgnoreCase(field) || tableColumnName.equalsIgnoreCase(field)){ if (fieldName.equalsIgnoreCase(field) || tableColumnName.equalsIgnoreCase(field)) {
return true; return true;
} }
} }
@@ -274,24 +275,26 @@ public class ReflectHelper {
/** /**
* 获取class的 包括父类的 * 获取class的 包括父类的
*
* @param clazz * @param clazz
* @return * @return
*/ */
public static List<Field> getClassFields(Class<?> clazz) { public static List<Field> getClassFields(Class<?> clazz) {
List<Field> list = new ArrayList<Field>(); List<Field> list = new ArrayList<Field>();
Field[] fields; Field[] fields;
do{ do {
fields = clazz.getDeclaredFields(); fields = clazz.getDeclaredFields();
for(int i = 0;i<fields.length;i++){ for (int i = 0; i < fields.length; i++) {
list.add(fields[i]); list.add(fields[i]);
} }
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
}while(clazz!= Object.class&&clazz!=null); } while (clazz != Object.class && clazz != null);
return list; return list;
} }
/** /**
* 获取表字段名 * 获取表字段名
*
* @param clazz * @param clazz
* @param name * @param name
* @return * @return
@@ -310,21 +313,21 @@ public class ReflectHelper {
if (field == null) { if (field == null) {
List<Field> allFields = getClassFields(clazz); List<Field> allFields = getClassFields(clazz);
List<Field> searchFields = allFields.stream().filter(a -> a.getName().equals(name)).collect(Collectors.toList()); List<Field> searchFields = allFields.stream().filter(a -> a.getName().equals(name)).collect(Collectors.toList());
if(searchFields!=null && searchFields.size()>0){ if (searchFields != null && searchFields.size() > 0) {
field = searchFields.get(0); field = searchFields.get(0);
} }
} }
if (field != null) { if (field != null) {
TableField tableField = field.getAnnotation(TableField.class); TableField tableField = field.getAnnotation(TableField.class);
if (tableField != null){ if (tableField != null) {
if(tableField.exist() == false){ if (tableField.exist() == false) {
//如果设置了TableField false 这个字段不需要处理 //如果设置了TableField false 这个字段不需要处理
return null; return null;
}else{ } else {
String column = tableField.value(); String column = tableField.value();
//如果设置了TableField value 这个字段是实体字段 //如果设置了TableField value 这个字段是实体字段
if(!"".equals(column)){ if (!"".equals(column)) {
return column; return column;
} }
} }

View File

@@ -29,7 +29,7 @@ public class RestUtil {
// issues/2959 // issues/2959
// 微服务版集成企业微信单点登录 // 微服务版集成企业微信单点登录
// 因为微服务版没有端口号,导致 SpringContextUtils.getDomain() 方法获取的域名的端口号变成了:-1所以出问题了只需要把这个-1给去掉就可以了。 // 因为微服务版没有端口号,导致 SpringContextUtils.getDomain() 方法获取的域名的端口号变成了:-1所以出问题了只需要把这个-1给去掉就可以了。
String port=":-1"; String port = ":-1";
if (domain.endsWith(port)) { if (domain.endsWith(port)) {
domain = domain.substring(0, domain.length() - 3); domain = domain.substring(0, domain.length() - 3);
} }
@@ -192,7 +192,7 @@ public class RestUtil {
* @return ResponseEntity<responseType> * @return ResponseEntity<responseType>
*/ */
public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) { public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {
log.info(" RestUtil --- request --- url = "+ url); log.info(" RestUtil --- request --- url = " + url);
if (StringUtils.isEmpty(url)) { if (StringUtils.isEmpty(url)) {
throw new RuntimeException("url 不能为空"); throw new RuntimeException("url 不能为空");
} }

View File

@@ -2,7 +2,6 @@ package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.ServiceNameConstants; import org.jeecg.common.constant.ServiceNameConstants;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
@@ -19,95 +18,96 @@ import org.springframework.web.context.request.ServletRequestAttributes;
@Component @Component
public class SpringContextUtils implements ApplicationContextAware { public class SpringContextUtils implements ApplicationContextAware {
/** /**
* 上下文对象实例 * 上下文对象实例
*/ */
private static ApplicationContext applicationContext; private static ApplicationContext applicationContext;
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextUtils.applicationContext = applicationContext; SpringContextUtils.applicationContext = applicationContext;
} }
/** /**
* 获取applicationContext * 获取applicationContext
* *
* @return * @return
*/ */
public static ApplicationContext getApplicationContext() { public static ApplicationContext getApplicationContext() {
return applicationContext; return applicationContext;
} }
/** /**
* 获取HttpServletRequest * 获取HttpServletRequest
*/ */
public static HttpServletRequest getHttpServletRequest() { public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
} }
/**
* 获取HttpServletResponse
*/
public static HttpServletResponse getHttpServletResponse() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
}
/** /**
* 获取项目根路径 basePath * 获取HttpServletResponse
*/ */
public static String getDomain(){ public static HttpServletResponse getHttpServletResponse() {
HttpServletRequest request = getHttpServletRequest(); return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
StringBuffer url = request.getRequestURL(); }
//1.微服务情况下获取gateway的basePath
String basePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH);
if(oConvertUtils.isNotEmpty(basePath)){
return basePath;
}else{
String domain = url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
//2.【兼容】SSL认证之后request.getScheme()获取不到https的问题
// https://blog.csdn.net/weixin_34376986/article/details/89767950
String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME);
if(scheme!=null && !request.getScheme().equals(scheme)){
domain = domain.replace(request.getScheme(),scheme);
}
return domain;
}
}
public static String getOrigin(){ /**
HttpServletRequest request = getHttpServletRequest(); * 获取项目根路径 basePath
return request.getHeader("Origin"); */
} public static String getDomain() {
HttpServletRequest request = getHttpServletRequest();
StringBuffer url = request.getRequestURL();
//1.微服务情况下获取gateway的basePath
String basePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH);
if (oConvertUtils.isNotEmpty(basePath)) {
return basePath;
} else {
String domain = url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
//2.【兼容】SSL认证之后request.getScheme()获取不到https的问题
// https://blog.csdn.net/weixin_34376986/article/details/89767950
String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME);
if (scheme != null && !request.getScheme().equals(scheme)) {
domain = domain.replace(request.getScheme(), scheme);
}
return domain;
}
}
/** public static String getOrigin() {
* 通过name获取 Bean. HttpServletRequest request = getHttpServletRequest();
* return request.getHeader("Origin");
* @param name }
* @return
*/
public static Object getBean(String name) {
return getApplicationContext().getBean(name);
}
/** /**
* 通过class获取Bean. * 通过name获取 Bean.
* *
* @param clazz * @param name
* @param <T> * @return
* @return */
*/ public static Object getBean(String name) {
public static <T> T getBean(Class<T> clazz) { return getApplicationContext().getBean(name);
return getApplicationContext().getBean(clazz); }
}
/** /**
* 通过name,以及Clazz返回指定的Bean * 通过class获取Bean.
* *
* @param name * @param clazz
* @param clazz * @param <T>
* @param <T> * @return
* @return */
*/ public static <T> T getBean(Class<T> clazz) {
public static <T> T getBean(String name, Class<T> clazz) { return getApplicationContext().getBean(clazz);
return getApplicationContext().getBean(name, clazz); }
}
/**
* 通过name,以及Clazz返回指定的Bean
*
* @param name
* @param clazz
* @param <T>
* @return
*/
public static <T> T getBean(String name, Class<T> clazz) {
return getApplicationContext().getBean(name, clazz);
}
} }

View File

@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.exception.JeecgSqlInjectionException; import org.jeecg.common.exception.JeecgSqlInjectionException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@@ -17,412 +18,420 @@ import java.util.regex.Pattern;
*/ */
@Slf4j @Slf4j
public class SqlInjectionUtil { public class SqlInjectionUtil {
/** /**
* 默认—sql注入关键词 * 默认—sql注入关键词
*/ */
private final static String XSS_STR = "and |exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|--"; private final static String XSS_STR = "and |exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|--";
/** /**
* online报表专用—sql注入关键词 * online报表专用—sql注入关键词
*/ */
private static String specialReportXssStr = "exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |alter |delete |grant |update |drop |master |truncate |declare |--"; private static String specialReportXssStr = "exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |alter |delete |grant |update |drop |master |truncate |declare |--";
/** /**
* 字典专用—sql注入关键词 * 字典专用—sql注入关键词
*/ */
private static String specialDictSqlXssStr = "exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|+|--"; private static String specialDictSqlXssStr = "exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|+|--";
/** /**
* 完整匹配的key不需要考虑前空格 * 完整匹配的key不需要考虑前空格
*/ */
private static List<String> FULL_MATCHING_KEYWRODS = new ArrayList<>(); private static List<String> FULL_MATCHING_KEYWRODS = new ArrayList<>();
static {
FULL_MATCHING_KEYWRODS.add(";");
FULL_MATCHING_KEYWRODS.add("+");
FULL_MATCHING_KEYWRODS.add("--");
}
static {
FULL_MATCHING_KEYWRODS.add(";");
FULL_MATCHING_KEYWRODS.add("+");
FULL_MATCHING_KEYWRODS.add("--");
}
/**
* sql注入风险的 正则关键字
*
* 函数匹配,需要用正则模式
*/
private final static String[] XSS_REGULAR_STR_ARRAY = new String[]{
"chr\\s*\\(",
"mid\\s*\\(",
" char\\s*\\(",
"sleep\\s*\\(",
"user\\s*\\(",
"show\\s+tables",
"user[\\s]*\\([\\s]*\\)",
"show\\s+databases",
"sleep\\(\\d*\\)",
"sleep\\(.*\\)",
};
/**
* sql注释的正则
*/
private final static Pattern SQL_ANNOTATION = Pattern.compile("/\\*[\\s\\S]*\\*/");
private final static String SQL_ANNOTATION2 = "--";
/**
* sql注入提示语
*/
private final static String SQL_INJECTION_KEYWORD_TIP = "请注意存在SQL注入关键词---> {}";
private final static String SQL_INJECTION_TIP = "请注意值可能存在SQL注入风险!--->";
private final static String SQL_INJECTION_TIP_VARIABLE = "请注意值可能存在SQL注入风险!---> {}";
/**
* sql注入过滤处理遇到注入关键字抛异常
* @param values
*/
public static void filterContentMulti(String... values) {
filterContent(values, null);
}
/**
* 校验比较严格
*
* sql注入过滤处理遇到注入关键字抛异常
*
* @param value
* @return
*/
public static void filterContent(String value, String customXssString) {
if (value == null || "".equals(value)) {
return;
}
// 一、校验sql注释 不允许有sql注释
checkSqlAnnotation(value);
// 转为小写进行后续比较
value = value.toLowerCase().trim();
// 二、SQL注入检测存在绕过风险 (普通文本校验)
//https://gitee.com/jeecg/jeecg-boot/issues/I4NZGE
String[] xssArr = XSS_STR.split("\\|");
for (int i = 0; i < xssArr.length; i++) {
if (value.indexOf(xssArr[i]) > -1) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
// 三、SQL注入检测存在绕过风险 (自定义传入普通文本校验)
if (customXssString != null) {
String[] xssArr2 = customXssString.split("\\|");
for (int i = 0; i < xssArr2.length; i++) {
if (value.indexOf(xssArr2[i]) > -1) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr2[i]);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
}
// 四、SQL注入检测存在绕过风险 (正则校验)
for (String regularOriginal : XSS_REGULAR_STR_ARRAY) {
String regular = ".*" + regularOriginal + ".*";
if (Pattern.matches(regular, value)) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
return;
}
/**
* 判断是否存在SQL注入关键词字符串
*
* @param keyword
* @return
*/
@SuppressWarnings("AlibabaUndefineMagicConstant")
private static boolean isExistSqlInjectKeyword(String sql, String keyword) {
if (sql.startsWith(keyword.trim())) {
return true;
} else if (sql.contains(keyword)) {
// 需要匹配的sql注入关键词
String matchingText = " " + keyword;
if(FULL_MATCHING_KEYWRODS.contains(keyword)){
matchingText = keyword;
}
if (sql.contains(matchingText)) {
return true;
} else {
String regularStr = "\\s+\\S+" + keyword;
List<String> resultFindAll = ReUtil.findAll(regularStr, sql, 0, new ArrayList<String>());
for (String res : resultFindAll) {
log.info("isExistSqlInjectKeyword —- 匹配到的SQL注入关键词{}", res);
/**
* SQL注入中可以替换空格的字符(%09 %0A %0D +都可以替代空格)
* http://blog.chinaunix.net/uid-12501104-id-2932639.html
* https://www.cnblogs.com/Vinson404/p/7253255.html
* */
if (res.contains("%") || res.contains("+") || res.contains("#") || res.contains("/") || res.contains(")")) {
return true;
}
}
}
}
return false;
}
/**
* sql注入过滤处理遇到注入关键字抛异常
*
* @param values
* @return
*/
public static void filterContent(String[] values, String customXssString) {
for (String val : values) {
if (oConvertUtils.isEmpty(val)) {
return;
}
filterContent(val, customXssString);
}
return;
}
/**
* 【提醒:不通用】
* 仅用于字典条件SQL参数注入过滤
*
* @param value
* @return
*/
public static void specialFilterContentForDictSql(String value) {
String[] xssArr = specialDictSqlXssStr.split("\\|");
if (value == null || "".equals(value)) {
return;
}
// 一、校验sql注释 不允许有sql注释
checkSqlAnnotation(value);
value = value.toLowerCase().trim();
// 二、SQL注入检测存在绕过风险 (普通文本校验)
for (int i = 0; i < xssArr.length; i++) {
if (isExistSqlInjectKeyword(value, xssArr[i])) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
// 三、SQL注入检测存在绕过风险 (正则校验)
for (String regularOriginal : XSS_REGULAR_STR_ARRAY) {
String regular = ".*" + regularOriginal + ".*";
if (Pattern.matches(regular, value)) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
return;
}
/** /**
* 【提醒:不通用】 * sql注入风险的 正则关键字
* 仅用于Online报表SQL解析注入过滤 * <p>
* 函数匹配,需要用正则模式
*/
private final static String[] XSS_REGULAR_STR_ARRAY = new String[]{
"chr\\s*\\(",
"mid\\s*\\(",
" char\\s*\\(",
"sleep\\s*\\(",
"user\\s*\\(",
"show\\s+tables",
"user[\\s]*\\([\\s]*\\)",
"show\\s+databases",
"sleep\\(\\d*\\)",
"sleep\\(.*\\)",
};
/**
* sql注释的正则
*/
private final static Pattern SQL_ANNOTATION = Pattern.compile("/\\*[\\s\\S]*\\*/");
private final static String SQL_ANNOTATION2 = "--";
/**
* sql注入提示语
*/
private final static String SQL_INJECTION_KEYWORD_TIP = "请注意存在SQL注入关键词---> {}";
private final static String SQL_INJECTION_TIP = "请注意值可能存在SQL注入风险!--->";
private final static String SQL_INJECTION_TIP_VARIABLE = "请注意值可能存在SQL注入风险!---> {}";
/**
* sql注入过滤处理遇到注入关键字抛异常
*
* @param values
*/
public static void filterContentMulti(String... values) {
filterContent(values, null);
}
/**
* 校验比较严格
* <p>
* sql注入过滤处理遇到注入关键字抛异常
*
* @param value * @param value
* @return * @return
*/ */
public static void specialFilterContentForOnlineReport(String value) { public static void filterContent(String value, String customXssString) {
String[] xssArr = specialReportXssStr.split("\\|"); if (value == null || "".equals(value)) {
if (value == null || "".equals(value)) { return;
return; }
} // 一、校验sql注释 不允许有sql注释
// 一、校验sql注释 不允许有sql注释 checkSqlAnnotation(value);
checkSqlAnnotation(value); // 转为小写进行后续比较
value = value.toLowerCase().trim(); value = value.toLowerCase().trim();
// 二、SQL注入检测存在绕过风险 (普通文本校验) // 二、SQL注入检测存在绕过风险 (普通文本校验)
for (int i = 0; i < xssArr.length; i++) { //https://gitee.com/jeecg/jeecg-boot/issues/I4NZGE
if (isExistSqlInjectKeyword(value, xssArr[i])) { String[] xssArr = XSS_STR.split("\\|");
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]); for (int i = 0; i < xssArr.length; i++) {
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); if (value.indexOf(xssArr[i]) > -1) {
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]);
} log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
} throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
// 三、SQL注入检测存在绕过风险 (自定义传入普通文本校验)
if (customXssString != null) {
String[] xssArr2 = customXssString.split("\\|");
for (int i = 0; i < xssArr2.length; i++) {
if (value.indexOf(xssArr2[i]) > -1) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr2[i]);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
}
// 、SQL注入检测存在绕过风险 (正则校验) // 、SQL注入检测存在绕过风险 (正则校验)
for (String regularOriginal : XSS_REGULAR_STR_ARRAY) { for (String regularOriginal : XSS_REGULAR_STR_ARRAY) {
String regular = ".*" + regularOriginal + ".*"; String regular = ".*" + regularOriginal + ".*";
if (Pattern.matches(regular, value)) { if (Pattern.matches(regular, value)) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal); log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value); log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value); throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
} }
} }
return; return;
} }
/**
* 判断是否存在SQL注入关键词字符串
*
* @param keyword
* @return
*/
@SuppressWarnings("AlibabaUndefineMagicConstant")
private static boolean isExistSqlInjectKeyword(String sql, String keyword) {
if (sql.startsWith(keyword.trim())) {
return true;
} else if (sql.contains(keyword)) {
// 需要匹配的sql注入关键词
String matchingText = " " + keyword;
if (FULL_MATCHING_KEYWRODS.contains(keyword)) {
matchingText = keyword;
}
if (sql.contains(matchingText)) {
return true;
} else {
String regularStr = "\\s+\\S+" + keyword;
List<String> resultFindAll = ReUtil.findAll(regularStr, sql, 0, new ArrayList<String>());
for (String res : resultFindAll) {
log.info("isExistSqlInjectKeyword —- 匹配到的SQL注入关键词{}", res);
/**
* SQL注入中可以替换空格的字符(%09 %0A %0D +都可以替代空格)
* http://blog.chinaunix.net/uid-12501104-id-2932639.html
* https://www.cnblogs.com/Vinson404/p/7253255.html
* */
if (res.contains("%") || res.contains("+") || res.contains("#") || res.contains("/") || res.contains(")")) {
return true;
}
}
}
}
return false;
}
/**
* sql注入过滤处理遇到注入关键字抛异常
*
* @param values
* @return
*/
public static void filterContent(String[] values, String customXssString) {
for (String val : values) {
if (oConvertUtils.isEmpty(val)) {
return;
}
filterContent(val, customXssString);
}
return;
}
/**
* 【提醒:不通用】
* 仅用于字典条件SQL参数注入过滤
*
* @param value
* @return
*/
public static void specialFilterContentForDictSql(String value) {
String[] xssArr = specialDictSqlXssStr.split("\\|");
if (value == null || "".equals(value)) {
return;
}
// 一、校验sql注释 不允许有sql注释
checkSqlAnnotation(value);
value = value.toLowerCase().trim();
// 二、SQL注入检测存在绕过风险 (普通文本校验)
for (int i = 0; i < xssArr.length; i++) {
if (isExistSqlInjectKeyword(value, xssArr[i])) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
// 三、SQL注入检测存在绕过风险 (正则校验)
for (String regularOriginal : XSS_REGULAR_STR_ARRAY) {
String regular = ".*" + regularOriginal + ".*";
if (Pattern.matches(regular, value)) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
return;
}
/**
* 【提醒:不通用】
* 仅用于Online报表SQL解析注入过滤
*
* @param value
* @return
*/
public static void specialFilterContentForOnlineReport(String value) {
String[] xssArr = specialReportXssStr.split("\\|");
if (value == null || "".equals(value)) {
return;
}
// 一、校验sql注释 不允许有sql注释
checkSqlAnnotation(value);
value = value.toLowerCase().trim();
// 二、SQL注入检测存在绕过风险 (普通文本校验)
for (int i = 0; i < xssArr.length; i++) {
if (isExistSqlInjectKeyword(value, xssArr[i])) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, xssArr[i]);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
// 三、SQL注入检测存在绕过风险 (正则校验)
for (String regularOriginal : XSS_REGULAR_STR_ARRAY) {
String regular = ".*" + regularOriginal + ".*";
if (Pattern.matches(regular, value)) {
log.error(SqlInjectionUtil.SQL_INJECTION_KEYWORD_TIP, regularOriginal);
log.error(SqlInjectionUtil.SQL_INJECTION_TIP_VARIABLE, value);
throw new JeecgSqlInjectionException(SqlInjectionUtil.SQL_INJECTION_TIP + value);
}
}
return;
}
/** /**
* 校验是否有sql注释 * 校验是否有sql注释
* @return *
*/ * @return
public static void checkSqlAnnotation(String str){ */
if(str.contains(SQL_ANNOTATION2)){ public static void checkSqlAnnotation(String str) {
String error = "请注意SQL中不允许含注释有安全风险"; if (str.contains(SQL_ANNOTATION2)) {
log.error(error); String error = "请注意SQL中不允许含注释有安全风险";
throw new RuntimeException(error); log.error(error);
} throw new RuntimeException(error);
}
Matcher matcher = SQL_ANNOTATION.matcher(str); Matcher matcher = SQL_ANNOTATION.matcher(str);
if(matcher.find()){ if (matcher.find()) {
String error = "请注意值可能存在SQL注入风险---> \\*.*\\"; String error = "请注意值可能存在SQL注入风险---> \\*.*\\";
log.error(error); log.error(error);
throw new JeecgSqlInjectionException(error); throw new JeecgSqlInjectionException(error);
} }
} }
/** /**
* 返回查询表名 * 返回查询表名
* <p> * <p>
* sql注入过滤处理遇到注入关键字抛异常 * sql注入过滤处理遇到注入关键字抛异常
* *
* @param table * @param table
*/ */
private static Pattern tableNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\$]{0,63}$"); private static Pattern tableNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\$]{0,63}$");
public static String getSqlInjectTableName(String table) {
if(oConvertUtils.isEmpty(table)){
return table;
}
//update-begin---author:scott ---date:2024-05-28 for表单设计器列表翻译存在表名带条件导致翻译出问题---- public static String getSqlInjectTableName(String table) {
int index = table.toLowerCase().indexOf(" where "); if (oConvertUtils.isEmpty(table)) {
if (index != -1) { return table;
table = table.substring(0, index); }
log.info("截掉where之后的新表名" + table);
}
//update-end---author:scott ---date::2024-05-28 for表单设计器列表翻译存在表名带条件导致翻译出问题----
table = table.trim(); //update-begin---author:scott ---date:2024-05-28 for表单设计器列表翻译存在表名带条件导致翻译出问题----
/** int index = table.toLowerCase().indexOf(" where ");
* 检验表名是否合法 if (index != -1) {
* table = table.substring(0, index);
* 表名只能由字母、数字和下划线组成。 log.info("截掉where之后的新表名" + table);
* 表名必须以字母开头。 }
* 表名长度通常有限制,例如最多为 64 个字符。 //update-end---author:scott ---date::2024-05-28 for表单设计器列表翻译存在表名带条件导致翻译出问题----
*/
boolean isValidTableName = tableNamePattern.matcher(table).matches();
if (!isValidTableName) {
String errorMsg = "表名不合法存在SQL注入风险!--->" + table;
log.error(errorMsg);
throw new JeecgSqlInjectionException(errorMsg);
}
//进一步验证是否存在SQL注入风险 table = table.trim();
filterContentMulti(table); /**
return table; * 检验表名是否合法
} *
* 表名只能由字母、数字和下划线组成。
* 表名必须以字母开头。
* 表名长度通常有限制,例如最多为 64 个字符。
*/
boolean isValidTableName = tableNamePattern.matcher(table).matches();
if (!isValidTableName) {
String errorMsg = "表名不合法存在SQL注入风险!--->" + table;
log.error(errorMsg);
throw new JeecgSqlInjectionException(errorMsg);
}
//进一步验证是否存在SQL注入风险
filterContentMulti(table);
return table;
}
/** /**
* 返回查询字段 * 返回查询字段
* <p> * <p>
* sql注入过滤处理遇到注入关键字抛异常 * sql注入过滤处理遇到注入关键字抛异常
* *
* @param field * @param field
*/ */
static final Pattern fieldPattern = Pattern.compile("^[a-zA-Z0-9_]+$"); static final Pattern fieldPattern = Pattern.compile("^[a-zA-Z0-9_]+$");
public static String getSqlInjectField(String field) {
if(oConvertUtils.isEmpty(field)){
return field;
}
field = field.trim(); public static String getSqlInjectField(String field) {
if (oConvertUtils.isEmpty(field)) {
return field;
}
if (field.contains(SymbolConstant.COMMA)) { field = field.trim();
return getSqlInjectField(field.split(SymbolConstant.COMMA));
}
/** if (field.contains(SymbolConstant.COMMA)) {
* 校验表字段是否有效 return getSqlInjectField(field.split(SymbolConstant.COMMA));
* }
* 字段定义只能是是字母 数字 下划线的组合(不允许有空格、转义字符串等)
*/
boolean isValidField = fieldPattern.matcher(field).matches();
if (!isValidField) {
String errorMsg = "字段不合法存在SQL注入风险!--->" + field;
log.error(errorMsg);
throw new JeecgSqlInjectionException(errorMsg);
}
//进一步验证是否存在SQL注入风险 /**
filterContentMulti(field); * 校验表字段是否有效
return field; *
} * 字段定义只能是是字母 数字 下划线的组合(不允许有空格、转义字符串等)
*/
boolean isValidField = fieldPattern.matcher(field).matches();
if (!isValidField) {
String errorMsg = "字段不合法存在SQL注入风险!--->" + field;
log.error(errorMsg);
throw new JeecgSqlInjectionException(errorMsg);
}
/** //进一步验证是否存在SQL注入风险
* 获取多个字段 filterContentMulti(field);
* 返回: 逗号拼接 return field;
* }
* @param fields
* @return /**
*/ * 获取多个字段
public static String getSqlInjectField(String... fields) { * 返回: 逗号拼接
for (String s : fields) { *
getSqlInjectField(s); * @param fields
} * @return
return String.join(SymbolConstant.COMMA, fields); */
} public static String getSqlInjectField(String... fields) {
for (String s : fields) {
getSqlInjectField(s);
}
return String.join(SymbolConstant.COMMA, fields);
}
/** /**
* 获取排序字段 * 获取排序字段
* 返回:字符串 * 返回:字符串
* * <p>
* 1.将驼峰命名转化成下划线 * 1.将驼峰命名转化成下划线
* 2.限制sql注入 * 2.限制sql注入
* @param sortField 排序字段 *
* @return * @param sortField 排序字段
*/ * @return
public static String getSqlInjectSortField(String sortField) { */
String field = SqlInjectionUtil.getSqlInjectField(oConvertUtils.camelToUnderline(sortField)); public static String getSqlInjectSortField(String sortField) {
return field; String field = SqlInjectionUtil.getSqlInjectField(oConvertUtils.camelToUnderline(sortField));
} return field;
}
/** /**
* 获取多个排序字段 * 获取多个排序字段
* 返回:数组 * 返回:数组
* * <p>
* 1.将驼峰命名转化成下划线 * 1.将驼峰命名转化成下划线
* 2.限制sql注入 * 2.限制sql注入
* @param sortFields 多个排序字段 *
* @return * @param sortFields 多个排序字段
*/ * @return
public static List getSqlInjectSortFields(String... sortFields) { */
List list = new ArrayList<String>(); public static List getSqlInjectSortFields(String... sortFields) {
for (String sortField : sortFields) { List list = new ArrayList<String>();
list.add(getSqlInjectSortField(sortField)); for (String sortField : sortFields) {
} list.add(getSqlInjectSortField(sortField));
return list; }
} return list;
}
/** /**
* 获取 orderBy type * 获取 orderBy type
* 返回:字符串 * 返回:字符串
* <p> * <p>
* 1.检测是否为 asc 或 desc 其中的一个 * 1.检测是否为 asc 或 desc 其中的一个
* 2.限制sql注入 * 2.限制sql注入
* *
* @param orderType * @param orderType
* @return * @return
*/ */
public static String getSqlInjectOrderType(String orderType) { public static String getSqlInjectOrderType(String orderType) {
if (orderType == null) { if (orderType == null) {
return null; return null;
} }
orderType = orderType.trim(); orderType = orderType.trim();
if (CommonConstant.ORDER_TYPE_ASC.equalsIgnoreCase(orderType)) { if (CommonConstant.ORDER_TYPE_ASC.equalsIgnoreCase(orderType)) {
return CommonConstant.ORDER_TYPE_ASC; return CommonConstant.ORDER_TYPE_ASC;
} else { } else {
return CommonConstant.ORDER_TYPE_DESC; return CommonConstant.ORDER_TYPE_DESC;
} }
} }
} }

View File

@@ -1,5 +1,6 @@
package org.jeecg.common.util; package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.CommonAPI; import org.jeecg.common.api.CommonAPI;
@@ -11,8 +12,6 @@ import org.jeecg.common.exception.JeecgBoot401Exception;
import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.system.vo.LoginUser;
import jakarta.servlet.http.HttpServletRequest;
/** /**
* @Author scott * @Author scott
* @Date 2019/9/23 14:12 * @Date 2019/9/23 14:12
@@ -41,6 +40,7 @@ public class TokenUtils {
/** /**
* 获取 request 里传递的 token * 获取 request 里传递的 token
*
* @return * @return
*/ */
public static String getTokenByRequest() { public static String getTokenByRequest() {
@@ -124,6 +124,7 @@ public class TokenUtils {
/** /**
* 刷新token保证用户在线操作不掉线 * 刷新token保证用户在线操作不掉线
*
* @param token * @param token
* @param userName * @param userName
* @param passWord * @param passWord

View File

@@ -4,93 +4,92 @@ package org.jeecg.common.util;
import java.net.InetAddress; import java.net.InetAddress;
/** /**
* * @Author 张代浩
* @Author 张代浩
*
*/ */
public class UUIDGenerator { public class UUIDGenerator {
/** /**
* 产生一个32位的UUID * 产生一个32位的UUID
* *
* @return * @return
*/ */
public static String generate() { public static String generate() {
return new StringBuilder(32).append(format(getIp())).append( return new StringBuilder(32).append(format(getIp())).append(
format(getJvm())).append(format(getHiTime())).append( format(getJvm())).append(format(getHiTime())).append(
format(getLoTime())).append(format(getCount())).toString(); format(getLoTime())).append(format(getCount())).toString();
} }
private static final int IP; private static final int IP;
static {
int ipadd;
try {
ipadd = toInt(InetAddress.getLocalHost().getAddress());
} catch (Exception e) {
ipadd = 0;
}
IP = ipadd;
}
private static short counter = (short) 0; static {
int ipadd;
try {
ipadd = toInt(InetAddress.getLocalHost().getAddress());
} catch (Exception e) {
ipadd = 0;
}
IP = ipadd;
}
private static final int JVM = (int) (System.currentTimeMillis() >>> 8); private static short counter = (short) 0;
private final static String format(int intval) { private static final int JVM = (int) (System.currentTimeMillis() >>> 8);
String formatted = Integer.toHexString(intval);
StringBuilder buf = new StringBuilder("00000000");
buf.replace(8 - formatted.length(), 8, formatted);
return buf.toString();
}
private final static String format(short shortval) { private final static String format(int intval) {
String formatted = Integer.toHexString(shortval); String formatted = Integer.toHexString(intval);
StringBuilder buf = new StringBuilder("0000"); StringBuilder buf = new StringBuilder("00000000");
buf.replace(4 - formatted.length(), 4, formatted); buf.replace(8 - formatted.length(), 8, formatted);
return buf.toString(); return buf.toString();
} }
private final static int getJvm() { private final static String format(short shortval) {
return JVM; String formatted = Integer.toHexString(shortval);
} StringBuilder buf = new StringBuilder("0000");
buf.replace(4 - formatted.length(), 4, formatted);
return buf.toString();
}
private final static short getCount() { private final static int getJvm() {
synchronized (UUIDGenerator.class) { return JVM;
if (counter < 0) { }
counter = 0;
}
return counter++;
}
}
/** private final static short getCount() {
* Unique in a local network synchronized (UUIDGenerator.class) {
*/ if (counter < 0) {
private final static int getIp() { counter = 0;
return IP; }
} return counter++;
}
}
/** /**
* Unique down to millisecond * Unique in a local network
*/ */
private final static short getHiTime() { private final static int getIp() {
return (short) (System.currentTimeMillis() >>> 32); return IP;
} }
private final static int getLoTime() { /**
return (int) System.currentTimeMillis(); * Unique down to millisecond
} */
private final static short getHiTime() {
return (short) (System.currentTimeMillis() >>> 32);
}
private final static int toInt(byte[] bytes) { private final static int getLoTime() {
int result = 0; return (int) System.currentTimeMillis();
int length = 4; }
for (int i = 0; i < length; i++) {
result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i]; private final static int toInt(byte[] bytes) {
} int result = 0;
return result; int length = 4;
} for (int i = 0; i < length; i++) {
result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i];
}
return result;
}
} }

View File

@@ -6,168 +6,171 @@ import io.netty.util.internal.StringUtil;
* 流水号生成规则(按默认规则递增数字从1-99开始递增数字到99递增字母;位数不够增加位数) * 流水号生成规则(按默认规则递增数字从1-99开始递增数字到99递增字母;位数不够增加位数)
* A001 * A001
* A001A002 * A001A002
* @Author zhangdaihao
* *
* @Author zhangdaihao
*/ */
public class YouBianCodeUtil { public class YouBianCodeUtil {
// 数字位数(默认生成3位的数字) // 数字位数(默认生成3位的数字)
/**代表数字位数*/ /**
private static final int NUM_LENGTH = 2; * 代表数字位数
*/
private static final int NUM_LENGTH = 2;
public static final int ZHANWEI_LENGTH = 1+ NUM_LENGTH; public static final int ZHANWEI_LENGTH = 1 + NUM_LENGTH;
public static final char LETTER= 'Z'; public static final char LETTER = 'Z';
/** /**
* 根据前一个code获取同级下一个code * 根据前一个code获取同级下一个code
* 例如:当前最大code为D01A04下一个code为D01A05 * 例如:当前最大code为D01A04下一个code为D01A05
* *
* @param code * @param code
* @return * @return
*/ */
public static synchronized String getNextYouBianCode(String code) { public static synchronized String getNextYouBianCode(String code) {
String newcode = ""; String newcode = "";
if (oConvertUtils.isEmpty(code)) { if (oConvertUtils.isEmpty(code)) {
String zimu = "A"; String zimu = "A";
String num = getStrNum(1); String num = getStrNum(1);
newcode = zimu + num; newcode = zimu + num;
} else { } else {
String beforeCode = code.substring(0, code.length() - 1- NUM_LENGTH); String beforeCode = code.substring(0, code.length() - 1 - NUM_LENGTH);
String afterCode = code.substring(code.length() - 1 - NUM_LENGTH,code.length()); String afterCode = code.substring(code.length() - 1 - NUM_LENGTH, code.length());
char afterCodeZimu = afterCode.substring(0, 1).charAt(0); char afterCodeZimu = afterCode.substring(0, 1).charAt(0);
Integer afterCodeNum = Integer.parseInt(afterCode.substring(1)); Integer afterCodeNum = Integer.parseInt(afterCode.substring(1));
// org.jeecgframework.core.util.LogUtil.info(after_code); // org.jeecgframework.core.util.LogUtil.info(after_code);
// org.jeecgframework.core.util.LogUtil.info(after_code_zimu); // org.jeecgframework.core.util.LogUtil.info(after_code_zimu);
// org.jeecgframework.core.util.LogUtil.info(after_code_num); // org.jeecgframework.core.util.LogUtil.info(after_code_num);
String nextNum = ""; String nextNum = "";
char nextZimu = 'A'; char nextZimu = 'A';
// 先判断数字等于999*则计数从1重新开始递增 // 先判断数字等于999*则计数从1重新开始递增
if (afterCodeNum == getMaxNumByLength(NUM_LENGTH)) { if (afterCodeNum == getMaxNumByLength(NUM_LENGTH)) {
nextNum = getNextStrNum(0); nextNum = getNextStrNum(0);
} else { } else {
nextNum = getNextStrNum(afterCodeNum); nextNum = getNextStrNum(afterCodeNum);
} }
// 先判断数字等于999*则字母从A重新开始,递增 // 先判断数字等于999*则字母从A重新开始,递增
if(afterCodeNum == getMaxNumByLength(NUM_LENGTH)) { if (afterCodeNum == getMaxNumByLength(NUM_LENGTH)) {
nextZimu = getNextZiMu(afterCodeZimu); nextZimu = getNextZiMu(afterCodeZimu);
}else{ } else {
nextZimu = afterCodeZimu; nextZimu = afterCodeZimu;
} }
// 例如Z99下一个code就是Z99A01 // 例如Z99下一个code就是Z99A01
if (LETTER == afterCodeZimu && getMaxNumByLength(NUM_LENGTH) == afterCodeNum) { if (LETTER == afterCodeZimu && getMaxNumByLength(NUM_LENGTH) == afterCodeNum) {
newcode = code + (nextZimu + nextNum); newcode = code + (nextZimu + nextNum);
} else { } else {
newcode = beforeCode + (nextZimu + nextNum); newcode = beforeCode + (nextZimu + nextNum);
} }
} }
return newcode; return newcode;
} }
/** /**
* 根据父亲code,获取下级的下一个code * 根据父亲code,获取下级的下一个code
* * <p>
* 例如父亲CODE:A01 * 例如父亲CODE:A01
* 当前CODE:A01B03 * 当前CODE:A01B03
* 获取的code:A01B04 * 获取的code:A01B04
* *
* @param parentCode 上级code * @param parentCode 上级code
* @param localCode 同级code * @param localCode 同级code
* @return * @return
*/ */
public static synchronized String getSubYouBianCode(String parentCode,String localCode) { public static synchronized String getSubYouBianCode(String parentCode, String localCode) {
if(localCode!=null && localCode!=""){ if (localCode != null && localCode != "") {
// return parentCode + getNextYouBianCode(localCode); // return parentCode + getNextYouBianCode(localCode);
return getNextYouBianCode(localCode); return getNextYouBianCode(localCode);
}else{ } else {
parentCode = parentCode + "A"+ getNextStrNum(0); parentCode = parentCode + "A" + getNextStrNum(0);
} }
return parentCode; return parentCode;
} }
/**
* 将数字前面位数补零
*
* @param num
* @return
*/
private static String getNextStrNum(int num) {
return getStrNum(getNextNum(num));
}
/** /**
* 将数字前面位数补零 * 将数字前面位数补零
* *
* @param num * @param num
* @return * @return
*/ */
private static String getNextStrNum(int num) { private static String getStrNum(int num) {
return getStrNum(getNextNum(num)); String s = String.format("%0" + NUM_LENGTH + "d", num);
} return s;
}
/** /**
* 将数字前面位数补零 * 递增获取下个数字
* *
* @param num * @param num
* @return * @return
*/ */
private static String getStrNum(int num) { private static int getNextNum(int num) {
String s = String.format("%0" + NUM_LENGTH + "d", num); num++;
return s; return num;
} }
/** /**
* 递增获取下个 * 递增获取下个字
* *
* @param num * @param num
* @return * @return
*/ */
private static int getNextNum(int num) { private static char getNextZiMu(char zimu) {
num++; if (zimu == LETTER) {
return num; return 'A';
} }
zimu++;
return zimu;
}
/** /**
* 递增获取下个字母 * 根据数字位数获取最大值
* *
* @param num * @param length
* @return * @return
*/ */
private static char getNextZiMu(char zimu) { private static int getMaxNumByLength(int length) {
if (zimu == LETTER) { if (length == 0) {
return 'A'; return 0;
} }
zimu++;
return zimu;
}
/**
* 根据数字位数获取最大值
* @param length
* @return
*/
private static int getMaxNumByLength(int length){
if(length==0){
return 0;
}
StringBuilder maxNum = new StringBuilder(); StringBuilder maxNum = new StringBuilder();
for (int i=0;i<length;i++){ for (int i = 0; i < length; i++) {
maxNum.append("9"); maxNum.append("9");
} }
return Integer.parseInt(maxNum.toString()); return Integer.parseInt(maxNum.toString());
} }
public static String[] cutYouBianCode(String code){
if(code==null || StringUtil.isNullOrEmpty(code)){
return null;
}else{
//获取标准长度为numLength+1,截取的数量为code.length/numLength+1
int c = code.length()/(NUM_LENGTH +1);
String[] cutcode = new String[c];
for(int i =0 ; i <c;i++){
cutcode[i] = code.substring(0,(i+1)*(NUM_LENGTH +1));
}
return cutcode;
}
} public static String[] cutYouBianCode(String code) {
if (code == null || StringUtil.isNullOrEmpty(code)) {
return null;
} else {
//获取标准长度为numLength+1,截取的数量为code.length/numLength+1
int c = code.length() / (NUM_LENGTH + 1);
String[] cutcode = new String[c];
for (int i = 0; i < c; i++) {
cutcode[i] = code.substring(0, (i + 1) * (NUM_LENGTH + 1));
}
return cutcode;
}
}
// public static void main(String[] args) { // public static void main(String[] args) {
// // org.jeecgframework.core.util.LogUtil.info(getNextZiMu('C')); // // org.jeecgframework.core.util.LogUtil.info(getNextZiMu('C'));
// // org.jeecgframework.core.util.LogUtil.info(getNextNum(8)); // // org.jeecgframework.core.util.LogUtil.info(getNextNum(8));

View File

@@ -6,16 +6,20 @@ import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.system.vo.DynamicDataSourceModel; import org.jeecg.common.system.vo.DynamicDataSourceModel;
import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.SpringContextUtils;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* 数据源缓存池 * 数据源缓存池
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class DataSourceCachePool { public class DataSourceCachePool {
/** 数据源连接池缓存【本地 class缓存 - 不支持分布式】 */ /**
* 数据源连接池缓存【本地 class缓存 - 不支持分布式】
*/
private static Map<String, DruidDataSource> dbSources = new HashMap<>(); private static Map<String, DruidDataSource> dbSources = new HashMap<>();
private static RedisTemplate<String, Object> redisTemplate; private static RedisTemplate<String, Object> redisTemplate;
@@ -64,10 +68,10 @@ public class DataSourceCachePool {
*/ */
public static void cleanAllCache() { public static void cleanAllCache() {
//关闭数据源连接 //关闭数据源连接
for(Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()){ for (Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()) {
String dbkey = entry.getKey(); String dbkey = entry.getKey();
DruidDataSource druidDataSource = entry.getValue(); DruidDataSource druidDataSource = entry.getValue();
if(druidDataSource!=null && druidDataSource.isEnable()){ if (druidDataSource != null && druidDataSource.isEnable()) {
druidDataSource.close(); druidDataSource.close();
} }
//清空redis缓存 //清空redis缓存
@@ -80,7 +84,7 @@ public class DataSourceCachePool {
public static void removeCache(String dbKey) { public static void removeCache(String dbKey) {
//关闭数据源连接 //关闭数据源连接
DruidDataSource druidDataSource = dbSources.get(dbKey); DruidDataSource druidDataSource = dbSources.get(dbKey);
if(druidDataSource!=null && druidDataSource.isEnable()){ if (druidDataSource != null && druidDataSource.isEnable()) {
druidDataSource.close(); druidDataSource.close();
} }
//清空redis缓存 //清空redis缓存

View File

@@ -9,12 +9,14 @@ import java.util.Map;
/** /**
* 数据库类型判断 * 数据库类型判断
* 【有些数据库引擎是一样的,以达到复用目的】 * 【有些数据库引擎是一样的,以达到复用目的】
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public class DbTypeUtils { public class DbTypeUtils {
public static Map<String, String> dialectMap = new HashMap<String, String>(); public static Map<String, String> dialectMap = new HashMap<String, String>();
static{
static {
dialectMap.put("mysql", "org.hibernate.dialect.MySQL5InnoDBDialect"); dialectMap.put("mysql", "org.hibernate.dialect.MySQL5InnoDBDialect");
// mariadb数据库 1 -- // mariadb数据库 1 --
dialectMap.put("mariadb", "org.hibernate.dialect.MariaDBDialect"); dialectMap.put("mariadb", "org.hibernate.dialect.MariaDBDialect");
@@ -77,33 +79,34 @@ public class DbTypeUtils {
} }
/** /**
* 根据枚举类 获取数据库类型的字符串 * 根据枚举类 获取数据库类型的字符串
*
* @param dbType * @param dbType
* @return * @return
*/ */
public static String getDbTypeString(DbType dbType){ public static String getDbTypeString(DbType dbType) {
if(DbType.DB2.equals(dbType)){ if (DbType.DB2.equals(dbType)) {
return DataBaseConstant.DB_TYPE_DB2; return DataBaseConstant.DB_TYPE_DB2;
}else if(DbType.HSQL.equals(dbType)){ } else if (DbType.HSQL.equals(dbType)) {
return DataBaseConstant.DB_TYPE_HSQL; return DataBaseConstant.DB_TYPE_HSQL;
}else if(dbTypeIsOracle(dbType)){ } else if (dbTypeIsOracle(dbType)) {
return DataBaseConstant.DB_TYPE_ORACLE; return DataBaseConstant.DB_TYPE_ORACLE;
}else if(dbTypeIsSqlServer(dbType)){ } else if (dbTypeIsSqlServer(dbType)) {
return DataBaseConstant.DB_TYPE_SQLSERVER; return DataBaseConstant.DB_TYPE_SQLSERVER;
}else if(dbTypeIsPostgre(dbType)){ } else if (dbTypeIsPostgre(dbType)) {
return DataBaseConstant.DB_TYPE_POSTGRESQL; return DataBaseConstant.DB_TYPE_POSTGRESQL;
} }
return DataBaseConstant.DB_TYPE_MYSQL; return DataBaseConstant.DB_TYPE_MYSQL;
} }
/** /**
* 根据枚举类 获取数据库方言字符串 * 根据枚举类 获取数据库方言字符串
*
* @param dbType * @param dbType
* @return * @return
*/ */
public static String getDbDialect(DbType dbType){ public static String getDbDialect(DbType dbType) {
return dialectMap.get(dbType.getDb()); return dialectMap.get(dbType.getDb());
} }

View File

@@ -4,14 +4,12 @@ import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.DynamicDataSourceModel; import org.jeecg.common.system.vo.DynamicDataSourceModel;
import org.jeecg.common.util.ReflectHelper; import org.jeecg.common.util.ReflectHelper;
import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.util.oConvertUtils;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import javax.sql.DataSource;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -61,7 +59,7 @@ public class DynamicDBUtil {
log.info("******************************************"); log.info("******************************************");
log.info("* *"); log.info("* *");
log.info("*====【"+dbSource.getCode()+"】=====Druid连接池已启用 ====*"); log.info("*====【" + dbSource.getCode() + "】=====Druid连接池已启用 ====*");
log.info("* *"); log.info("* *");
log.info("******************************************"); log.info("******************************************");
return dataSource; return dataSource;
@@ -83,10 +81,10 @@ public class DynamicDBUtil {
return cacheDbSource; return cacheDbSource;
} else { } else {
DruidDataSource dataSource = getJdbcDataSource(dbSource); DruidDataSource dataSource = getJdbcDataSource(dbSource);
if(dataSource!=null && dataSource.isEnable()){ if (dataSource != null && dataSource.isEnable()) {
DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource); DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
}else{ } else {
throw new JeecgBootException("动态数据源连接失败dbKey"+dbKey); throw new JeecgBootException("动态数据源连接失败dbKey" + dbKey);
} }
log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------"); log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------");
return dataSource; return dataSource;
@@ -120,6 +118,7 @@ public class DynamicDBUtil {
/** /**
* 根据数据源获取NamedParameterJdbcTemplate * 根据数据源获取NamedParameterJdbcTemplate
*
* @param dbKey * @param dbKey
* @return * @return
*/ */
@@ -240,18 +239,20 @@ public class DynamicDBUtil {
/** /**
* 查询数量 * 查询数量
*
* @param dbKey * @param dbKey
* @param sql * @param sql
* @param param * @param param
* @return * @return
*/ */
public static Map<String, Object> queryCount(String dbKey, String sql, Map<String, Object> param){ public static Map<String, Object> queryCount(String dbKey, String sql, Map<String, Object> param) {
NamedParameterJdbcTemplate npJdbcTemplate = getNamedParameterJdbcTemplate(dbKey); NamedParameterJdbcTemplate npJdbcTemplate = getNamedParameterJdbcTemplate(dbKey);
return npJdbcTemplate.queryForMap(sql, param); return npJdbcTemplate.queryForMap(sql, param);
} }
/** /**
* 查询列表数据 * 查询列表数据
*
* @param dbKey * @param dbKey
* @param sql * @param sql
* @param param * @param param
@@ -283,8 +284,9 @@ public class DynamicDBUtil {
/** /**
* 此方法只能返回单列,不能返回实体类 * 此方法只能返回单列,不能返回实体类
*
* @param dbKey 数据源的key * @param dbKey 数据源的key
* @param sql sal * @param sql sal
* @param clazz 类 * @param clazz 类
* @param param 参数 * @param param 参数
* @param <T> * @param <T>

View File

@@ -42,7 +42,9 @@ public class FreemarkerParseFactory {
private static StringTemplateLoader stringTemplateLoader = new StringTemplateLoader(); private static StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
/**使用内嵌的(?ms)打开单行和多行模式*/ /**
* 使用内嵌的(?ms)打开单行和多行模式
*/
private final static Pattern NOTES_PATTERN = Pattern private final static Pattern NOTES_PATTERN = Pattern
.compile("(?ms)/\\*.*?\\*/|^\\s*//.*?$"); .compile("(?ms)/\\*.*?\\*/|^\\s*//.*?$");
@@ -121,12 +123,13 @@ public class FreemarkerParseFactory {
* @param paras 参数 * @param paras 参数
* @return String 模板解析后内容 * @return String 模板解析后内容
*/ */
public static String parseTemplateContent(String tplContent,Map<String, Object> paras) { public static String parseTemplateContent(String tplContent, Map<String, Object> paras) {
return parseTemplateContent(tplContent, paras, false); return parseTemplateContent(tplContent, paras, false);
} }
public static String parseTemplateContent(String tplContent, Map<String, Object> paras, boolean keepSpace) { public static String parseTemplateContent(String tplContent, Map<String, Object> paras, boolean keepSpace) {
try { try {
String sqlUnderline="sql_"; String sqlUnderline = "sql_";
StringWriter swriter = new StringWriter(); StringWriter swriter = new StringWriter();
if (stringTemplateLoader.findTemplateSource(sqlUnderline + tplContent.hashCode()) == null) { if (stringTemplateLoader.findTemplateSource(sqlUnderline + tplContent.hashCode()) == null) {
stringTemplateLoader.putTemplate(sqlUnderline + tplContent.hashCode(), tplContent); stringTemplateLoader.putTemplate(sqlUnderline + tplContent.hashCode(), tplContent);
@@ -165,11 +168,11 @@ public class FreemarkerParseFactory {
} }
// 去掉 最后是 where这样的问题 // 去掉 最后是 where这样的问题
//where空格 "where " //where空格 "where "
String whereSpace = DataBaseConstant.SQL_WHERE+" "; String whereSpace = DataBaseConstant.SQL_WHERE + " ";
//"where and" //"where and"
String whereAnd = DataBaseConstant.SQL_WHERE+" and"; String whereAnd = DataBaseConstant.SQL_WHERE + " and";
//", where" //", where"
String commaWhere = SymbolConstant.COMMA+" "+DataBaseConstant.SQL_WHERE; String commaWhere = SymbolConstant.COMMA + " " + DataBaseConstant.SQL_WHERE;
//", " //", "
String commaSpace = SymbolConstant.COMMA + " "; String commaSpace = SymbolConstant.COMMA + " ";
if (sql.endsWith(DataBaseConstant.SQL_WHERE) || sql.endsWith(whereSpace)) { if (sql.endsWith(DataBaseConstant.SQL_WHERE) || sql.endsWith(whereSpace)) {

View File

@@ -21,9 +21,10 @@ public class AesEncryptUtil {
/** /**
* 加密方法 * 加密方法
* @param data 要加密的数据 *
* @param key 加密key * @param data 要加密的数据
* @param iv 加密iv * @param key 加密key
* @param iv 加密iv
* @return 加密的结果 * @return 加密的结果
* @throws Exception * @throws Exception
*/ */
@@ -59,9 +60,10 @@ public class AesEncryptUtil {
/** /**
* 解密方法 * 解密方法
*
* @param data 要解密的数据 * @param data 要解密的数据
* @param key 解密key * @param key 解密key
* @param iv 解密iv * @param iv 解密iv
* @return 解密的结果 * @return 解密的结果
* @throws Exception * @throws Exception
*/ */
@@ -84,6 +86,7 @@ public class AesEncryptUtil {
/** /**
* 使用默认的key和iv加密 * 使用默认的key和iv加密
*
* @param data * @param data
* @return * @return
* @throws Exception * @throws Exception
@@ -94,6 +97,7 @@ public class AesEncryptUtil {
/** /**
* 使用默认的key和iv解密 * 使用默认的key和iv解密
*
* @param data * @param data
* @return * @return
* @throws Exception * @throws Exception
@@ -103,7 +107,6 @@ public class AesEncryptUtil {
} }
// /** // /**
// * 测试 // * 测试
// */ // */

Some files were not shown because too many files have changed in this diff Show More