同步ruoyi4,1最新版本,修复订单发货及其规格修改bug
This commit is contained in:
1 parent
d2306354db
commit
49e46e68c4
156 files changed
+12006
-10025
No files matched your search
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>4.0.0</version>
|
||||
<version>4.1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -77,12 +77,6 @@
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- HTML解析器 -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
|
||||
@@ -1,119 +1,93 @@
|
||||
package com.ruoyi.common.config;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.YamlUtil;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 全局配置类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "ruoyi")
|
||||
public class Global
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(Global.class);
|
||||
/** 项目名称 */
|
||||
private static String name;
|
||||
|
||||
private static String NAME = "application.yml";
|
||||
/** 版本 */
|
||||
private static String version;
|
||||
|
||||
/**
|
||||
* 当前对象实例
|
||||
*/
|
||||
private static Global global;
|
||||
/** 版权年份 */
|
||||
private static String copyrightYear;
|
||||
|
||||
/**
|
||||
* 保存全局属性值
|
||||
*/
|
||||
private static Map<String, String> map = new HashMap<String, String>();
|
||||
/** 实例演示开关 */
|
||||
private static boolean demoEnabled;
|
||||
|
||||
private Global()
|
||||
{
|
||||
}
|
||||
/** 上传路径 */
|
||||
private static String profile;
|
||||
|
||||
/**
|
||||
* 静态工厂方法
|
||||
*/
|
||||
public static synchronized Global getInstance()
|
||||
{
|
||||
if (global == null)
|
||||
{
|
||||
global = new Global();
|
||||
}
|
||||
return global;
|
||||
}
|
||||
/** 获取地址开关 */
|
||||
private static boolean addressEnabled;
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*/
|
||||
public static String getConfig(String key)
|
||||
{
|
||||
String value = map.get(key);
|
||||
if (value == null)
|
||||
{
|
||||
Map<?, ?> yamlMap = null;
|
||||
try
|
||||
{
|
||||
yamlMap = YamlUtil.loadYaml(NAME);
|
||||
value = String.valueOf(YamlUtil.getProperty(yamlMap, key));
|
||||
map.put(key, value != null ? value : StringUtils.EMPTY);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
log.error("获取全局配置异常 {}", key);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目名称
|
||||
*/
|
||||
public static String getName()
|
||||
{
|
||||
return StringUtils.nvl(getConfig("ruoyi.name"), "RuoYi");
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
Global.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目版本
|
||||
*/
|
||||
public static String getVersion()
|
||||
{
|
||||
return StringUtils.nvl(getConfig("ruoyi.version"), "4.0.0");
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
Global.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版权年份
|
||||
*/
|
||||
public static String getCopyrightYear()
|
||||
{
|
||||
return StringUtils.nvl(getConfig("ruoyi.copyrightYear"), "2019");
|
||||
return copyrightYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例演示开关
|
||||
*/
|
||||
public static String isDemoEnabled()
|
||||
public void setCopyrightYear(String copyrightYear)
|
||||
{
|
||||
return StringUtils.nvl(getConfig("ruoyi.demoEnabled"), "true");
|
||||
Global.copyrightYear = copyrightYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip地址开关
|
||||
*/
|
||||
public static Boolean isAddressEnabled()
|
||||
public static boolean isDemoEnabled()
|
||||
{
|
||||
return Boolean.valueOf(getConfig("ruoyi.addressEnabled"));
|
||||
return demoEnabled;
|
||||
}
|
||||
|
||||
public void setDemoEnabled(boolean demoEnabled)
|
||||
{
|
||||
Global.demoEnabled = demoEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件上传路径
|
||||
*/
|
||||
public static String getProfile()
|
||||
{
|
||||
return getConfig("ruoyi.profile");
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile)
|
||||
{
|
||||
Global.profile = profile;
|
||||
}
|
||||
|
||||
public static boolean isAddressEnabled()
|
||||
{
|
||||
return addressEnabled;
|
||||
}
|
||||
|
||||
public void setAddressEnabled(boolean addressEnabled)
|
||||
{
|
||||
Global.addressEnabled = addressEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +103,7 @@ public class Global
|
||||
*/
|
||||
public static String getDownloadPath()
|
||||
{
|
||||
return getProfile() + "/download";
|
||||
return getProfile() + "/download/";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,11 +37,6 @@ public class Constants
|
||||
*/
|
||||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 自动去除表前缀
|
||||
*/
|
||||
public static final String AUTO_REOMVE_PRE = "true";
|
||||
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
@@ -61,4 +56,9 @@ public class Constants
|
||||
* 排序的方向 "desc" 或者 "asc".
|
||||
*/
|
||||
public static final String IS_ASC = "isAsc";
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
}
|
||||
@@ -44,6 +44,12 @@ public class GenConstants
|
||||
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time", "remark" };
|
||||
|
||||
/** Entity基类字段 */
|
||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||
|
||||
/** Tree基类字段 */
|
||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors" };
|
||||
|
||||
/** 文本框 */
|
||||
public static final String HTML_INPUT = "input";
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ public class TreeEntity extends BaseEntity
|
||||
/** 显示顺序 */
|
||||
private Integer orderNum;
|
||||
|
||||
/** 祖级列表 */
|
||||
private String ancestors;
|
||||
|
||||
public String getParentName()
|
||||
{
|
||||
return parentName;
|
||||
@@ -47,4 +50,14 @@ public class TreeEntity extends BaseEntity
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getAncestors()
|
||||
{
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors(String ancestors)
|
||||
{
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
}
|
||||
@@ -152,36 +152,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
|
||||
/* //日期转换为时间戳 */
|
||||
public static long timeToStamp(String timers) {
|
||||
Date d = new Date();
|
||||
long timeStemp = 0;
|
||||
try {
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
d = sf.parse(timers);// 日期转换为时间戳
|
||||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
timeStemp = d.getTime();
|
||||
return timeStemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式字符串转换成时间戳
|
||||
* @param date 字符串日期
|
||||
* @param format 如:yyyy-MM-dd HH:mm:ss
|
||||
* @return
|
||||
*/
|
||||
public static String date2TimeStamp(String date_str,String format){
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
return String.valueOf(sdf.parse(date_str).getTime()/1000);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.config.Global;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
|
||||
import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
|
||||
import com.ruoyi.common.exception.file.InvalidExtensionException;
|
||||
@@ -145,9 +146,9 @@ public class FileUploadUtils
|
||||
|
||||
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
||||
{
|
||||
int dirLastIndex = uploadDir.lastIndexOf("/") + 1;
|
||||
int dirLastIndex = Global.getProfile().length() + 1;
|
||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||
String pathFileName = "/profile/" + currentDir + "/" + fileName;
|
||||
String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
||||
return pathFileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.ruoyi.common.utils.html;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 转义和反转义工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class EscapeUtil
|
||||
{
|
||||
public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)";
|
||||
|
||||
private static final char[][] TEXT = new char[64][];
|
||||
|
||||
static
|
||||
{
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
TEXT[i] = new char[] { (char) i };
|
||||
}
|
||||
|
||||
// special HTML characters
|
||||
TEXT['\''] = "'".toCharArray(); // 单引号
|
||||
TEXT['"'] = """.toCharArray(); // 单引号
|
||||
TEXT['&'] = "&".toCharArray(); // &符
|
||||
TEXT['<'] = "<".toCharArray(); // 小于号
|
||||
TEXT['>'] = ">".toCharArray(); // 大于号
|
||||
}
|
||||
|
||||
/**
|
||||
* 转义文本中的HTML字符为安全的字符
|
||||
*
|
||||
* @param text 被转义的文本
|
||||
* @return 转义后的文本
|
||||
*/
|
||||
public static String escape(String text)
|
||||
{
|
||||
return encode(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原被转义的HTML特殊字符
|
||||
*
|
||||
* @param content 包含转义符的HTML内容
|
||||
* @return 转换后的字符串
|
||||
*/
|
||||
public static String unescape(String content)
|
||||
{
|
||||
return decode(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有HTML标签,但是不删除标签内的内容
|
||||
*
|
||||
* @param content 文本
|
||||
* @return 清除标签后的文本
|
||||
*/
|
||||
public static String clean(String content)
|
||||
{
|
||||
return content.replaceAll(RE_HTML_MARK, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape编码
|
||||
*
|
||||
* @param text 被编码的文本
|
||||
* @return 编码后的字符
|
||||
*/
|
||||
private static String encode(String text)
|
||||
{
|
||||
int len;
|
||||
if ((text == null) || ((len = text.length()) == 0))
|
||||
{
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
StringBuilder buffer = new StringBuilder(len + (len >> 2));
|
||||
char c;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
c = text.charAt(i);
|
||||
if (c < 64)
|
||||
{
|
||||
buffer.append(TEXT[c]);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.append(c);
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape解码
|
||||
*
|
||||
* @param content 被转义的内容
|
||||
* @return 解码后的字符串
|
||||
*/
|
||||
public static String decode(String content)
|
||||
{
|
||||
if (StringUtils.isEmpty(content))
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
StringBuilder tmp = new StringBuilder(content.length());
|
||||
int lastPos = 0, pos = 0;
|
||||
char ch;
|
||||
while (lastPos < content.length())
|
||||
{
|
||||
pos = content.indexOf("%", lastPos);
|
||||
if (pos == lastPos)
|
||||
{
|
||||
if (content.charAt(pos + 1) == 'u')
|
||||
{
|
||||
ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16);
|
||||
tmp.append(ch);
|
||||
lastPos = pos + 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16);
|
||||
tmp.append(ch);
|
||||
lastPos = pos + 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos == -1)
|
||||
{
|
||||
tmp.append(content.substring(lastPos));
|
||||
lastPos = content.length();
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp.append(content.substring(lastPos, pos));
|
||||
lastPos = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tmp.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
String html = "<script>alert(1);</script>";
|
||||
System.out.println(EscapeUtil.clean(html));
|
||||
System.out.println(EscapeUtil.escape(html));
|
||||
System.out.println(EscapeUtil.unescape(html));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2,8 +2,7 @@ package com.ruoyi.common.xss;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.safety.Whitelist;
|
||||
import com.ruoyi.common.utils.html.EscapeUtil;
|
||||
|
||||
/**
|
||||
* XSS过滤处理
|
||||
@@ -31,7 +30,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
// 防xss攻击和过滤前后空格
|
||||
escapseValues[i] = Jsoup.clean(values[i], Whitelist.relaxed()).trim();
|
||||
escapseValues[i] = EscapeUtil.clean(values[i]).trim();
|
||||
}
|
||||
return escapseValues;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user