Bladeren bron

Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue

 Conflicts:
	ruoyi-ui/bin/package.bat
	ruoyi-ui/package.json
	ruoyi-ui/src/assets/styles/element-ui.scss
	ruoyi-ui/src/layout/components/Navbar.vue
	ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue
	ruoyi-ui/src/layout/components/TagsView/index.vue
	ruoyi-ui/src/router/index.js
	ruoyi-ui/src/views/components/icons/element-icons.js
	ruoyi-ui/src/views/dashboard/mixins/resize.js
	ruoyi-ui/src/views/system/menu/index.vue
	ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java
	ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
	ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java
	ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java
	ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java
	ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java
	ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
	ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
	ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
	ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
	ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java
	ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java
	ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
疯狂的狮子li 5 jaren geleden
bovenliggende
commit
2e6bb454f4
28 gewijzigde bestanden met toevoegingen van 319 en 1335 verwijderingen
  1. 12 0
      ruoyi-ui/bin/build.bat
  2. 1 1
      ruoyi-ui/bin/package.bat
  3. 1 1
      ruoyi-ui/package.json
  4. 5 0
      ruoyi-ui/src/assets/styles/element-ui.scss
  5. 3 3
      ruoyi-ui/src/layout/components/Navbar.vue
  6. 1 1
      ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue
  7. 6 3
      ruoyi-ui/src/layout/components/TagsView/index.vue
  8. 1 1
      ruoyi-ui/src/router/index.js
  9. 0 72
      ruoyi-ui/src/views/components/icons/element-icons.js
  10. 30 26
      ruoyi-ui/src/views/dashboard/mixins/resize.js
  11. 11 8
      ruoyi-ui/src/views/system/menu/index.vue
  12. 49 0
      ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java
  13. 72 0
      ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java
  14. 1 1
      ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java
  15. 1 1
      ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
  16. 56 0
      ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java
  17. 0 87
      ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java
  18. 0 999
      ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java
  19. 0 93
      ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java
  20. 16 2
      ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java
  21. 23 10
      ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
  22. 3 3
      ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
  23. 1 1
      ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java
  24. 1 1
      ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java
  25. 1 1
      ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java
  26. 1 1
      ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java
  27. 1 1
      ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java
  28. 22 18
      ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java

+ 12 - 0
ruoyi-ui/bin/build.bat

@@ -0,0 +1,12 @@
+@echo off
+echo.
+echo [信息] 打包Web工程,生成dist文件。
+echo.
+
+%~d0
+cd %~dp0
+
+cd ..
+npm run build:prod
+
+pause

+ 1 - 1
ruoyi-ui/bin/package.bat

@@ -1,6 +1,6 @@
 @echo off
 echo.
-echo [信息] 打包Web工程,生成node_modules包文件。
+echo [信息] 安装Web工程,生成node_modules文件。
 echo.
 
 %~d0

+ 1 - 1
ruoyi-ui/package.json

@@ -44,7 +44,7 @@
     "axios": "0.18.1",
     "clipboard": "2.0.4",
     "echarts": "4.2.1",
-    "element-ui": "2.11.1",
+    "element-ui": "2.13.0",
     "file-saver": "2.0.1",
     "js-beautify": "^1.10.2",
     "fuse.js": "3.4.4",

+ 5 - 0
ruoyi-ui/src/assets/styles/element-ui.scss

@@ -77,3 +77,8 @@
 .el-range-editor.el-input__inner {
   display: inline-flex !important;
 }
+
+// to fix el-date-picker css style
+.el-range-separator {
+  box-sizing: content-box;
+}

+ 3 - 3
ruoyi-ui/src/layout/components/Navbar.vue

@@ -7,7 +7,7 @@
     <div class="right-menu">
       <template v-if="device!=='mobile'">
         <search id="header-search" class="right-menu-item" />
-
+        
         <el-tooltip content="源码地址" effect="dark" placement="bottom">
           <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
         </el-tooltip>
@@ -36,8 +36,8 @@
           <el-dropdown-item>
             <span @click="setting = true">布局设置</span>
           </el-dropdown-item>
-          <el-dropdown-item divided>
-            <span @click="logout">退出登录</span>
+          <el-dropdown-item divided @click.native="logout">
+            <span>退出登录</span>
           </el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>

+ 1 - 1
ruoyi-ui/src/layout/components/Sidebar/SidebarItem.vue

@@ -1,5 +1,5 @@
 <template>
-  <div v-if="!item.hidden" class="menu-wrapper">
+  <div v-if="!item.hidden">
     <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
       <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
         <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">

+ 6 - 3
ruoyi-ui/src/layout/components/TagsView/index.vue

@@ -9,16 +9,16 @@
         :to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
         tag="span"
         class="tags-view-item"
-        @click.middle.native="closeSelectedTag(tag)"
+        @click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
         @contextmenu.prevent.native="openMenu(tag,$event)"
       >
         {{ tag.title }}
