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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,6 +8,7 @@ import java.util.List;
/**
* online 拦截器权限判断
* cloud api 用到的接口传输对象
*
* @author: jeecg-boot
*/
@Data
@@ -37,11 +38,11 @@ public class OnlineAuthDTO implements Serializable {
private String onlineWorkOrderUrl;
//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.possibleUrl = possibleUrl;
this.onlineFormUrl = onlineFormUrl;

View File

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

View File

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

View File

@@ -4,10 +4,12 @@ import lombok.Data;
import org.jeecg.common.constant.CommonConstant;
import java.io.Serializable;
import java.util.*;
import java.util.Map;
import java.util.Set;
/**
* 普通消息
*
* @author: jeecg-boot
*/
@Data
@@ -86,13 +88,13 @@ public class MessageDTO implements Serializable {
protected Set<String> ccEmailList;
//---【邮件相关参数】-------------------------------------------------------------
public MessageDTO(){
public MessageDTO() {
}
/**
* 构造器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.toUser = toUser;
this.title = title;
@@ -104,7 +106,7 @@ public class MessageDTO implements Serializable {
/**
* 构造器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.toUser = toUser;
this.title = title;

View File

@@ -7,6 +7,7 @@ import java.util.Map;
/**
* 消息模板dto
*
* @author: jeecg-boot
*/
@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.templateParam = templateParam;
}
public TemplateDTO(){
public TemplateDTO() {
}
}

View File

@@ -1,11 +1,13 @@
package org.jeecg.common.api.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* 模板消息
*
* @author: jeecg-boot
*/
@Data
@@ -30,14 +32,14 @@ public class TemplateMessageDTO extends TemplateDTO implements Serializable {
protected String title;
public TemplateMessageDTO(){
public TemplateMessageDTO() {
}
/**
* 构造器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);
this.fromUser = fromUser;
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
* @email jeecgos@163.com
* @date 2019年1月19日
*/
@Data
@Schema(description="接口返回对象")
@Schema(description = "接口返回对象")
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
@@ -54,6 +55,7 @@ public class Result<T> implements Serializable {
/**
* 兼容VUE3版token失效不跳转登录页面
*
* @param code
* @param message
*/
@@ -69,14 +71,14 @@ public class Result<T> implements Serializable {
return this;
}
public static<T> Result<T> ok() {
public static <T> Result<T> ok() {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
return r;
}
public static<T> Result<T> ok(String msg) {
public static <T> Result<T> ok(String msg) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
@@ -86,7 +88,7 @@ public class Result<T> implements Serializable {
return r;
}
public static<T> Result<T> ok(T data) {
public static <T> Result<T> ok(T data) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
@@ -94,7 +96,7 @@ public class Result<T> implements Serializable {
return r;
}
public static<T> Result<T> OK() {
public static <T> Result<T> OK() {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
@@ -108,7 +110,7 @@ public class Result<T> implements Serializable {
* @param <T>
* @return
*/
public static<T> Result<T> OK(String msg) {
public static <T> Result<T> OK(String msg) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
@@ -118,7 +120,7 @@ public class Result<T> implements Serializable {
return r;
}
public static<T> Result<T> OK(T data) {
public static <T> Result<T> OK(T data) {
Result<T> r = new Result<T>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
@@ -126,7 +128,7 @@ public class Result<T> implements Serializable {
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>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
@@ -135,7 +137,7 @@ public class Result<T> implements Serializable {
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>();
r.setSuccess(false);
r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
@@ -144,11 +146,11 @@ public class Result<T> implements Serializable {
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);
}
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>();
r.setCode(code);
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);
}

View File

@@ -2,6 +2,10 @@ package org.jeecg.common.aspect;
import com.alibaba.fastjson.JSONObject;
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.aspectj.lang.JoinPoint;
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.enums.ModuleType;
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.util.IpUtils;
import org.jeecg.common.util.SpringContextUtils;
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.stereotype.Component;
import org.springframework.validation.BindingResult;
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.util.Date;
@@ -72,10 +72,10 @@ public class AutoLogAspect {
LogDTO dto = new LogDTO();
AutoLog syslog = method.getAnnotation(AutoLog.class);
if(syslog != null){
if (syslog != null) {
//update-begin-author:taoyan date:
String content = syslog.value();
if(syslog.module()== ModuleType.ONLINE){
if (syslog.module() == ModuleType.ONLINE) {
content = getOnlineLogContent(obj, content);
}
//注解上的描述,操作日志内容
@@ -97,12 +97,12 @@ public class AutoLogAspect {
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//请求的参数
dto.setRequestParam(getReqestParams(request,joinPoint));
dto.setRequestParam(getReqestParams(request, joinPoint));
//设置IP地址
dto.setIp(IpUtils.getIpAddr(request));
//获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(sysUser!=null){
if (sysUser != null) {
dto.setUserid(sysUser.getUsername());
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) {
return operateType;
}
@@ -128,11 +128,11 @@ public class AutoLogAspect {
}
/**
* @param request: request
* @param joinPoint: joinPoint
* @Description: 获取请求参数
* @author: scott
* @date: 2020/4/16 0:10
* @param request: request
* @param joinPoint: joinPoint
* @Return: java.lang.String
*/
private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) {
@@ -156,10 +156,10 @@ public class AutoLogAspect {
@Override
public boolean apply(Object o, String name, Object value) {
int length = 500;
if(value!=null && value.toString().length()>length){
if (value != null && value.toString().length() > length) {
return false;
}
if(value instanceof MultipartFile){
if (value instanceof MultipartFile) {
return false;
}
return true;
@@ -173,7 +173,7 @@ public class AutoLogAspect {
// 请求的方法参数值
Object[] args = joinPoint.getArgs();
// 请求的方法参数名称
StandardReflectionParameterNameDiscoverer u=new StandardReflectionParameterNameDiscoverer();
StandardReflectionParameterNameDiscoverer u = new StandardReflectionParameterNameDiscoverer();
String[] paramNames = u.getParameterNames(method);
if (args != null && paramNames != null) {
for (int i = 0; i < args.length; i++) {
@@ -186,22 +186,23 @@ public class AutoLogAspect {
/**
* online日志内容拼接
*
* @param obj
* @param content
* @return
*/
private String getOnlineLogContent(Object obj, String content){
if (Result.class.isInstance(obj)){
Result res = (Result)obj;
private String getOnlineLogContent(Object obj, String content) {
if (Result.class.isInstance(obj)) {
Result res = (Result) obj;
String msg = res.getMessage();
String tableName = res.getOnlTable();
if(oConvertUtils.isNotEmpty(tableName)){
content+=",表名:"+tableName;
if (oConvertUtils.isNotEmpty(tableName)) {
content += ",表名:" + tableName;
}
if(res.isSuccess()){
content+= ","+(oConvertUtils.isEmpty(msg)?"操作成功":msg);
}else{
content+= ","+(oConvertUtils.isEmpty(msg)?"操作失败":msg);
if (res.isSuccess()) {
content += "," + (oConvertUtils.isEmpty(msg) ? "操作成功" : msg);
} else {
content += "," + (oConvertUtils.isEmpty(msg) ? "操作失败" : msg);
}
}
return content;

View File

@@ -60,14 +60,14 @@ public class DictAspect {
@Around("excudeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long time1=System.currentTimeMillis();
long time1 = System.currentTimeMillis();
Object result = pjp.proceed();
long time2=System.currentTimeMillis();
log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
long start=System.currentTimeMillis();
result=this.parseDictText(result);
long end=System.currentTimeMillis();
log.debug("注入字典到JSON数据 耗时"+(end-start)+"ms");
long time2 = System.currentTimeMillis();
log.debug("获取JSON数据 耗时:" + (time2 - time1) + "ms");
long start = System.currentTimeMillis();
result = this.parseDictText(result);
long end = System.currentTimeMillis();
log.debug("注入字典到JSON数据 耗时" + (end - start) + "ms");
return result;
}
@@ -91,6 +91,7 @@ public class DictAspect {
* }
* }
* 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
*
* @param result
*/
private Object parseDictText(Object result) {
@@ -104,24 +105,24 @@ public class DictAspect {
// 字典数据列表, key = 字典codevalue=数据列表
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】 判断是否含有字典注解,没有注解返回-----
Boolean hasDict= checkHasDict(records);
if(!hasDict){
Boolean hasDict = checkHasDict(records);
if (!hasDict) {
return result;
}
log.debug(" __ 进入字典翻译切面 DictAspect —— " );
log.debug(" __ 进入字典翻译切面 DictAspect —— ");
//update-end--Author:zyf -- Date:20220606 ----for【VUEN-1230】 判断是否含有字典注解,没有注解返回-----
for (Object record : records) {
String json="{}";
String json = "{}";
try {
//update-begin--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错-----
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = objectMapper.writeValueAsString(record);
//update-end--Author:zyf -- Date:20220531 ----for【issues/#3629】 DictAspect Jackson序列化报错-----
} 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顺序错乱 -----
JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
@@ -190,7 +191,7 @@ public class DictAspect {
String value = record.getString(field.getName());
if (oConvertUtils.isNotEmpty(value)) {
List<DictModel> dictModels = translText.get(fieldDictCode);
if(dictModels==null || dictModels.size()==0){
if (dictModels == null || dictModels.size() == 0) {
continue;
}
@@ -229,6 +230,7 @@ public class DictAspect {
* 一次性把所有的字典都翻译了
* 1. 所有的普通数据字典的所有数据只执行一次SQL
* 2. 表字典相同的所有数据只执行一次SQL
*
* @param dataListMap
* @return
*/
@@ -298,7 +300,7 @@ public class DictAspect {
//update-begin---author:chenrui ---date:20231221 for[issues/#5643]解决分布式下表字典跨库无法查询问题------------
//update-begin---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串---
if(null == dataSource){
if (null == dataSource) {
dataSource = "";
}
//update-end---author:wangshuai---date:2024-01-09---for:微服务下为空报错没有参数需要传递空字符串---
@@ -381,6 +383,7 @@ public class DictAspect {
/**
* 翻译字典文本
*
* @param code
* @param text
* @param table
@@ -389,39 +392,39 @@ public class DictAspect {
*/
@Deprecated
private String translateDictValue(String code, String text, String table, String key) {
if(oConvertUtils.isEmpty(key)) {
if (oConvertUtils.isEmpty(key)) {
return null;
}
StringBuffer textValue=new StringBuffer();
StringBuffer textValue = new StringBuffer();
String[] keys = key.split(",");
for (String k : keys) {
String tmpValue = null;
log.debug(" 字典 key : "+ k);
log.debug(" 字典 key : " + k);
if (k.trim().length() == 0) {
continue; //跳过循环
}
//update-begin--Author:scott -- Date:20210531 ----for !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
if (!StringUtils.isEmpty(table)){
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());
if (redisTemplate.hasKey(keyString)){
if (!StringUtils.isEmpty(table)) {
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());
if (redisTemplate.hasKey(keyString)) {
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
tmpValue= commonApi.translateDictFromTable(table,text,code,k.trim());
} else {
tmpValue = commonApi.translateDictFromTable(table, text, code, k.trim());
}
}else {
String keyString = String.format("sys:cache:dict::%s:%s",code,k.trim());
if (redisTemplate.hasKey(keyString)){
} else {
String keyString = String.format("sys:cache:dict::%s:%s", code, k.trim());
if (redisTemplate.hasKey(keyString)) {
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
} else {
tmpValue = commonApi.translateDict(code, k.trim());
}
}
@@ -440,11 +443,12 @@ public class DictAspect {
/**
* 检测返回结果集中是否包含Dict注解
*
* @param records
* @return
*/
private Boolean checkHasDict(List<Object> records){
if(oConvertUtils.isNotEmpty(records) && records.size()>0){
private Boolean checkHasDict(List<Object> records) {
if (oConvertUtils.isNotEmpty(records) && records.size() > 0) {
for (Field field : oConvertUtils.getAllFields(records.get(0))) {
if (oConvertUtils.isNotEmpty(field.getAnnotation(Dict.class))) {
return true;

View File

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

View File

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

View File

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

View File

@@ -40,6 +40,7 @@ public @interface AutoLog {
/**
* 模块类型 默认为common
*
* @return
*/
ModuleType module() default ModuleType.COMMON;

View File

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

View File

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

View File

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

View File

@@ -1,22 +1,20 @@
package org.jeecg.common.aspect.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;
/**
* 数据权限注解
*
* @Author taoyan
* @Date 2019年4月11日
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD})
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
public @interface PermissionData {
/**
* 暂时没用
*
* @return
*/
String value() default "";

View File

@@ -77,27 +77,43 @@ public interface CommonConstant {
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;
/** {@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;
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
/**
* {@code 200 OK} (HTTP/1.0 - RFC 1945)
*/
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:";
/** 登录用户Token令牌缓存KEY前缀 */
/**
* 登录用户Token令牌缓存KEY前缀
*/
String PREFIX_USER_TOKEN = "prefix_user_token:";
// /** Token缓存时间3600秒即一小时 */
// int TOKEN_EXPIRE_TIME = 3600;
/** 登录二维码 */
/**
* 登录二维码
*/
String LOGIN_QRCODE_PRE = "QRCODELOGIN:";
String LOGIN_QRCODE = "LQ:";
/** 登录二维码token */
/**
* 登录二维码token
*/
String LOGIN_QRCODE_TOKEN = "LQT:";
@@ -114,20 +130,28 @@ public interface CommonConstant {
*/
Integer MENU_TYPE_2 = 2;
/**通告对象类型USER:指定用户ALL:全体用户)*/
/**
* 通告对象类型USER:指定用户ALL:全体用户)
*/
String MSG_TYPE_UESR = "USER";
String MSG_TYPE_ALL = "ALL";
/**发布状态0未发布1已发布2已撤销*/
/**
* 发布状态0未发布1已发布2已撤销
*/
String NO_SEND = "0";
String HAS_SEND = "1";
String HAS_CANCLE = "2";
/**阅读状态0未读1已读*/
/**
* 阅读状态0未读1已读
*/
Integer HAS_READ_FLAG = 1;
Integer NO_READ_FLAG = 0;
/**优先级L低M中H高*/
/**
* 优先级L低M中H高
*/
String PRIORITY_L = "L";
String PRIORITY_M = "M";
String PRIORITY_H = "H";
@@ -170,9 +194,13 @@ public interface CommonConstant {
Integer USER_FREEZE = 2;
Integer USER_QUIT = 3;
/**字典翻译文本后缀*/
/**
* 字典翻译文本后缀
*/
String DICT_TEXT_SUFFIX = "_dictText";
/**字典翻译颜色后缀*/
/**
* 字典翻译颜色后缀
*/
String DICT_COLOR_SUFFIX = "_dictColor";
/**
@@ -248,26 +276,46 @@ public interface CommonConstant {
Integer USER_IDENTITY_1 = 1;
Integer USER_IDENTITY_2 = 2;
/** sys_user 表 username 唯一键索引 */
/**
* 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";
/** sys_user 表 phone 唯一键索引 */
/**
* sys_user 表 phone 唯一键索引
*/
String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone";
/** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */
/**
* 达梦数据库升提示。违反表[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";
/** sys_quartz_job 表 job_class_name 唯一键索引 */
/**
* sys_quartz_job 表 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";
/** sys_role 表 code 唯一键索引 */
/**
* sys_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";
/** sys_category 表 code 唯一键索引 */
/**
* sys_category 表 code 唯一键索引
*/
String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code";
/**
* 在线聊天 是否为默认分组
@@ -319,8 +367,8 @@ public interface CommonConstant {
/**
* WPS存储值类别(1 code文号 2 textWPS模板还是公文发文模板)
*/
String WPS_TYPE_1="1";
String WPS_TYPE_2="2";
String WPS_TYPE_1 = "1";
String WPS_TYPE_2 = "2";
/**===============================================================================================*/
@@ -331,11 +379,17 @@ public interface CommonConstant {
String X_ACCESS_TOKEN = "X-Access-Token";
String X_SIGN = "X-Sign";
String X_TIMESTAMP = "X-TIMESTAMP";
/** 租户请求头 更名为X-Tenant-Id */
/**
* 租户请求头 更名为X-Tenant-Id
*/
String TENANT_ID = "X-Tenant-Id";
/** 简流接口请求头,用于排除不支持的控件字段 */
/**
* 简流接口请求头,用于排除不支持的控件字段
*/
String X_MiniFlowExclusionFieldMode = "X-Miniflowexclusionfieldmode";
/**===============================================================================================*/
/**
* ===============================================================================================
*/
String TOKEN_IS_INVALID_MSG = "Token失效请重新登录!";
String X_FORWARDED_SCHEME = "X-Forwarded-Scheme";
@@ -360,41 +414,65 @@ public interface CommonConstant {
*/
String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL";
/** 系统通告消息状态0=未发布 */
/**
* 系统通告消息状态0=未发布
*/
String ANNOUNCEMENT_SEND_STATUS_0 = "0";
/** 系统通告消息状态1=已发布 */
/**
* 系统通告消息状态1=已发布
*/
String ANNOUNCEMENT_SEND_STATUS_1 = "1";
/** 系统通告消息状态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";
/**PUT请求*/
/**
* PUT请求
*/
String HTTP_PUT = "PUT";
/**PATCH请求*/
/**
* PATCH请求
*/
String HTTP_PATCH = "PATCH";
/**未知的*/
/**
* 未知的
*/
String UNKNOWN = "unknown";
/**字符串http*/
/**
* 字符串http
*/
String STR_HTTP = "http";
/**String 类型的空值*/
/**
* String 类型的空值
*/
String STRING_NULL = "null";
/**前端vue3版本Header参数名*/
String VERSION="X-Version";
/**
* 前端vue3版本Header参数名
*/
String VERSION = "X-Version";
String VERSION_V3 = "v3";
/**存储在线程变量里的动态表名*/
String DYNAMIC_TABLE_NAME="DYNAMIC_TABLE_NAME";
/**
* 存储在线程变量里的动态表名
*/
String DYNAMIC_TABLE_NAME = "DYNAMIC_TABLE_NAME";
/**
* http:// http协议
*/
@@ -405,9 +483,13 @@ public interface CommonConstant {
*/
String HTTPS_PROTOCOL = "https://";
/** 部门表唯一keyid */
/**
* 部门表唯一keyid
*/
String DEPART_KEY_ID = "id";
/** 部门表唯一keyorgCode */
/**
* 部门表唯一keyorgCode
*/
String DEPART_KEY_ORG_CODE = "orgCode";
/**======【消息推送相关】==============================================================================*/
@@ -446,7 +528,9 @@ public interface CommonConstant {
*/
String DATA_LOG_TYPE_JSON = "json";
/** 消息模板markdown */
/**
* 消息模板markdown
*/
String MSG_TEMPLATE_TYPE_MD = "5";
/**========【消息推送相关】==========================================================================*/
@@ -561,7 +645,9 @@ public interface CommonConstant {
*/
String COPY_LEVEL_COVER = "cover";
/** 【QQYUN-6034】关联字段变更历史值缓存半个小时 */
/**
* 【QQYUN-6034】关联字段变更历史值缓存半个小时
*/
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 {
@@ -29,15 +29,25 @@ public interface CommonSendStatus {
/**-----【流程相关通知模板code】------------------------------------------------------------*/
/**流程催办——系统通知消息模板*/
/**
* 流程催办——系统通知消息模板
*/
public static final String TZMB_BPM_CUIBAN = "bpm_cuiban";
/**流程抄送——系统通知消息模板*/
/**
* 流程抄送——系统通知消息模板
*/
public static final String TZMB_BPM_CC = "bpm_cc";
/**流程催办——邮件通知消息模板*/
/**
* 流程催办——邮件通知消息模板
*/
public static final String TZMB_BPM_CUIBAN_EMAIL = "bpm_cuiban_email";
/**标准模板—系统消息通知*/
/**
* 标准模板—系统消息通知
*/
public static final String TZMB_SYS_TS_NOTE = "sys_ts_note";
/**流程超时提醒——系统通知消息模板*/
/**
* 流程超时提醒——系统通知消息模板
*/
public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip";
/**-----【流程相关通知模板code】-----------------------------------------------------------*/

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,6 +7,7 @@ import java.util.Map;
/**
* online表单枚举 代码生成器用到
*
* @author: jeecg-boot
*/
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_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(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(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/树

View File

@@ -8,22 +8,38 @@ import org.apache.commons.lang3.StringUtils;
*/
public enum DySmsEnum {
/**登录短信模板编码*/
LOGIN_TEMPLATE_CODE("SMS_175435174","敲敲云","code"),
/**忘记密码短信模板编码*/
FORGET_PASSWORD_TEMPLATE_CODE("SMS_175435174","敲敲云","code"),
/**修改密码短信模板编码*/
CHANGE_PASSWORD_TEMPLATE_CODE("SMS_465391221","敲敲云","code"),
/**注册账号短信模板编码*/
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");
/**
* 登录短信模板编码
*/
LOGIN_TEMPLATE_CODE("SMS_175435174", "敲敲云", "code"),
/**
* 忘记密码短信模板编码
*/
FORGET_PASSWORD_TEMPLATE_CODE("SMS_175435174", "敲敲云", "code"),
/**
* 修改密码短信模板编码
*/
CHANGE_PASSWORD_TEMPLATE_CODE("SMS_465391221", "敲敲云", "code"),
/**
* 注册账号短信模板编码
*/
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 DySmsEnum(String templateCode,String signName,String keys) {
private DySmsEnum(String templateCode, String signName, String keys) {
this.templateCode = templateCode;
this.signName = signName;
this.keys = keys;
@@ -69,11 +85,11 @@ public enum DySmsEnum {
}
public static DySmsEnum toEnum(String templateCode) {
if(StringUtils.isEmpty(templateCode)){
if (StringUtils.isEmpty(templateCode)) {
return null;
}
for(DySmsEnum item : DySmsEnum.values()) {
if(item.getTemplateCode().equals(templateCode)) {
for (DySmsEnum item : DySmsEnum.values()) {
if (item.getTemplateCode().equals(templateCode)) {
return item;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -25,19 +25,29 @@ import java.util.*;
@Component
@ConditionalOnProperty(prefix = "jeecg.elasticsearch", name = "cluster-nodes")
public class JeecgElasticsearchTemplate {
/** es服务地址 */
/**
* es服务地址
*/
private String baseUrl;
private final String FORMAT_JSON = "format=json";
/** Elasticsearch 的版本号 */
/**
* Elasticsearch 的版本号
*/
private String version = null;
/**ElasticSearch 最大可返回条目数*/
/**
* ElasticSearch 最大可返回条目数
*/
public static final int ES_MAX_SIZE = 10000;
/**es7*/
/**
* es7
*/
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 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);
}
//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);
log.info("-------剔除上传控件字段------------key: "+ key);
log.info("-------剔除上传控件字段------------key: " + key);
}
}
for (String key : emptyKeys) {

View File

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

View File

@@ -7,17 +7,15 @@ package org.jeecg.common.exception;
public class JeecgBoot401Exception extends RuntimeException {
private static final long serialVersionUID = 1L;
public JeecgBoot401Exception(String message){
public JeecgBoot401Exception(String message) {
super(message);
}
public JeecgBoot401Exception(Throwable cause)
{
public JeecgBoot401Exception(Throwable cause) {
super(cause);
}
public JeecgBoot401Exception(String message, Throwable cause)
{
super(message,cause);
public JeecgBoot401Exception(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -15,11 +15,11 @@ public class JeecgBootBizTipException extends RuntimeException {
*/
private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
public JeecgBootBizTipException(String message){
public JeecgBootBizTipException(String message) {
super(message);
}
public JeecgBootBizTipException(String message, int errCode){
public JeecgBootBizTipException(String message, int errCode) {
super(message);
this.errCode = errCode;
}
@@ -28,13 +28,11 @@ public class JeecgBootBizTipException extends RuntimeException {
return errCode;
}
public JeecgBootBizTipException(Throwable cause)
{
public JeecgBootBizTipException(Throwable cause) {
super(cause);
}
public JeecgBootBizTipException(String message, Throwable cause)
{
super(message,cause);
public JeecgBootBizTipException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -14,11 +14,11 @@ public class JeecgBootException extends RuntimeException {
*/
private int errCode = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
public JeecgBootException(String message){
public JeecgBootException(String message) {
super(message);
}
public JeecgBootException(String message, int errCode){
public JeecgBootException(String message, int errCode) {
super(message);
this.errCode = errCode;
}
@@ -27,13 +27,11 @@ public class JeecgBootException extends RuntimeException {
return errCode;
}
public JeecgBootException(Throwable cause)
{
public JeecgBootException(Throwable cause) {
super(cause);
}
public JeecgBootException(String message,Throwable cause)
{
super(message,cause);
public JeecgBootException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -51,7 +51,7 @@ public class JeecgBootExceptionHandler {
* 处理自定义异常
*/
@ExceptionHandler(JeecgBootException.class)
public Result<?> handleJeecgBootException(JeecgBootException e){
public Result<?> handleJeecgBootException(JeecgBootException e) {
log.error(e.getMessage(), e);
addSysLog(e);
return Result.error(e.getErrCode(), e.getMessage());
@@ -61,7 +61,7 @@ public class JeecgBootExceptionHandler {
* 处理自定义异常
*/
@ExceptionHandler(JeecgBootBizTipException.class)
public Result<?> handleJeecgBootBizTipException(JeecgBootBizTipException e){
public Result<?> handleJeecgBootBizTipException(JeecgBootBizTipException e) {
log.error(e.getMessage());
return Result.error(e.getErrCode(), e.getMessage());
}
@@ -70,7 +70,7 @@ public class JeecgBootExceptionHandler {
* 处理自定义微服务异常
*/
@ExceptionHandler(JeecgCloudException.class)
public Result<?> handleJeecgCloudException(JeecgCloudException e){
public Result<?> handleJeecgCloudException(JeecgCloudException e) {
log.error(e.getMessage(), e);
addSysLog(e);
return Result.error(e.getMessage());
@@ -81,10 +81,10 @@ public class JeecgBootExceptionHandler {
*/
@ExceptionHandler(JeecgBoot401Exception.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e){
public Result<?> handleJeecgBoot401Exception(JeecgBoot401Exception e) {
log.error(e.getMessage(), e);
addSysLog(e);
return new Result(401,e.getMessage());
return new Result(401, e.getMessage());
}
@ExceptionHandler(NoHandlerFoundException.class)
@@ -95,20 +95,20 @@ public class JeecgBootExceptionHandler {
}
@ExceptionHandler(DuplicateKeyException.class)
public Result<?> handleDuplicateKeyException(DuplicateKeyException e){
public Result<?> handleDuplicateKeyException(DuplicateKeyException e) {
log.error(e.getMessage(), e);
addSysLog(e);
return Result.error("数据库中已存在该记录");
}
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
public Result<?> handleAuthorizationException(AuthorizationException e){
public Result<?> handleAuthorizationException(AuthorizationException e) {
log.error(e.getMessage(), e);
return Result.noauth("没有权限,请联系管理员授权,后刷新缓存!");
}
@ExceptionHandler(Exception.class)
public Result<?> handleException(Exception e){
public Result<?> handleException(Exception e) {
log.error(e.getMessage(), e);
//update-begin---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
Throwable throwable = e.getCause();
@@ -118,24 +118,24 @@ public class JeecgBootExceptionHandler {
}
//update-end---author:zyf ---date:20220411 for处理Sentinel限流自定义异常
addSysLog(e);
return Result.error("操作失败,"+e.getMessage());
return Result.error("操作失败," + e.getMessage());
}
/**
* @Author 政辉
* @param e
* @return
* @Author 政辉
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
public Result<?> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
StringBuffer sb = new StringBuffer();
sb.append("不支持");
sb.append(e.getMethod());
sb.append("请求方法,");
sb.append("支持以下");
String [] methods = e.getSupportedMethods();
if(methods!=null){
for(String str:methods){
String[] methods = e.getSupportedMethods();
if (methods != null) {
for (String str : methods) {
sb.append(str);
sb.append("");
}
@@ -143,7 +143,7 @@ public class JeecgBootExceptionHandler {
log.error(sb.toString(), e);
//return Result.error("没有权限,请联系管理员授权");
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]把错误的日志都抓取了 方便后续处理,单独弄个日志类型------------
/**
* 添加异常新系统日志
*
* @param e 异常
* @author chenrui
* @date 2024/4/22 17:16
@@ -202,7 +204,7 @@ public class JeecgBootExceptionHandler {
private void addSysLog(Throwable e) {
LogDTO log = new LogDTO();
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));
//获取request
HttpServletRequest request = null;
@@ -213,7 +215,7 @@ public class JeecgBootExceptionHandler {
if (null != request) {
//请求的参数
Map<String, String[]> parameterMap = request.getParameterMap();
if(!CollectionUtils.isEmpty(parameterMap)){
if (!CollectionUtils.isEmpty(parameterMap)) {
log.setMethod(oConvertUtils.mapToString(request.getParameterMap()));
}
// 请求地址
@@ -221,9 +223,9 @@ public class JeecgBootExceptionHandler {
//设置IP地址
log.setIp(IpUtils.getIpAddr(request));
//设置客户端
if(BrowserUtils.isDesktop(request)){
if (BrowserUtils.isDesktop(request)) {
log.setClientType(ClientTerminalTypeEnum.PC.getKey());
}else{
} else {
log.setClientType(ClientTerminalTypeEnum.APP.getKey());
}
}
@@ -231,7 +233,7 @@ public class JeecgBootExceptionHandler {
//获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(sysUser!=null){
if (sysUser != null) {
log.setUserid(sysUser.getUsername());
log.setUsername(sysUser.getRealname());

View File

@@ -7,17 +7,15 @@ package org.jeecg.common.exception;
public class JeecgSqlInjectionException extends RuntimeException {
private static final long serialVersionUID = 1L;
public JeecgSqlInjectionException(String message){
public JeecgSqlInjectionException(String message) {
super(message);
}
public JeecgSqlInjectionException(Throwable cause)
{
public JeecgSqlInjectionException(Throwable cause) {
super(cause);
}
public JeecgSqlInjectionException(String message, Throwable cause)
{
super(message,cause);
public JeecgSqlInjectionException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -12,6 +12,7 @@ public interface IFillRuleHandler {
/**
* 填值规则
*
* @param params 页面配置固定参数
* @param formData 动态表单参数
* @return

View File

@@ -4,6 +4,7 @@ import java.lang.annotation.*;
/**
* 将枚举类转化成字典数据
*
* @Author taoYan
* @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.extension.plugins.pagination.Page;
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 org.apache.commons.beanutils.PropertyUtils;
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.servlet.ModelAndView;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
@@ -37,7 +37,9 @@ import java.util.*;
*/
@Slf4j
public class JeecgController<T, S extends IService<T>> {
/**issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service*/
/**
* issues/2933 JeecgController注入service时改用protected修饰能避免重复引用service
*/
@Autowired
protected S service;
@Resource
@@ -57,7 +59,7 @@ public class JeecgController<T, S extends IService<T>> {
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList);
queryWrapper.in("id", selectionList);
}
// Step.2 获取导出数据
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.CLASS, clazz);
//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());
//update-end--Author:liusq Date:20210126 for图片导出报错ImageBasePath未设置----------------------
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
/**
* 根据每页sheet数量导出多sheet
*
@@ -86,35 +89,35 @@ public class JeecgController<T, S extends IService<T>> {
* @param pageNum 每个sheet的数据条数
* @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 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 计算分页sheet数据
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导出根据选择导出写法调整 ---
// Step.3 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
queryWrapper.in("id",selectionList);
queryWrapper.in("id", selectionList);
}
//update-end-author:liusq---date:20220629--for: 多sheet导出根据选择导出写法调整 ---
// Step.4 多sheet处理
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);
IPage<T> pageList = service.page(page, queryWrapper);
List<T> exportList = pageList.getRecords();
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);
//map.put("title",exportParams);
//表格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);
listMap.add(map);
@@ -133,9 +136,9 @@ public class JeecgController<T, S extends IService<T>> {
*
* @param request
*/
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields) {
ModelAndView mv = this.exportXls(request,object,clazz,title);
mv.addObject(NormalExcelConstants.EXPORT_FIELDS,exportFields);
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title, String exportFields) {
ModelAndView mv = this.exportXls(request, object, clazz, title);
mv.addObject(NormalExcelConstants.EXPORT_FIELDS, exportFields);
return mv;
}
@@ -184,9 +187,9 @@ public class JeecgController<T, S extends IService<T>> {
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage();
log.error(msg, e);
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
return Result.error("文件导入失败:有重复数据!");
}else{
} else {
return Result.error("文件导入失败:" + e.getMessage());
}
//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示

View File

@@ -1,18 +1,16 @@
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.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
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基类

View File

@@ -1,11 +1,10 @@
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.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecg.common.system.base.service.JeecgService;
/**
* @Description: ServiceImpl基类

View File

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

View File

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

View File

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

View File

@@ -4,64 +4,115 @@ import org.jeecg.common.util.oConvertUtils;
/**
* Query 规则 常量
*
* @Author Scott
* @Date 2019年02月14日
*/
public enum QueryRuleEnum {
/**查询规则 大于*/
GT(">","gt","大于"),
/**查询规则 大于等于*/
GE(">=","ge","大于等于"),
/**查询规则 小于*/
LT("<","lt","小于"),
/**查询规则 小于等于*/
LE("<=","le","于等于"),
/**查询规则 等于*/
EQ("=","eq","等于"),
/**查询规则 不等于*/
NE("!=","ne","不等"),
/**查询规则 包含*/
IN("IN","in","包含"),
/**查询规则 全模糊*/
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片段"),
/**
* 查询规则 大于
*/
GT(">", "gt", "大于"),
/**
* 查询规则 大于等于
*/
GE(">=", "ge", "于等于"),
/**
* 查询规则 小于
*/
LT("<", "lt", ""),
/**
* 查询规则 小于等于
*/
LE("<=", "le", "小于等于"),
/**
* 查询规则 等于
*/
EQ("=", "eq", "等于"),
/**
* 查询规则 不等于
*/
NE("!=", "ne", "等于"),
/**
* 查询规则 包含
*/
IN("IN", "in", "包含"),
/**
* 查询规则 全模糊
*/
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","不以…开头"),
/** 值为空 */
EMPTY("EMPTY","empty","值为空"),
/** 值不为空 */
NOT_EMPTY("NOT_EMPTY","not_empty","值不为空"),
/**查询规则 不包含*/
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查询语句");
/**
* 查询规则 不以…结尾
*/
NOT_LEFT_LIKE("NOT_LEFT_LIKE", "not_left_like", "不以…结尾"),
/**
* 查询规则 不以…开头
*/
NOT_RIGHT_LIKE("NOT_RIGHT_LIKE", "not_right_like", "不以…开头"),
/**
* 值为空
*/
EMPTY("EMPTY", "empty", "值为空"),
/**
* 值不为空
*/
NOT_EMPTY("NOT_EMPTY", "not_empty", "值不为空"),
/**
* 查询规则 不包含
*/
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;
@@ -70,7 +121,7 @@ public enum QueryRuleEnum {
private String msg;
QueryRuleEnum(String value, String condition, String msg){
QueryRuleEnum(String value, String condition, String msg) {
this.value = value;
this.condition = condition;
this.msg = msg;
@@ -100,12 +151,12 @@ public enum QueryRuleEnum {
this.condition = condition;
}
public static QueryRuleEnum getByValue(String value){
if(oConvertUtils.isEmpty(value)) {
public static QueryRuleEnum getByValue(String value) {
if (oConvertUtils.isEmpty(value)) {
return null;
}
for(QueryRuleEnum val :values()){
if (val.getValue().equals(value) || val.getCondition().equalsIgnoreCase(value)){
for (QueryRuleEnum val : values()) {
if (val.getValue().equals(value) || val.getCondition().equalsIgnoreCase(value)) {
return val;
}
}

View File

@@ -1,11 +1,11 @@
package org.jeecg.common.system.util;
import jakarta.servlet.http.HttpServletRequest;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.system.vo.SysUserCacheInfo;
import org.jeecg.common.util.SpringContextUtils;
import org.springframework.util.StringUtils;
import jakarta.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@@ -14,7 +14,6 @@ import java.util.List;
* @Description: 数据权限查询规则容器工具类
* @Author: 张代浩
* @Date: 2012-12-15 下午11:27:39
*
*/
public class JeecgDataAutorUtils {
@@ -33,8 +32,8 @@ public class JeecgDataAutorUtils {
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) {
@SuppressWarnings("unchecked")
// 1.先从request获取MENU_DATA_AUTHOR_RULES如果存则获取到LIST
List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon();
if (list==null) {
List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>) loadDataSearchConditon();
if (list == null) {
// 2.如果不存在则new一个list
list = new ArrayList<SysPermissionDataRuleModel>();
}
@@ -74,12 +73,13 @@ public class JeecgDataAutorUtils {
public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) {
String ruleSql = (String) loadDataSearchConditonSqlString();
if (!StringUtils.hasText(ruleSql)) {
request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL,sql);
request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL, sql);
}
}
/**
* 将用户信息存到request
*
* @param request
* @param userinfo
*/
@@ -89,6 +89,7 @@ public class JeecgDataAutorUtils {
/**
* 将用户信息存到request
*
* @param userinfo
*/
public static synchronized void installUserInfo(SysUserCacheInfo userinfo) {
@@ -97,6 +98,7 @@ public class JeecgDataAutorUtils {
/**
* 从request获取用户信息
*
* @return
*/
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.fasterxml.jackson.databind.ObjectMapper;
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.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
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.oConvertUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
/**
* @Author Scott
* @Date 2018-07-12 14:23
@@ -38,12 +37,13 @@ import org.jeecg.common.util.oConvertUtils;
@Slf4j
public class JwtUtil {
/**Token有效期为7天Token在reids中缓存时间为两倍*/
/**
* Token有效期为7天Token在reids中缓存时间为两倍
*/
public static final long EXPIRE_TIME = (7 * 12) * 60 * 60 * 1000;
static final String WELL_NUMBER = SymbolConstant.WELL_NUMBER + SymbolConstant.LEFT_CURLY_BRACKET;
/**
*
* @param response
* @param code
* @param errorMsg
@@ -134,6 +134,7 @@ public class JwtUtil {
/**
* 从session中获取变量
*
* @param key
* @return
*/
@@ -143,31 +144,34 @@ public class JwtUtil {
String moshi = "";
String wellNumber = WELL_NUMBER;
if(key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET)!=-1){
moshi = key.substring(key.indexOf("}")+1);
if (key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET) != -1) {
moshi = key.substring(key.indexOf("}") + 1);
}
String returnValue = null;
if (key.contains(wellNumber)) {
key = key.substring(2,key.indexOf("}"));
key = key.substring(2, key.indexOf("}"));
}
if (oConvertUtils.isNotEmpty(key)) {
HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
returnValue = (String) session.getAttribute(key);
}
//结果加上${} 后面的值
if(returnValue!=null){returnValue = returnValue + moshi;}
if (returnValue != null) {
returnValue = returnValue + moshi;
}
return returnValue;
}
/**
* 从当前用户中获取变量
*
* @param key
* @param user
* @return
*/
public static String getUserSystemData(String key, SysUserCacheInfo user) {
//1.优先获取 SysUserCacheInfo
if(user==null) {
if (user == null) {
try {
user = JeecgDataAutorUtils.loadUserInfo();
} catch (Exception e) {
@@ -185,66 +189,66 @@ public class JwtUtil {
//#{sys_user_code}%
String moshi = "";
String wellNumber = WELL_NUMBER;
if(key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET)!=-1){
moshi = key.substring(key.indexOf("}")+1);
if (key.indexOf(SymbolConstant.RIGHT_CURLY_BRACKET) != -1) {
moshi = key.substring(key.indexOf("}") + 1);
}
String returnValue = null;
//针对特殊标示处理#{sysOrgCode},判断替换
if (key.contains(wellNumber)) {
key = key.substring(2,key.indexOf("}"));
key = key.substring(2, key.indexOf("}"));
} else {
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();
}
//替换为当前系统时间(年月日时分秒)
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();
}
//流程状态默认值(默认未发起)
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";
}
//后台任务获取用户信息异常,导致程序中断
if(sysUser==null && user==null){
if (sysUser == null && user == null) {
return null;
}
//替换为系统登录用户帐号
if (key.equals(DataBaseConstant.SYS_USER_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
if(user==null) {
if (key.equals(DataBaseConstant.SYS_USER_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
if (user == null) {
returnValue = sysUser.getUsername();
}else {
} else {
returnValue = user.getSysUserCode();
}
}
// 替换为系统登录用户ID
else if (key.equals(DataBaseConstant.SYS_USER_ID) || key.equalsIgnoreCase(DataBaseConstant.SYS_USER_ID_TABLE)) {
if(user==null) {
if (user == null) {
returnValue = sysUser.getId();
}else {
} else {
returnValue = user.getSysUserId();
}
}
//替换为系统登录用户真实名字
else if (key.equals(DataBaseConstant.SYS_USER_NAME)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
if(user==null) {
else if (key.equals(DataBaseConstant.SYS_USER_NAME) || key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
if (user == null) {
returnValue = sysUser.getRealname();
}else {
} else {
returnValue = user.getSysUserName();
}
}
//替换为系统用户登录所使用的机构编码
else if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
if(user==null) {
else if (key.equals(DataBaseConstant.SYS_ORG_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
if (user == null) {
returnValue = sysUser.getOrgCode();
}else {
} else {
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)) {
if(user==null){
else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE) || key.toLowerCase().equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) {
if (user == null) {
//TODO 暂时使用用户登录部门,存在逻辑缺陷,不是用户所拥有的部门
returnValue = sysUser.getOrgCode();
}else{
if(user.isOneDepart()) {
} else {
if (user.isOneDepart()) {
returnValue = user.getSysMultiOrgCode().get(0);
}else {
} else {
returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
}
}
@@ -282,7 +286,7 @@ public class JwtUtil {
}
//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 {
returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID);
} catch (Exception e) {
@@ -290,7 +294,9 @@ public class JwtUtil {
}
}
//update-end-author:taoyan date:20210330 for:多租户ID作为系统变量
if(returnValue!=null){returnValue = returnValue + moshi;}
if (returnValue != null) {
returnValue = returnValue + moshi;
}
return returnValue;
}

View File

@@ -21,6 +21,7 @@ import java.util.Map;
/**
* 资源加载工具类
*
* @Author taoYan
* @Date 2022/7/8 10:40
**/
@@ -36,13 +37,13 @@ public class ResourceUtil {
/**
* 所有java类
*/
private final static String CLASS_PATTERN="/**/*.class";
private final static String CLASS_PATTERN = "/**/*.class";
/**
* 所有枚举java类
*/
private final static String CLASS_ENUM_PATTERN="/**/*Enum.class";
private final static String CLASS_ENUM_PATTERN = "/**/*Enum.class";
/**
* 包路径 org.jeecg
@@ -56,10 +57,11 @@ public class ResourceUtil {
/**
* 获取枚举类对应的字典数据 SysDictServiceImpl#queryAllDictItems()
*
* @return
*/
public static Map<String, List<DictModel>> getEnumDictData(){
if(enumDictData.keySet().size()>0){
public static Map<String, List<DictModel>> getEnumDictData() {
if (enumDictData.keySet().size() > 0) {
return enumDictData;
}
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
@@ -75,13 +77,13 @@ public class ResourceUtil {
if (enumDict != null) {
EnumDict annotation = clazz.getAnnotation(EnumDict.class);
String key = annotation.value();
if(oConvertUtils.isNotEmpty(key)){
if (oConvertUtils.isNotEmpty(key)) {
List<DictModel> list = (List<DictModel>) clazz.getDeclaredMethod(METHOD_NAME).invoke(null);
enumDictData.put(key, list);
}
}
}
}catch (Exception e){
} catch (Exception e) {
log.error("获取枚举类字典数据异常", e.getMessage());
// e.printStackTrace();
}
@@ -90,24 +92,25 @@ public class ResourceUtil {
/**
* 用于后端字典翻译 SysDictServiceImpl#queryManyDictByKeys(java.util.List, java.util.List)
*
* @param dictCodeList
* @param keys
* @return
*/
public static Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys){
if(enumDictData.keySet().size()==0){
public static Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys) {
if (enumDictData.keySet().size() == 0) {
getEnumDictData();
}
Map<String, List<DictModel>> map = new HashMap<>();
for (String code : enumDictData.keySet()) {
if(dictCodeList.indexOf(code)>=0){
if (dictCodeList.indexOf(code) >= 0) {
List<DictModel> dictItemList = enumDictData.get(code);
for(DictModel dm: dictItemList){
for (DictModel dm : dictItemList) {
String value = dm.getValue();
if(keys.indexOf(value)>=0){
if (keys.indexOf(value) >= 0) {
List<DictModel> list = new ArrayList<>();
list.add(new DictModel(value, dm.getText()));
map.put(code,list);
map.put(code, list);
break;
}
}
@@ -121,15 +124,15 @@ public class ResourceUtil {
*
* @param classPath
*/
public static Object getImplementationClass(String classPath){
public static Object getImplementationClass(String classPath) {
try {
Class<?> aClass = Class.forName(classPath);
return SpringContextUtils.getBean(aClass);
} catch (ClassNotFoundException e) {
log.error("类没有找到",e);
log.error("类没有找到", e);
return null;
} catch (NoSuchBeanDefinitionException e){
log.error(classPath + "没有实现",e);
} catch (NoSuchBeanDefinitionException e) {
log.error(classPath + "没有实现", e);
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.util.CommonUtils;
import org.jeecg.common.util.oConvertUtils;
import java.util.ArrayList;
import java.util.List;
@@ -20,18 +21,20 @@ public class SqlConcatUtil {
/**
* 获取单个查询条件的值
*
* @param rule
* @param field
* @param value
* @param isString
* @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);
}
/**
* 报表获取查询条件 支持多数据源
*
* @param field
* @param alias
* @param value
@@ -39,17 +42,18 @@ public class SqlConcatUtil {
* @param dataBaseType
* @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) {
return "";
}
field = alias+oConvertUtils.camelToUnderline(field);
field = alias + oConvertUtils.camelToUnderline(field);
QueryRuleEnum rule = QueryGenerator.convert2Rule(value);
return getSingleSqlByRule(rule, field, value, isString, dataBaseType);
}
/**
* 获取单个查询条件的值
*
* @param rule
* @param field
* @param value
@@ -57,44 +61,44 @@ public class SqlConcatUtil {
* @param dataBaseType
* @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 = "";
switch (rule) {
case GT:
res =field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType);
res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break;
case GE:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType);
res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break;
case LT:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType);
res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break;
case LE:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType);
res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break;
case EQ:
res = field+rule.getValue()+getFieldConditionValue(value, isString, dataBaseType);
res = field + rule.getValue() + getFieldConditionValue(value, isString, dataBaseType);
break;
case EQ_WITH_ADD:
res = field+" = "+getFieldConditionValue(value, isString, dataBaseType);
res = field + " = " + getFieldConditionValue(value, isString, dataBaseType);
break;
case NE:
res = field+" <> "+getFieldConditionValue(value, isString, dataBaseType);
res = field + " <> " + getFieldConditionValue(value, isString, dataBaseType);
break;
case IN:
res = field + " in "+getInConditionValue(value, isString);
res = field + " in " + getInConditionValue(value, isString);
break;
case LIKE:
res = field + " like "+getLikeConditionValue(value, QueryRuleEnum.LIKE);
res = field + " like " + getLikeConditionValue(value, QueryRuleEnum.LIKE);
break;
case LEFT_LIKE:
res = field + " like "+getLikeConditionValue(value, QueryRuleEnum.LEFT_LIKE);
res = field + " like " + getLikeConditionValue(value, QueryRuleEnum.LEFT_LIKE);
break;
case RIGHT_LIKE:
res = field + " like "+getLikeConditionValue(value, QueryRuleEnum.RIGHT_LIKE);
res = field + " like " + getLikeConditionValue(value, QueryRuleEnum.RIGHT_LIKE);
break;
default:
res = field+" = "+getFieldConditionValue(value, isString, dataBaseType);
res = field + " = " + getFieldConditionValue(value, isString, dataBaseType);
break;
}
return res;
@@ -102,62 +106,63 @@ public class SqlConcatUtil {
/**
* 获取查询条件的值
*
* @param value
* @param isString
* @param dataBaseType
* @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();
if(str.startsWith(SymbolConstant.EXCLAMATORY_MARK)) {
if (str.startsWith(SymbolConstant.EXCLAMATORY_MARK)) {
str = str.substring(1);
}else if(str.startsWith(QueryRuleEnum.GE.getValue())) {
} else if (str.startsWith(QueryRuleEnum.GE.getValue())) {
str = str.substring(2);
}else if(str.startsWith(QueryRuleEnum.LE.getValue())) {
} else if (str.startsWith(QueryRuleEnum.LE.getValue())) {
str = str.substring(2);
}else if(str.startsWith(QueryRuleEnum.GT.getValue())) {
} else if (str.startsWith(QueryRuleEnum.GT.getValue())) {
str = str.substring(1);
}else if(str.startsWith(QueryRuleEnum.LT.getValue())) {
} else if (str.startsWith(QueryRuleEnum.LT.getValue())) {
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);
}
if(dataBaseType==null){
if (dataBaseType == null) {
dataBaseType = getDbType();
}
if(isString) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType)){
return " N'"+str+"' ";
}else{
return " '"+str+"' ";
if (isString) {
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType)) {
return " N'" + str + "' ";
} else {
return " '" + str + "' ";
}
}else {
} else {
// 如果不是字符串 有一种特殊情况 popup调用都走这个逻辑 参数传递的可能是“admin”这种格式的
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK)){
return " N"+str;
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(dataBaseType) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK)) {
return " N" + str;
}
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报错
String[] temp = value.toString().split(",");
if(temp.length==0){
if (temp.length == 0) {
return "('')";
}
if(isString) {
if (isString) {
List<String> res = new ArrayList<>();
for (String string : temp) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
res.add("N'"+string+"'");
}else{
res.add("'"+string+"'");
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
res.add("N'" + string + "'");
} else {
res.add("'" + string + "'");
}
}
return "("+String.join("," ,res)+")";
}else {
return "("+value.toString()+")";
return "(" + String.join(",", res) + ")";
} else {
return "(" + value.toString() + ")";
}
//update-end-author:taoyan date:20210628 for: 查询条件如果输入,导致sql报错
}
@@ -165,46 +170,47 @@ public class SqlConcatUtil {
/**
* 先根据值判断 走左模糊还是右模糊
* 最后如果值不带任何标识(*或者%)则再根据ruleEnum判断
*
* @param value
* @param ruleEnum
* @return
*/
private static String getLikeConditionValue(Object value, QueryRuleEnum ruleEnum) {
String str = value.toString().trim();
if(str.startsWith(SymbolConstant.ASTERISK) && str.endsWith(SymbolConstant.ASTERISK)) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'%"+str.substring(1,str.length()-1)+"%'";
}else{
return "'%"+str.substring(1,str.length()-1)+"%'";
if (str.startsWith(SymbolConstant.ASTERISK) && str.endsWith(SymbolConstant.ASTERISK)) {
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
return "N'%" + str.substring(1, str.length() - 1) + "%'";
} else {
return "'%" + str.substring(1, str.length() - 1) + "%'";
}
}else if(str.startsWith(SymbolConstant.ASTERISK)) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'%"+str.substring(1)+"'";
}else{
return "'%"+str.substring(1)+"'";
} else if (str.startsWith(SymbolConstant.ASTERISK)) {
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
return "N'%" + str.substring(1) + "'";
} else {
return "'%" + str.substring(1) + "'";
}
}else if(str.endsWith(SymbolConstant.ASTERISK)) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N'"+str.substring(0,str.length()-1)+"%'";
}else{
return "'"+str.substring(0,str.length()-1)+"%'";
} else if (str.endsWith(SymbolConstant.ASTERISK)) {
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
return "N'" + str.substring(0, str.length() - 1) + "%'";
} else {
return "'" + str.substring(0, str.length() - 1) + "%'";
}
}else {
if(str.indexOf(SymbolConstant.PERCENT_SIGN)>=0) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
if(str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)){
return "N"+str;
}else{
return "N"+"'"+str+"'";
} else {
if (str.indexOf(SymbolConstant.PERCENT_SIGN) >= 0) {
if (DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())) {
if (str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)) {
return "N" + str;
} else {
return "N" + "'" + str + "'";
}
}else{
if(str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)){
} else {
if (str.startsWith(SymbolConstant.SINGLE_QUOTATION_MARK) && str.endsWith(SymbolConstant.SINGLE_QUOTATION_MARK)) {
return str;
}else{
return "'"+str+"'";
} else {
return "'" + str + "'";
}
}
}else {
} else {
//update-begin-author:taoyan date:2022-6-30 for: issues/3810 数据权限规则问题
// 走到这里说明 value不带有任何模糊查询的标识(*或者%)

View File

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

View File

@@ -1,14 +1,13 @@
package org.jeecg.common.system.vo;
import java.io.Serializable;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Description: 字典类
* @author: jeecg-boot
@@ -17,7 +16,7 @@ import lombok.experimental.Accessors;
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DictModel implements Serializable{
public class DictModel implements Serializable {
private static final long serialVersionUID = 1L;
public DictModel() {
@@ -49,11 +48,13 @@ public class DictModel implements Serializable{
/**
* 特殊用途: JgEditableTable
*
* @return
*/
public String getTitle() {
return this.text;
}
/**
* 特殊用途: vue3 Select组件
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,19 +7,33 @@ package org.jeecg.common.system.vo;
* @date: 2022年08月11日 9:48
*/
public class SysFilesModel {
/**主键id*/
/**
* 主键id
*/
private String id;
/**文件名称*/
/**
* 文件名称
*/
private String fileName;
/**文件地址*/
/**
* 文件地址
*/
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;
/**文件上传类型(temp/本地上传(临时文件) manage/知识库)*/
/**
* 文件上传类型(temp/本地上传(临时文件) manage/知识库)
*/
private String storeType;
/**文件大小kb*/
/**
* 文件大小kb
*/
private Double fileSize;
/**租户id*/
/**
* 租户id
*/
private String tenantId;
public String getId() {

View File

@@ -1,12 +1,5 @@
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;
/**

View File

@@ -1,9 +1,9 @@
package org.jeecg.common.system.vo;
import java.util.List;
import org.jeecg.common.util.DateUtils;
import java.util.List;
/**
* @Description: 用户缓存信息
* @author: jeecg-boot

View File

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

View File

@@ -1,13 +1,11 @@
package org.jeecg.common.util;
/**
*
* @Author 张代浩
*
*/
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
}

View File

@@ -1,21 +1,20 @@
package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jakarta.servlet.http.HttpServletRequest;
/**
*
* @Author 张代浩
*
*/
public class BrowserUtils {
/**
* 判断是否是IE
*
* @param request
* @return
*/
@@ -178,8 +177,7 @@ public class BrowserUtils {
private final static String EN_US = "en";
static
{
static {
langMap.put(ZH, ZH_CN);
langMap.put(EN, EN_US);
}
@@ -187,21 +185,24 @@ public class BrowserUtils {
public static String getBrowserLanguage(HttpServletRequest request) {
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;
}
return browserLangCode;
}
/** 判断请求是否来自电脑端 */
/**
* 判断请求是否来自电脑端
*/
public static boolean isDesktop(HttpServletRequest request) {
return !isMobile(request);
}
/** 判断请求是否来自移动端 */
/**
* 判断请求是否来自移动端
*/
public static boolean isMobile(HttpServletRequest request) {
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)";

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

View File

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

View File

@@ -20,21 +20,28 @@ import org.slf4j.LoggerFactory;
* 工程依赖了2个jar包(存放在工程的libs目录下)
* 1:aliyun-java-sdk-core.jar
* 2:aliyun-java-sdk-dysmsapi.jar
*
* <p>
* 备注:Demo工程编码采用UTF-8
* 国际短信发送请勿参照此DEMO
*
* @author: jeecg-boot
*/
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 DOMAIN = "dysmsapi.aliyuncs.com";
/**TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)*/
/**
* TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
*/
static String accessKeyId;
static String accessKeySecret;
@@ -74,7 +81,7 @@ public class DySmsHelper {
IAcsClient acsClient = new DefaultAcsClient(profile);
//验证json参数
validateParam(templateParamJson,dySmsEnum);
validateParam(templateParamJson, dySmsEnum);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
@@ -98,7 +105,7 @@ public class DySmsHelper {
//hint 此处可能会抛出异常注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
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";
if (ok.equals(sendSmsResponse.getCode())) {
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 [] keyArr = keys.split(",");
for(String item :keyArr) {
if(!templateParamJson.containsKey(item)) {
throw new RuntimeException("模板缺少参数:"+item);
String[] keyArr = keys.split(",");
for (String item : keyArr) {
if (!templateParamJson.containsKey(item)) {
throw new RuntimeException("模板缺少参数:" + item);
}
}
}

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.slf4j.Logger;
@@ -24,7 +23,7 @@ public class IpUtils {
/**
* 获取IP地址
*
* <p>
* 使用Nginx等反向代理软件 则不能通过request.getRemoteAddr()获取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)) {
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");
}
if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
@@ -72,6 +71,7 @@ public class IpUtils {
/**
* 判断是否是IP格式
*
* @param ipAddress
* @return
*/
@@ -84,9 +84,10 @@ public class IpUtils {
/**
* 获取服务器上的ip
*
* @return
*/
public static String getServerIp(){
public static String getServerIp() {
InetAddress inetAddress = null;
try {
inetAddress = InetAddress.getLocalHost();

View File

@@ -8,12 +8,12 @@ import java.security.MessageDigest;
*/
public class Md5Util {
private static final String[] HEXDIGITS = { "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
private static final String[] HEXDIGITS = {"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
public static String byteArrayToHexString(byte[] b) {
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]));
}
return resultSb.toString();

View File

@@ -12,13 +12,14 @@ public class MyClassLoader extends ClassLoader {
myclass = Class.forName(className);
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(className+" not found!");
throw new RuntimeException(className + " not found!");
}
return myclass;
}
/**
* 获得类的全名,包括包名
*
* @param object
* @return
*/
@@ -46,8 +47,8 @@ public class MyClassLoader extends ClassLoader {
// 如果不是匿名包,将包名转化为路径
if (pack != null) {
String packName = pack.getName();
String javaSpot="java.";
String javaxSpot="javax.";
String javaSpot = "java.";
String javaxSpot = "javax.";
// 此处简单判定是否是Java基础类库防止用户传入JDK内置的类库
if (packName.startsWith(javaSpot) || packName.startsWith(javaxSpot)) {
throw new java.lang.IllegalArgumentException("不要传送系统类!");
@@ -67,7 +68,7 @@ public class MyClassLoader extends ClassLoader {
start = end + 1;
end = packName.indexOf(".", start);
}
if(oConvertUtils.isNotEmpty(pathBuilder.toString())){
if (oConvertUtils.isNotEmpty(pathBuilder.toString())) {
path = pathBuilder.toString();
}
path = path + packName.substring(start) + "/";

View File

@@ -1,12 +1,12 @@
package org.jeecg.common.util;
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.security.Key;
import java.security.SecureRandom;
/**
* @Description: 密码工具类
@@ -40,7 +40,7 @@ public class PasswordUtil {
* 获取加密算法中使用的盐值,解密中使用的盐值必须与加密中使用的相同才能完成操作. 盐长度必须为8字节
*
* @return byte[] 盐值
* */
*/
public static byte[] getSalt() throws Exception {
// 实例化安全随机数
SecureRandom random = new SecureRandom();
@@ -56,10 +56,9 @@ public class PasswordUtil {
/**
* 根据PBE密码生成一把密钥
*
* @param password
* 生成密钥时所使用的密码
* @param password 生成密钥时所使用的密码
* @return Key PBE算法密钥
* */
*/
private static Key getPbeKey(String password) {
// 实例化使用的算法
SecretKeyFactory keyFactory;
@@ -81,12 +80,9 @@ public class PasswordUtil {
/**
* 加密明文字符串
*
* @param plaintext
* 待加密的明文字符串
* @param password
* 生成密钥时所使用的密码
* @param salt
* 盐值
* @param plaintext 待加密的明文字符串
* @param password 生成密钥时所使用的密码
* @param salt 盐值
* @return 加密后的密文字符串
* @throws Exception
*/
@@ -110,12 +106,9 @@ public class PasswordUtil {
/**
* 解密密文字符串
*
* @param ciphertext
* 待解密的密文字符串
* @param password
* 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
* @param salt
* 盐值(如需解密,该参数需要与加密时使用的一致)
* @param ciphertext 待解密的密文字符串
* @param password 生成密钥时所使用的密码(如需解密,该参数需要与加密时使用的一致)
* @param salt 盐值(如需解密,该参数需要与加密时使用的一致)
* @return 解密后的明文字符串
* @throws Exception
*/
@@ -130,9 +123,7 @@ public class PasswordUtil {
cipher.init(Cipher.DECRYPT_MODE, key, parameterSpec);
passDec = cipher.doFinal(hexStringToBytes(ciphertext));
}
catch (Exception e) {
} catch (Exception e) {
// TODO: handle exception
}
return new String(passDec);
@@ -141,8 +132,7 @@ public class PasswordUtil {
/**
* 将字节数组转换为十六进制字符串
*
* @param src
* 字节数组
* @param src 字节数组
* @return
*/
public static String bytesToHexString(byte[] src) {
@@ -164,8 +154,7 @@ public class PasswordUtil {
/**
* 将十六进制字符串转换为字节数组
*
* @param hexString
* 十六进制字符串
* @param hexString 十六进制字符串
* @return
*/
public static byte[] hexStringToBytes(String hexString) {

View File

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

View File

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

View File

@@ -2,7 +2,6 @@ package org.jeecg.common.util;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.ServiceNameConstants;
import org.springframework.beans.BeansException;
@@ -44,6 +43,7 @@ public class SpringContextUtils implements ApplicationContextAware {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
/**
* 获取HttpServletResponse
*/
@@ -54,26 +54,26 @@ public class SpringContextUtils implements ApplicationContextAware {
/**
* 获取项目根路径 basePath
*/
public static String getDomain(){
public static String getDomain() {
HttpServletRequest request = getHttpServletRequest();
StringBuffer url = request.getRequestURL();
//1.微服务情况下获取gateway的basePath
String basePath = request.getHeader(ServiceNameConstants.X_GATEWAY_BASE_PATH);
if(oConvertUtils.isNotEmpty(basePath)){
if (oConvertUtils.isNotEmpty(basePath)) {
return basePath;
}else{
} else {
String domain = url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
//2.【兼容】SSL认证之后request.getScheme()获取不到https的问题
// https://blog.csdn.net/weixin_34376986/article/details/89767950
String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME);
if(scheme!=null && !request.getScheme().equals(scheme)){
domain = domain.replace(request.getScheme(),scheme);
if (scheme != null && !request.getScheme().equals(scheme)) {
domain = domain.replace(request.getScheme(), scheme);
}
return domain;
}
}
public static String getOrigin(){
public static String getOrigin() {
HttpServletRequest request = getHttpServletRequest();
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.SymbolConstant;
import org.jeecg.common.exception.JeecgSqlInjectionException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
@@ -33,6 +34,7 @@ public class SqlInjectionUtil {
* 完整匹配的key不需要考虑前空格
*/
private static List<String> FULL_MATCHING_KEYWRODS = new ArrayList<>();
static {
FULL_MATCHING_KEYWRODS.add(";");
FULL_MATCHING_KEYWRODS.add("+");
@@ -42,7 +44,7 @@ public class SqlInjectionUtil {
/**
* sql注入风险的 正则关键字
*
* <p>
* 函数匹配,需要用正则模式
*/
private final static String[] XSS_REGULAR_STR_ARRAY = new String[]{
@@ -73,6 +75,7 @@ public class SqlInjectionUtil {
/**
* sql注入过滤处理遇到注入关键字抛异常
*
* @param values
*/
public static void filterContentMulti(String... values) {
@@ -81,7 +84,7 @@ public class SqlInjectionUtil {
/**
* 校验比较严格
*
* <p>
* sql注入过滤处理遇到注入关键字抛异常
*
* @param value
@@ -143,7 +146,7 @@ public class SqlInjectionUtil {
} else if (sql.contains(keyword)) {
// 需要匹配的sql注入关键词
String matchingText = " " + keyword;
if(FULL_MATCHING_KEYWRODS.contains(keyword)){
if (FULL_MATCHING_KEYWRODS.contains(keyword)) {
matchingText = keyword;
}
@@ -224,6 +227,7 @@ public class SqlInjectionUtil {
/**
* 【提醒:不通用】
* 仅用于Online报表SQL解析注入过滤
*
* @param value
* @return
*/
@@ -260,10 +264,11 @@ public class SqlInjectionUtil {
/**
* 校验是否有sql注释
*
* @return
*/
public static void checkSqlAnnotation(String str){
if(str.contains(SQL_ANNOTATION2)){
public static void checkSqlAnnotation(String str) {
if (str.contains(SQL_ANNOTATION2)) {
String error = "请注意SQL中不允许含注释有安全风险";
log.error(error);
throw new RuntimeException(error);
@@ -271,7 +276,7 @@ public class SqlInjectionUtil {
Matcher matcher = SQL_ANNOTATION.matcher(str);
if(matcher.find()){
if (matcher.find()) {
String error = "请注意值可能存在SQL注入风险---> \\*.*\\";
log.error(error);
throw new JeecgSqlInjectionException(error);
@@ -287,8 +292,9 @@ public class SqlInjectionUtil {
* @param table
*/
private static Pattern tableNamePattern = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_\\$]{0,63}$");
public static String getSqlInjectTableName(String table) {
if(oConvertUtils.isEmpty(table)){
if (oConvertUtils.isEmpty(table)) {
return table;
}
@@ -329,8 +335,9 @@ public class SqlInjectionUtil {
* @param field
*/
static final Pattern fieldPattern = Pattern.compile("^[a-zA-Z0-9_]+$");
public static String getSqlInjectField(String field) {
if(oConvertUtils.isEmpty(field)){
if (oConvertUtils.isEmpty(field)) {
return field;
}
@@ -375,9 +382,10 @@ public class SqlInjectionUtil {
/**
* 获取排序字段
* 返回:字符串
*
* <p>
* 1.将驼峰命名转化成下划线
* 2.限制sql注入
*
* @param sortField 排序字段
* @return
*/
@@ -389,9 +397,10 @@ public class SqlInjectionUtil {
/**
* 获取多个排序字段
* 返回:数组
*
* <p>
* 1.将驼峰命名转化成下划线
* 2.限制sql注入
*
* @param sortFields 多个排序字段
* @return
*/

View File

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

View File

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

View File

@@ -6,19 +6,21 @@ import io.netty.util.internal.StringUtil;
* 流水号生成规则(按默认规则递增数字从1-99开始递增数字到99递增字母;位数不够增加位数)
* A001
* A001A002
* @Author zhangdaihao
*
* @Author zhangdaihao
*/
public class YouBianCodeUtil {
// 数字位数(默认生成3位的数字)
/**代表数字位数*/
/**
* 代表数字位数
*/
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
@@ -34,8 +36,8 @@ public class YouBianCodeUtil {
String num = getStrNum(1);
newcode = zimu + num;
} else {
String beforeCode = code.substring(0, code.length() - 1- NUM_LENGTH);
String afterCode = code.substring(code.length() - 1 - NUM_LENGTH,code.length());
String beforeCode = code.substring(0, code.length() - 1 - NUM_LENGTH);
String afterCode = code.substring(code.length() - 1 - NUM_LENGTH, code.length());
char afterCodeZimu = afterCode.substring(0, 1).charAt(0);
Integer afterCodeNum = Integer.parseInt(afterCode.substring(1));
// org.jeecgframework.core.util.LogUtil.info(after_code);
@@ -51,9 +53,9 @@ public class YouBianCodeUtil {
nextNum = getNextStrNum(afterCodeNum);
}
// 先判断数字等于999*则字母从A重新开始,递增
if(afterCodeNum == getMaxNumByLength(NUM_LENGTH)) {
if (afterCodeNum == getMaxNumByLength(NUM_LENGTH)) {
nextZimu = getNextZiMu(afterCodeZimu);
}else{
} else {
nextZimu = afterCodeZimu;
}
@@ -70,7 +72,7 @@ public class YouBianCodeUtil {
/**
* 根据父亲code,获取下级的下一个code
*
* <p>
* 例如父亲CODE:A01
* 当前CODE:A01B03
* 获取的code:A01B04
@@ -79,20 +81,19 @@ public class YouBianCodeUtil {
* @param localCode 同级code
* @return
*/
public static synchronized String getSubYouBianCode(String parentCode,String localCode) {
if(localCode!=null && localCode!=""){
public static synchronized String getSubYouBianCode(String parentCode, String localCode) {
if (localCode != null && localCode != "") {
// return parentCode + getNextYouBianCode(localCode);
return getNextYouBianCode(localCode);
}else{
parentCode = parentCode + "A"+ getNextStrNum(0);
} else {
parentCode = parentCode + "A" + getNextStrNum(0);
}
return parentCode;
}
/**
* 将数字前面位数补零
*
@@ -141,28 +142,30 @@ public class YouBianCodeUtil {
/**
* 根据数字位数获取最大值
*
* @param length
* @return
*/
private static int getMaxNumByLength(int length){
if(length==0){
private static int getMaxNumByLength(int length) {
if (length == 0) {
return 0;
}
StringBuilder maxNum = new StringBuilder();
for (int i=0;i<length;i++){
for (int i = 0; i < length; i++) {
maxNum.append("9");
}
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;
}else{
} else {
//获取标准长度为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];
for(int i =0 ; i <c;i++){
cutcode[i] = code.substring(0,(i+1)*(NUM_LENGTH +1));
for (int i = 0; i < c; i++) {
cutcode[i] = code.substring(0, (i + 1) * (NUM_LENGTH + 1));
}
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.util.SpringContextUtils;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.HashMap;
import java.util.Map;
/**
* 数据源缓存池
*
* @author: jeecg-boot
*/
public class DataSourceCachePool {
/** 数据源连接池缓存【本地 class缓存 - 不支持分布式】 */
/**
* 数据源连接池缓存【本地 class缓存 - 不支持分布式】
*/
private static Map<String, DruidDataSource> dbSources = new HashMap<>();
private static RedisTemplate<String, Object> redisTemplate;
@@ -64,10 +68,10 @@ public class DataSourceCachePool {
*/
public static void cleanAllCache() {
//关闭数据源连接
for(Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()){
for (Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()) {
String dbkey = entry.getKey();
DruidDataSource druidDataSource = entry.getValue();
if(druidDataSource!=null && druidDataSource.isEnable()){
if (druidDataSource != null && druidDataSource.isEnable()) {
druidDataSource.close();
}
//清空redis缓存
@@ -80,7 +84,7 @@ public class DataSourceCachePool {
public static void removeCache(String dbKey) {
//关闭数据源连接
DruidDataSource druidDataSource = dbSources.get(dbKey);
if(druidDataSource!=null && druidDataSource.isEnable()){
if (druidDataSource != null && druidDataSource.isEnable()) {
druidDataSource.close();
}
//清空redis缓存

View File

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

View File

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

View File

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

View File

@@ -21,6 +21,7 @@ public class AesEncryptUtil {
/**
* 加密方法
*
* @param data 要加密的数据
* @param key 加密key
* @param iv 加密iv
@@ -59,6 +60,7 @@ public class AesEncryptUtil {
/**
* 解密方法
*
* @param data 要解密的数据
* @param key 解密key
* @param iv 解密iv
@@ -84,6 +86,7 @@ public class AesEncryptUtil {
/**
* 使用默认的key和iv加密
*
* @param data
* @return
* @throws Exception
@@ -94,6 +97,7 @@ public class AesEncryptUtil {
/**
* 使用默认的key和iv解密
*
* @param data
* @return
* @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<>();
/**初始化文件头类型,不够的自行补充*/
/**
* 初始化文件头类型,不够的自行补充
*/
final static HashMap<String, String> FILE_TYPE_MAP = new HashMap<>();
static {
//图片文件
FILE_TYPE_WHITE_LIST.add("jpg");
@@ -197,7 +200,7 @@ public class SsrfFileTypeFilter {
break;
}
}
log.info("-----获取到的指定文件类型------"+fileExtendName);
log.info("-----获取到的指定文件类型------" + fileExtendName);
// 如果不是上述类型,则判断扩展名
if (StringUtils.isBlank(fileExtendName)) {
String fileName = file.getOriginalFilename();
@@ -208,13 +211,13 @@ public class SsrfFileTypeFilter {
// 如果有扩展名,则返回扩展名
return getFileTypeBySuffix(fileName);
}
log.info("-----最終的文件类型------"+fileExtendName);
log.info("-----最終的文件类型------" + fileExtendName);
is.close();
return fileExtendName;
} catch (Exception e) {
log.error(e.getMessage(), e);
return "";
}finally {
} finally {
if (is != null) {
is.close();
}

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