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,6 +93,7 @@ public interface CommonAPI {
/** /**
* 8查询数据权限 * 8查询数据权限
*
* @param component 组件 * @param component 组件
* @param username 用户名 * @param username 用户名
* @param requestPath 前段请求地址 * @param requestPath 前段请求地址
@@ -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,6 +138,7 @@ 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
@@ -132,8 +146,10 @@ public interface CommonAPI {
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

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
@@ -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

@@ -9,12 +9,13 @@ 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;
@@ -54,6 +55,7 @@ public class Result<T> implements Serializable {
/** /**
* 兼容VUE3版token失效不跳转登录页面 * 兼容VUE3版token失效不跳转登录页面
*
* @param code * @param code
* @param message * @param message
*/ */
@@ -69,14 +71,14 @@ public class Result<T> implements Serializable {
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);
@@ -86,7 +88,7 @@ public class Result<T> implements Serializable {
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);
@@ -94,7 +96,7 @@ public class Result<T> implements Serializable {
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);
@@ -108,7 +110,7 @@ public class Result<T> implements Serializable {
* @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);
@@ -118,7 +120,7 @@ public class Result<T> implements Serializable {
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);
@@ -126,7 +128,7 @@ public class Result<T> implements Serializable {
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);
@@ -135,7 +137,7 @@ public class Result<T> implements Serializable {
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);
@@ -144,11 +146,11 @@ public class Result<T> implements Serializable {
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);
@@ -166,7 +168,7 @@ public class Result<T> implements Serializable {
/** /**
* 无权限访问返回结果 * 无权限访问返回结果
*/ */
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);
} }

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) {
@@ -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;
} }
@@ -91,6 +91,7 @@ public class DictAspect {
* } * }
* } * }
* 目前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);
@@ -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:微服务下为空报错没有参数需要传递空字符串---
@@ -381,6 +383,7 @@ 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,7 +73,7 @@ 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 微服务情况下也得支持缓存机制
@@ -82,12 +83,12 @@ public class PermissionDataAspect {
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

@@ -16,6 +16,7 @@ public @interface AutoDict {
/** /**
* 暂时无用 * 暂时无用
*
* @return * @return
*/ */
String value() default ""; String value() default "";

View File

@@ -40,6 +40,7 @@ public @interface AutoLog {
/** /**
* 模块类型 默认为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,22 +1,20 @@
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 "";

View File

@@ -77,27 +77,43 @@ public interface CommonConstant {
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前缀 */ /**
* 登录用户Shiro权限缓存KEY前缀
*/
public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:";
/** 登录用户Token令牌缓存KEY前缀 */ /**
* 登录用户Token令牌缓存KEY前缀
*/
String PREFIX_USER_TOKEN = "prefix_user_token:"; 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_PRE = "QRCODELOGIN:";
String LOGIN_QRCODE = "LQ:"; String LOGIN_QRCODE = "LQ:";
/** 登录二维码token */ /**
* 登录二维码token
*/
String LOGIN_QRCODE_TOKEN = "LQT:"; String LOGIN_QRCODE_TOKEN = "LQT:";
@@ -114,20 +130,28 @@ public interface CommonConstant {
*/ */
Integer MENU_TYPE_2 = 2; Integer MENU_TYPE_2 = 2;
/**通告对象类型USER:指定用户ALL:全体用户)*/ /**
* 通告对象类型USER:指定用户ALL:全体用户)
*/
String MSG_TYPE_UESR = "USER"; String MSG_TYPE_UESR = "USER";
String MSG_TYPE_ALL = "ALL"; String MSG_TYPE_ALL = "ALL";
/**发布状态0未发布1已发布2已撤销*/ /**
* 发布状态0未发布1已发布2已撤销
*/
String NO_SEND = "0"; String NO_SEND = "0";
String HAS_SEND = "1"; String HAS_SEND = "1";
String HAS_CANCLE = "2"; String HAS_CANCLE = "2";
/**阅读状态0未读1已读*/ /**
* 阅读状态0未读1已读
*/
Integer HAS_READ_FLAG = 1; Integer HAS_READ_FLAG = 1;
Integer NO_READ_FLAG = 0; Integer NO_READ_FLAG = 0;
/**优先级L低M中H高*/ /**
* 优先级L低M中H高
*/
String PRIORITY_L = "L"; String PRIORITY_L = "L";
String PRIORITY_M = "M"; String PRIORITY_M = "M";
String PRIORITY_H = "H"; String PRIORITY_H = "H";
@@ -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";
/** /**
* 在线聊天 是否为默认分组 * 在线聊天 是否为默认分组
@@ -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";
/**======【消息推送相关】==============================================================================*/ /**======【消息推送相关】==============================================================================*/
@@ -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";
/**========【消息推送相关】==========================================================================*/ /**========【消息推送相关】==========================================================================*/
@@ -561,7 +645,9 @@ public interface CommonConstant {
*/ */
String COPY_LEVEL_COVER = "cover"; String COPY_LEVEL_COVER = "cover";
/** 【QQYUN-6034】关联字段变更历史值缓存半个小时 */ /**
* 【QQYUN-6034】关联字段变更历史值缓存半个小时
*/
String CACHE_REL_FIELD_OLD_VAL = "sys:cache:desform:relFieldOldVal:"; String CACHE_REL_FIELD_OLD_VAL = "sys:cache:desform:relFieldOldVal:";
/** /**

View File

@@ -2,8 +2,8 @@ package org.jeecg.common.constant;
/** /**
* 系统通告 - 发布状态 * 系统通告 - 发布状态
* @Author LeeShaoQing
* *
* @Author LeeShaoQing
*/ */
public interface CommonSendStatus { public interface CommonSendStatus {
@@ -29,15 +29,25 @@ public interface CommonSendStatus {
/**-----【流程相关通知模板code】------------------------------------------------------------*/ /**-----【流程相关通知模板code】------------------------------------------------------------*/
/**流程催办——系统通知消息模板*/ /**
* 流程催办——系统通知消息模板
*/
public static final String TZMB_BPM_CUIBAN = "bpm_cuiban"; public static final String TZMB_BPM_CUIBAN = "bpm_cuiban";
/**流程抄送——系统通知消息模板*/ /**
* 流程抄送——系统通知消息模板
*/
public static final String TZMB_BPM_CC = "bpm_cc"; public static final String TZMB_BPM_CC = "bpm_cc";
/**流程催办——邮件通知消息模板*/ /**
* 流程催办——邮件通知消息模板
*/
public static final String TZMB_BPM_CUIBAN_EMAIL = "bpm_cuiban_email"; 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_SYS_TS_NOTE = "sys_ts_note";
/**流程超时提醒——系统通知消息模板*/ /**
* 流程超时提醒——系统通知消息模板
*/
public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip"; public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip";
/**-----【流程相关通知模板code】-----------------------------------------------------------*/ /**-----【流程相关通知模板code】-----------------------------------------------------------*/

View File

@@ -1,36 +1,56 @@
package org.jeecg.common.constant; package org.jeecg.common.constant;
/** /**
* 数据库上下文常量 * 数据库上下文常量
*
* @author: jeecg-boot * @author: jeecg-boot
*/ */
public interface DataBaseConstant { public interface DataBaseConstant {
//*********数据库类型**************************************** //*********数据库类型****************************************
/**MYSQL数据库*/ /**
* MYSQL数据库
*/
public static final String DB_TYPE_MYSQL = "MYSQL"; public static final String DB_TYPE_MYSQL = "MYSQL";
/** ORACLE*/ /**
* ORACLE
*/
public static final String DB_TYPE_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达梦数据库*/ /**
* postgreSQL达梦数据库
*/
public static final String DB_TYPE_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数据库*/ /**
* sqlserver数据库
*/
public static final String DB_TYPE_SQLSERVER = "SQLSERVER"; public static final String DB_TYPE_SQLSERVER = "SQLSERVER";
/**mariadb 数据库*/ /**
* mariadb 数据库
*/
public static final String DB_TYPE_MARIADB = "MARIADB"; public static final String DB_TYPE_MARIADB = "MARIADB";
/**DB2 数据库*/ /**
* DB2 数据库
*/
public static final String DB_TYPE_DB2 = "DB2"; public static final String DB_TYPE_DB2 = "DB2";
/**HSQL 数据库*/ /**
* HSQL 数据库
*/
public static final String DB_TYPE_HSQL = "HSQL"; public static final String DB_TYPE_HSQL = "HSQL";
// // 数据库类型,对应 database_type 字典 // // 数据库类型,对应 database_type 字典

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

@@ -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/树

View File

@@ -8,22 +8,38 @@ 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");
/** /**
* 短信模板编码 * 短信模板编码
@@ -38,7 +54,7 @@ public enum DySmsEnum {
*/ */
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;
@@ -69,11 +85,11 @@ public enum DySmsEnum {
} }
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;
} }
} }

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", "系统消息"), XT("system", "系统消息"),
/** 邮件消息 */ /**
* 邮件消息
*/
YJ("email", "邮件消息"), 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"),
@@ -42,8 +45,10 @@ public enum RoleIndexConfigEnum {
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,6 +22,7 @@ public class SensitiveInfoUtil {
/** /**
* 处理嵌套对象 * 处理嵌套对象
*
* @param obj 方法返回值 * @param obj 方法返回值
* @param entity 实体class * @param entity 实体class
* @param isEncode 是否加密true: 加密操作 / false:解密操作) * @param isEncode 是否加密true: 加密操作 / false:解密操作)
@@ -29,21 +31,21 @@ public class SensitiveInfoUtil {
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,6 +59,7 @@ public class SensitiveInfoUtil {
/** /**
* 处理Object * 处理Object
*
* @param obj 方法返回值 * @param obj 方法返回值
* @param isEncode 是否加密true: 加密操作 / false:解密操作) * @param isEncode 是否加密true: 加密操作 / false:解密操作)
* @return * @return
@@ -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,6 +214,7 @@ public class SensitiveInfoUtil {
/** /**
* [中文姓名] 只显示第一个汉字其他隐藏为2个星号 * [中文姓名] 只显示第一个汉字其他隐藏为2个星号
*
* @param familyName 姓 * @param familyName 姓
* @param firstName 名 * @param firstName 名
* @return <例子:李**> * @return <例子:李**>
@@ -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,6 +272,7 @@ 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) {

View File

@@ -74,6 +74,7 @@ public class QueryStringBuilder {
/** /**
* 是否在两边加上双引号 * 是否在两边加上双引号
*
* @param builder * @param builder
* @param str * @param str
* @param addQuot * @param addQuot

View File

@@ -7,17 +7,15 @@ package org.jeecg.common.exception;
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

@@ -15,11 +15,11 @@ public class JeecgBootBizTipException extends RuntimeException {
*/ */
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;
} }
@@ -28,13 +28,11 @@ public class JeecgBootBizTipException extends RuntimeException {
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

@@ -14,11 +14,11 @@ public class JeecgBootException extends RuntimeException {
*/ */
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;
} }
@@ -27,13 +27,11 @@ public class JeecgBootException extends RuntimeException {
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

@@ -51,7 +51,7 @@ public class JeecgBootExceptionHandler {
* 处理自定义异常 * 处理自定义异常
*/ */
@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());
@@ -61,7 +61,7 @@ public class JeecgBootExceptionHandler {
* 处理自定义异常 * 处理自定义异常
*/ */
@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());
} }
@@ -70,7 +70,7 @@ public class JeecgBootExceptionHandler {
* 处理自定义微服务异常 * 处理自定义微服务异常
*/ */
@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());
@@ -81,10 +81,10 @@ public class JeecgBootExceptionHandler {
*/ */
@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)
@@ -95,20 +95,20 @@ public class JeecgBootExceptionHandler {
} }
@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();
@@ -118,24 +118,24 @@ public class JeecgBootExceptionHandler {
} }
//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("");
} }
@@ -143,7 +143,7 @@ public class JeecgBootExceptionHandler {
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());
} }
/** /**
@@ -193,8 +193,10 @@ public class JeecgBootExceptionHandler {
} }
//update-begin---author:chenrui ---date:20240423 for[QQYUN-8732]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------ //update-begin---author:chenrui ---date:20240423 for[QQYUN-8732]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------
/** /**
* 添加异常新系统日志 * 添加异常新系统日志
*
* @param e 异常 * @param e 异常
* @author chenrui * @author chenrui
* @date 2024/4/22 17:16 * @date 2024/4/22 17:16
@@ -202,7 +204,7 @@ public class JeecgBootExceptionHandler {
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;
@@ -213,7 +215,7 @@ public class JeecgBootExceptionHandler {
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()));
} }
// 请求地址 // 请求地址
@@ -221,9 +223,9 @@ public class JeecgBootExceptionHandler {
//设置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());
} }
} }
@@ -231,7 +233,7 @@ public class JeecgBootExceptionHandler {
//获取登录用户信息 //获取登录用户信息
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());

View File

@@ -7,17 +7,15 @@ package org.jeecg.common.exception;
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,6 +12,7 @@ public interface IFillRuleHandler {
/** /**
* 填值规则 * 填值规则
*
* @param params 页面配置固定参数 * @param params 页面配置固定参数
* @param formData 动态表单参数 * @param formData 动态表单参数
* @return * @return

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,13 +70,14 @@ 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
* *
@@ -86,35 +89,35 @@ public class JeecgController<T, S extends IService<T>> {
* @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

@@ -11,7 +11,9 @@ 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 */ /**
* 组件的类型例如input、select、radio
*/
private String type; private String type;
/** /**
* 对应的数据库字段的类型 * 对应的数据库字段的类型
@@ -70,9 +72,9 @@ public class QueryCondition implements Serializable {
} }
@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);

View File

@@ -1,16 +1,8 @@
package org.jeecg.common.system.query; package org.jeecg.common.system.query;
import java.beans.PropertyDescriptor; import com.alibaba.fastjson.JSON;
import java.io.UnsupportedEncodingException; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.math.BigDecimal; import lombok.extern.slf4j.Slf4j;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.DataBaseConstant; import org.jeecg.common.constant.DataBaseConstant;
@@ -22,10 +14,16 @@ import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.util.*; import org.jeecg.common.util.*;
import org.springframework.util.NumberUtils; import org.springframework.util.NumberUtils;
import com.alibaba.fastjson.JSON; import java.beans.PropertyDescriptor;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import lombok.extern.slf4j.Slf4j; import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* @Description: 查询生成器 * @Description: 查询生成器
@@ -48,34 +46,55 @@ public class QueryGenerator {
*/ */
public static final String QUERY_COMMA_ESCAPE = "++"; public static final String QUERY_COMMA_ESCAPE = "++";
private static final String NOT_EQUAL = "!"; private static final String NOT_EQUAL = "!";
/**页面带有规则值查询,空格作为分隔符*/ /**
* 页面带有规则值查询,空格作为分隔符
*/
private static final String QUERY_SEPARATE_KEYWORD = " "; private static final String QUERY_SEPARATE_KEYWORD = " ";
/**高级查询前端传来的参数名*/ /**
* 高级查询前端传来的参数名
*/
private static final String SUPER_QUERY_PARAMS = "superQueryParams"; private static final String SUPER_QUERY_PARAMS = "superQueryParams";
/** 高级查询前端传来的拼接方式参数名 */ /**
* 高级查询前端传来的拼接方式参数名
*/
private static final String SUPER_QUERY_MATCH_TYPE = "superQueryMatchType"; private static final String SUPER_QUERY_MATCH_TYPE = "superQueryMatchType";
/** 单引号 */ /**
* 单引号
*/
public static final String SQL_SQ = "'"; public static final String SQL_SQ = "'";
/**排序列*/ /**
* 排序列
*/
private static final String ORDER_COLUMN = "column"; private static final String ORDER_COLUMN = "column";
/**排序方式*/ /**
* 排序方式
*/
private static final String ORDER_TYPE = "order"; private static final String ORDER_TYPE = "order";
private static final String ORDER_TYPE_ASC = "ASC"; private static final String ORDER_TYPE_ASC = "ASC";
/**mysql 模糊查询之特殊字符下划线 _、\*/ /**
* mysql 模糊查询之特殊字符下划线 _、\
*/
public static final String LIKE_MYSQL_SPECIAL_STRS = "_,%"; public static final String LIKE_MYSQL_SPECIAL_STRS = "_,%";
/**日期格式化yyyy-MM-dd*/ /**
* 日期格式化yyyy-MM-dd
*/
public static final String YYYY_MM_DD = "yyyy-MM-dd"; public static final String YYYY_MM_DD = "yyyy-MM-dd";
/**to_date*/ /**
* to_date
*/
public static final String TO_DATE = "to_date"; public static final String TO_DATE = "to_date";
/**时间格式化 */ /**
* 时间格式化
*/
private static final ThreadLocal<SimpleDateFormat> LOCAL = new ThreadLocal<SimpleDateFormat>(); private static final ThreadLocal<SimpleDateFormat> LOCAL = new ThreadLocal<SimpleDateFormat>();
private static SimpleDateFormat getTime(){
private static SimpleDateFormat getTime() {
SimpleDateFormat time = LOCAL.get(); SimpleDateFormat time = LOCAL.get();
if(time == null){ if (time == null) {
time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LOCAL.set(time); LOCAL.set(time);
} }
@@ -84,31 +103,34 @@ public class QueryGenerator {
/** /**
* 获取查询条件构造器QueryWrapper实例 通用查询条件已被封装完成 * 获取查询条件构造器QueryWrapper实例 通用查询条件已被封装完成
*
* @param searchObj 查询实体 * @param searchObj 查询实体
* @param parameterMap request.getParameterMap() * @param parameterMap request.getParameterMap()
* @return QueryWrapper实例 * @return QueryWrapper实例
*/ */
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj,Map<String, String[]> parameterMap){ public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
QueryWrapper<T> queryWrapper = new QueryWrapper<T>(); QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
installMplus(queryWrapper, searchObj, parameterMap, null); installMplus(queryWrapper, searchObj, parameterMap, null);
log.debug("---查询条件构造器初始化完成,耗时:"+(System.currentTimeMillis()-start)+"毫秒----"); log.debug("---查询条件构造器初始化完成,耗时:" + (System.currentTimeMillis() - start) + "毫秒----");
return queryWrapper; return queryWrapper;
} }
//update-begin---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------ //update-begin---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------
/** /**
* 获取查询条件构造器QueryWrapper实例 通用查询条件已被封装完成 * 获取查询条件构造器QueryWrapper实例 通用查询条件已被封装完成
*
* @param searchObj 查询实体 * @param searchObj 查询实体
* @param parameterMap request.getParameterMap() * @param parameterMap request.getParameterMap()
* @param customRuleMap 自定义字段查询规则 {field:QueryRuleEnum} * @param customRuleMap 自定义字段查询规则 {field:QueryRuleEnum}
* @return QueryWrapper实例 * @return QueryWrapper实例
*/ */
public static <T> QueryWrapper<T> initQueryWrapper(T searchObj,Map<String, String[]> parameterMap, Map<String, QueryRuleEnum> customRuleMap){ public static <T> QueryWrapper<T> initQueryWrapper(T searchObj, Map<String, String[]> parameterMap, Map<String, QueryRuleEnum> customRuleMap) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
QueryWrapper<T> queryWrapper = new QueryWrapper<T>(); QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
installMplus(queryWrapper, searchObj, parameterMap, customRuleMap); installMplus(queryWrapper, searchObj, parameterMap, customRuleMap);
log.debug("---查询条件构造器初始化完成,耗时:"+(System.currentTimeMillis()-start)+"毫秒----"); log.debug("---查询条件构造器初始化完成,耗时:" + (System.currentTimeMillis() - start) + "毫秒----");
return queryWrapper; return queryWrapper;
} }
//update-end---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------ //update-end---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------
@@ -131,37 +153,37 @@ public class QueryGenerator {
//区间条件组装 模糊查询 高级查询组装 简单排序 权限查询 //区间条件组装 模糊查询 高级查询组装 简单排序 权限查询
PropertyDescriptor[] origDescriptors = PropertyUtils.getPropertyDescriptors(searchObj); PropertyDescriptor[] origDescriptors = PropertyUtils.getPropertyDescriptors(searchObj);
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); Map<String, SysPermissionDataRuleModel> ruleMap = getRuleMap();
//权限规则自定义SQL表达式 //权限规则自定义SQL表达式
for (String c : ruleMap.keySet()) { for (String c : ruleMap.keySet()) {
if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ if (oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)) {
queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); queryWrapper.and(i -> i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue())));
} }
} }
String name, type, column; String name, type, column;
// update-begin--Author:taoyan Date:20200923 forissues/1671 如果字段加注解了@TableField(exist = false),不走DB查询------- // update-begin--Author:taoyan Date:20200923 forissues/1671 如果字段加注解了@TableField(exist = false),不走DB查询-------
//定义实体字段和数据库字段名称的映射 高级查询中 只能获取实体字段 如果设置TableField注解 那么查询条件会出问题 //定义实体字段和数据库字段名称的映射 高级查询中 只能获取实体字段 如果设置TableField注解 那么查询条件会出问题
Map<String,String> fieldColumnMap = new HashMap<>(5); Map<String, String> fieldColumnMap = new HashMap<>(5);
for (int i = 0; i < origDescriptors.length; i++) { for (int i = 0; i < origDescriptors.length; i++) {
//aliasName = origDescriptors[i].getName(); mybatis 不存在实体属性 不用处理别名的情况 //aliasName = origDescriptors[i].getName(); mybatis 不存在实体属性 不用处理别名的情况
name = origDescriptors[i].getName(); name = origDescriptors[i].getName();
type = origDescriptors[i].getPropertyType().toString(); type = origDescriptors[i].getPropertyType().toString();
try { try {
if (judgedIsUselessField(name)|| !PropertyUtils.isReadable(searchObj, name)) { if (judgedIsUselessField(name) || !PropertyUtils.isReadable(searchObj, name)) {
continue; continue;
} }
Object value = PropertyUtils.getSimpleProperty(searchObj, name); Object value = PropertyUtils.getSimpleProperty(searchObj, name);
column = ReflectHelper.getTableFieldName(searchObj.getClass(), name); column = ReflectHelper.getTableFieldName(searchObj.getClass(), name);
if(column==null){ if (column == null) {
//column为null只有一种情况 那就是 添加了注解@TableField(exist = false) 后续都不用处理了 //column为null只有一种情况 那就是 添加了注解@TableField(exist = false) 后续都不用处理了
continue; continue;
} }
fieldColumnMap.put(name,column); fieldColumnMap.put(name, column);
//数据权限查询 //数据权限查询
if(ruleMap.containsKey(name)) { if (ruleMap.containsKey(name)) {
addRuleToQueryWrapper(ruleMap.get(name), column, origDescriptors[i].getPropertyType(), queryWrapper); addRuleToQueryWrapper(ruleMap.get(name), column, origDescriptors[i].getPropertyType(), queryWrapper);
} }
//区间查询 //区间查询
@@ -172,32 +194,32 @@ public class QueryGenerator {
String multiLikeval = value.toString().replace(",,", COMMA); String multiLikeval = value.toString().replace(",,", COMMA);
String[] vals = multiLikeval.substring(1, multiLikeval.length()).split(COMMA); String[] vals = multiLikeval.substring(1, multiLikeval.length()).split(COMMA);
final String field = oConvertUtils.camelToUnderline(column); final String field = oConvertUtils.camelToUnderline(column);
if(vals.length>1) { if (vals.length > 1) {
queryWrapper.and(j -> { queryWrapper.and(j -> {
log.info("---查询过滤器Query规则---field:{}, rule:{}, value:{}", field, "like", vals[0]); log.info("---查询过滤器Query规则---field:{}, rule:{}, value:{}", field, "like", vals[0]);
j = j.like(field,vals[0]); j = j.like(field, vals[0]);
for (int k=1;k<vals.length;k++) { for (int k = 1; k < vals.length; k++) {
j = j.or().like(field,vals[k]); j = j.or().like(field, vals[k]);
log.info("---查询过滤器Query规则 .or()---field:{}, rule:{}, value:{}", field, "like", vals[k]); log.info("---查询过滤器Query规则 .or()---field:{}, rule:{}, value:{}", field, "like", vals[k]);
} }
//return j; //return j;
}); });
}else { } else {
log.info("---查询过滤器Query规则---field:{}, rule:{}, value:{}", field, "like", vals[0]); log.info("---查询过滤器Query规则---field:{}, rule:{}, value:{}", field, "like", vals[0]);
queryWrapper.and(j -> j.like(field,vals[0])); queryWrapper.and(j -> j.like(field, vals[0]));
} }
}else { } else {
//update-begin---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------ //update-begin---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------
QueryRuleEnum rule; QueryRuleEnum rule;
if(null != customRuleMap && customRuleMap.containsKey(name)) { if (null != customRuleMap && customRuleMap.containsKey(name)) {
// 有自定义规则,使用自定义规则. // 有自定义规则,使用自定义规则.
rule = customRuleMap.get(name); rule = customRuleMap.get(name);
}else { } else {
//根据参数值带什么关键字符串判断走什么类型的查询 //根据参数值带什么关键字符串判断走什么类型的查询
rule = convert2Rule(value); rule = convert2Rule(value);
} }
//update-end---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------ //update-end---author:chenrui ---date:20240527 for[TV360X-378]增加自定义字段查询规则功能------------
value = replaceValue(rule,value); value = replaceValue(rule, value);
// add -begin 添加判断为字符串时设为全模糊查询 // add -begin 添加判断为字符串时设为全模糊查询
//if( (rule==null || QueryRuleEnum.EQ.equals(rule)) && "class java.lang.String".equals(type)) { //if( (rule==null || QueryRuleEnum.EQ.equals(rule)) && "class java.lang.String".equals(type)) {
// 可以设置左右模糊或全模糊,因人而异 // 可以设置左右模糊或全模糊,因人而异
@@ -223,6 +245,7 @@ public class QueryGenerator {
/** /**
* 区间查询 * 区间查询
*
* @param queryWrapper query对象 * @param queryWrapper query对象
* @param parameterMap 参数map * @param parameterMap 参数map
* @param type 字段类型 * @param type 字段类型
@@ -231,7 +254,7 @@ public class QueryGenerator {
*/ */
private static void doIntervalQuery(QueryWrapper<?> queryWrapper, Map<String, String[]> parameterMap, String type, String filedName, String columnName) throws ParseException { private static void doIntervalQuery(QueryWrapper<?> queryWrapper, Map<String, String[]> parameterMap, String type, String filedName, String columnName) throws ParseException {
// 添加 判断是否有区间值 // 添加 判断是否有区间值
String endValue = null,beginValue = null; String endValue = null, beginValue = null;
if (parameterMap != null && parameterMap.containsKey(filedName + BEGIN)) { if (parameterMap != null && parameterMap.containsKey(filedName + BEGIN)) {
beginValue = parameterMap.get(filedName + BEGIN)[0].trim(); beginValue = parameterMap.get(filedName + BEGIN)[0].trim();
addQueryByRule(queryWrapper, columnName, type, beginValue, QueryRuleEnum.GE); addQueryByRule(queryWrapper, columnName, type, beginValue, QueryRuleEnum.GE);
@@ -244,24 +267,24 @@ public class QueryGenerator {
//多值查询 //多值查询
if (parameterMap != null && parameterMap.containsKey(filedName + MULTI)) { if (parameterMap != null && parameterMap.containsKey(filedName + MULTI)) {
endValue = parameterMap.get(filedName + MULTI)[0].trim(); endValue = parameterMap.get(filedName + MULTI)[0].trim();
addQueryByRule(queryWrapper, columnName.replace(MULTI,""), type, endValue, QueryRuleEnum.IN); addQueryByRule(queryWrapper, columnName.replace(MULTI, ""), type, endValue, QueryRuleEnum.IN);
} }
} }
private static void doMultiFieldsOrder(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap, Map<String,String> fieldColumnMap) { private static void doMultiFieldsOrder(QueryWrapper<?> queryWrapper, Map<String, String[]> parameterMap, Map<String, String> fieldColumnMap) {
Set<String> allFields = fieldColumnMap.keySet(); Set<String> allFields = fieldColumnMap.keySet();
String column=null,order=null; String column = null, order = null;
if(parameterMap!=null&& parameterMap.containsKey(ORDER_COLUMN)) { if (parameterMap != null && parameterMap.containsKey(ORDER_COLUMN)) {
column = parameterMap.get(ORDER_COLUMN)[0]; column = parameterMap.get(ORDER_COLUMN)[0];
} }
if(parameterMap!=null&& parameterMap.containsKey(ORDER_TYPE)) { if (parameterMap != null && parameterMap.containsKey(ORDER_TYPE)) {
order = parameterMap.get(ORDER_TYPE)[0]; order = parameterMap.get(ORDER_TYPE)[0];
} }
log.debug("排序规则>>列:" + column + ",排序方式:" + order); log.debug("排序规则>>列:" + column + ",排序方式:" + order);
//update-begin-author:scott date:2022-11-07 for:避免用户自定义表无默认字段{创建时间},导致排序报错 //update-begin-author:scott date:2022-11-07 for:避免用户自定义表无默认字段{创建时间},导致排序报错
//TODO 避免用户自定义表无默认字段创建时间,导致排序报错 //TODO 避免用户自定义表无默认字段创建时间,导致排序报错
if(DataBaseConstant.CREATE_TIME.equals(column) && !fieldColumnMap.containsKey(DataBaseConstant.CREATE_TIME)){ if (DataBaseConstant.CREATE_TIME.equals(column) && !fieldColumnMap.containsKey(DataBaseConstant.CREATE_TIME)) {
column = "id"; column = "id";
log.warn("检测到实体里没有字段createTime改成采用ID排序"); log.warn("检测到实体里没有字段createTime改成采用ID排序");
} }
@@ -269,13 +292,13 @@ public class QueryGenerator {
if (oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) { if (oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
//字典字段,去掉字典翻译文本后缀 //字典字段,去掉字典翻译文本后缀
if(column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) {
column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX));
} }
//update-begin-author:taoyan date:2022-5-16 for: issues/3676 获取系统用户列表时使用SQL注入生效 //update-begin-author:taoyan date:2022-5-16 for: issues/3676 获取系统用户列表时使用SQL注入生效
//判断column是不是当前实体的 //判断column是不是当前实体的
log.debug("当前字段有:"+ allFields); log.debug("当前字段有:" + allFields);
if (!allColumnExist(column, allFields)) { if (!allColumnExist(column, allFields)) {
throw new JeecgBootException("请注意,将要排序的列字段不存在:" + column); throw new JeecgBootException("请注意,将要排序的列字段不存在:" + column);
} }
@@ -289,7 +312,7 @@ public class QueryGenerator {
if (oConvertUtils.isNotEmpty(columnStrNew)) { if (oConvertUtils.isNotEmpty(columnStrNew)) {
column = columnStrNew; column = columnStrNew;
} }
}else{ } else {
column = fieldColumnMap.get(column); column = fieldColumnMap.get(column);
} }
//update-end-author:scott date:2022-10-10 for:【jeecg-boot/issues/I5FJU6】doMultiFieldsOrder() 多字段排序方法存在问题 //update-end-author:scott date:2022-10-10 for:【jeecg-boot/issues/I5FJU6】doMultiFieldsOrder() 多字段排序方法存在问题
@@ -301,7 +324,7 @@ public class QueryGenerator {
// 排序规则修改 // 排序规则修改
// 将现有排序 _ 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1,column2 desc" // 将现有排序 _ 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1,column2 desc"
// 修改为 _ 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1 desc,column2 desc" // 修改为 _ 前端传递排序条件{....,column: 'column1,column2',order: 'desc'} 翻译成sql "column1 desc,column2 desc"
if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) { if (order.toUpperCase().indexOf(ORDER_TYPE_ASC) >= 0) {
queryWrapper.orderByAsc(SqlInjectionUtil.getSqlInjectSortFields(column.split(","))); queryWrapper.orderByAsc(SqlInjectionUtil.getSqlInjectSortFields(column.split(",")));
} else { } else {
queryWrapper.orderByDesc(SqlInjectionUtil.getSqlInjectSortFields(column.split(","))); queryWrapper.orderByDesc(SqlInjectionUtil.getSqlInjectSortFields(column.split(",")));
@@ -311,21 +334,23 @@ public class QueryGenerator {
} }
//update-begin-author:taoyan date:2022-5-23 for: issues/3676 获取系统用户列表时使用SQL注入生效 //update-begin-author:taoyan date:2022-5-23 for: issues/3676 获取系统用户列表时使用SQL注入生效
/** /**
* 多字段排序 判断所传字段是否存在 * 多字段排序 判断所传字段是否存在
*
* @return * @return
*/ */
private static boolean allColumnExist(String columnStr, Set<String> allFields){ private static boolean allColumnExist(String columnStr, Set<String> allFields) {
boolean exist = true; boolean exist = true;
if(columnStr.indexOf(COMMA)>=0){ if (columnStr.indexOf(COMMA) >= 0) {
String[] arr = columnStr.split(COMMA); String[] arr = columnStr.split(COMMA);
for(String column: arr){ for (String column : arr) {
if(!allFields.contains(column)){ if (!allFields.contains(column)) {
exist = false; exist = false;
break; break;
} }
} }
}else{ } else {
exist = allFields.contains(columnStr); exist = allFields.contains(columnStr);
} }
return exist; return exist;
@@ -334,12 +359,13 @@ public class QueryGenerator {
/** /**
* 高级查询 * 高级查询
*
* @param queryWrapper 查询对象 * @param queryWrapper 查询对象
* @param parameterMap 参数对象 * @param parameterMap 参数对象
* @param fieldColumnMap 实体字段和数据库列对应的map * @param fieldColumnMap 实体字段和数据库列对应的map
*/ */
private static void doSuperQuery(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap, Map<String,String> fieldColumnMap) { private static void doSuperQuery(QueryWrapper<?> queryWrapper, Map<String, String[]> parameterMap, Map<String, String> fieldColumnMap) {
if(parameterMap!=null&& parameterMap.containsKey(SUPER_QUERY_PARAMS)){ if (parameterMap != null && parameterMap.containsKey(SUPER_QUERY_PARAMS)) {
String superQueryParams = parameterMap.get(SUPER_QUERY_PARAMS)[0]; String superQueryParams = parameterMap.get(SUPER_QUERY_PARAMS)[0];
String superQueryMatchType = parameterMap.get(SUPER_QUERY_MATCH_TYPE) != null ? parameterMap.get(SUPER_QUERY_MATCH_TYPE)[0] : MatchTypeEnum.AND.getValue(); String superQueryMatchType = parameterMap.get(SUPER_QUERY_MATCH_TYPE) != null ? parameterMap.get(SUPER_QUERY_MATCH_TYPE)[0] : MatchTypeEnum.AND.getValue();
MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType); MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType);
@@ -373,9 +399,9 @@ public class QueryGenerator {
//update-begin-author:taoyan date:20201228 for: 【高级查询】 oracle 日期等于查询报错 //update-begin-author:taoyan date:20201228 for: 【高级查询】 oracle 日期等于查询报错
Object queryValue = rule.getVal(); Object queryValue = rule.getVal();
if("date".equals(rule.getType())){ if ("date".equals(rule.getType())) {
queryValue = DateUtils.str2Date(rule.getVal(),DateUtils.date_sdf.get()); queryValue = DateUtils.str2Date(rule.getVal(), DateUtils.date_sdf.get());
}else if("datetime".equals(rule.getType())){ } else if ("datetime".equals(rule.getType())) {
queryValue = DateUtils.str2Date(rule.getVal(), DateUtils.datetimeFormat.get()); queryValue = DateUtils.str2Date(rule.getVal(), DateUtils.datetimeFormat.get());
} }
// update-begin--author:sunjianlei date:20210702 for【/issues/I3VR8E】高级查询没有类型转换查询参数都是字符串类型 ---- // update-begin--author:sunjianlei date:20210702 for【/issues/I3VR8E】高级查询没有类型转换查询参数都是字符串类型 ----
@@ -433,9 +459,11 @@ public class QueryGenerator {
} }
//log.info(" superQuery getCustomSqlSegment: "+ queryWrapper.getCustomSqlSegment()); //log.info(" superQuery getCustomSqlSegment: "+ queryWrapper.getCustomSqlSegment());
} }
/** /**
* 根据所传的值 转化成对应的比较方式 * 根据所传的值 转化成对应的比较方式
* 支持><= like in ! * 支持><= like in !
*
* @param value * @param value
* @return * @return
*/ */
@@ -450,7 +478,7 @@ public class QueryGenerator {
return QueryRuleEnum.EQ; return QueryRuleEnum.EQ;
} }
// update-end-author:taoyan date:20210629 for: 查询条件输入空格导致return null后续判断导致抛出null异常 // update-end-author:taoyan date:20210629 for: 查询条件输入空格导致return null后续判断导致抛出null异常
QueryRuleEnum rule =null; QueryRuleEnum rule = null;
//update-begin--Author:scott Date:20190724 forinitQueryWrapper组装sql查询条件错误 #284------------------- //update-begin--Author:scott Date:20190724 forinitQueryWrapper组装sql查询条件错误 #284-------------------
//TODO 此处规则,只适用于 le lt ge gt //TODO 此处规则,只适用于 le lt ge gt
@@ -458,13 +486,13 @@ public class QueryGenerator {
int length2 = 2; int length2 = 2;
int length3 = 3; int length3 = 3;
if (rule == null && val.length() >= length3) { if (rule == null && val.length() >= length3) {
if(QUERY_SEPARATE_KEYWORD.equals(val.substring(length2, length3))){ if (QUERY_SEPARATE_KEYWORD.equals(val.substring(length2, length3))) {
rule = QueryRuleEnum.getByValue(val.substring(0, 2)); rule = QueryRuleEnum.getByValue(val.substring(0, 2));
} }
} }
// step 1 .> < // step 1 .> <
if (rule == null && val.length() >= length2) { if (rule == null && val.length() >= length2) {
if(QUERY_SEPARATE_KEYWORD.equals(val.substring(1, length2))){ if (QUERY_SEPARATE_KEYWORD.equals(val.substring(1, length2))) {
rule = QueryRuleEnum.getByValue(val.substring(0, 1)); rule = QueryRuleEnum.getByValue(val.substring(0, 1));
} }
} }
@@ -472,7 +500,7 @@ public class QueryGenerator {
// step 3 like // step 3 like
//update-begin-author:taoyan for: /issues/3382 默认带*就走模糊,但是如果只有一个*,那么走等于查询 //update-begin-author:taoyan for: /issues/3382 默认带*就走模糊,但是如果只有一个*,那么走等于查询
if(rule == null && val.equals(STAR)){ if (rule == null && val.equals(STAR)) {
rule = QueryRuleEnum.EQ; rule = QueryRuleEnum.EQ;
} }
//update-end-author:taoyan for: /issues/3382 默认带*就走模糊,但是如果只有一个*,那么走等于查询 //update-end-author:taoyan for: /issues/3382 默认带*就走模糊,但是如果只有一个*,那么走等于查询
@@ -481,7 +509,7 @@ public class QueryGenerator {
rule = QueryRuleEnum.LIKE; rule = QueryRuleEnum.LIKE;
} else if (val.startsWith(STAR)) { } else if (val.startsWith(STAR)) {
rule = QueryRuleEnum.LEFT_LIKE; rule = QueryRuleEnum.LEFT_LIKE;
} else if(val.endsWith(STAR)){ } else if (val.endsWith(STAR)) {
rule = QueryRuleEnum.RIGHT_LIKE; rule = QueryRuleEnum.RIGHT_LIKE;
} }
} }
@@ -492,17 +520,17 @@ public class QueryGenerator {
rule = QueryRuleEnum.IN; rule = QueryRuleEnum.IN;
} }
// step 5 != // step 5 !=
if(rule == null && val.startsWith(NOT_EQUAL)){ if (rule == null && val.startsWith(NOT_EQUAL)) {
rule = QueryRuleEnum.NE; rule = QueryRuleEnum.NE;
} }
// step 6 xx+xx+xx 这种情况适用于如果想要用逗号作精确查询 但是系统默认逗号走in 所以可以用++替换【此逻辑作废】 // step 6 xx+xx+xx 这种情况适用于如果想要用逗号作精确查询 但是系统默认逗号走in 所以可以用++替换【此逻辑作废】
if(rule == null && val.indexOf(QUERY_COMMA_ESCAPE)>0){ if (rule == null && val.indexOf(QUERY_COMMA_ESCAPE) > 0) {
rule = QueryRuleEnum.EQ_WITH_ADD; rule = QueryRuleEnum.EQ_WITH_ADD;
} }
//update-begin--Author:taoyan Date:20201229 forinitQueryWrapper组装sql查询条件错误 #284--------------------- //update-begin--Author:taoyan Date:20201229 forinitQueryWrapper组装sql查询条件错误 #284---------------------
//特殊处理Oracle的表达式to_date('xxx','yyyy-MM-dd')含有逗号会被识别为in查询转为等于查询 //特殊处理Oracle的表达式to_date('xxx','yyyy-MM-dd')含有逗号会被识别为in查询转为等于查询
if(rule == QueryRuleEnum.IN && val.indexOf(YYYY_MM_DD)>=0 && val.indexOf(TO_DATE)>=0){ if (rule == QueryRuleEnum.IN && val.indexOf(YYYY_MM_DD) >= 0 && val.indexOf(TO_DATE) >= 0) {
rule = QueryRuleEnum.EQ; rule = QueryRuleEnum.EQ;
} }
//update-end--Author:taoyan Date:20201229 forinitQueryWrapper组装sql查询条件错误 #284--------------------- //update-end--Author:taoyan Date:20201229 forinitQueryWrapper组装sql查询条件错误 #284---------------------
@@ -521,12 +549,12 @@ public class QueryGenerator {
if (rule == null) { if (rule == null) {
return null; return null;
} }
if (! (value instanceof String)){ if (!(value instanceof String)) {
return value; return value;
} }
String val = (value + "").toString().trim(); String val = (value + "").toString().trim();
//update-begin-author:taoyan date:20220302 for: 查询条件的值为等号(=bug #3443 //update-begin-author:taoyan date:20220302 for: 查询条件的值为等号(=bug #3443
if(QueryRuleEnum.EQ.getValue().equals(val)){ if (QueryRuleEnum.EQ.getValue().equals(val)) {
return val; return val;
} }
//update-end-author:taoyan date:20220302 for: 查询条件的值为等号(=bug #3443 //update-end-author:taoyan date:20220302 for: 查询条件的值为等号(=bug #3443
@@ -546,24 +574,24 @@ public class QueryGenerator {
value = val.split(","); value = val.split(",");
} else if (rule == QueryRuleEnum.EQ_WITH_ADD) { } else if (rule == QueryRuleEnum.EQ_WITH_ADD) {
value = val.replaceAll("\\+\\+", COMMA); value = val.replaceAll("\\+\\+", COMMA);
}else { } else {
//update-begin--Author:scott Date:20190724 forinitQueryWrapper组装sql查询条件错误 #284------------------- //update-begin--Author:scott Date:20190724 forinitQueryWrapper组装sql查询条件错误 #284-------------------
if(val.startsWith(rule.getValue())){ if (val.startsWith(rule.getValue())) {
//TODO 此处逻辑应该注释掉-> 如果查询内容中带有查询匹配规则符号,就会被截取的(比如:>=您好) //TODO 此处逻辑应该注释掉-> 如果查询内容中带有查询匹配规则符号,就会被截取的(比如:>=您好)
value = val.replaceFirst(rule.getValue(),""); value = val.replaceFirst(rule.getValue(), "");
}else if(val.startsWith(rule.getCondition()+QUERY_SEPARATE_KEYWORD)){ } else if (val.startsWith(rule.getCondition() + QUERY_SEPARATE_KEYWORD)) {
value = val.replaceFirst(rule.getCondition()+QUERY_SEPARATE_KEYWORD,"").trim(); value = val.replaceFirst(rule.getCondition() + QUERY_SEPARATE_KEYWORD, "").trim();
} }
//update-end--Author:scott Date:20190724 forinitQueryWrapper组装sql查询条件错误 #284------------------- //update-end--Author:scott Date:20190724 forinitQueryWrapper组装sql查询条件错误 #284-------------------
} }
return value; return value;
} }
private static void addQueryByRule(QueryWrapper<?> queryWrapper,String name,String type,String value,QueryRuleEnum rule) throws ParseException { private static void addQueryByRule(QueryWrapper<?> queryWrapper, String name, String type, String value, QueryRuleEnum rule) throws ParseException {
if(oConvertUtils.isNotEmpty(value)) { if (oConvertUtils.isNotEmpty(value)) {
//update-begin--Author:sunjianlei Date:20220104 for【JTC-409】修复逗号分割情况下没有转换类型导致类型严格的数据库查询报错 ------------------- //update-begin--Author:sunjianlei Date:20220104 for【JTC-409】修复逗号分割情况下没有转换类型导致类型严格的数据库查询报错 -------------------
// 针对数字类型字段,多值查询 // 针对数字类型字段,多值查询
if(value.contains(COMMA)){ if (value.contains(COMMA)) {
Object[] temp = Arrays.stream(value.split(COMMA)).map(v -> { Object[] temp = Arrays.stream(value.split(COMMA)).map(v -> {
try { try {
return QueryGenerator.parseByType(v, type, rule); return QueryGenerator.parseByType(v, type, rule);
@@ -583,6 +611,7 @@ public class QueryGenerator {
/** /**
* 根据类型转换给定的值 * 根据类型转换给定的值
*
* @param value * @param value
* @param type * @param type
* @param rule * @param rule
@@ -622,25 +651,26 @@ public class QueryGenerator {
/** /**
* 获取日期类型的值 * 获取日期类型的值
*
* @param value * @param value
* @param rule * @param rule
* @return * @return
* @throws ParseException * @throws ParseException
*/ */
private static Date getDateQueryByRule(String value,QueryRuleEnum rule) throws ParseException { private static Date getDateQueryByRule(String value, QueryRuleEnum rule) throws ParseException {
Date date = null; Date date = null;
int length = 10; int length = 10;
if(value.length()==length) { if (value.length() == length) {
if(rule==QueryRuleEnum.GE) { if (rule == QueryRuleEnum.GE) {
//比较大于 //比较大于
date = getTime().parse(value + " 00:00:00"); date = getTime().parse(value + " 00:00:00");
}else if(rule==QueryRuleEnum.LE) { } else if (rule == QueryRuleEnum.LE) {
//比较小于 //比较小于
date = getTime().parse(value + " 23:59:59"); date = getTime().parse(value + " 23:59:59");
} }
//TODO 日期类型比较特殊 可能oracle下不一定好使 //TODO 日期类型比较特殊 可能oracle下不一定好使
} }
if(date==null) { if (date == null) {
date = getTime().parse(value); date = getTime().parse(value);
} }
return date; return date;
@@ -648,17 +678,18 @@ public class QueryGenerator {
/** /**
* 根据规则走不同的查询 * 根据规则走不同的查询
*
* @param queryWrapper QueryWrapper * @param queryWrapper QueryWrapper
* @param name 字段名字 * @param name 字段名字
* @param rule 查询规则 * @param rule 查询规则
* @param value 查询条件值 * @param value 查询条件值
*/ */
public static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) { public static void addEasyQuery(QueryWrapper<?> queryWrapper, String name, QueryRuleEnum rule, Object value) {
if (name==null || value == null || rule == null || oConvertUtils.isEmpty(value)) { if (name == null || value == null || rule == null || oConvertUtils.isEmpty(value)) {
return; return;
} }
name = oConvertUtils.camelToUnderline(name); name = oConvertUtils.camelToUnderline(name);
log.debug("---高级查询 Query规则---field:{} , rule:{} , value:{}",name,rule.getValue(),value); log.debug("---高级查询 Query规则---field:{} , rule:{} , value:{}", name, rule.getValue(), value);
switch (rule) { switch (rule) {
case GT: case GT:
queryWrapper.gt(name, value); queryWrapper.gt(name, value);
@@ -680,15 +711,15 @@ public class QueryGenerator {
queryWrapper.ne(name, value); queryWrapper.ne(name, value);
break; break;
case IN: case IN:
if(value instanceof String) { if (value instanceof String) {
queryWrapper.in(name, (Object[])value.toString().split(COMMA)); queryWrapper.in(name, (Object[]) value.toString().split(COMMA));
}else if(value instanceof String[]) { } else if (value instanceof String[]) {
queryWrapper.in(name, (Object[]) value); queryWrapper.in(name, (Object[]) value);
} }
//update-begin-author:taoyan date:20200909 for:【bug】in 类型多值查询 不适配postgresql #1671 //update-begin-author:taoyan date:20200909 for:【bug】in 类型多值查询 不适配postgresql #1671
else if(value.getClass().isArray()) { else if (value.getClass().isArray()) {
queryWrapper.in(name, (Object[])value); queryWrapper.in(name, (Object[]) value);
}else { } else {
queryWrapper.in(name, value); queryWrapper.in(name, value);
} }
//update-end-author:taoyan date:20200909 for:【bug】in 类型多值查询 不适配postgresql #1671 //update-end-author:taoyan date:20200909 for:【bug】in 类型多值查询 不适配postgresql #1671
@@ -738,8 +769,8 @@ public class QueryGenerator {
break; break;
} }
} }
/** /**
*
* @param name * @param name
* @return * @return
*/ */
@@ -750,9 +781,9 @@ public class QueryGenerator {
} }
/** /**
* 获取请求对应的数据权限规则 TODO 相同列权限多个 有问题 * 获取请求对应的数据权限规则 TODO 相同列权限多个 有问题
*
* @return * @return
*/ */
public static Map<String, SysPermissionDataRuleModel> getRuleMap() { public static Map<String, SysPermissionDataRuleModel> getRuleMap() {
@@ -761,18 +792,18 @@ public class QueryGenerator {
//update-begin-author:taoyan date:2023-6-1 for:QQYUN-5441 【简流】获取多个用户/部门/角色 设置部门查询 报错 //update-begin-author:taoyan date:2023-6-1 for:QQYUN-5441 【简流】获取多个用户/部门/角色 设置部门查询 报错
try { try {
list = JeecgDataAutorUtils.loadDataSearchConditon(); list = JeecgDataAutorUtils.loadDataSearchConditon();
}catch (Exception e){ } catch (Exception e) {
log.error("根据request对象获取权限数据失败可能是定时任务中执行的。", e); log.error("根据request对象获取权限数据失败可能是定时任务中执行的。", e);
} }
//update-end-author:taoyan date:2023-6-1 for:QQYUN-5441 【简流】获取多个用户/部门/角色 设置部门查询 报错 //update-end-author:taoyan date:2023-6-1 for:QQYUN-5441 【简流】获取多个用户/部门/角色 设置部门查询 报错
if(list != null&&list.size()>0){ if (list != null && list.size() > 0) {
if(list.get(0)==null){ if (list.get(0) == null) {
return ruleMap; return ruleMap;
} }
for (SysPermissionDataRuleModel rule : list) { for (SysPermissionDataRuleModel rule : list) {
String column = rule.getRuleColumn(); String column = rule.getRuleColumn();
if(QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) { if (QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) {
column = SQL_RULES_COLUMN+rule.getId(); column = SQL_RULES_COLUMN + rule.getId();
} }
ruleMap.put(column, rule); ruleMap.put(column, rule);
} }
@@ -782,40 +813,40 @@ public class QueryGenerator {
private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) { private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) {
QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions());
if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) { if (rule.equals(QueryRuleEnum.IN) && !propertyType.equals(String.class)) {
String[] values = dataRule.getRuleValue().split(","); String[] values = dataRule.getRuleValue().split(",");
Object[] objs = new Object[values.length]; Object[] objs = new Object[values.length];
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
objs[i] = NumberUtils.parseNumber(values[i], propertyType); objs[i] = NumberUtils.parseNumber(values[i], propertyType);
} }
addEasyQuery(queryWrapper, name, rule, objs); addEasyQuery(queryWrapper, name, rule, objs);
}else { } else {
if (propertyType.equals(String.class)) { if (propertyType.equals(String.class)) {
addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue())); addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue()));
}else if (propertyType.equals(Date.class)) { } else if (propertyType.equals(Date.class)) {
String dateStr =converRuleValue(dataRule.getRuleValue()); String dateStr = converRuleValue(dataRule.getRuleValue());
int length = 10; int length = 10;
if(dateStr.length()==length){ if (dateStr.length() == length) {
addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.date_sdf.get())); addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr, DateUtils.date_sdf.get()));
}else{ } else {
addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.datetimeFormat.get())); addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr, DateUtils.datetimeFormat.get()));
} }
}else { } else {
addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType)); addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType));
} }
} }
} }
public static String converRuleValue(String ruleValue) { public static String converRuleValue(String ruleValue) {
String value = JwtUtil.getUserSystemData(ruleValue,null); String value = JwtUtil.getUserSystemData(ruleValue, null);
return value!= null ? value : ruleValue; return value != null ? value : ruleValue;
} }
/** /**
* @param ruleValue:
* @author: scott * @author: scott
* @Description: 去掉值前后单引号 * @Description: 去掉值前后单引号
* @date: 2020/3/19 21:26 * @date: 2020/3/19 21:26
* @param ruleValue:
* @Return: java.lang.String * @Return: java.lang.String
*/ */
public static String trimSingleQuote(String ruleValue) { public static String trimSingleQuote(String ruleValue) {
@@ -831,12 +862,12 @@ public class QueryGenerator {
return ruleValue; return ruleValue;
} }
public static String getSqlRuleValue(String sqlRule){ public static String getSqlRuleValue(String sqlRule) {
try { try {
Set<String> varParams = getSqlRuleParams(sqlRule); Set<String> varParams = getSqlRuleParams(sqlRule);
for(String var:varParams){ for (String var : varParams) {
String tempValue = converRuleValue(var); String tempValue = converRuleValue(var);
sqlRule = sqlRule.replace("#{"+var+"}",tempValue); sqlRule = sqlRule.replace("#{" + var + "}", tempValue);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@@ -848,7 +879,7 @@ public class QueryGenerator {
* 获取sql中的#{key} 这个key组成的set * 获取sql中的#{key} 这个key组成的set
*/ */
public static Set<String> getSqlRuleParams(String sql) { public static Set<String> getSqlRuleParams(String sql) {
if(oConvertUtils.isEmpty(sql)){ if (oConvertUtils.isEmpty(sql)) {
return null; return null;
} }
Set<String> varParams = new HashSet<String>(); Set<String> varParams = new HashSet<String>();
@@ -856,40 +887,42 @@ public class QueryGenerator {
Pattern p = Pattern.compile(regex); Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(sql); Matcher m = p.matcher(sql);
while(m.find()){ while (m.find()) {
String var = m.group(); String var = m.group();
varParams.add(var.substring(var.indexOf("{")+1,var.indexOf("}"))); varParams.add(var.substring(var.indexOf("{") + 1, var.indexOf("}")));
} }
return varParams; return varParams;
} }
/** /**
* 获取查询条件 * 获取查询条件
*
* @param field * @param field
* @param alias * @param alias
* @param value * @param value
* @param isString * @param isString
* @return * @return
*/ */
public static String getSingleQueryConditionSql(String field,String alias,Object value,boolean isString) { public static String getSingleQueryConditionSql(String field, String alias, Object value, boolean isString) {
return SqlConcatUtil.getSingleQueryConditionSql(field, alias, value, isString,null); return SqlConcatUtil.getSingleQueryConditionSql(field, alias, value, isString, null);
} }
/** /**
* 根据权限相关配置生成相关的SQL 语句 * 根据权限相关配置生成相关的SQL 语句
*
* @param clazz * @param clazz
* @return * @return
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({"unchecked", "rawtypes"})
public static String installAuthJdbc(Class<?> clazz) { public static String installAuthJdbc(Class<?> clazz) {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
//权限查询 //权限查询
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); Map<String, SysPermissionDataRuleModel> ruleMap = getRuleMap();
PropertyDescriptor[] origDescriptors = PropertyUtils.getPropertyDescriptors(clazz); PropertyDescriptor[] origDescriptors = PropertyUtils.getPropertyDescriptors(clazz);
String sqlAnd = " and "; String sqlAnd = " and ";
for (String c : ruleMap.keySet()) { for (String c : ruleMap.keySet()) {
if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ if (oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)) {
sb.append(sqlAnd+getSqlRuleValue(ruleMap.get(c).getRuleValue())); sb.append(sqlAnd + getSqlRuleValue(ruleMap.get(c).getRuleValue()));
} }
} }
String name, column; String name, column;
@@ -898,9 +931,9 @@ public class QueryGenerator {
if (judgedIsUselessField(name)) { if (judgedIsUselessField(name)) {
continue; continue;
} }
if(ruleMap.containsKey(name)) { if (ruleMap.containsKey(name)) {
column = ReflectHelper.getTableFieldName(clazz, name); column = ReflectHelper.getTableFieldName(clazz, name);
if(column==null){ if (column == null) {
continue; continue;
} }
SysPermissionDataRuleModel dataRule = ruleMap.get(name); SysPermissionDataRuleModel dataRule = ruleMap.get(name);
@@ -909,33 +942,34 @@ public class QueryGenerator {
boolean isString = propType.equals(String.class); boolean isString = propType.equals(String.class);
Object value; Object value;
//update-begin---author:chenrui ---date:20240527 for[TV360X-539]数据权限,配置日期等于条件时后端报转换错误------------ //update-begin---author:chenrui ---date:20240527 for[TV360X-539]数据权限,配置日期等于条件时后端报转换错误------------
if(isString || Date.class.equals(propType)) { if (isString || Date.class.equals(propType)) {
//update-end---author:chenrui ---date:20240527 for[TV360X-539]数据权限,配置日期等于条件时后端报转换错误------------ //update-end---author:chenrui ---date:20240527 for[TV360X-539]数据权限,配置日期等于条件时后端报转换错误------------
value = converRuleValue(dataRule.getRuleValue()); value = converRuleValue(dataRule.getRuleValue());
}else { } else {
value = NumberUtils.parseNumber(dataRule.getRuleValue(),propType); value = NumberUtils.parseNumber(dataRule.getRuleValue(), propType);
} }
String filedSql = SqlConcatUtil.getSingleSqlByRule(rule, oConvertUtils.camelToUnderline(column), value,isString); String filedSql = SqlConcatUtil.getSingleSqlByRule(rule, oConvertUtils.camelToUnderline(column), value, isString);
sb.append(sqlAnd+filedSql); sb.append(sqlAnd + filedSql);
} }
} }
log.info("query auth sql is:"+sb.toString()); log.info("query auth sql is:" + sb.toString());
return sb.toString(); return sb.toString();
} }
/** /**
* 根据权限相关配置 组装mp需要的权限 * 根据权限相关配置 组装mp需要的权限
*
* @param queryWrapper * @param queryWrapper
* @param clazz * @param clazz
* @return * @return
*/ */
public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) { public static void installAuthMplus(QueryWrapper<?> queryWrapper, Class<?> clazz) {
//权限查询 //权限查询
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); Map<String, SysPermissionDataRuleModel> ruleMap = getRuleMap();
PropertyDescriptor[] origDescriptors = PropertyUtils.getPropertyDescriptors(clazz); PropertyDescriptor[] origDescriptors = PropertyUtils.getPropertyDescriptors(clazz);
for (String c : ruleMap.keySet()) { for (String c : ruleMap.keySet()) {
if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ if (oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)) {
queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); queryWrapper.and(i -> i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue())));
} }
} }
String name, column; String name, column;
@@ -945,10 +979,10 @@ public class QueryGenerator {
continue; continue;
} }
column = ReflectHelper.getTableFieldName(clazz, name); column = ReflectHelper.getTableFieldName(clazz, name);
if(column==null){ if (column == null) {
continue; continue;
} }
if(ruleMap.containsKey(name)) { if (ruleMap.containsKey(name)) {
addRuleToQueryWrapper(ruleMap.get(name), column, origDescriptors[i].getPropertyType(), queryWrapper); addRuleToQueryWrapper(ruleMap.get(name), column, origDescriptors[i].getPropertyType(), queryWrapper);
} }
} }
@@ -956,17 +990,18 @@ public class QueryGenerator {
/** /**
* 转换sql中的系统变量 * 转换sql中的系统变量
*
* @param sql * @param sql
* @return * @return
*/ */
public static String convertSystemVariables(String sql){ public static String convertSystemVariables(String sql) {
return getSqlRuleValue(sql); return getSqlRuleValue(sql);
} }
/** /**
* 获取系统数据库类型 * 获取系统数据库类型
*/ */
private static String getDbType(){ private static String getDbType() {
return CommonUtils.getDatabaseType(); return CommonUtils.getDatabaseType();
} }
@@ -980,7 +1015,7 @@ public class QueryGenerator {
if (DataBaseConstant.DB_TYPE_MYSQL.equals(getDbType()) || DataBaseConstant.DB_TYPE_MARIADB.equals(getDbType())) { if (DataBaseConstant.DB_TYPE_MYSQL.equals(getDbType()) || DataBaseConstant.DB_TYPE_MARIADB.equals(getDbType())) {
String[] specialStr = QueryGenerator.LIKE_MYSQL_SPECIAL_STRS.split(","); String[] specialStr = QueryGenerator.LIKE_MYSQL_SPECIAL_STRS.split(",");
for (String str : specialStr) { for (String str : specialStr) {
if (value.indexOf(str) !=-1) { if (value.indexOf(str) != -1) {
value = value.replace(str, "\\" + str); value = value.replace(str, "\\" + str);
} }
} }

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;
@@ -100,12 +151,12 @@ public enum QueryRuleEnum {
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;
} }
} }

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,7 +14,6 @@ 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 {
@@ -33,8 +32,8 @@ public class JeecgDataAutorUtils {
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>();
} }
@@ -74,12 +73,13 @@ public class JeecgDataAutorUtils {
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 request
* @param userinfo * @param userinfo
*/ */
@@ -89,6 +89,7 @@ public class JeecgDataAutorUtils {
/** /**
* 将用户信息存到request * 将用户信息存到request
*
* @param userinfo * @param userinfo
*/ */
public static synchronized void installUserInfo(SysUserCacheInfo userinfo) { public static synchronized void installUserInfo(SysUserCacheInfo userinfo) {
@@ -97,6 +98,7 @@ public class JeecgDataAutorUtils {
/** /**
* 从request获取用户信息 * 从request获取用户信息
*
* @return * @return
*/ */
public static synchronized SysUserCacheInfo loadUserInfo() { public static synchronized SysUserCacheInfo loadUserInfo() {

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,12 +37,13 @@ import org.jeecg.common.util.oConvertUtils;
@Slf4j @Slf4j
public class JwtUtil { public class JwtUtil {
/**Token有效期为7天Token在reids中缓存时间为两倍*/ /**
* Token有效期为7天Token在reids中缓存时间为两倍
*/
public static final long EXPIRE_TIME = (7 * 12) * 60 * 60 * 1000; public static final long EXPIRE_TIME = (7 * 12) * 60 * 60 * 1000;
static final String WELL_NUMBER = SymbolConstant.WELL_NUMBER + SymbolConstant.LEFT_CURLY_BRACKET; static final String WELL_NUMBER = SymbolConstant.WELL_NUMBER + SymbolConstant.LEFT_CURLY_BRACKET;
/** /**
*
* @param response * @param response
* @param code * @param code
* @param errorMsg * @param errorMsg
@@ -134,6 +134,7 @@ public class JwtUtil {
/** /**
* 从session中获取变量 * 从session中获取变量
*
* @param key * @param key
* @return * @return
*/ */
@@ -143,31 +144,34 @@ public class JwtUtil {
String moshi = ""; String moshi = "";
String wellNumber = WELL_NUMBER; String wellNumber = WELL_NUMBER;
if(key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET)!=-1){ if (key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET) != -1) {
moshi = key.substring(key.indexOf("}")+1); moshi = key.substring(key.indexOf("}") + 1);
} }
String returnValue = null; String returnValue = null;
if (key.contains(wellNumber)) { if (key.contains(wellNumber)) {
key = key.substring(2,key.indexOf("}")); key = key.substring(2, key.indexOf("}"));
} }
if (oConvertUtils.isNotEmpty(key)) { if (oConvertUtils.isNotEmpty(key)) {
HttpSession session = SpringContextUtils.getHttpServletRequest().getSession(); HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
returnValue = (String) session.getAttribute(key); returnValue = (String) session.getAttribute(key);
} }
//结果加上${} 后面的值 //结果加上${} 后面的值
if(returnValue!=null){returnValue = returnValue + moshi;} if (returnValue != null) {
returnValue = returnValue + moshi;
}
return returnValue; return returnValue;
} }
/** /**
* 从当前用户中获取变量 * 从当前用户中获取变量
*
* @param key * @param key
* @param user * @param user
* @return * @return
*/ */
public static String getUserSystemData(String key, SysUserCacheInfo user) { public static String getUserSystemData(String key, SysUserCacheInfo user) {
//1.优先获取 SysUserCacheInfo //1.优先获取 SysUserCacheInfo
if(user==null) { if (user == null) {
try { try {
user = JeecgDataAutorUtils.loadUserInfo(); user = JeecgDataAutorUtils.loadUserInfo();
} catch (Exception e) { } catch (Exception e) {
@@ -185,66 +189,66 @@ public class JwtUtil {
//#{sys_user_code}% //#{sys_user_code}%
String moshi = ""; String moshi = "";
String wellNumber = WELL_NUMBER; String wellNumber = WELL_NUMBER;
if(key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET)!=-1){ if (key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET) != -1) {
moshi = key.substring(key.indexOf("}")+1); moshi = key.substring(key.indexOf("}") + 1);
} }
String returnValue = null; String returnValue = null;
//针对特殊标示处理#{sysOrgCode},判断替换 //针对特殊标示处理#{sysOrgCode},判断替换
if (key.contains(wellNumber)) { if (key.contains(wellNumber)) {
key = key.substring(2,key.indexOf("}")); key = key.substring(2, key.indexOf("}"));
} else { } else {
key = key; key = key;
} }
//替换为当前系统时间(年月日) //替换为当前系统时间(年月日)
if (key.equals(DataBaseConstant.SYS_DATE)|| key.toLowerCase().equals(DataBaseConstant.SYS_DATE_TABLE)) { if (key.equals(DataBaseConstant.SYS_DATE) || key.toLowerCase().equals(DataBaseConstant.SYS_DATE_TABLE)) {
returnValue = DateUtils.formatDate(); returnValue = DateUtils.formatDate();
} }
//替换为当前系统时间(年月日时分秒) //替换为当前系统时间(年月日时分秒)
else if (key.equals(DataBaseConstant.SYS_TIME)|| key.toLowerCase().equals(DataBaseConstant.SYS_TIME_TABLE)) { else if (key.equals(DataBaseConstant.SYS_TIME) || key.toLowerCase().equals(DataBaseConstant.SYS_TIME_TABLE)) {
returnValue = DateUtils.now(); returnValue = DateUtils.now();
} }
//流程状态默认值(默认未发起) //流程状态默认值(默认未发起)
else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) { else if (key.equals(DataBaseConstant.BPM_STATUS) || key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) {
returnValue = "1"; returnValue = "1";
} }
//后台任务获取用户信息异常,导致程序中断 //后台任务获取用户信息异常,导致程序中断
if(sysUser==null && user==null){ if (sysUser == null && user == null) {
return null; return null;
} }
//替换为系统登录用户帐号 //替换为系统登录用户帐号
if (key.equals(DataBaseConstant.SYS_USER_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_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.getUsername(); returnValue = sysUser.getUsername();
}else { } else {
returnValue = user.getSysUserCode(); returnValue = user.getSysUserCode();
} }
} }
// 替换为系统登录用户ID // 替换为系统登录用户ID
else if (key.equals(DataBaseConstant.SYS_USER_ID) || key.equalsIgnoreCase(DataBaseConstant.SYS_USER_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.getId(); returnValue = sysUser.getId();
}else { } else {
returnValue = user.getSysUserId(); returnValue = user.getSysUserId();
} }
} }
//替换为系统登录用户真实名字 //替换为系统登录用户真实名字
else if (key.equals(DataBaseConstant.SYS_USER_NAME)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) { else if (key.equals(DataBaseConstant.SYS_USER_NAME) || key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
if(user==null) { if (user == null) {
returnValue = sysUser.getRealname(); returnValue = sysUser.getRealname();
}else { } else {
returnValue = user.getSysUserName(); returnValue = user.getSysUserName();
} }
} }
//替换为系统用户登录所使用的机构编码 //替换为系统用户登录所使用的机构编码
else if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_ORG_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.getOrgCode(); returnValue = sysUser.getOrgCode();
}else { } else {
returnValue = user.getSysOrgCode(); returnValue = user.getSysOrgCode();
} }
} }
@@ -259,14 +263,14 @@ public class JwtUtil {
} }
//替换为系统用户所拥有的所有机构编码 //替换为系统用户所拥有的所有机构编码
else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) { else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) {
if(user==null){ if (user == null) {
//TODO 暂时使用用户登录部门,存在逻辑缺陷,不是用户所拥有的部门 //TODO 暂时使用用户登录部门,存在逻辑缺陷,不是用户所拥有的部门
returnValue = sysUser.getOrgCode(); returnValue = sysUser.getOrgCode();
}else{ } else {
if(user.isOneDepart()) { if (user.isOneDepart()) {
returnValue = user.getSysMultiOrgCode().get(0); returnValue = user.getSysMultiOrgCode().get(0);
}else { } else {
returnValue = Joiner.on(",").join(user.getSysMultiOrgCode()); returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
} }
} }
@@ -282,7 +286,7 @@ public class JwtUtil {
} }
//update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量 //update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量
else if (key.equals(TenantConstant.TENANT_ID) || key.toLowerCase().equals(TenantConstant.TENANT_ID_TABLE)){ else if (key.equals(TenantConstant.TENANT_ID) || key.toLowerCase().equals(TenantConstant.TENANT_ID_TABLE)) {
try { try {
returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID); returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID);
} catch (Exception e) { } catch (Exception e) {
@@ -290,7 +294,9 @@ public class JwtUtil {
} }
} }
//update-end-author:taoyan date:20210330 for:多租户ID作为系统变量 //update-end-author:taoyan date:20210330 for:多租户ID作为系统变量
if(returnValue!=null){returnValue = returnValue + moshi;} if (returnValue != null) {
returnValue = returnValue + moshi;
}
return returnValue; return returnValue;
} }

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,7 +16,7 @@ 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() {
@@ -49,11 +48,13 @@ public class DictModel implements Serializable{
/** /**
* 特殊用途: JgEditableTable * 特殊用途: JgEditableTable
*
* @return * @return
*/ */
public String getTitle() { public String getTitle() {
return this.text; return this.text;
} }
/** /**
* 特殊用途: vue3 Select组件 * 特殊用途: vue3 Select组件
*/ */

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

@@ -131,11 +131,15 @@ public class LoginUser {
@SensitiveField @SensitiveField
private String telephone; private String telephone;
/** 多租户ids临时用不持久化数据库(数据库字段不存在) */ /**
* 多租户ids临时用不持久化数据库(数据库字段不存在)
*/
@SensitiveField @SensitiveField
private String relTenantIds; private String relTenantIds;
/**设备id uniapp推送用*/ /**
* 设备id uniapp推送用
*/
private String clientId; 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,9 +1,9 @@
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

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,21 +1,20 @@
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
*/ */
@@ -178,8 +177,7 @@ public class BrowserUtils {
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);
} }
@@ -187,21 +185,24 @@ public class BrowserUtils {
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('/');
@@ -99,10 +100,10 @@ public class CommonUtils {
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 mf 文件
* @param bizPath 自定义路径 * @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
*/ */
@@ -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,21 +20,28 @@ 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(在阿里云访问控制台寻找)*/ /**
* TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
*/
static String accessKeyId; static String accessKeyId;
static String accessKeySecret; static String accessKeySecret;
@@ -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,12 +114,12 @@ 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,10 +6,10 @@ 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

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 {
@@ -40,11 +41,11 @@ 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;
@@ -24,7 +23,7 @@ public class IpUtils {
/** /**
* 获取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地址
*/ */
@@ -35,7 +34,7 @@ public class IpUtils {
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)) {
@@ -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,12 +8,12 @@ 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();

View File

@@ -12,13 +12,14 @@ public class MyClassLoader extends ClassLoader {
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
*/ */
@@ -46,8 +47,8 @@ public class MyClassLoader extends ClassLoader {
// 如果不是匿名包,将包名转化为路径 // 如果不是匿名包,将包名转化为路径
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("不要传送系统类!");
@@ -67,7 +68,7 @@ public class MyClassLoader extends ClassLoader {
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) + "/";

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: 密码工具类
@@ -40,7 +40,7 @@ public class PasswordUtil {
* 获取加密算法中使用的盐值,解密中使用的盐值必须与加密中使用的相同才能完成操作. 盐长度必须为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();
@@ -56,10 +56,9 @@ public class PasswordUtil {
/** /**
* 根据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;
@@ -81,12 +80,9 @@ public class PasswordUtil {
/** /**
* 加密明文字符串 * 加密明文字符串
* *
* @param plaintext * @param plaintext 待加密的明文字符串
* 待加密的明文字符串 * @param password 生成密钥时所使用的密码
* @param password * @param salt 盐值
* 生成密钥时所使用的密码
* @param salt
* 盐值
* @return 加密后的密文字符串 * @return 加密后的密文字符串
* @throws Exception * @throws Exception
*/ */
@@ -110,12 +106,9 @@ public class PasswordUtil {
/** /**
* 解密密文字符串 * 解密密文字符串
* *
* @param ciphertext * @param ciphertext 待解密的密文字符串
* 待解密的密文字符串 * @param password 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
* @param password * @param salt 盐值(如需解密,该参数需要与加密时使用的一致)
* 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
* @param salt
* 盐值(如需解密,该参数需要与加密时使用的一致)
* @return 解密后的明文字符串 * @return 解密后的明文字符串
* @throws Exception * @throws Exception
*/ */
@@ -130,9 +123,7 @@ public class PasswordUtil {
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) {
catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
return new String(passDec); return new String(passDec);
@@ -141,8 +132,7 @@ public class PasswordUtil {
/** /**
* 将字节数组转换为十六进制字符串 * 将字节数组转换为十六进制字符串
* *
* @param src * @param src 字节数组
* 字节数组
* @return * @return
*/ */
public static String bytesToHexString(byte[] src) { public static String bytesToHexString(byte[] src) {
@@ -164,8 +154,7 @@ public class PasswordUtil {
/** /**
* 将十六进制字符串转换为字节数组 * 将十六进制字符串转换为字节数组
* *
* @param hexString * @param hexString 十六进制字符串
* 十六进制字符串
* @return * @return
*/ */
public static byte[] hexStringToBytes(String hexString) { public static byte[] hexStringToBytes(String hexString) {

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;
@@ -44,6 +43,7 @@ public class SpringContextUtils implements ApplicationContextAware {
public static HttpServletRequest getHttpServletRequest() { public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
} }
/** /**
* 获取HttpServletResponse * 获取HttpServletResponse
*/ */
@@ -54,26 +54,26 @@ public class SpringContextUtils implements ApplicationContextAware {
/** /**
* 获取项目根路径 basePath * 获取项目根路径 basePath
*/ */
public static String getDomain(){ public static String getDomain() {
HttpServletRequest request = getHttpServletRequest(); HttpServletRequest request = getHttpServletRequest();
StringBuffer url = request.getRequestURL(); StringBuffer url = request.getRequestURL();
//1.微服务情况下获取gateway的basePath //1.微服务情况下获取gateway的basePath
String basePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH); String basePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH);
if(oConvertUtils.isNotEmpty(basePath)){ if (oConvertUtils.isNotEmpty(basePath)) {
return basePath; return basePath;
}else{ } else {
String domain = url.delete(url.length() - request.getRequestURI().length(), url.length()).toString(); String domain = url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
//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(scheme!=null && !request.getScheme().equals(scheme)){ if (scheme != null && !request.getScheme().equals(scheme)) {
domain = domain.replace(request.getScheme(),scheme); domain = domain.replace(request.getScheme(), scheme);
} }
return domain; return domain;
} }
} }
public static String getOrigin(){ public static String getOrigin() {
HttpServletRequest request = getHttpServletRequest(); HttpServletRequest request = getHttpServletRequest();
return request.getHeader("Origin"); return request.getHeader("Origin");
} }

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;
@@ -33,6 +34,7 @@ public class SqlInjectionUtil {
* 完整匹配的key不需要考虑前空格 * 完整匹配的key不需要考虑前空格
*/ */
private static List<String> FULL_MATCHING_KEYWRODS = new ArrayList<>(); private static List<String> FULL_MATCHING_KEYWRODS = new ArrayList<>();
static { static {
FULL_MATCHING_KEYWRODS.add(";"); FULL_MATCHING_KEYWRODS.add(";");
FULL_MATCHING_KEYWRODS.add("+"); FULL_MATCHING_KEYWRODS.add("+");
@@ -42,7 +44,7 @@ public class SqlInjectionUtil {
/** /**
* sql注入风险的 正则关键字 * sql注入风险的 正则关键字
* * <p>
* 函数匹配,需要用正则模式 * 函数匹配,需要用正则模式
*/ */
private final static String[] XSS_REGULAR_STR_ARRAY = new String[]{ private final static String[] XSS_REGULAR_STR_ARRAY = new String[]{
@@ -73,6 +75,7 @@ public class SqlInjectionUtil {
/** /**
* sql注入过滤处理遇到注入关键字抛异常 * sql注入过滤处理遇到注入关键字抛异常
*
* @param values * @param values
*/ */
public static void filterContentMulti(String... values) { public static void filterContentMulti(String... values) {
@@ -81,7 +84,7 @@ public class SqlInjectionUtil {
/** /**
* 校验比较严格 * 校验比较严格
* * <p>
* sql注入过滤处理遇到注入关键字抛异常 * sql注入过滤处理遇到注入关键字抛异常
* *
* @param value * @param value
@@ -143,7 +146,7 @@ public class SqlInjectionUtil {
} else if (sql.contains(keyword)) { } else if (sql.contains(keyword)) {
// 需要匹配的sql注入关键词 // 需要匹配的sql注入关键词
String matchingText = " " + keyword; String matchingText = " " + keyword;
if(FULL_MATCHING_KEYWRODS.contains(keyword)){ if (FULL_MATCHING_KEYWRODS.contains(keyword)) {
matchingText = keyword; matchingText = keyword;
} }
@@ -224,6 +227,7 @@ public class SqlInjectionUtil {
/** /**
* 【提醒:不通用】 * 【提醒:不通用】
* 仅用于Online报表SQL解析注入过滤 * 仅用于Online报表SQL解析注入过滤
*
* @param value * @param value
* @return * @return
*/ */
@@ -260,10 +264,11 @@ public class SqlInjectionUtil {
/** /**
* 校验是否有sql注释 * 校验是否有sql注释
*
* @return * @return
*/ */
public static void checkSqlAnnotation(String str){ public static void checkSqlAnnotation(String str) {
if(str.contains(SQL_ANNOTATION2)){ if (str.contains(SQL_ANNOTATION2)) {
String error = "请注意SQL中不允许含注释有安全风险"; String error = "请注意SQL中不允许含注释有安全风险";
log.error(error); log.error(error);
throw new RuntimeException(error); throw new RuntimeException(error);
@@ -271,7 +276,7 @@ public class SqlInjectionUtil {
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);
@@ -287,8 +292,9 @@ public class SqlInjectionUtil {
* @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) { public static String getSqlInjectTableName(String table) {
if(oConvertUtils.isEmpty(table)){ if (oConvertUtils.isEmpty(table)) {
return table; return table;
} }
@@ -329,8 +335,9 @@ public class SqlInjectionUtil {
* @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) { public static String getSqlInjectField(String field) {
if(oConvertUtils.isEmpty(field)){ if (oConvertUtils.isEmpty(field)) {
return field; return field;
} }
@@ -375,9 +382,10 @@ public class SqlInjectionUtil {
/** /**
* 获取排序字段 * 获取排序字段
* 返回:字符串 * 返回:字符串
* * <p>
* 1.将驼峰命名转化成下划线 * 1.将驼峰命名转化成下划线
* 2.限制sql注入 * 2.限制sql注入
*
* @param sortField 排序字段 * @param sortField 排序字段
* @return * @return
*/ */
@@ -389,9 +397,10 @@ public class SqlInjectionUtil {
/** /**
* 获取多个排序字段 * 获取多个排序字段
* 返回:数组 * 返回:数组
* * <p>
* 1.将驼峰命名转化成下划线 * 1.将驼峰命名转化成下划线
* 2.限制sql注入 * 2.限制sql注入
*
* @param sortFields 多个排序字段 * @param sortFields 多个排序字段
* @return * @return
*/ */

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,9 +4,7 @@ package org.jeecg.common.util;
import java.net.InetAddress; import java.net.InetAddress;
/** /**
*
* @Author 张代浩 * @Author 张代浩
*
*/ */
public class UUIDGenerator { public class UUIDGenerator {
@@ -25,6 +23,7 @@ public class UUIDGenerator {
} }
private static final int IP; private static final int IP;
static { static {
int ipadd; int ipadd;
try { try {

View File

@@ -6,19 +6,21 @@ 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
@@ -34,8 +36,8 @@ public class YouBianCodeUtil {
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);
@@ -51,9 +53,9 @@ public class YouBianCodeUtil {
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;
} }
@@ -70,7 +72,7 @@ public class YouBianCodeUtil {
/** /**
* 根据父亲code,获取下级的下一个code * 根据父亲code,获取下级的下一个code
* * <p>
* 例如父亲CODE:A01 * 例如父亲CODE:A01
* 当前CODE:A01B03 * 当前CODE:A01B03
* 获取的code:A01B04 * 获取的code:A01B04
@@ -79,20 +81,19 @@ public class YouBianCodeUtil {
* @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;
} }
/** /**
* 将数字前面位数补零 * 将数字前面位数补零
* *
@@ -141,28 +142,30 @@ public class YouBianCodeUtil {
/** /**
* 根据数字位数获取最大值 * 根据数字位数获取最大值
*
* @param length * @param length
* @return * @return
*/ */
private static int getMaxNumByLength(int length){ private static int getMaxNumByLength(int length) {
if(length==0){ if (length == 0) {
return 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)){ public static String[] cutYouBianCode(String code) {
if (code == null || StringUtil.isNullOrEmpty(code)) {
return null; return null;
}else{ } else {
//获取标准长度为numLength+1,截取的数量为code.length/numLength+1 //获取标准长度为numLength+1,截取的数量为code.length/numLength+1
int c = code.length()/(NUM_LENGTH +1); int c = code.length() / (NUM_LENGTH + 1);
String[] cutcode = new String[c]; String[] cutcode = new String[c];
for(int i =0 ; i <c;i++){ for (int i = 0; i < c; i++) {
cutcode[i] = code.substring(0,(i+1)*(NUM_LENGTH +1)); cutcode[i] = code.substring(0, (i + 1) * (NUM_LENGTH + 1));
} }
return cutcode; return cutcode;
} }

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,22 +79,22 @@ 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;
@@ -100,10 +102,11 @@ public class DbTypeUtils {
/** /**
* 根据枚举类 获取数据库方言字符串 * 根据枚举类 获取数据库方言字符串
*
* @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,6 +284,7 @@ public class DynamicDBUtil {
/** /**
* 此方法只能返回单列,不能返回实体类 * 此方法只能返回单列,不能返回实体类
*
* @param dbKey 数据源的key * @param dbKey 数据源的key
* @param sql sal * @param sql sal
* @param clazz 类 * @param clazz 类

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,6 +21,7 @@ public class AesEncryptUtil {
/** /**
* 加密方法 * 加密方法
*
* @param data 要加密的数据 * @param data 要加密的数据
* @param key 加密key * @param key 加密key
* @param iv 加密iv * @param iv 加密iv
@@ -59,6 +60,7 @@ public class AesEncryptUtil {
/** /**
* 解密方法 * 解密方法
*
* @param data 要解密的数据 * @param data 要解密的数据
* @param key 解密key * @param key 解密key
* @param iv 解密iv * @param iv 解密iv
@@ -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 {
} }
// /** // /**
// * 测试 // * 测试
// */ // */

View File

@@ -23,8 +23,11 @@ public class SsrfFileTypeFilter {
* 允许操作文件类型白名单 * 允许操作文件类型白名单
*/ */
private final static List<String> FILE_TYPE_WHITE_LIST = new ArrayList<>(); private final static List<String> FILE_TYPE_WHITE_LIST = new ArrayList<>();
/**初始化文件头类型,不够的自行补充*/ /**
* 初始化文件头类型,不够的自行补充
*/
final static HashMap<String, String> FILE_TYPE_MAP = new HashMap<>(); final static HashMap<String, String> FILE_TYPE_MAP = new HashMap<>();
static { static {
//图片文件 //图片文件
FILE_TYPE_WHITE_LIST.add("jpg"); FILE_TYPE_WHITE_LIST.add("jpg");
@@ -197,7 +200,7 @@ public class SsrfFileTypeFilter {
break; break;
} }
} }
log.info("-----获取到的指定文件类型------"+fileExtendName); log.info("-----获取到的指定文件类型------" + fileExtendName);
// 如果不是上述类型,则判断扩展名 // 如果不是上述类型,则判断扩展名
if (StringUtils.isBlank(fileExtendName)) { if (StringUtils.isBlank(fileExtendName)) {
String fileName = file.getOriginalFilename(); String fileName = file.getOriginalFilename();
@@ -208,13 +211,13 @@ public class SsrfFileTypeFilter {
// 如果有扩展名,则返回扩展名 // 如果有扩展名,则返回扩展名
return getFileTypeBySuffix(fileName); return getFileTypeBySuffix(fileName);
} }
log.info("-----最終的文件类型------"+fileExtendName); log.info("-----最終的文件类型------" + fileExtendName);
is.close(); is.close();
return fileExtendName; return fileExtendName;
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return ""; return "";
}finally { } finally {
if (is != null) { if (is != null) {
is.close(); is.close();
} }

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