-        <span v-if="!tag.meta.affix" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
+        <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
       </router-link>
     </scroll-pane>
     <ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
       <li @click="refreshSelectedTag(selectedTag)">刷新页面</li>
-      <li v-if="!(selectedTag.meta&&selectedTag.meta.affix)" @click="closeSelectedTag(selectedTag)">关闭当前</li>
+      <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">关闭当前</li>
       <li @click="closeOthersTags">关闭其他</li>
       <li @click="closeAllTags(selectedTag)">关闭所有</li>
     </ul>
@@ -69,6 +69,9 @@ export default {
     isActive(route) {
       return route.path === this.$route.path
     },
+    isAffix(tag) {
+      return tag.meta && tag.meta.affix
+    },
     filterAffixTags(routes, basePath = '/') {
       let tags = []
       routes.forEach(route => {

+ 1 - 1
ruoyi-ui/src/router/index.js

@@ -32,7 +32,7 @@ export const constantRoutes = [
     hidden: true,
     children: [
       {
-        path: '/redirect/:path*',
+        path: '/redirect/:path(.*)',
         component: () => import('@/views/redirect')
       }
     ]

File diff suppressed because it is too large
+ 0 - 72
ruoyi-ui/src/views/components/icons/element-icons.js


+ 30 - 26
ruoyi-ui/src/views/dashboard/mixins/resize.js

@@ -3,50 +3,54 @@ import { debounce } from '@/utils'
 export default {
   data() {
     return {
-      $_sidebarElm: null
+      $_sidebarElm: null,
+      $_resizeHandler: null
     }
   },
   mounted() {
-    this.$_initResizeEvent()
-    this.$_initSidebarResizeEvent()
-  },
-  beforeDestroy() {
-    this.$_destroyResizeEvent()
-    this.$_destroySidebarResizeEvent()
+    this.initListener()
   },
   activated() {
-    this.$_initResizeEvent()
-    this.$_initSidebarResizeEvent()
+    if (!this.$_resizeHandler) {
+      // avoid duplication init
+      this.initListener()
+    }
+
+    // when keep-alive chart activated, auto resize
+    this.resize()
+  },
+  beforeDestroy() {
+    this.destroyListener()
   },
   deactivated() {
-    this.$_destroyResizeEvent()
-    this.$_destroySidebarResizeEvent()
+    this.destroyListener()
   },
   methods: {
-    $_resizeHandler() {
-      return debounce(() => {
-        if (this.chart) {
-          this.chart.resize()
-        }
-      }, 100)()
-    },
-    $_initResizeEvent() {
-      window.addEventListener('resize', this.$_resizeHandler)
-    },
-    $_destroyResizeEvent() {
-      window.removeEventListener('resize', this.$_resizeHandler)
-    },
+    // use $_ for mixins properties
+    // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
     $_sidebarResizeHandler(e) {
       if (e.propertyName === 'width') {
         this.$_resizeHandler()
       }
     },
-    $_initSidebarResizeEvent() {
+    initListener() {
+      this.$_resizeHandler = debounce(() => {
+        this.resize()
+      }, 100)
+      window.addEventListener('resize', this.$_resizeHandler)
+
       this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
       this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
     },
-    $_destroySidebarResizeEvent() {
+    destroyListener() {
+      window.removeEventListener('resize', this.$_resizeHandler)
+      this.$_resizeHandler = null
+
       this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
+    },
+    resize() {
+      const { chart } = this
+      chart && chart.resize()
     }
   }
 }

+ 11 - 8
ruoyi-ui/src/views/system/menu/index.vue

@@ -49,16 +49,16 @@
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
-          <el-button size="mini"
-            type="text"
-            icon="el-icon-edit"
+          <el-button size="mini" 
+            type="text" 
+            icon="el-icon-edit" 
             @click="handleUpdate(scope.row)"
             v-hasPermi="['system:menu:edit']"
           >修改</el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-plus"
+          <el-button 
+            size="mini" 
+            type="text" 
+            icon="el-icon-plus" 
             @click="handleAdd(scope.row)"
             v-hasPermi="['system:menu:add']"
           >新增</el-button>
@@ -210,6 +210,9 @@ export default {
         ],
         orderNum: [
           { required: true, message: "菜单顺序不能为空", trigger: "blur" }
+        ],
+        path: [
+          { required: true, message: "路由地址不能为空", trigger: "blur" }
         ]
       }
     };
@@ -346,4 +349,4 @@ export default {
     }
   }
 };
-</script>
+</script>

+ 49 - 0
ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java

@@ -0,0 +1,49 @@
+package com.ruoyi.common.filter;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Repeatable 过滤器
+ * 
+ * @author ruoyi
+ */
+public class RepeatableFilter implements Filter
+{
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException
+    {
+
+    }
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+            throws IOException, ServletException
+    {
+        ServletRequest requestWrapper = null;
+        if (request instanceof HttpServletRequest)
+        {
+            requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
+        }
+        if (null == requestWrapper)
+        {
+            chain.doFilter(request, response);
+        }
+        else
+        {
+            chain.doFilter(requestWrapper, response);
+        }
+    }
+
+    @Override
+    public void destroy()
+    {
+
+    }
+}

+ 72 - 0
ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java

@@ -0,0 +1,72 @@
+package com.ruoyi.common.filter;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import com.ruoyi.common.utils.http.HttpHelper;
+
+/**
+ * 构建可重复读取inputStream的request
+ * 
+ * @author ruoyi
+ */
+public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
+{
+    private final byte[] body;
+
+    public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
+    {
+        super(request);
+        request.setCharacterEncoding("UTF-8");
+        response.setCharacterEncoding("UTF-8");
+
+        body = HttpHelper.getBodyString(request).getBytes("UTF-8");
+    }
+
+    @Override
+    public BufferedReader getReader() throws IOException
+    {
+        return new BufferedReader(new InputStreamReader(getInputStream()));
+    }
+
+    @Override
+    public ServletInputStream getInputStream() throws IOException
+    {
+
+        final ByteArrayInputStream bais = new ByteArrayInputStream(body);
+
+        return new ServletInputStream()
+        {
+
+            @Override
+            public int read() throws IOException
+            {
+                return bais.read();
+            }
+
+            @Override
+            public boolean isFinished()
+            {
+                return false;
+            }
+
+            @Override
+            public boolean isReady()
+            {
+                return false;
+            }
+
+            @Override
+            public void setReadListener(ReadListener readListener)
+            {
+
+            }
+        };
+    }
+}

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/common/xss/XssFilter.java → ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java

@@ -1,4 +1,4 @@
-package com.ruoyi.common.xss;
+package com.ruoyi.common.filter;
 
 import java.io.IOException;
 import java.util.ArrayList;

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/common/xss/XssHttpServletRequestWrapper.java → ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java

@@ -1,4 +1,4 @@
-package com.ruoyi.common.xss;
+package com.ruoyi.common.filter;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;

+ 56 - 0
ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java

@@ -0,0 +1,56 @@
+package com.ruoyi.common.utils.http;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import javax.servlet.ServletRequest;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 通用http工具封装
+ * 
+ * @author ruoyi
+ */
+public class HttpHelper
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class);
+
+    public static String getBodyString(ServletRequest request)
+    {
+
+        StringBuilder sb = new StringBuilder();
+        BufferedReader reader = null;
+        try (InputStream inputStream = request.getInputStream())
+        {
+            reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
+            String line = "";
+            while ((line = reader.readLine()) != null)
+            {
+                sb.append(line);
+            }
+        }
+        catch (IOException e)
+        {
+            LOGGER.warn("getBodyString出现问题!");
+        }
+        finally
+        {
+            if (reader != null)
+            {
+                try
+                {
+                    reader.close();
+                }
+                catch (IOException e)
+                {
+                    LOGGER.error(ExceptionUtils.getFullStackTrace(e));
+                }
+            }
+        }
+        return sb.toString();
+    }
+}

+ 0 - 87
ruoyi/src/main/java/com/ruoyi/common/utils/text/CharsetKit.java

@@ -1,87 +0,0 @@
-package com.ruoyi.common.utils.text;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 字符集工具类
- * 
- * @author ruoyi
- *
- */
-public class CharsetKit
-{
-    /** ISO-8859-1 */
-    public static final String ISO_8859_1 = "ISO-8859-1";
-    /** UTF-8 */
-    public static final String UTF_8 = "UTF-8";
-    /** GBK */
-    public static final String GBK = "GBK";
-
-    /** ISO-8859-1 */
-    public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
-    /** UTF-8 */
-    public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
-    /** GBK */
-    public static final Charset CHARSET_GBK = Charset.forName(GBK);
-
-    /**
-     * 转换为Charset对象
-     * 
-     * @param charset 字符集,为空则返回默认字符集
-     * @return Charset
-     */
-    public static Charset charset(String charset)
-    {
-        return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
-    }
-
-    /**
-     * 转换字符串的字符集编码
-     * 
-     * @param source 字符串
-     * @param srcCharset 源字符集,默认ISO-8859-1
-     * @param destCharset 目标字符集,默认UTF-8
-     * @return 转换后的字符集
-     */
-    public static String convert(String source, String srcCharset, String destCharset)
-    {
-        return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
-    }
-
-    /**
-     * 转换字符串的字符集编码
-     * 
-     * @param source 字符串
-     * @param srcCharset 源字符集,默认ISO-8859-1
-     * @param destCharset 目标字符集,默认UTF-8
-     * @return 转换后的字符集
-     */
-    public static String convert(String source, Charset srcCharset, Charset destCharset)
-    {
-        if (null == srcCharset)
-        {
-            srcCharset = StandardCharsets.ISO_8859_1;
-        }
-
-        if (null == destCharset)
-        {
-            srcCharset = StandardCharsets.UTF_8;
-        }
-
-        if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
-        {
-            return source;
-        }
-        return new String(source.getBytes(srcCharset), destCharset);
-    }
-
-    /**
-     * @return 系统字符集编码
-     */
-    public static String systemCharset()
-    {
-        return Charset.defaultCharset().name();
-    }
-}

+ 0 - 999
ruoyi/src/main/java/com/ruoyi/common/utils/text/Convert.java

@@ -1,999 +0,0 @@
-package com.ruoyi.common.utils.text;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.text.NumberFormat;
-import java.util.Set;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 类型转换器
- * 
- * @author ruoyi
- */
-public class Convert
-{
-    /**
-     * 转换为字符串<br>
-     * 如果给定的值为null,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static String toStr(Object value, String defaultValue)
-    {
-        if (null == value)
-        {
-            return defaultValue;
-        }
-        if (value instanceof String)
-        {
-            return (String) value;
-        }
-        return value.toString();
-    }
-
-    /**
-     * 转换为字符串<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static String toStr(Object value)
-    {
-        return toStr(value, null);
-    }
-
-    /**
-     * 转换为字符<br>
-     * 如果给定的值为null,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Character toChar(Object value, Character defaultValue)
-    {
-        if (null == value)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Character)
-        {
-            return (Character) value;
-        }
-
-        final String valueStr = toStr(value, null);
-        return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
-    }
-
-    /**
-     * 转换为字符<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Character toChar(Object value)
-    {
-        return toChar(value, null);
-    }
-
-    /**
-     * 转换为byte<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Byte toByte(Object value, Byte defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Byte)
-        {
-            return (Byte) value;
-        }
-        if (value instanceof Number)
-        {
-            return ((Number) value).byteValue();
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return Byte.parseByte(valueStr);
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为byte<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Byte toByte(Object value)
-    {
-        return toByte(value, null);
-    }
-
-    /**
-     * 转换为Short<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Short toShort(Object value, Short defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Short)
-        {
-            return (Short) value;
-        }
-        if (value instanceof Number)
-        {
-            return ((Number) value).shortValue();
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return Short.parseShort(valueStr.trim());
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为Short<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Short toShort(Object value)
-    {
-        return toShort(value, null);
-    }
-
-    /**
-     * 转换为Number<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Number toNumber(Object value, Number defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Number)
-        {
-            return (Number) value;
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return NumberFormat.getInstance().parse(valueStr);
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为Number<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Number toNumber(Object value)
-    {
-        return toNumber(value, null);
-    }
-
-    /**
-     * 转换为int<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Integer toInt(Object value, Integer defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Integer)
-        {
-            return (Integer) value;
-        }
-        if (value instanceof Number)
-        {
-            return ((Number) value).intValue();
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return Integer.parseInt(valueStr.trim());
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为int<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Integer toInt(Object value)
-    {
-        return toInt(value, null);
-    }
-
-    /**
-     * 转换为Integer数组<br>
-     * 
-     * @param str 被转换的值
-     * @return 结果
-     */
-    public static Integer[] toIntArray(String str)
-    {
-        return toIntArray(",", str);
-    }
-
-    /**
-     * 转换为Long数组<br>
-     * 
-     * @param str 被转换的值
-     * @return 结果
-     */
-    public static Long[] toLongArray(String str)
-    {
-        return toLongArray(",", str);
-    }
-
-    /**
-     * 转换为Integer数组<br>
-     * 
-     * @param split 分隔符
-     * @param split 被转换的值
-     * @return 结果
-     */
-    public static Integer[] toIntArray(String split, String str)
-    {
-        if (StringUtils.isEmpty(str))
-        {
-            return new Integer[] {};
-        }
-        String[] arr = str.split(split);
-        final Integer[] ints = new Integer[arr.length];
-        for (int i = 0; i < arr.length; i++)
-        {
-            final Integer v = toInt(arr[i], 0);
-            ints[i] = v;
-        }
-        return ints;
-    }
-
-    /**
-     * 转换为Long数组<br>
-     * 
-     * @param split 分隔符
-     * @param str 被转换的值
-     * @return 结果
-     */
-    public static Long[] toLongArray(String split, String str)
-    {
-        if (StringUtils.isEmpty(str))
-        {
-            return new Long[] {};
-        }
-        String[] arr = str.split(split);
-        final Long[] longs = new Long[arr.length];
-        for (int i = 0; i < arr.length; i++)
-        {
-            final Long v = toLong(arr[i], null);
-            longs[i] = v;
-        }
-        return longs;
-    }
-
-    /**
-     * 转换为String数组<br>
-     * 
-     * @param str 被转换的值
-     * @return 结果
-     */
-    public static String[] toStrArray(String str)
-    {
-        return toStrArray(",", str);
-    }
-
-    /**
-     * 转换为String数组<br>
-     * 
-     * @param split 分隔符
-     * @param split 被转换的值
-     * @return 结果
-     */
-    public static String[] toStrArray(String split, String str)
-    {
-        return str.split(split);
-    }
-
-    /**
-     * 转换为long<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Long toLong(Object value, Long defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Long)
-        {
-            return (Long) value;
-        }
-        if (value instanceof Number)
-        {
-            return ((Number) value).longValue();
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            // 支持科学计数法
-            return new BigDecimal(valueStr.trim()).longValue();
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为long<br>
-     * 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Long toLong(Object value)
-    {
-        return toLong(value, null);
-    }
-
-    /**
-     * 转换为double<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Double toDouble(Object value, Double defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Double)
-        {
-            return (Double) value;
-        }
-        if (value instanceof Number)
-        {
-            return ((Number) value).doubleValue();
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            // 支持科学计数法
-            return new BigDecimal(valueStr.trim()).doubleValue();
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为double<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Double toDouble(Object value)
-    {
-        return toDouble(value, null);
-    }
-
-    /**
-     * 转换为Float<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Float toFloat(Object value, Float defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Float)
-        {
-            return (Float) value;
-        }
-        if (value instanceof Number)
-        {
-            return ((Number) value).floatValue();
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return Float.parseFloat(valueStr.trim());
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为Float<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Float toFloat(Object value)
-    {
-        return toFloat(value, null);
-    }
-
-    /**
-     * 转换为boolean<br>
-     * String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static Boolean toBool(Object value, Boolean defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof Boolean)
-        {
-            return (Boolean) value;
-        }
-        String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        valueStr = valueStr.trim().toLowerCase();
-        switch (valueStr)
-        {
-            case "true":
-                return true;
-            case "false":
-                return false;
-            case "yes":
-                return true;
-            case "ok":
-                return true;
-            case "no":
-                return false;
-            case "1":
-                return true;
-            case "0":
-                return false;
-            default:
-                return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为boolean<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static Boolean toBool(Object value)
-    {
-        return toBool(value, null);
-    }
-
-    /**
-     * 转换为Enum对象<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 
-     * @param clazz Enum的Class
-     * @param value 值
-     * @param defaultValue 默认值
-     * @return Enum
-     */
-    public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (clazz.isAssignableFrom(value.getClass()))
-        {
-            @SuppressWarnings("unchecked")
-            E myE = (E) value;
-            return myE;
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return Enum.valueOf(clazz, valueStr);
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为Enum对象<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
-     * 
-     * @param clazz Enum的Class
-     * @param value 值
-     * @return Enum
-     */
-    public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value)
-    {
-        return toEnum(clazz, value, null);
-    }
-
-    /**
-     * 转换为BigInteger<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static BigInteger toBigInteger(Object value, BigInteger defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof BigInteger)
-        {
-            return (BigInteger) value;
-        }
-        if (value instanceof Long)
-        {
-            return BigInteger.valueOf((Long) value);
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return new BigInteger(valueStr);
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为BigInteger<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static BigInteger toBigInteger(Object value)
-    {
-        return toBigInteger(value, null);
-    }
-
-    /**
-     * 转换为BigDecimal<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @param defaultValue 转换错误时的默认值
-     * @return 结果
-     */
-    public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
-    {
-        if (value == null)
-        {
-            return defaultValue;
-        }
-        if (value instanceof BigDecimal)
-        {
-            return (BigDecimal) value;
-        }
-        if (value instanceof Long)
-        {
-            return new BigDecimal((Long) value);
-        }
-        if (value instanceof Double)
-        {
-            return new BigDecimal((Double) value);
-        }
-        if (value instanceof Integer)
-        {
-            return new BigDecimal((Integer) value);
-        }
-        final String valueStr = toStr(value, null);
-        if (StringUtils.isEmpty(valueStr))
-        {
-            return defaultValue;
-        }
-        try
-        {
-            return new BigDecimal(valueStr);
-        }
-        catch (Exception e)
-        {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * 转换为BigDecimal<br>
-     * 如果给定的值为空,或者转换失败,返回默认值<br>
-     * 转换失败不会报错
-     * 
-     * @param value 被转换的值
-     * @return 结果
-     */
-    public static BigDecimal toBigDecimal(Object value)
-    {
-        return toBigDecimal(value, null);
-    }
-
-    /**
-     * 将对象转为字符串<br>
-     * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
-     * 
-     * @param obj 对象
-     * @return 字符串
-     */
-    public static String utf8Str(Object obj)
-    {
-        return str(obj, CharsetKit.CHARSET_UTF_8);
-    }
-
-    /**
-     * 将对象转为字符串<br>
-     * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
-     * 
-     * @param obj 对象
-     * @param charsetName 字符集
-     * @return 字符串
-     */
-    public static String str(Object obj, String charsetName)
-    {
-        return str(obj, Charset.forName(charsetName));
-    }
-
-    /**
-     * 将对象转为字符串<br>
-     * 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
-     * 
-     * @param obj 对象
-     * @param charset 字符集
-     * @return 字符串
-     */
-    public static String str(Object obj, Charset charset)
-    {
-        if (null == obj)
-        {
-            return null;
-        }
-
-        if (obj instanceof String)
-        {
-            return (String) obj;
-        }
-        else if (obj instanceof byte[] || obj instanceof Byte[])
-        {
-            return str((Byte[]) obj, charset);
-        }
-        else if (obj instanceof ByteBuffer)
-        {
-            return str((ByteBuffer) obj, charset);
-        }
-        return obj.toString();
-    }
-
-    /**
-     * 将byte数组转为字符串
-     * 
-     * @param bytes byte数组
-     * @param charset 字符集
-     * @return 字符串
-     */
-    public static String str(byte[] bytes, String charset)
-    {
-        return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
-    }
-
-    /**
-     * 解码字节码
-     * 
-     * @param data 字符串
-     * @param charset 字符集,如果此字段为空,则解码的结果取决于平台
-     * @return 解码后的字符串
-     */
-    public static String str(byte[] data, Charset charset)
-    {
-        if (data == null)
-        {
-            return null;
-        }
-
-        if (null == charset)
-        {
-            return new String(data);
-        }
-        return new String(data, charset);
-    }
-
-    /**
-     * 将编码的byteBuffer数据转换为字符串
-     * 
-     * @param data 数据
-     * @param charset 字符集,如果为空使用当前系统字符集
-     * @return 字符串
-     */
-    public static String str(ByteBuffer data, String charset)
-    {
-        if (data == null)
-        {
-            return null;
-        }
-
-        return str(data, Charset.forName(charset));
-    }
-
-    /**
-     * 将编码的byteBuffer数据转换为字符串
-     * 
-     * @param data 数据
-     * @param charset 字符集,如果为空使用当前系统字符集
-     * @return 字符串
-     */
-    public static String str(ByteBuffer data, Charset charset)
-    {
-        if (null == charset)
-        {
-            charset = Charset.defaultCharset();
-        }
-        return charset.decode(data).toString();
-    }
-
-    // ----------------------------------------------------------------------- 全角半角转换
-    /**
-     * 半角转全角
-     * 
-     * @param input String.
-     * @return 全角字符串.
-     */
-    public static String toSBC(String input)
-    {
-        return toSBC(input, null);
-    }
-
-    /**
-     * 半角转全角
-     * 
-     * @param input String
-     * @param notConvertSet 不替换的字符集合
-     * @return 全角字符串.
-     */
-    public static String toSBC(String input, Set<Character> notConvertSet)
-    {
-        char c[] = input.toCharArray();
-        for (int i = 0; i < c.length; i++)
-        {
-            if (null != notConvertSet && notConvertSet.contains(c[i]))
-            {
-                // 跳过不替换的字符
-                continue;
-            }
-
-            if (c[i] == ' ')
-            {
-                c[i] = '\u3000';
-            }
-            else if (c[i] < '\177')
-            {
-                c[i] = (char) (c[i] + 65248);
-
-            }
-        }
-        return new String(c);
-    }
-
-    /**
-     * 全角转半角
-     * 
-     * @param input String.
-     * @return 半角字符串
-     */
-    public static String toDBC(String input)
-    {
-        return toDBC(input, null);
-    }
-
-    /**
-     * 替换全角为半角
-     * 
-     * @param text 文本
-     * @param notConvertSet 不替换的字符集合
-     * @return 替换后的字符
-     */
-    public static String toDBC(String text, Set<Character> notConvertSet)
-    {
-        char c[] = text.toCharArray();
-        for (int i = 0; i < c.length; i++)
-        {
-            if (null != notConvertSet && notConvertSet.contains(c[i]))
-            {
-                // 跳过不替换的字符
-                continue;
-            }
-
-            if (c[i] == '\u3000')
-            {
-                c[i] = ' ';
-            }
-            else if (c[i] > '\uFF00' && c[i] < '\uFF5F')
-            {
-                c[i] = (char) (c[i] - 65248);
-            }
-        }
-        String returnString = new String(c);
-
-        return returnString;
-    }
-
-    /**
-     * 数字金额大写转换 先写个完整的然后将如零拾替换成零
-     * 
-     * @param n 数字
-     * @return 中文大写数字
-     */
-    public static String digitUppercase(double n)
-    {
-        String[] fraction = { "角", "分" };
-        String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
-        String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } };
-
-        String head = n < 0 ? "负" : "";
-        n = Math.abs(n);
-
-        String s = "";
-        for (int i = 0; i < fraction.length; i++)
-        {
-            s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
-        }
-        if (s.length() < 1)
-        {
-            s = "整";
-        }
-        int integerPart = (int) Math.floor(n);
-
-        for (int i = 0; i < unit[0].length && integerPart > 0; i++)
-        {
-            String p = "";
-            for (int j = 0; j < unit[1].length && n > 0; j++)
-            {
-                p = digit[integerPart % 10] + unit[1][j] + p;
-                integerPart = integerPart / 10;
-            }
-            s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
-        }
-        return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
-    }
-}

+ 0 - 93
ruoyi/src/main/java/com/ruoyi/common/utils/text/StrFormatter.java

@@ -1,93 +0,0 @@
-package com.ruoyi.common.utils.text;
-
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * 字符串格式化
- * 
- * @author ruoyi
- */
-public class StrFormatter
-{
-    public static final String EMPTY_JSON = "{}";
-    public static final char C_BACKSLASH = '\\';
-    public static final char C_DELIM_START = '{';
-    public static final char C_DELIM_END = '}';
-
-    /**
-     * 格式化字符串<br>
-     * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
-     * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
-     * 例:<br>
-     * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
-     * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
-     * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
-     * 
-     * @param strPattern 字符串模板
-     * @param argArray 参数列表
-     * @return 结果
-     */
-    public static String format(final String strPattern, final Object... argArray)
-    {
-        if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
-        {
-            return strPattern;
-        }
-        final int strPatternLength = strPattern.length();
-
-        // 初始化定义好的长度以获得更好的性能
-        StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
-
-        int handledPosition = 0;
-        int delimIndex;// 占位符所在位置
-        for (int argIndex = 0; argIndex < argArray.length; argIndex++)
-        {
-            delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
-            if (delimIndex == -1)
-            {
-                if (handledPosition == 0)
-                {
-                    return strPattern;
-                }
-                else
-                { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
-                    sbuf.append(strPattern, handledPosition, strPatternLength);
-                    return sbuf.toString();
-                }
-            }
-            else
-            {
-                if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
-                {
-                    if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
-                    {
-                        // 转义符之前还有一个转义符,占位符依旧有效
-                        sbuf.append(strPattern, handledPosition, delimIndex - 1);
-                        sbuf.append(Convert.utf8Str(argArray[argIndex]));
-                        handledPosition = delimIndex + 2;
-                    }
-                    else
-                    {
-                        // 占位符被转义
-                        argIndex--;
-                        sbuf.append(strPattern, handledPosition, delimIndex - 1);
-                        sbuf.append(C_DELIM_START);
-                        handledPosition = delimIndex + 1;
-                    }
-                }
-                else
-                {
-                    // 正常占位符
-                    sbuf.append(strPattern, handledPosition, delimIndex);
-                    sbuf.append(Convert.utf8Str(argArray[argIndex]));
-                    handledPosition = delimIndex + 2;
-                }
-            }
-        }
-        // append the characters following the last {} pair.
-        // 加入最后一个占位符后所有的字符
-        sbuf.append(strPattern, handledPosition, strPattern.length());
-
-        return sbuf.toString();
-    }
-}

+ 16 - 2
ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java

@@ -7,8 +7,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import com.ruoyi.common.filter.RepeatableFilter;
+import com.ruoyi.common.filter.XssFilter;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.xss.XssFilter;
 
 /**
  * Filter配置
@@ -36,11 +37,24 @@ public class FilterConfig
         registration.setFilter(new XssFilter());
         registration.addUrlPatterns(StringUtils.split(urlPatterns, ","));
         registration.setName("xssFilter");
-        registration.setOrder(Integer.MAX_VALUE);
+        registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
         Map<String, String> initParameters = new HashMap<String, String>();
         initParameters.put("excludes", excludes);
         initParameters.put("enabled", enabled);
         registration.setInitParameters(initParameters);
         return registration;
     }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @Bean
+    public FilterRegistrationBean someFilterRegistration()
+    {
+        FilterRegistrationBean registration = new FilterRegistrationBean();
+        registration.setFilter(new RepeatableFilter());
+        registration.addUrlPatterns("/*");
+        registration.setName("repeatableFilter");
+        registration.setOrder(FilterRegistrationBean.LOWEST_PRECEDENCE);
+        return registration;
+    }
+
 }

+ 23 - 10
ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java

@@ -2,14 +2,19 @@ package com.ruoyi.framework.interceptor.impl;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.http.HttpHelper;
 import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
+import com.ruoyi.framework.redis.RedisCache;
 
 /**
- * 判断请求url和数据是否和上一次相同, 
+ * 判断请求url和数据是否和上一次相同,
  * 如果和上次相同,则是重复提交表单。 有效时间为10秒内。
  * 
  * @author ruoyi
@@ -21,7 +26,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
 
     public final String REPEAT_TIME = "repeatTime";
 
-    public final String SESSION_REPEAT_KEY = "repeatData";
+    public final String CACHE_REPEAT_KEY = "repeatData";
+
+    @Autowired
+    private RedisCache redisCache;
 
     /**
      * 间隔时间,单位:秒 默认10秒
@@ -39,8 +47,14 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
     @Override
     public boolean isRepeatSubmit(HttpServletRequest request)
     {
-        // 本次参数及系统时间
-        String nowParams = JSONObject.toJSONString(request.getParameterMap());
+        RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
+        String nowParams = HttpHelper.getBodyString(repeatedlyRequest);
+
+        // body参数为空,获取Parameter的数据
+        if (StringUtils.isEmpty(nowParams))
+        {
+            nowParams = JSONObject.toJSONString(request.getParameterMap());
+        }
         Map<String, Object> nowDataMap = new HashMap<String, Object>();
         nowDataMap.put(REPEAT_PARAMS, nowParams);
         nowDataMap.put(REPEAT_TIME, System.currentTimeMillis());
@@ -48,8 +62,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
         // 请求地址(作为存放session的key值)
         String url = request.getRequestURI();
 
-        HttpSession session = request.getSession();
-        Object sessionObj = session.getAttribute(SESSION_REPEAT_KEY);
+        Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY);
         if (sessionObj != null)
         {
             Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
@@ -62,9 +75,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
                 }
             }
         }
-        Map<String, Object> sessionMap = new HashMap<String, Object>();
-        sessionMap.put(url, nowDataMap);
-        session.setAttribute(SESSION_REPEAT_KEY, sessionMap);
+        Map<String, Object> cacheMap = new HashMap<String, Object>();
+        cacheMap.put(url, nowDataMap);
+        redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS);
         return false;
     }
 

+ 3 - 3
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java

@@ -84,9 +84,9 @@ public class SysNoticeController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:notice:remove')")
     @Log(title = "通知公告", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{noticeId}")
-    public AjaxResult remove(@PathVariable Long noticeId)
+    @DeleteMapping("/{noticeIds}")
+    public AjaxResult remove(@PathVariable Long[] noticeIds)
     {
-        return toAjax(noticeService.deleteNoticeById(noticeId));
+        return toAjax(noticeService.deleteNoticeByIds(noticeIds));
     }
 }

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java

@@ -56,5 +56,5 @@ public interface SysNoticeMapper
      * @param noticeIds 需要删除的公告ID
      * @return 结果
      */
-    public int deleteNoticeByIds(Long noticeIds);
+    public int deleteNoticeByIds(Long[] noticeIds);
 }

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java

@@ -56,5 +56,5 @@ public interface ISysNoticeService
      * @param noticeIds 需要删除的公告ID
      * @return 结果
      */
-    public int deleteNoticeByIds(Long noticeIds);
+    public int deleteNoticeByIds(Long[] noticeIds);
 }

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java

@@ -84,7 +84,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService
      * @param noticeIds 需要删除的公告ID
      * @return 结果
      */
-    public int deleteNoticeByIds(Long noticeIds)
+    public int deleteNoticeByIds(Long[] noticeIds)
     {
         return noticeMapper.deleteNoticeByIds(noticeIds);
     }

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java

@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.utils.text.Convert;
+import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.framework.web.controller.BaseController;

+ 1 - 1
ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java

@@ -3,7 +3,7 @@ package com.ruoyi.project.tool.gen.service;
 import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.common.utils.text.Convert;
+import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.project.tool.gen.domain.GenTableColumn;
 import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper;
 

+ 22 - 18
ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java

@@ -166,12 +166,32 @@ public class GenUtils
         if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
         {
             String[] searchList = StringUtils.split(tablePrefix, ",");
-            String[] replacementList = emptyList(searchList.length);
-            tableName = StringUtils.replaceEach(tableName, searchList, replacementList);
+            tableName = replaceFirst(tableName, searchList);
         }
         return StringUtils.convertToCamelCase(tableName);
     }
 
+    /**
+     * 批量替换前缀
+     * 
+     * @param replacementm 替换值
+     * @param searchList 替换列表
+     * @return
+     */
+    public static String replaceFirst(String replacementm, String[] searchList)
+    {
+        String text = replacementm;
+        for (String searchString : searchList)
+        {
+            if (replacementm.startsWith(searchString))
+            {
+                text = replacementm.replaceFirst(searchString, "");
+                break;
+            }
+        }
+        return text;
+    }
+
     /**
      * 关键字替换
      * 
@@ -219,20 +239,4 @@ public class GenUtils
             return 0;
         }
     }
-
-    /**
-     * 获取空数组列表
-     * 
-     * @param length 长度
-     * @return 数组信息
-     */
-    public static String[] emptyList(int length)
-    {
-        String[] values = new String[length];
-        for (int i = 0; i < length; i++)
-        {
-            values[i] = StringUtils.EMPTY;
-        }
-        return values;
-    }
 }

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