From df3ef54b41466f34dfda99313fdc9fb7b4de81b3 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Jul 2020 11:17:04 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=94=AF=E6=8C=81=EF=BC=88=E6=95=B0=E7=BB=84=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E3=80=81=E5=AD=97=E7=AC=A6=E9=AA=8C=E8=AF=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++ .../controller/common/CaptchaController.java | 64 +++++++++----- .../src/main/resources/application.yml | 2 + ruoyi-framework/pom.xml | 12 +++ .../ruoyi/framework/config/CaptchaConfig.java | 83 +++++++++++++++++++ .../framework/config/KaptchaTextCreator.java | 75 +++++++++++++++++ ruoyi-ui/src/views/login.vue | 5 +- 7 files changed, 228 insertions(+), 21 deletions(-) create mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java create mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java diff --git a/pom.xml b/pom.xml index cb9ecfbb..bde1e1b3 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ 1.1.14 1.19 2.9.2 + 2.3.2 1.2.5 1.2.70 3.9.1 @@ -137,6 +138,13 @@ jjwt ${jwt.version} + + + + com.github.penggle + kaptcha + ${kaptcha.version} + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java index a4ee00ff..035cfd28 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java @@ -1,16 +1,20 @@ package com.ruoyi.web.controller.common; -import java.io.ByteArrayOutputStream; +import java.awt.image.BufferedImage; import java.io.IOException; import java.util.concurrent.TimeUnit; +import javax.annotation.Resource; +import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.FastByteArrayOutputStream; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; +import com.google.code.kaptcha.Producer; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.redis.RedisCache; -import com.ruoyi.common.utils.VerifyCodeUtils; import com.ruoyi.common.utils.sign.Base64; import com.ruoyi.common.utils.uuid.IdUtils; @@ -22,8 +26,18 @@ import com.ruoyi.common.utils.uuid.IdUtils; @RestController public class CaptchaController { + @Resource(name = "captchaProducer") + private Producer captchaProducer; + + @Resource(name = "captchaProducerMath") + private Producer captchaProducerMath; + @Autowired private RedisCache redisCache; + + // 验证码类型 + @Value("${ruoyi.captchaType}") + private String captchaType; /** * 生成验证码 @@ -31,32 +45,42 @@ public class CaptchaController @GetMapping("/captchaImage") public AjaxResult getCode(HttpServletResponse response) throws IOException { - // 生成随机字串 - String verifyCode = VerifyCodeUtils.generateVerifyCode(4); - // 唯一标识 + // 保存验证码信息 String uuid = IdUtils.simpleUUID(); String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; - redisCache.setCacheObject(verifyKey, verifyCode, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); - // 生成图片 - int w = 111, h = 36; - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - VerifyCodeUtils.outputImage(w, h, stream, verifyCode); + String capStr = null, code = null; + BufferedImage image = null; + + // 生成验证码 + if ("math".equals(captchaType)) + { + String capText = captchaProducerMath.createText(); + capStr = capText.substring(0, capText.lastIndexOf("@")); + code = capText.substring(capText.lastIndexOf("@") + 1); + image = captchaProducerMath.createImage(capStr); + } + else if ("char".equals(captchaType)) + { + capStr = code = captchaProducer.createText(); + image = captchaProducer.createImage(capStr); + } + + redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); + // 转换流信息写出 + FastByteArrayOutputStream os = new FastByteArrayOutputStream(); try { - AjaxResult ajax = AjaxResult.success(); - ajax.put("uuid", uuid); - ajax.put("img", Base64.encode(stream.toByteArray())); - return ajax; + ImageIO.write(image, "jpg", os); } - catch (Exception e) + catch (IOException e) { - e.printStackTrace(); return AjaxResult.error(e.getMessage()); } - finally - { - stream.close(); - } + + AjaxResult ajax = AjaxResult.success(); + ajax.put("uuid", uuid); + ajax.put("img", Base64.encode(os.toByteArray())); + return ajax; } } diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index c87725a4..9b679d0f 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -12,6 +12,8 @@ ruoyi: profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false + # 验证码类型 math 数组计算 char 字符验证 + captchaType: char # 开发环境配置 server: diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index 4d93d31a..ba2e0ab7 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -35,6 +35,18 @@ druid-spring-boot-starter + + + com.github.penggle + kaptcha + + + javax.servlet-api + javax.servlet + + + + com.github.oshi diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java new file mode 100644 index 00000000..43e78aeb --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java @@ -0,0 +1,83 @@ +package com.ruoyi.framework.config; + +import java.util.Properties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import static com.google.code.kaptcha.Constants.*; + +/** + * 验证码配置 + * + * @author ruoyi + */ +@Configuration +public class CaptchaConfig +{ + @Bean(name = "captchaProducer") + public DefaultKaptcha getKaptchaBean() + { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties properties = new Properties(); + // 是否有边框 默认为true 我们可以自己设置yes,no + properties.setProperty(KAPTCHA_BORDER, "yes"); + // 验证码文本字符颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black"); + // 验证码图片宽度 默认为200 + properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); + // 验证码图片高度 默认为50 + properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); + // 验证码文本字符大小 默认为40 + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38"); + // KAPTCHA_SESSION_KEY + properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode"); + // 验证码文本字符长度 默认为5 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4"); + // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); + // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); + Config config = new Config(properties); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } + + @Bean(name = "captchaProducerMath") + public DefaultKaptcha getKaptchaBeanMath() + { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties properties = new Properties(); + // 是否有边框 默认为true 我们可以自己设置yes,no + properties.setProperty(KAPTCHA_BORDER, "yes"); + // 边框颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90"); + // 验证码文本字符颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_COLOR, "blue"); + // 验证码图片宽度 默认为200 + properties.setProperty(KAPTCHA_IMAGE_WIDTH, "160"); + // 验证码图片高度 默认为50 + properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60"); + // 验证码文本字符大小 默认为40 + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "35"); + // KAPTCHA_SESSION_KEY + properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath"); + // 验证码文本生成器 + properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.ruoyi.framework.config.KaptchaTextCreator"); + // 验证码文本字符间距 默认为2 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3"); + // 验证码文本字符长度 默认为5 + properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6"); + // 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize) + properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier"); + // 验证码噪点颜色 默认为Color.BLACK + properties.setProperty(KAPTCHA_NOISE_COLOR, "white"); + // 干扰实现类 + properties.setProperty(KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise"); + // 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy + properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy"); + Config config = new Config(properties); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java new file mode 100644 index 00000000..3e745800 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java @@ -0,0 +1,75 @@ +package com.ruoyi.framework.config; + +import java.util.Random; +import com.google.code.kaptcha.text.impl.DefaultTextCreator; + +/** + * 验证码文本生成器 + * + * @author ruoyi + */ +public class KaptchaTextCreator extends DefaultTextCreator +{ + private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(","); + + @Override + public String getText() + { + Integer result = 0; + Random random = new Random(); + int x = random.nextInt(10); + int y = random.nextInt(10); + StringBuilder suChinese = new StringBuilder(); + int randomoperands = (int) Math.round(Math.random() * 2); + if (randomoperands == 0) + { + result = x * y; + suChinese.append(CNUMBERS[x]); + suChinese.append("*"); + suChinese.append(CNUMBERS[y]); + } + else if (randomoperands == 1) + { + if (!(x == 0) && y % x == 0) + { + result = y / x; + suChinese.append(CNUMBERS[y]); + suChinese.append("/"); + suChinese.append(CNUMBERS[x]); + } + else + { + result = x + y; + suChinese.append(CNUMBERS[x]); + suChinese.append("+"); + suChinese.append(CNUMBERS[y]); + } + } + else if (randomoperands == 2) + { + if (x >= y) + { + result = x - y; + suChinese.append(CNUMBERS[x]); + suChinese.append("-"); + suChinese.append(CNUMBERS[y]); + } + else + { + result = y - x; + suChinese.append(CNUMBERS[y]); + suChinese.append("-"); + suChinese.append(CNUMBERS[x]); + } + } + else + { + result = x + y; + suChinese.append(CNUMBERS[x]); + suChinese.append("+"); + suChinese.append(CNUMBERS[y]); + } + suChinese.append("=?@" + result); + return suChinese.toString(); + } +} \ No newline at end of file diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index b63d0461..64ecbc47 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -29,7 +29,7 @@ 记住密码 @@ -200,4 +200,7 @@ export default { font-size: 12px; letter-spacing: 1px; } +.login-code-img { + height: 38px; +} From 52d48fa63eb62d87df796c86b5d04c39a0b993e2 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Jul 2020 11:29:40 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B0=8F=E6=95=B0=E7=82=B9&=E9=99=8D?= =?UTF-8?q?=E7=BA=A7=E6=94=B9=E6=88=90=E5=BC=82=E5=B8=B8=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java index b8aeaa15..39e88ef7 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java @@ -1,5 +1,6 @@ package com.ruoyi.common.utils.sql; +import com.ruoyi.common.exception.BaseException; import com.ruoyi.common.utils.StringUtils; /** @@ -10,9 +11,9 @@ import com.ruoyi.common.utils.StringUtils; public class SqlUtil { /** - * 仅支持字母、数字、下划线、空格、逗号(支持多个字段排序) + * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序) */ - public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,]+"; + public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+"; /** * 检查字符,防止注入绕过 @@ -21,7 +22,7 @@ public class SqlUtil { if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) { - return StringUtils.EMPTY; + throw new BaseException("参数不符合规范,不能进行查询"); } return value; } From be778ba37037d7557c8dcb2355115e87414f85e2 Mon Sep 17 00:00:00 2001 From: Sxile <3440626@qq.com> Date: Thu, 23 Jul 2020 14:54:11 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/core/redis/RedisCache.java | 6 ++-- .../common/utils/file/FileUploadUtils.java | 8 ++--- .../framework/aspectj/DataScopeAspect.java | 6 ++-- .../interceptor/RepeatSubmitInterceptor.java | 6 ++-- .../framework/web/service/TokenService.java | 18 +++++------ .../ruoyi/generator/util/VelocityUtils.java | 32 +++++++++---------- .../ruoyi/quartz/util/AbstractQuartzJob.java | 2 +- .../ruoyi/system/mapper/SysMenuMapper.java | 30 ++++++++--------- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java index 530dcd9f..1f91350a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java @@ -13,7 +13,7 @@ import org.springframework.stereotype.Component; /** * spring redis 工具类 - * + * * @author ruoyi **/ @SuppressWarnings(value = { "unchecked", "rawtypes" }) @@ -109,7 +109,7 @@ public class RedisCache * 缓存List数据 * * @param key 缓存的键值 - * @param values 待缓存的List数据 + * @param dataList 待缓存的List数据 * @return 缓存的对象 */ public long setCacheList(final String key, final List dataList) @@ -216,7 +216,7 @@ public class RedisCache /** * 获得缓存的基本对象列表 - * + * * @param pattern 字符串前缀 * @return 对象列表 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index 183f9186..cb2f0239 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -15,7 +15,7 @@ import com.ruoyi.common.utils.uuid.IdUtils; /** * 文件上传工具类 - * + * * @author ruoyi */ public class FileUploadUtils @@ -89,7 +89,7 @@ public class FileUploadUtils * * @param baseDir 相对应用的基目录 * @param file 上传的文件 - * @param extension 上传文件类型 + * @param allowedExtension 上传文件类型 * @return 返回上传成功的文件名 * @throws FileSizeLimitExceededException 如果超出最大大小 * @throws FileNameLengthLimitExceededException 文件名太长 @@ -215,7 +215,7 @@ public class FileUploadUtils /** * 获取文件名的后缀 - * + * * @param file 表单文件 * @return 后缀名 */ @@ -228,4 +228,4 @@ public class FileUploadUtils } return extension; } -} \ No newline at end of file +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index 58040b6d..46949474 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -20,7 +20,7 @@ import com.ruoyi.framework.web.service.TokenService; /** * 数据过滤处理 - * + * * @author ruoyi */ @Aspect @@ -93,10 +93,10 @@ public class DataScopeAspect /** * 数据范围过滤 - * + * * @param joinPoint 切点 * @param user 用户 - * @param alias 别名 + * @param userAlias 别名 */ public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) { diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index bce2f3fe..d310382f 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -13,7 +13,7 @@ import com.ruoyi.common.utils.ServletUtils; /** * 防止重复提交拦截器 - * + * * @author ruoyi */ @Component @@ -46,8 +46,8 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter /** * 验证是否重复提交由子类实现具体的防重复提交的规则 - * - * @param httpServletRequest + * + * @param request * @return * @throws Exception */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java index 66885afd..943eae21 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -22,7 +22,7 @@ import io.jsonwebtoken.SignatureAlgorithm; /** * token验证处理 - * + * * @author ruoyi */ @Component @@ -51,7 +51,7 @@ public class TokenService /** * 获取用户身份信息 - * + * * @return 用户信息 */ public LoginUser getLoginUser(HttpServletRequest request) @@ -95,7 +95,7 @@ public class TokenService /** * 创建令牌 - * + * * @param loginUser 用户信息 * @return 令牌 */ @@ -113,8 +113,8 @@ public class TokenService /** * 验证令牌有效期,相差不足20分钟,自动刷新缓存 - * - * @param token 令牌 + * + * @param loginUser * @return 令牌 */ public void verifyToken(LoginUser loginUser) @@ -129,7 +129,7 @@ public class TokenService /** * 刷新令牌有效期 - * + * * @param loginUser 登录信息 */ public void refreshToken(LoginUser loginUser) @@ -140,10 +140,10 @@ public class TokenService String userKey = getTokenKey(loginUser.getToken()); redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); } - + /** * 设置用户代理信息 - * + * * @param loginUser 登录信息 */ public void setUserAgent(LoginUser loginUser) @@ -155,7 +155,7 @@ public class TokenService loginUser.setBrowser(userAgent.getBrowser().getName()); loginUser.setOs(userAgent.getOperatingSystem().getName()); } - + /** * 从数据声明生成令牌 * diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java index dc3bf45a..b061ee89 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java @@ -24,7 +24,7 @@ public class VelocityUtils /** * 设置模板变量信息 - * + * * @return 模板列表 */ public static VelocityContext prepareContext(GenTable genTable) @@ -93,7 +93,7 @@ public class VelocityUtils /** * 获取模板信息 - * + * * @return 模板列表 */ public static List getTemplateList(String tplCategory) @@ -183,7 +183,7 @@ public class VelocityUtils /** * 获取包前缀 - * + * * @param packageName 包名称 * @return 包前缀名称 */ @@ -196,8 +196,8 @@ public class VelocityUtils /** * 根据列类型获取导入包 - * - * @param column 列集合 + * + * @param columns 列集合 * @return 返回需要导入的包列表 */ public static HashSet getImportList(List columns) @@ -220,7 +220,7 @@ public class VelocityUtils /** * 获取权限前缀 - * + * * @param moduleName 模块名称 * @param businessName 业务名称 * @return 返回权限前缀 @@ -233,8 +233,8 @@ public class VelocityUtils /** * 获取上级菜单ID字段 - * - * @param options 生成其他选项 + * + * @param paramsObj 生成其他选项 * @return 上级菜单ID字段 */ public static String getParentMenuId(JSONObject paramsObj) @@ -248,8 +248,8 @@ public class VelocityUtils /** * 获取树编码 - * - * @param options 生成其他选项 + * + * @param paramsObj 生成其他选项 * @return 树编码 */ public static String getTreecode(JSONObject paramsObj) @@ -263,8 +263,8 @@ public class VelocityUtils /** * 获取树父编码 - * - * @param options 生成其他选项 + * + * @param paramsObj 生成其他选项 * @return 树父编码 */ public static String getTreeParentCode(JSONObject paramsObj) @@ -278,8 +278,8 @@ public class VelocityUtils /** * 获取树名称 - * - * @param options 生成其他选项 + * + * @param paramsObj 生成其他选项 * @return 树名称 */ public static String getTreeName(JSONObject paramsObj) @@ -293,7 +293,7 @@ public class VelocityUtils /** * 获取需要在哪一列上面显示展开按钮 - * + * * @param genTable 业务表对象 * @return 展开按钮列序号 */ @@ -317,4 +317,4 @@ public class VelocityUtils } return num; } -} \ No newline at end of file +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java index a0aadb68..fd652d67 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java @@ -66,7 +66,7 @@ public abstract class AbstractQuartzJob implements Job * 执行后 * * @param context 工作执行上下文对象 - * @param sysScheduleJob 系统计划任务 + * @param sysJob 系统计划任务 */ protected void after(JobExecutionContext context, SysJob sysJob, Exception e) { diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java index 907c613f..ebb25464 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java @@ -6,14 +6,14 @@ import com.ruoyi.common.core.domain.entity.SysMenu; /** * 菜单表 数据层 - * + * * @author ruoyi */ public interface SysMenuMapper { /** * 查询系统菜单列表 - * + * * @param menu 菜单信息 * @return 菜单列表 */ @@ -21,14 +21,14 @@ public interface SysMenuMapper /** * 根据用户所有权限 - * + * * @return 权限列表 */ public List selectMenuPerms(); /** * 根据用户查询系统菜单列表 - * + * * @param menu 菜单信息 * @return 菜单列表 */ @@ -36,7 +36,7 @@ public interface SysMenuMapper /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @@ -44,22 +44,22 @@ public interface SysMenuMapper /** * 根据用户ID查询菜单 - * + * * @return 菜单列表 */ public List selectMenuTreeAll(); /** * 根据用户ID查询菜单 - * - * @param username 用户ID + * + * @param userId 用户ID * @return 菜单列表 */ public List selectMenuTreeByUserId(Long userId); /** * 根据角色ID查询菜单树信息 - * + * * @param roleId 角色ID * @return 选中菜单列表 */ @@ -67,7 +67,7 @@ public interface SysMenuMapper /** * 根据菜单ID查询信息 - * + * * @param menuId 菜单ID * @return 菜单信息 */ @@ -75,7 +75,7 @@ public interface SysMenuMapper /** * 是否存在菜单子节点 - * + * * @param menuId 菜单ID * @return 结果 */ @@ -83,7 +83,7 @@ public interface SysMenuMapper /** * 新增菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @@ -91,7 +91,7 @@ public interface SysMenuMapper /** * 修改菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @@ -99,7 +99,7 @@ public interface SysMenuMapper /** * 删除菜单管理信息 - * + * * @param menuId 菜单ID * @return 结果 */ @@ -107,7 +107,7 @@ public interface SysMenuMapper /** * 校验菜单名称是否唯一 - * + * * @param menuName 菜单名称 * @param parentId 父菜单ID * @return 结果 From 8dd3ca5bb6b48e73f748ff4770f223b63cc09548 Mon Sep 17 00:00:00 2001 From: soulCoke <296312250@qq.com> Date: Thu, 23 Jul 2020 15:54:03 +0800 Subject: [PATCH 04/19] =?UTF-8?q?excel=20=E5=AF=BC=E5=85=A5=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E4=B8=8D=E9=9C=80=E8=A6=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=20=EF=BC=8C=E5=AF=BC=E5=85=A5=E5=85=81=E8=AE=B8=E5=88=97?= =?UTF-8?q?=E5=92=8C=E5=B1=9E=E6=80=A7=E4=B8=AA=E6=95=B0=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index affb08f7..9e9932f6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -8,7 +8,6 @@ import java.io.OutputStream; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.math.BigDecimal; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -18,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; + import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; @@ -41,6 +41,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFDataValidation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.annotation.Excel.Type; @@ -200,7 +201,9 @@ public class ExcelUtil // 设置类的私有字段属性可访问. field.setAccessible(true); Integer column = cellMap.get(attr.name()); - fieldsMap.put(column, field); + if(column !=null ) { // 字段在excel 中没有,那么就不需要设置值 + fieldsMap.put(column, field); + } } } for (int i = 1; i < rows; i++) @@ -875,14 +878,15 @@ public class ExcelUtil } else { - if ((Double) val % 1 > 0) - { - val = new DecimalFormat("0.00").format(val); - } - else - { - val = new DecimalFormat("0").format(val); - } + /* if ((Double) val % 1 > 0) + { + val = new DecimalFormat("0.00").format(val); + } + else + { + val = new DecimalFormat("0").format(val); + }*/ + val = new BigDecimal(val.toString()); // 导入的数据保证原汁原味,不做处理 } } else if (cell.getCellTypeEnum() == CellType.STRING) From 5c6adb25fc3c114085e64f0c34bab3623c3e647a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Jul 2020 17:02:55 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=8D=E9=80=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/vm/vue/index-tree.vue.vm | 32 +++++++++++++- .../src/main/resources/vm/vue/index.vue.vm | 32 +++++++++++++- ruoyi-ui/src/main.js | 3 +- ruoyi-ui/src/utils/ruoyi.js | 43 +++++++++++++------ sql/{ry_20200629.sql => ry_20200723.sql} | 2 +- 5 files changed, 94 insertions(+), 18 deletions(-) rename sql/{ry_20200629.sql => ry_20200723.sql} (98%) diff --git a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index fb10ed6d..7435ae77 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -157,6 +157,23 @@ +#elseif($column.htmlType == "checkbox" && "" != $dictType) + + + + {{dict.dictLabel}} + + + +#elseif($column.htmlType == "checkbox" && $dictType) + + + 请选择字典生成 + + #elseif($column.htmlType == "radio" && "" != $dictType) @@ -312,7 +329,7 @@ export default { #end // $comment字典翻译 ${column.javaField}Format(row, column) { - return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField}); + return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField}); }, #end #end @@ -328,6 +345,9 @@ export default { #if($column.htmlType == "radio") $column.javaField: "0"#if($velocityCount != $columns.size()),#end +#elseif($column.htmlType == "checkbox") + $column.javaField: []#if($velocityCount != $columns.size()),#end + #else $column.javaField: undefined#if($velocityCount != $columns.size()),#end @@ -361,6 +381,11 @@ export default { } get${BusinessName}(row.${pkColumn.javaField}).then(response => { this.form = response.data; +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.split(","); +#end +#end this.open = true; this.title = "修改${functionName}"; }); @@ -369,6 +394,11 @@ export default { submitForm: function() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.join(","); +#end +#end if (this.form.${pkColumn.javaField} != undefined) { update${BusinessName}(this.form).then(response => { if (response.code === 200) { diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 0b64a0c8..df2890eb 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -185,6 +185,23 @@ +#elseif($column.htmlType == "checkbox" && "" != $dictType) + + + + {{dict.dictLabel}} + + + +#elseif($column.htmlType == "checkbox" && $dictType) + + + 请选择字典生成 + + #elseif($column.htmlType == "radio" && "" != $dictType) @@ -326,7 +343,7 @@ export default { #end // $comment字典翻译 ${column.javaField}Format(row, column) { - return this.selectDictLabel(this.${column.javaField}Options, row.${column.javaField}); + return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField}); }, #end #end @@ -342,6 +359,9 @@ export default { #if($column.htmlType == "radio") $column.javaField: "0"#if($velocityCount != $columns.size()),#end +#elseif($column.htmlType == "checkbox") + $column.javaField: []#if($velocityCount != $columns.size()),#end + #else $column.javaField: undefined#if($velocityCount != $columns.size()),#end @@ -378,6 +398,11 @@ export default { const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids get${BusinessName}(${pkColumn.javaField}).then(response => { this.form = response.data; +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.split(","); +#end +#end this.open = true; this.title = "修改${functionName}"; }); @@ -386,6 +411,11 @@ export default { submitForm: function() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.join(","); +#end +#end if (this.form.${pkColumn.javaField} != undefined) { update${BusinessName}(this.form).then(response => { if (response.code === 200) { diff --git a/ruoyi-ui/src/main.js b/ruoyi-ui/src/main.js index c2834bf7..7a28b51f 100644 --- a/ruoyi-ui/src/main.js +++ b/ruoyi-ui/src/main.js @@ -18,7 +18,7 @@ import './assets/icons' // icon import './permission' // permission control import { getDicts } from "@/api/system/dict/data"; import { getConfigKey } from "@/api/system/config"; -import { parseTime, resetForm, addDateRange, selectDictLabel, download, handleTree } from "@/utils/ruoyi"; +import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; import Pagination from "@/components/Pagination"; // 全局方法挂载 @@ -28,6 +28,7 @@ Vue.prototype.parseTime = parseTime Vue.prototype.resetForm = resetForm Vue.prototype.addDateRange = addDateRange Vue.prototype.selectDictLabel = selectDictLabel +Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.download = download Vue.prototype.handleTree = handleTree diff --git a/ruoyi-ui/src/utils/ruoyi.js b/ruoyi-ui/src/utils/ruoyi.js index decad410..23879aaf 100644 --- a/ruoyi-ui/src/utils/ruoyi.js +++ b/ruoyi-ui/src/utils/ruoyi.js @@ -77,6 +77,21 @@ export function selectDictLabel(datas, value) { return actions.join(''); } +// 回显数据字典(字符串数组) +export function selectDictLabels(datas, value, separator) { + var actions = []; + var currentSeparator = undefined === separator ? "," : separator; + var temp = value.split(currentSeparator); + Object.keys(value.split(currentSeparator)).some((val) => { + Object.keys(datas).some((key) => { + if (datas[key].dictValue == ('' + temp[val])) { + actions.push(datas[key].dictLabel + currentSeparator); + } + }) + }) + return actions.join('').substring(0, actions.join('').length - 1); +} + // 通用下载方法 export function download(fileName) { window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; @@ -98,10 +113,10 @@ export function sprintf(str) { // 转换字符串,undefined,null等转化为"" export function praseStrEmpty(str) { - if (!str || str == "undefined" || str == "null") { - return ""; - } - return str; + if (!str || str == "undefined" || str == "null") { + return ""; + } + return str; } /** @@ -120,15 +135,15 @@ export function handleTree(data, id, parentId, children, rootId) { //对源数据深度克隆 const cloneData = JSON.parse(JSON.stringify(data)) //循环所有项 - const treeData = cloneData.filter(father => { - let branchArr = cloneData.filter(child => { - //返回每一项的子级数组 - return father[id] === child[parentId] - }); - branchArr.length > 0 ? father.children = branchArr : ''; - //返回第一层 - return father[parentId] === rootId; + const treeData = cloneData.filter(father => { + let branchArr = cloneData.filter(child => { + //返回每一项的子级数组 + return father[id] === child[parentId] + }); + branchArr.length > 0 ? father.children = branchArr : ''; + //返回第一层 + return father[parentId] === rootId; }); return treeData != '' ? treeData : data; - } - +} + diff --git a/sql/ry_20200629.sql b/sql/ry_20200723.sql similarity index 98% rename from sql/ry_20200629.sql rename to sql/ry_20200723.sql index 7c8e8c87..727ac6cb 100644 --- a/sql/ry_20200629.sql +++ b/sql/ry_20200723.sql @@ -120,7 +120,7 @@ create table sys_role ( -- ---------------------------- -- 初始化-角色信息表数据 -- ---------------------------- -insert into sys_role values('1', '系统管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统管理员'); +insert into sys_role values('1', '超级管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '超级管理员'); insert into sys_role values('2', '普通角色', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '普通角色'); From 92c630128545884479adbc060b1f0b79bc66d1d2 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Jul 2020 18:58:45 +0800 Subject: [PATCH 06/19] =?UTF-8?q?Excel=E6=94=AF=E6=8C=81=E5=88=86=E5=89=B2?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=BB=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 +- .../com/ruoyi/common/annotation/Excel.java | 5 + .../com/ruoyi/common/utils/DictUtils.java | 101 ++++++++++++++---- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 85 +++++++++------ 4 files changed, 137 insertions(+), 56 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 9b679d0f..51c37e69 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -13,7 +13,7 @@ ruoyi: # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 - captchaType: char + captchaType: math # 开发环境配置 server: diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java index 9ce5acab..eed41a2a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -39,6 +39,11 @@ public @interface Excel */ public String readConverterExp() default ""; + /** + * 分隔符,读取字符串组内容 + */ + public String separator() default ","; + /** * 导出类型(0数字 1字符串) */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java index cdc6f6fc..e40b0c00 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -14,6 +14,11 @@ import com.ruoyi.common.utils.spring.SpringUtils; */ public class DictUtils { + /** + * 分隔符 + */ + public static final String SEPARATOR = ","; + /** * 设置字典缓存 * @@ -51,21 +56,7 @@ public class DictUtils */ public static String getDictLabel(String dictType, String dictValue) { - if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotEmpty(dictValue)) - { - List datas = getDictCache(dictType); - if (StringUtils.isNotEmpty(datas)) - { - for (SysDictData dict : datas) - { - if (dictValue.equals(dict.getDictValue())) - { - return dict.getDictLabel(); - } - } - } - } - return dictValue; + return getDictLabel(dictType, dictValue, SEPARATOR); } /** @@ -77,21 +68,87 @@ public class DictUtils */ public static String getDictValue(String dictType, String dictLabel) { - if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotEmpty(dictLabel)) + return getDictValue(dictType, dictLabel, SEPARATOR); + } + + /** + * 根据字典类型和字典值获取字典标签 + * + * @param dictType 字典类型 + * @param dictValue 字典值 + * @param separator 分隔符 + * @return 字典标签 + */ + public static String getDictLabel(String dictType, String dictValue, String separator) + { + StringBuilder propertyString = new StringBuilder(); + List datas = getDictCache(dictType); + + if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) { - List datas = getDictCache(dictType); - if (StringUtils.isNotEmpty(datas)) + for (SysDictData dict : datas) { - for (SysDictData dict : datas) + for (String value : dictValue.split(separator)) { - if (dictLabel.equals(dict.getDictLabel())) + if (value.equals(dict.getDictValue())) { - return dict.getDictValue(); + propertyString.append(dict.getDictLabel() + separator); + break; } } } } - return dictLabel; + else + { + for (SysDictData dict : datas) + { + if (dictValue.equals(dict.getDictValue())) + { + return dict.getDictLabel(); + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); + } + + /** + * 根据字典类型和字典标签获取字典值 + * + * @param dictType 字典类型 + * @param dictLabel 字典标签 + * @param separator 分隔符 + * @return 字典值 + */ + public static String getDictValue(String dictType, String dictLabel, String separator) + { + StringBuilder propertyString = new StringBuilder(); + List datas = getDictCache(dictType); + + if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) + { + for (SysDictData dict : datas) + { + for (String label : dictLabel.split(separator)) + { + if (label.equals(dict.getDictLabel())) + { + propertyString.append(dict.getDictValue() + separator); + break; + } + } + } + } + else + { + for (SysDictData dict : datas) + { + if (dictLabel.equals(dict.getDictLabel())) + { + return dict.getDictValue(); + } + } + } + return StringUtils.stripEnd(propertyString.toString(), separator); } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index affb08f7..2d6ed8c5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -271,11 +271,11 @@ public class ExcelUtil } else if (StringUtils.isNotEmpty(attr.readConverterExp())) { - val = reverseByExp(Convert.toStr(val), attr.readConverterExp()); + val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator()); } else if (StringUtils.isNotEmpty(attr.dictType())) { - val = reverseDictByExp(attr.dictType(), Convert.toStr(val)); + val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator()); } ReflectUtils.invokeSetter(entity, propertyName, val); } @@ -534,6 +534,7 @@ public class ExcelUtil Object value = getTargetValue(vo, field, attr); String dateFormat = attr.dateFormat(); String readConverterExp = attr.readConverterExp(); + String separator = attr.separator(); String dictType = attr.dictType(); if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) { @@ -541,11 +542,11 @@ public class ExcelUtil } else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) { - cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp)); + cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator)); } else if (StringUtils.isNotEmpty(dictType)) { - cell.setCellValue(convertDictByExp(dictType, Convert.toStr(value))); + cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator)); } else { @@ -623,28 +624,36 @@ public class ExcelUtil * * @param propertyValue 参数值 * @param converterExp 翻译注解 + * @param separator 分隔符 * @return 解析后值 - * @throws Exception */ - public static String convertByExp(String propertyValue, String converterExp) throws Exception + public static String convertByExp(String propertyValue, String converterExp, String separator) { - try + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { - String[] convertSource = converterExp.split(","); - for (String item : convertSource) + String[] itemArray = item.split("="); + if (StringUtils.containsAny(separator, propertyValue)) + { + for (String value : propertyValue.split(separator)) + { + if (itemArray[0].equals(value)) + { + propertyString.append(itemArray[1] + separator); + break; + } + } + } + else { - String[] itemArray = item.split("="); if (itemArray[0].equals(propertyValue)) { return itemArray[1]; } } } - catch (Exception e) - { - throw e; - } - return propertyValue; + return StringUtils.stripEnd(propertyString.toString(), separator); } /** @@ -652,52 +661,62 @@ public class ExcelUtil * * @param propertyValue 参数值 * @param converterExp 翻译注解 + * @param separator 分隔符 * @return 解析后值 - * @throws Exception */ - public static String reverseByExp(String propertyValue, String converterExp) throws Exception + public static String reverseByExp(String propertyValue, String converterExp, String separator) { - try + StringBuilder propertyString = new StringBuilder(); + String[] convertSource = converterExp.split(","); + for (String item : convertSource) { - String[] convertSource = converterExp.split(","); - for (String item : convertSource) + String[] itemArray = item.split("="); + if (StringUtils.containsAny(separator, propertyValue)) + { + for (String value : propertyValue.split(separator)) + { + if (itemArray[1].equals(value)) + { + propertyString.append(itemArray[0] + separator); + break; + } + } + } + else { - String[] itemArray = item.split("="); if (itemArray[1].equals(propertyValue)) { return itemArray[0]; } } } - catch (Exception e) - { - throw e; - } - return propertyValue; + return StringUtils.stripEnd(propertyString.toString(), separator); } - + /** * 解析字典值 * - * @param dictType 字典类型 * @param dictValue 字典值 + * @param dictType 字典类型 + * @param separator 分隔符 * @return 字典标签 */ - public static String convertDictByExp(String dictType, String dictValue) throws Exception + public static String convertDictByExp(String dictValue, String dictType, String separator) { - return DictUtils.getDictLabel(dictType, dictValue); + return DictUtils.getDictLabel(dictType, dictValue, separator); } /** * 反向解析值字典值 * + * @param dictLabel 字典标签 * @param dictType 字典类型 - * @param dictValue 字典标签 + * @param separator 分隔符 * @return 字典值 */ - public static String reverseDictByExp(String dictType, String dictLabel) throws Exception + public static String reverseDictByExp(String dictLabel, String dictType, String separator) { - return DictUtils.getDictValue(dictType, dictLabel); + return DictUtils.getDictValue(dictType, dictLabel, separator); } /** From ee4b4de7b1096c346ea02c7b5322af75e8c6835e Mon Sep 17 00:00:00 2001 From: "HR.Hu" <418836876@qq.com> Date: Thu, 23 Jul 2020 21:01:18 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E9=BB=98=E8=AE=A4mapper=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=B8=8E=E9=BB=98=E8=AE=A4mapperScan=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/generator/util/VelocityUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java index b061ee89..ba0da074 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java @@ -17,7 +17,7 @@ public class VelocityUtils private static final String PROJECT_PATH = "main/java"; /** mybatis空间路径 */ - private static final String MYBATIS_PATH = "main/resources/mybatis"; + private static final String MYBATIS_PATH = "main/resources/mapper"; /** 默认上级菜单,系统工具 */ private static final String DEFAULT_PARENT_MENU_ID = "3"; From 388e36ed4dc5024195fbc2a60fa1be64be89d65f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Jul 2020 21:45:22 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/utils/DictUtils.java | 4 ++-- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 17 +++++------------ .../com/ruoyi/generator/util/VelocityUtils.java | 5 +++++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java index e40b0c00..0d3a23d5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -41,8 +41,8 @@ public class DictUtils Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); if (StringUtils.isNotNull(cacheObj)) { - List DictDatas = StringUtils.cast(cacheObj); - return DictDatas; + List dictDatas = StringUtils.cast(cacheObj); + return dictDatas; } return null; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 51dbcd70..13af4861 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -201,8 +201,9 @@ public class ExcelUtil // 设置类的私有字段属性可访问. field.setAccessible(true); Integer column = cellMap.get(attr.name()); - if(column !=null ) { // 字段在excel 中没有,那么就不需要设置值 - fieldsMap.put(column, field); + if (column != null) + { + fieldsMap.put(column, field); } } } @@ -695,7 +696,7 @@ public class ExcelUtil } return StringUtils.stripEnd(propertyString.toString(), separator); } - + /** * 解析字典值 * @@ -897,15 +898,7 @@ public class ExcelUtil } else { - /* if ((Double) val % 1 > 0) - { - val = new DecimalFormat("0.00").format(val); - } - else - { - val = new DecimalFormat("0").format(val); - }*/ - val = new BigDecimal(val.toString()); // 导入的数据保证原汁原味,不做处理 + val = new BigDecimal(val.toString()); // 浮点格式处理 } } else if (cell.getCellTypeEnum() == CellType.STRING) diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java index ba0da074..15c23d0f 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java @@ -11,6 +11,11 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.generator.domain.GenTable; import com.ruoyi.generator.domain.GenTableColumn; +/** + * 模板处理工具类 + * + * @author ruoyi + */ public class VelocityUtils { /** 项目空间路径 */ From 6e7d7aba934158d047c7c31bac356b3d18db4455 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 24 Jul 2020 15:37:57 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/utils/file/FileUtils.java | 2 +- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 2 - .../generator/controller/GenController.java | 24 +++++-- .../com/ruoyi/generator/domain/GenTable.java | 26 +++++++ .../service/GenTableServiceImpl.java | 70 +++++++++++++++++-- .../generator/service/IGenTableService.java | 16 +++-- .../mapper/generator/GenTableMapper.xml | 14 +++- ruoyi-ui/src/api/tool/gen.js | 10 +++ ruoyi-ui/src/views/tool/gen/genInfoForm.vue | 50 +++++++++++-- ruoyi-ui/src/views/tool/gen/index.vue | 10 ++- sql/{ry_20200723.sql => ry_20200724.sql} | 2 + 11 files changed, 200 insertions(+), 26 deletions(-) rename sql/{ry_20200723.sql => ry_20200724.sql} (98%) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index 03f5aa2a..f0dee601 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest; * * @author ruoyi */ -public class FileUtils +public class FileUtils extends org.apache.commons.io.FileUtils { public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 13af4861..494fb4b4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; - import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; @@ -41,7 +40,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFDataValidation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.annotation.Excel.Type; diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java index c2f50230..df72fcb9 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java @@ -148,15 +148,27 @@ public class GenController extends BaseController } /** - * 生成代码 + * 生成代码(下载方式) + */ + @PreAuthorize("@ss.hasPermi('tool:gen:code')") + @Log(title = "代码生成", businessType = BusinessType.GENCODE) + @GetMapping("/download/{tableName}") + public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException + { + byte[] data = genTableService.downloadCode(tableName); + genCode(response, data); + } + + /** + * 生成代码(自定义路径) */ @PreAuthorize("@ss.hasPermi('tool:gen:code')") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/genCode/{tableName}") - public void genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException + public AjaxResult genCode(HttpServletResponse response, @PathVariable("tableName") String tableName) { - byte[] data = genTableService.generatorCode(tableName); - genCode(response, data); + genTableService.generatorCode(tableName); + return AjaxResult.success(); } /** @@ -168,7 +180,7 @@ public class GenController extends BaseController public void batchGenCode(HttpServletResponse response, String tables) throws IOException { String[] tableNames = Convert.toStrArray(tables); - byte[] data = genTableService.generatorCode(tableNames); + byte[] data = genTableService.downloadCode(tableNames); genCode(response, data); } @@ -185,4 +197,4 @@ public class GenController extends BaseController response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } -} +} \ No newline at end of file diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java index aa05e701..4f4aea40 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java @@ -55,6 +55,12 @@ public class GenTable extends BaseEntity @NotBlank(message = "作者不能为空") private String functionAuthor; + /** 生成代码方式(0zip压缩包 1自定义路径) */ + private String genType; + + /** 生成路径(不填默认项目路径) */ + private String genPath; + /** 主键信息 */ private GenTableColumn pkColumn; @@ -180,6 +186,26 @@ public class GenTable extends BaseEntity this.functionAuthor = functionAuthor; } + public String getGenType() + { + return genType; + } + + public void setGenType(String genType) + { + this.genType = genType; + } + + public String getGenPath() + { + return genPath; + } + + public void setGenPath(String genPath) + { + this.genPath = genPath; + } + public GenTableColumn getPkColumn() { return pkColumn; diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java index e7531847..1286a005 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.generator.service; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.util.LinkedHashMap; @@ -21,9 +22,11 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.GenConstants; +import com.ruoyi.common.core.text.CharsetKit; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.generator.domain.GenTable; import com.ruoyi.generator.domain.GenTableColumn; import com.ruoyi.generator.mapper.GenTableColumnMapper; @@ -202,13 +205,13 @@ public class GenTableServiceImpl implements IGenTableService } /** - * 生成代码 + * 生成代码(下载方式) * * @param tableName 表名称 * @return 数据 */ @Override - public byte[] generatorCode(String tableName) + public byte[] downloadCode(String tableName) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); @@ -218,13 +221,55 @@ public class GenTableServiceImpl implements IGenTableService } /** - * 批量生成代码 + * 生成代码(自定义路径) + * + * @param tableName 表名称 + * @return 数据 + */ + @Override + public void generatorCode(String tableName) + { + // 查询表信息 + GenTable table = genTableMapper.selectGenTableByName(tableName); + // 查询列信息 + List columns = table.getColumns(); + setPkColumn(table, columns); + + VelocityInitializer.initVelocity(); + + VelocityContext context = VelocityUtils.prepareContext(table); + + // 获取模板列表 + List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + for (String template : templates) + { + if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) + { + // 渲染模板 + StringWriter sw = new StringWriter(); + Template tpl = Velocity.getTemplate(template, Constants.UTF8); + tpl.merge(context, sw); + try + { + String path = getGenPath(table, template); + FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); + } + catch (IOException e) + { + throw new CustomException("渲染模板失败,表名:" + table.getTableName()); + } + } + } + } + + /** + * 批量生成代码(下载方式) * * @param tableNames 表数组 * @return 数据 */ @Override - public byte[] generatorCode(String[] tableNames) + public byte[] downloadCode(String[] tableNames) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); @@ -347,4 +392,21 @@ public class GenTableServiceImpl implements IGenTableService genTable.setParentMenuName(parentMenuName); } } + + /** + * 获取代码生成地址 + * + * @param table 业务表信息 + * @param template 模板文件路径 + * @return 生成地址 + */ + public static String getGenPath(GenTable table, String template) + { + String genPath = table.getGenPath(); + if (StringUtils.equals(genPath, "/")) + { + return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); + } + return genPath + File.separator + VelocityUtils.getFileName(template, table); + } } \ No newline at end of file diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java index 2bff5976..049cb5fd 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java @@ -75,20 +75,28 @@ public interface IGenTableService public Map previewCode(Long tableId); /** - * 生成代码 + * 生成代码(下载方式) * * @param tableName 表名称 * @return 数据 */ - public byte[] generatorCode(String tableName); + public byte[] downloadCode(String tableName); /** - * 批量生成代码 + * 生成代码(自定义路径) + * + * @param tableName 表名称 + * @return 数据 + */ + public void generatorCode(String tableName); + + /** + * 批量生成代码(下载方式) * * @param tableNames 表数组 * @return 数据 */ - public byte[] generatorCode(String[] tableNames); + public byte[] downloadCode(String[] tableNames); /** * 修改保存参数校验 diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml index 503bb15c..6ff51ff8 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -15,6 +15,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -50,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table + select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table where dept_name=#{deptName} and parent_id = #{parentId} + limit 1 From b32d0724b7a912973f2afb14b5b783e9a0f1183f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 31 Jul 2020 22:35:30 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7vue-cli=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=B04.4.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/system/SysDeptMapper.xml | 3 +- ruoyi-ui/babel.config.js | 12 +++++-- ruoyi-ui/package.json | 32 +++++++++---------- ruoyi-ui/vue.config.js | 12 +------ 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 191f1cca..9da14d8f 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -77,8 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-ui/babel.config.js b/ruoyi-ui/babel.config.js index c8e69f56..b732c91f 100644 --- a/ruoyi-ui/babel.config.js +++ b/ruoyi-ui/babel.config.js @@ -1,5 +1,13 @@ module.exports = { presets: [ - '@vue/app' - ] + // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app + '@vue/cli-plugin-babel/preset' + ], + 'env': { + 'development': { + // babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require(). + // This plugin can significantly increase the speed of hot updates, when you have a large number of pages. + 'plugins': ['dynamic-import-node'] + } + } } diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index a78acadf..f359fb6c 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -5,7 +5,7 @@ "author": "若依", "license": "MIT", "scripts": { - "dev": "vue-cli-service serve --open", + "dev": "vue-cli-service serve", "build:prod": "vue-cli-service build", "build:stage": "vue-cli-service build --mode staging", "preview": "node build/index.js --preview", @@ -43,10 +43,11 @@ "@riophae/vue-treeselect": "0.4.0", "axios": "0.18.1", "clipboard": "2.0.4", + "core-js": "3.6.5", "echarts": "4.2.1", "element-ui": "2.13.2", "file-saver": "2.0.1", - "js-beautify": "^1.10.2", + "js-beautify": "1.10.2", "fuse.js": "3.4.4", "js-cookie": "2.2.0", "jsencrypt": "3.0.0-rc.1", @@ -65,32 +66,31 @@ "vuex": "3.1.0" }, "devDependencies": { - "@vue/cli-plugin-babel": "3.5.3", - "@vue/cli-plugin-eslint": "^3.9.1", - "@vue/cli-plugin-unit-jest": "3.5.3", - "@vue/cli-service": "3.5.3", + "@vue/cli-plugin-babel": "4.4.4", + "@vue/cli-plugin-eslint": "4.4.4", + "@vue/cli-plugin-unit-jest": "4.4.4", + "@vue/cli-service": "4.4.4", "@vue/test-utils": "1.0.0-beta.29", - "autoprefixer": "^9.5.1", - "babel-core": "7.0.0-bridge.0", - "babel-eslint": "10.0.1", + "autoprefixer": "9.5.1", + "babel-eslint": "10.1.0", "babel-jest": "23.6.0", + "babel-plugin-dynamic-import-node": "2.3.3", "chalk": "2.4.2", "chokidar": "2.1.5", "connect": "3.6.6", - "eslint": "5.15.3", - "eslint-plugin-vue": "5.2.2", + "eslint": "6.7.2", + "eslint-plugin-vue": "6.2.2", "html-webpack-plugin": "3.2.0", - "http-proxy-middleware": "^0.19.1", "husky": "1.3.1", "lint-staged": "8.1.5", "mockjs": "1.0.1-beta3", "plop": "2.3.0", - "runjs": "^4.3.2", - "sass": "^1.26.10", - "sass-loader": "^7.1.0", + "runjs": "4.3.2", + "sass": "1.26.10", + "sass-loader": "8.0.2", "script-ext-html-webpack-plugin": "2.1.3", "script-loader": "0.7.2", - "serve-static": "^1.13.2", + "serve-static": "1.13.2", "svg-sprite-loader": "4.1.3", "svgo": "1.2.0", "vue-template-compiler": "2.6.10" diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index b7f16f3e..fb708578 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -30,6 +30,7 @@ module.exports = { devServer: { host: '0.0.0.0', port: port, + open: true, proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { @@ -71,17 +72,6 @@ module.exports = { }) .end() - // set preserveWhitespace - config.module - .rule('vue') - .use('vue-loader') - .loader('vue-loader') - .tap(options => { - options.compilerOptions.preserveWhitespace = true - return options - }) - .end() - config .when(process.env.NODE_ENV !== 'development', config => { From 4dcf737db03720bff2216ea04aba082be1ebb413 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 1 Aug 2020 15:45:38 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E5=8F=B3=E4=BE=A7=E6=B7=BB=E5=8A=A0=E5=88=B7=E6=96=B0?= =?UTF-8?q?&=E6=98=BE=E9=9A=90=E6=9F=A5=E8=AF=A2=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/vm/vue/index-tree.vue.vm | 31 +++++++++----- .../src/main/resources/vm/vue/index.vue.vm | 14 ++++++- ruoyi-ui/src/assets/styles/ruoyi.scss | 27 ++++++++++++- ruoyi-ui/src/views/monitor/job/index.vue | 14 ++++++- ruoyi-ui/src/views/monitor/job/log.vue | 14 ++++++- .../src/views/monitor/logininfor/index.vue | 14 ++++++- ruoyi-ui/src/views/monitor/online/index.vue | 2 +- ruoyi-ui/src/views/monitor/operlog/index.vue | 14 ++++++- ruoyi-ui/src/views/system/config/index.vue | 14 ++++++- ruoyi-ui/src/views/system/dept/index.vue | 40 +++++++++++++------ ruoyi-ui/src/views/system/dict/data.vue | 14 ++++++- ruoyi-ui/src/views/system/dict/index.vue | 14 ++++++- ruoyi-ui/src/views/system/menu/index.vue | 37 ++++++++++++++--- ruoyi-ui/src/views/system/notice/index.vue | 14 ++++++- ruoyi-ui/src/views/system/post/index.vue | 14 ++++++- ruoyi-ui/src/views/system/role/index.vue | 14 ++++++- ruoyi-ui/src/views/system/user/index.vue | 14 ++++++- ruoyi-ui/src/views/tool/gen/index.vue | 14 ++++++- 18 files changed, 262 insertions(+), 57 deletions(-) diff --git a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index 2b26f795..a6ae2026 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -1,6 +1,6 @@