From 26fc652d33fb82a75d6ec7771ca50ee414b21723 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期二, 11 一月 2022 16:58:47 +0800 Subject: [PATCH] update 统一代码间隔符 --- ruoyi-common/src/main/java/com/ruoyi/common/captcha/UnsignedMathGenerator.java | 118 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 59 insertions(+), 59 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 9c0f26f..ec2d682 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 @@ -13,73 +13,73 @@ */ public class UnsignedMathGenerator implements CodeGenerator { - private static final long serialVersionUID = -5514819971774091076L; + private static final long serialVersionUID = -5514819971774091076L; - private static final String operators = "+-*"; + private static final String operators = "+-*"; - /** - * 鍙備笌璁$畻鏁板瓧鏈�澶ч暱搴� - */ - private final int numberLength; + /** + * 鍙備笌璁$畻鏁板瓧鏈�澶ч暱搴� + */ + private final int numberLength; - /** - * 鏋勯�� - */ - public UnsignedMathGenerator() { - this(2); - } + /** + * 鏋勯�� + */ + public UnsignedMathGenerator() { + this(2); + } - /** - * 鏋勯�� - * - * @param numberLength 鍙備笌璁$畻鏈�澶ф暟瀛椾綅鏁� - */ - public UnsignedMathGenerator(int numberLength) { - this.numberLength = numberLength; - } + /** + * 鏋勯�� + * + * @param numberLength 鍙備笌璁$畻鏈�澶ф暟瀛椾綅鏁� + */ + public UnsignedMathGenerator(int numberLength) { + this.numberLength = numberLength; + } - @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); + @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); - return number1 + RandomUtil.randomChar(operators) + number2 + '='; - } + return number1 + RandomUtil.randomChar(operators) + number2 + '='; + } - @Override - public boolean verify(String code, String userInputCode) { - int result; - try { - result = Integer.parseInt(userInputCode); - } catch (NumberFormatException e) { - // 鐢ㄦ埛杈撳叆闈炴暟瀛� - return false; - } + @Override + public boolean verify(String code, String userInputCode) { + int result; + try { + result = Integer.parseInt(userInputCode); + } catch (NumberFormatException e) { + // 鐢ㄦ埛杈撳叆闈炴暟瀛� + return false; + } - final int calculateResult = (int) Calculator.conversion(code); - return result == calculateResult; - } + final int calculateResult = (int) Calculator.conversion(code); + return result == calculateResult; + } - /** - * 鑾峰彇楠岃瘉鐮侀暱搴� - * - * @return 楠岃瘉鐮侀暱搴� - */ - public int getLength() { - return this.numberLength * 2 + 2; - } + /** + * 鑾峰彇楠岃瘉鐮侀暱搴� + * + * @return 楠岃瘉鐮侀暱搴� + */ + public int getLength() { + return this.numberLength * 2 + 2; + } - /** - * 鏍规嵁闀垮害鑾峰彇鍙備笌璁$畻鏁板瓧鏈�澶у�� - * - * @return 鏈�澶у�� - */ - private int getLimit() { - return Integer.parseInt("1" + StringUtils.repeat('0', this.numberLength)); - } + /** + * 鏍规嵁闀垮害鑾峰彇鍙備笌璁$畻鏁板瓧鏈�澶у�� + * + * @return 鏈�澶у�� + */ + private int getLimit() { + return Integer.parseInt("1" + StringUtils.repeat('0', this.numberLength)); + } } -- Gitblit v1.9.3