From 8b097af195e5b0056eaad06f199cd1d291821912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=9F=E6=98=8E=E9=94=AE?= Date: Thu, 24 Feb 2022 12:39:28 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E6=95=B0=E7=94=9F=E6=88=90=E6=96=B9=E5=BC=8F=20=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=AE=B9=E6=98=93=E7=94=9F=E6=88=90=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E9=9A=8F=E6=9C=BA=E6=95=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/captcha/UnsignedMathGenerator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/captcha/UnsignedMathGenerator.java b/ruoyi-common/src/main/java/com/ruoyi/common/captcha/UnsignedMathGenerator.java index 7b908a24..5dd00ec0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/captcha/UnsignedMathGenerator.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/captcha/UnsignedMathGenerator.java @@ -41,14 +41,14 @@ public class UnsignedMathGenerator implements CodeGenerator { @Override public String generate() { final int limit = getLimit(); - int min = RandomUtil.randomInt(limit); - int max = RandomUtil.randomInt(min, limit); - String number1 = Integer.toString(max); - String number2 = Integer.toString(min); - number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE); - number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE); + int a = RandomUtil.randomInt(limit); + int b = RandomUtil.randomInt(limit); + String max = Integer.toString(Math.max(a,b)); + String min = Integer.toString(Math.min(a,b)); + max = StringUtils.rightPad(max, this.numberLength, CharUtil.SPACE); + min = StringUtils.rightPad(min, this.numberLength, CharUtil.SPACE); - return number1 + RandomUtil.randomChar(OPERATORS) + number2 + '='; + return max + RandomUtil.randomChar(OPERATORS) + min + '='; } @Override