| | |
| | | Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
| | | if (StringUtils.isNotNull(cacheObj))
|
| | | {
|
| | | List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
| | | return dictDatas;
|
| | | return StringUtils.cast(cacheObj);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | {
|
| | | if (value.equals(dict.getDictValue()))
|
| | | {
|
| | | propertyString.append(dict.getDictLabel() + separator);
|
| | | propertyString.append(dict.getDictLabel()).append(separator);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | if (label.equals(dict.getDictLabel()))
|
| | | {
|
| | | propertyString.append(dict.getDictValue() + separator);
|
| | | propertyString.append(dict.getDictValue()).append(separator);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | StringWriter sw = new StringWriter();
|
| | | e.printStackTrace(new PrintWriter(sw, true));
|
| | | String str = sw.toString();
|
| | | return str;
|
| | | return sw.toString();
|
| | | }
|
| | |
|
| | | public static String getRootErrorMessage(Exception e)
|
| | |
| | | *
|
| | | * @param response 渲染对象
|
| | | * @param string 待渲染的字符串
|
| | | * @return null
|
| | | */
|
| | | public static String renderString(HttpServletResponse response, String string)
|
| | | public static void renderString(HttpServletResponse response, String string)
|
| | | {
|
| | | try
|
| | | {
|
| | |
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | public static boolean isAjaxRequest(HttpServletRequest request)
|
| | | {
|
| | | String accept = request.getHeader("accept");
|
| | | if (accept != null && accept.indexOf("application/json") != -1)
|
| | | if (accept != null && accept.contains("application/json"))
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | String xRequestedWith = request.getHeader("X-Requested-With");
|
| | | if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
|
| | | if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | String ajax = request.getParameter("__ajax");
|
| | | if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | | import java.util.Objects;
|
| | | import org.apache.commons.io.FilenameUtils;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | |
| | |
|
| | | /**
|
| | | * 文件上传工具类
|
| | | * |
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | public class FileUploadUtils
|
| | |
| | | *
|
| | | * @param baseDir 相对应用的基目录
|
| | | * @param file 上传的文件
|
| | | * @param extension 上传文件类型
|
| | | * @param allowedExtension 上传文件类型
|
| | | * @return 返回上传成功的文件名
|
| | | * @throws FileSizeLimitExceededException 如果超出最大大小
|
| | | * @throws FileNameLengthLimitExceededException 文件名太长
|
| | |
| | | throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
| | | InvalidExtensionException
|
| | | {
|
| | | int fileNamelength = file.getOriginalFilename().length();
|
| | | int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
|
| | | if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
| | | {
|
| | | throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
| | |
| | |
|
| | | File desc = getAbsoluteFile(baseDir, fileName);
|
| | | file.transferTo(desc);
|
| | | String pathFileName = getPathFileName(baseDir, fileName);
|
| | | return pathFileName;
|
| | | return getPathFileName(baseDir, fileName);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
| | | String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
| | | String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
| | | return pathFileName;
|
| | | return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | throws FileSizeLimitExceededException, InvalidExtensionException
|
| | | {
|
| | | long size = file.getSize();
|
| | | if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
|
| | | if (size > DEFAULT_MAX_SIZE)
|
| | | {
|
| | | throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
| | | }
|
| | |
| | |
|
| | | /**
|
| | | * 获取文件名的后缀
|
| | | * |
| | | *
|
| | | * @param file 表单文件
|
| | | * @return 后缀名
|
| | | */
|
| | |
| | | String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
| | | if (StringUtils.isEmpty(extension))
|
| | | {
|
| | | extension = MimeTypeUtils.getExtension(file.getContentType());
|
| | | extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
| | | }
|
| | | return extension;
|
| | | }
|
| | | } |
| | | }
|
| | |
| | | /**
|
| | | * 读取文件为字节数据
|
| | | *
|
| | | * @param key 地址
|
| | | * @param url 地址
|
| | | * @return 字节数据
|
| | | */
|
| | | public static byte[] readFile(String url)
|
| | |
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.nio.charset.Charset;
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import javax.servlet.ServletRequest;
|
| | | import org.apache.commons.lang3.exception.ExceptionUtils;
|
| | | import org.slf4j.Logger;
|
| | |
| | | BufferedReader reader = null;
|
| | | try (InputStream inputStream = request.getInputStream())
|
| | | {
|
| | | reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
| | | reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
| | | String line = "";
|
| | | while ((line = reader.readLine()) != null)
|
| | | {
|
| | |
| | | import java.net.SocketTimeoutException;
|
| | | import java.net.URL;
|
| | | import java.net.URLConnection;
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.security.cert.X509Certificate;
|
| | | import javax.net.ssl.HostnameVerifier;
|
| | | import javax.net.ssl.HttpsURLConnection;
|
| | |
| | | StringBuilder result = new StringBuilder();
|
| | | try
|
| | | {
|
| | | String urlNameString = url;
|
| | | log.info("sendPost - {}", urlNameString);
|
| | | URL realUrl = new URL(urlNameString);
|
| | | log.info("sendPost - {}", url);
|
| | | URL realUrl = new URL(url);
|
| | | URLConnection conn = realUrl.openConnection();
|
| | | conn.setRequestProperty("accept", "*/*");
|
| | | conn.setRequestProperty("connection", "Keep-Alive");
|
| | |
| | | out = new PrintWriter(conn.getOutputStream());
|
| | | out.print(param);
|
| | | out.flush();
|
| | | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
|
| | | in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
| | | String line;
|
| | | while ((line = in.readLine()) != null)
|
| | | {
|
| | |
| | | {
|
| | | if (ret != null && !"".equals(ret.trim()))
|
| | | {
|
| | | result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
|
| | | result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
|
| | | }
|
| | | }
|
| | | log.info("recv - {}", result);
|
| | |
| | |
|
| | | public static String getRealAddressByIP(String ip)
|
| | | {
|
| | | String address = UNKNOWN;
|
| | | // 内网不查询
|
| | | if (IpUtils.internalIp(ip))
|
| | | {
|
| | |
| | | log.error("获取地理位置异常 {}", ip);
|
| | | }
|
| | | }
|
| | | return address;
|
| | | return UNKNOWN;
|
| | | }
|
| | | }
|
| | |
| | | if (StringUtils.isNotEmpty(excel.targetAttr()))
|
| | | {
|
| | | String target = excel.targetAttr();
|
| | | if (target.indexOf(".") > -1)
|
| | | if (target.contains("."))
|
| | | {
|
| | | String[] targets = target.split("[.]");
|
| | | for (String name : targets)
|
| | |
| | | for (Object[] os : this.fields)
|
| | | {
|
| | | Excel excel = (Excel) os[1];
|
| | | maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
| | | maxHeight = Math.max(maxHeight, excel.height());
|
| | | }
|
| | | return (short) (maxHeight * 20);
|
| | | }
|
| | |
| | | package com.ruoyi.common.utils.sign;
|
| | |
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.security.MessageDigest;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
| | | {
|
| | | try
|
| | | {
|
| | | return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
|
| | | return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | | return;
|
| | | }
|
| | | String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
| | | for (int i = 0; i < sqlKeywords.length; i++)
|
| | | for (String sqlKeyword : sqlKeywords)
|
| | | {
|
| | | if (StringUtils.indexOfIgnoreCase(value, sqlKeywords[i]) > -1)
|
| | | if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
|
| | | {
|
| | | throw new UtilException("参数存在SQL注入风险");
|
| | | }
|
| | |
| | | /**
|
| | | * 唯一标识
|
| | | */
|
| | | private String uuid = "";
|
| | | private String uuid;
|
| | |
|
| | | public String getUsername()
|
| | | {
|
| | |
| | | */
|
| | | public void validateCaptcha(String username, String code, String uuid)
|
| | | {
|
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
| | | String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
| | | String captcha = redisCache.getCacheObject(verifyKey);
|
| | | redisCache.deleteObject(verifyKey);
|
| | | if (captcha == null)
|
| | |
| | | * 批量删除系统登录日志
|
| | | *
|
| | | * @param infoIds 需要删除的登录日志ID
|
| | | * @return
|
| | | * @return 结果
|
| | | */
|
| | | public int deleteLogininforByIds(Long[] infoIds);
|
| | |
|
| | |
| | | * 批量删除系统登录日志
|
| | | *
|
| | | * @param infoIds 需要删除的登录日志ID
|
| | | * @return
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public int deleteLogininforByIds(Long[] infoIds)
|
| | |
| | | * 批量删除参数信息
|
| | | *
|
| | | * @param configIds 需要删除的参数ID
|
| | | * @return 结果
|
| | | */
|
| | | public void deleteConfigByIds(Long[] configIds);
|
| | |
|
| | |
| | | * 批量删除字典数据信息
|
| | | *
|
| | | * @param dictCodes 需要删除的字典数据ID
|
| | | * @return 结果
|
| | | */
|
| | | public void deleteDictDataByIds(Long[] dictCodes);
|
| | |
|
| | |
| | | * 批量删除字典信息
|
| | | *
|
| | | * @param dictIds 需要删除的字典ID
|
| | | * @return 结果
|
| | | */
|
| | | public void deleteDictTypeByIds(Long[] dictIds);
|
| | |
|
| | |
| | | *
|
| | | * @param postIds 需要删除的岗位ID
|
| | | * @return 结果
|
| | | * @throws Exception 异常
|
| | | */
|
| | | public int deletePostByIds(Long[] postIds);
|
| | |
|
| | |
| | | * 批量删除参数信息
|
| | | *
|
| | | * @param configIds 需要删除的参数ID
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public void deleteConfigByIds(Long[] configIds)
|
| | |
| | | {
|
| | | tempList.add(dept.getDeptId());
|
| | | }
|
| | | for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
|
| | | for (SysDept dept : depts)
|
| | | {
|
| | | SysDept dept = (SysDept) iterator.next();
|
| | | // 如果是顶级节点, 遍历该父节点的所有子节点
|
| | | if (!tempList.contains(dept.getParentId()))
|
| | | {
|
| | |
| | | * 批量删除字典数据信息
|
| | | *
|
| | | * @param dictCodes 需要删除的字典数据ID
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public void deleteDictDataByIds(Long[] dictCodes)
|
| | |
| | | * 批量删除字典类型信息
|
| | | *
|
| | | * @param dictIds 需要删除的字典ID
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | public void deleteDictTypeByIds(Long[] dictIds)
|
| | |
| | | */
|
| | | private boolean hasChild(List<SysMenu> list, SysMenu t)
|
| | | {
|
| | | return getChildList(list, t).size() > 0 ? true : false;
|
| | | return getChildList(list, t).size() > 0;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | *
|
| | | * @param postIds 需要删除的岗位ID
|
| | | * @return 结果
|
| | | * @throws Exception 异常
|
| | | */
|
| | | @Override
|
| | | public int deletePostByIds(Long[] postIds)
|
| | |
| | | {
|
| | | int lastIndex = packageName.lastIndexOf(".");
|
| | | int nameLength = packageName.length();
|
| | | String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
| | | return moduleName;
|
| | | return StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | {
|
| | | int lastIndex = tableName.lastIndexOf("_");
|
| | | int nameLength = tableName.length();
|
| | | String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
| | | return businessName;
|
| | | return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return 0;
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | |
| | |
|
| | | /**
|
| | | * 设置模板变量信息
|
| | | * |
| | | *
|
| | | * @return 模板列表
|
| | | */
|
| | | public static VelocityContext prepareContext(GenTable genTable)
|
| | |
| | | context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
| | | context.put("subImportList", getImportList(genTable.getSubTable()));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取模板信息
|
| | | * |
| | | *
|
| | | * @return 模板列表
|
| | | */
|
| | | public static List<String> getTemplateList(String tplCategory)
|
| | |
| | |
|
| | | /**
|
| | | * 获取包前缀
|
| | | * |
| | | *
|
| | | * @param packageName 包名称
|
| | | * @return 包前缀名称
|
| | | */
|
| | | public static String getPackagePrefix(String packageName)
|
| | | {
|
| | | int lastIndex = packageName.lastIndexOf(".");
|
| | | String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
| | | return basePackage;
|
| | | return StringUtils.substring(packageName, 0, lastIndex);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | /**
|
| | | * 获取权限前缀
|
| | | * |
| | | *
|
| | | * @param moduleName 模块名称
|
| | | * @param businessName 业务名称
|
| | | * @return 返回权限前缀
|
| | |
| | |
|
| | | /**
|
| | | * 获取上级菜单ID字段
|
| | | * |
| | | * @param options 生成其他选项
|
| | | *
|
| | | * @param paramsObj 生成其他选项
|
| | | * @return 上级菜单ID字段
|
| | | */
|
| | | public static String getParentMenuId(JSONObject paramsObj)
|
| | |
| | |
|
| | | /**
|
| | | * 获取树编码
|
| | | * |
| | | * @param options 生成其他选项
|
| | | *
|
| | | * @param paramsObj 生成其他选项
|
| | | * @return 树编码
|
| | | */
|
| | | public static String getTreecode(JSONObject paramsObj)
|
| | |
| | |
|
| | | /**
|
| | | * 获取树父编码
|
| | | * |
| | | * @param options 生成其他选项
|
| | | *
|
| | | * @param paramsObj 生成其他选项
|
| | | * @return 树父编码
|
| | | */
|
| | | public static String getTreeParentCode(JSONObject paramsObj)
|
| | |
| | |
|
| | | /**
|
| | | * 获取树名称
|
| | | * |
| | | * @param options 生成其他选项
|
| | | *
|
| | | * @param paramsObj 生成其他选项
|
| | | * @return 树名称
|
| | | */
|
| | | public static String getTreeName(JSONObject paramsObj)
|
| | |
| | |
|
| | | /**
|
| | | * 获取需要在哪一列上面显示展开按钮
|
| | | * |
| | | *
|
| | | * @param genTable 业务表对象
|
| | | * @return 展开按钮列序号
|
| | | */
|
| | |
| | | }
|
| | | return num;
|
| | | }
|
| | | } |
| | | }
|