Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cnooc_zydeepen-cggl_expert-manage-miniapp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙德龙
cnooc_zydeepen-cggl_expert-manage-miniapp
Commits
654783e3
Commit
654783e3
authored
Nov 14, 2025
by
刘红梅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
验证密码格式
parent
3ae486e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletions
+10
-1
src/main/java/com/cnooc/expert/auth/service/impl/LoginServiceImpl.java
+2
-0
src/main/java/com/cnooc/expert/common/exception/GlobalErrorCodeConstants.java
+1
-0
src/main/java/com/cnooc/expert/common/utils/ValidUtils.java
+7
-1
No files found.
src/main/java/com/cnooc/expert/auth/service/impl/LoginServiceImpl.java
View file @
654783e3
...
...
@@ -113,6 +113,7 @@ public class LoginServiceImpl implements LoginService {
ValidUtils
.
isText
(
loginVO
.
getPhoneCode
(),
"请输入验证码"
);
ValidUtils
.
isTrue
(
Validator
.
isMobile
(
loginVO
.
getPhoneNumber
()),
"请输入正确格式的手机号"
);
ValidUtils
.
isText
(
loginVO
.
getPassword
(),
"请输入密码"
);
ValidUtils
.
isValidPassword
(
loginVO
.
getPassword
(),
GlobalErrorCodeConstants
.
PARAM_PASSWORD_FORMAT_ERROR
);
//1.根据手机号去库中查询是否存在
ExpertInfoResp
expertInfoResp
=
loginServicesClient
.
querySingleByShengFenZhengOrMobile
(
loginVO
.
getPhoneNumber
(),
null
);
if
(
expertInfoResp
==
null
){
...
...
@@ -160,6 +161,7 @@ public class LoginServiceImpl implements LoginService {
ValidUtils
.
isText
(
loginVO
.
getIdNumber
(),
"请输入身份证号"
);
ValidUtils
.
isText
(
loginVO
.
getPassword
(),
"请输入密码"
);
ValidUtils
.
isTrue
(
IdcardUtil
.
isValidCard
(
loginVO
.
getIdNumber
()),
"请输入正确的身份证号"
);
ValidUtils
.
isValidPassword
(
loginVO
.
getPassword
(),
GlobalErrorCodeConstants
.
PARAM_PASSWORD_FORMAT_ERROR
);
ExpertInfoResp
expertInfoResp
=
loginServicesClient
.
querySingleByShengFenZhengOrMobile
(
null
,
loginVO
.
getIdNumber
());
if
(
expertInfoResp
==
null
){
throw
new
BusinessException
(
GlobalErrorCodeConstants
.
USER_NOT_EXISTS
.
getCode
(),
GlobalErrorCodeConstants
.
USER_NOT_EXISTS
.
getMsg
());
...
...
src/main/java/com/cnooc/expert/common/exception/GlobalErrorCodeConstants.java
View file @
654783e3
...
...
@@ -31,6 +31,7 @@ public interface GlobalErrorCodeConstants {
ErrorCode
PARAM_REQUIRED
=
new
ErrorCode
(
3001
,
"必填字段不能为空"
);
ErrorCode
PARAM_FORMAT_ERROR
=
new
ErrorCode
(
3002
,
"参数格式不正确"
);
ErrorCode
PARAM_RANGE_ERROR
=
new
ErrorCode
(
3003
,
"参数超出范围"
);
ErrorCode
PARAM_PASSWORD_FORMAT_ERROR
=
new
ErrorCode
(
3004
,
"密码强度不符合要求:密码必须包含大小写字母、数字和特殊字符,且长度不少于8位"
);
// ========== 业务逻辑错误 (4000-4999) ==========
ErrorCode
OPERATION_TOO_FREQUENT
=
new
ErrorCode
(
4001
,
"操作太频繁,请稍后再试"
);
...
...
src/main/java/com/cnooc/expert/common/utils/ValidUtils.java
View file @
654783e3
...
...
@@ -90,5 +90,11 @@ public class ValidUtils {
}
}
//判断是否有效的密码
public
static
void
isValidPassword
(
String
password
,
ErrorCode
errorCode
)
{
String
passwordRegex
=
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`])[a-zA-Z\\d!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`]{8,}$"
;
if
(!
password
.
matches
(
passwordRegex
))
{
throw
new
BusinessException
(
errorCode
.
getCode
(),
errorCode
.
getMsg
());
}
}
}
Write
Preview
Markdown
is supported
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