Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
e06ec084
Unverified
Commit
e06ec084
authored
Mar 04, 2022
by
YJRY
Committed by
GitHub
Mar 04, 2022
Browse files
[代码优化]枚举值调整为统一大写;枚举的find方法优化 (#730)
Co-authored-by:
xuqi
<
xuqi@zed.com
>
parent
0705b123
Changes
6
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/utils/enums/CodeBiEnum.java
View file @
e06ec084
...
@@ -40,7 +40,7 @@ public enum CodeBiEnum {
...
@@ -40,7 +40,7 @@ public enum CodeBiEnum {
public
static
CodeBiEnum
find
(
Integer
code
)
{
public
static
CodeBiEnum
find
(
Integer
code
)
{
for
(
CodeBiEnum
value
:
CodeBiEnum
.
values
())
{
for
(
CodeBiEnum
value
:
CodeBiEnum
.
values
())
{
if
(
code
.
equals
(
value
.
getCode
()))
{
if
(
value
.
getCode
()
.
equals
(
code
))
{
return
value
;
return
value
;
}
}
}
}
...
...
eladmin-common/src/main/java/me/zhengjie/utils/enums/DataScopeEnum.java
View file @
e06ec084
...
@@ -43,7 +43,7 @@ public enum DataScopeEnum {
...
@@ -43,7 +43,7 @@ public enum DataScopeEnum {
public
static
DataScopeEnum
find
(
String
val
)
{
public
static
DataScopeEnum
find
(
String
val
)
{
for
(
DataScopeEnum
dataScopeEnum
:
DataScopeEnum
.
values
())
{
for
(
DataScopeEnum
dataScopeEnum
:
DataScopeEnum
.
values
())
{
if
(
val
.
equals
(
dataScopeEnum
.
getValue
()))
{
if
(
dataScopeEnum
.
getValue
()
.
equals
(
val
))
{
return
dataScopeEnum
;
return
dataScopeEnum
;
}
}
}
}
...
...
eladmin-common/src/main/java/me/zhengjie/utils/enums/RequestMethodEnum.java
View file @
e06ec084
...
@@ -65,7 +65,7 @@ public enum RequestMethodEnum {
...
@@ -65,7 +65,7 @@ public enum RequestMethodEnum {
public
static
RequestMethodEnum
find
(
String
type
)
{
public
static
RequestMethodEnum
find
(
String
type
)
{
for
(
RequestMethodEnum
value
:
RequestMethodEnum
.
values
())
{
for
(
RequestMethodEnum
value
:
RequestMethodEnum
.
values
())
{
if
(
type
.
equals
(
value
.
getType
()))
{
if
(
value
.
getType
()
.
equals
(
type
))
{
return
value
;
return
value
;
}
}
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/config/bean/LoginCodeEnum.java
View file @
e06ec084
...
@@ -26,18 +26,18 @@ public enum LoginCodeEnum {
...
@@ -26,18 +26,18 @@ public enum LoginCodeEnum {
/**
/**
* 算数
* 算数
*/
*/
arithmetic
,
ARITHMETIC
,
/**
/**
* 中文
* 中文
*/
*/
chinese
,
CHINESE
,
/**
/**
* 中文闪图
* 中文闪图
*/
*/
chinese_gif
,
CHINESE_GIF
,
/**
/**
* 闪图
* 闪图
*/
*/
gif
,
GIF
,
spec
SPEC
}
}
eladmin-system/src/main/java/me/zhengjie/modules/security/config/bean/LoginProperties.java
View file @
e06ec084
...
@@ -62,7 +62,7 @@ public class LoginProperties {
...
@@ -62,7 +62,7 @@ public class LoginProperties {
if
(
Objects
.
isNull
(
loginCode
))
{
if
(
Objects
.
isNull
(
loginCode
))
{
loginCode
=
new
LoginCode
();
loginCode
=
new
LoginCode
();
if
(
Objects
.
isNull
(
loginCode
.
getCodeType
()))
{
if
(
Objects
.
isNull
(
loginCode
.
getCodeType
()))
{
loginCode
.
setCodeType
(
LoginCodeEnum
.
arithmetic
);
loginCode
.
setCodeType
(
LoginCodeEnum
.
ARITHMETIC
);
}
}
}
}
return
switchCaptcha
(
loginCode
);
return
switchCaptcha
(
loginCode
);
...
@@ -78,25 +78,25 @@ public class LoginProperties {
...
@@ -78,25 +78,25 @@ public class LoginProperties {
Captcha
captcha
;
Captcha
captcha
;
synchronized
(
this
)
{
synchronized
(
this
)
{
switch
(
loginCode
.
getCodeType
())
{
switch
(
loginCode
.
getCodeType
())
{
case
arithmetic
:
case
ARITHMETIC
:
// 算术类型 https://gitee.com/whvse/EasyCaptcha
// 算术类型 https://gitee.com/whvse/EasyCaptcha
captcha
=
new
FixedArithmeticCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
=
new
FixedArithmeticCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
// 几位数运算,默认是两位
// 几位数运算,默认是两位
captcha
.
setLen
(
loginCode
.
getLength
());
captcha
.
setLen
(
loginCode
.
getLength
());
break
;
break
;
case
chinese
:
case
CHINESE
:
captcha
=
new
ChineseCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
=
new
ChineseCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
.
setLen
(
loginCode
.
getLength
());
captcha
.
setLen
(
loginCode
.
getLength
());
break
;
break
;
case
chinese_gif
:
case
CHINESE_GIF
:
captcha
=
new
ChineseGifCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
=
new
ChineseGifCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
.
setLen
(
loginCode
.
getLength
());
captcha
.
setLen
(
loginCode
.
getLength
());
break
;
break
;
case
gif
:
case
GIF
:
captcha
=
new
GifCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
=
new
GifCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
.
setLen
(
loginCode
.
getLength
());
captcha
.
setLen
(
loginCode
.
getLength
());
break
;
break
;
case
spec
:
case
SPEC
:
captcha
=
new
SpecCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
=
new
SpecCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
.
setLen
(
loginCode
.
getLength
());
captcha
.
setLen
(
loginCode
.
getLength
());
break
;
break
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
View file @
e06ec084
...
@@ -123,7 +123,7 @@ public class AuthorizationController {
...
@@ -123,7 +123,7 @@ public class AuthorizationController {
String
uuid
=
properties
.
getCodeKey
()
+
IdUtil
.
simpleUUID
();
String
uuid
=
properties
.
getCodeKey
()
+
IdUtil
.
simpleUUID
();
//当验证码类型为 arithmetic时且长度 >= 2 时,captcha.text()的结果有几率为浮点型
//当验证码类型为 arithmetic时且长度 >= 2 时,captcha.text()的结果有几率为浮点型
String
captchaValue
=
captcha
.
text
();
String
captchaValue
=
captcha
.
text
();
if
(
captcha
.
getCharType
()
-
1
==
LoginCodeEnum
.
arithmetic
.
ordinal
()
&&
captchaValue
.
contains
(
"."
))
{
if
(
captcha
.
getCharType
()
-
1
==
LoginCodeEnum
.
ARITHMETIC
.
ordinal
()
&&
captchaValue
.
contains
(
"."
))
{
captchaValue
=
captchaValue
.
split
(
"\\."
)[
0
];
captchaValue
=
captchaValue
.
split
(
"\\."
)[
0
];
}
}
// 保存
// 保存
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment