Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
19cdac75
Commit
19cdac75
authored
Apr 08, 2020
by
邓实川
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
密码修改,短信验证优化
parent
4131e0f0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
23 deletions
+69
-23
src/main/java/cn/timer/api/controller/LoginController.java
+41
-9
src/main/java/cn/timer/api/dto/qyzx/EntRegisterDto.java
+4
-1
src/main/java/cn/timer/api/utils/AliyunSMS.java
+24
-13
No files found.
src/main/java/cn/timer/api/controller/LoginController.java
View file @
19cdac75
...
...
@@ -6,7 +6,6 @@ import java.util.List;
import
java.util.stream.Stream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -84,9 +83,9 @@ public class LoginController {
phone
=
entRegisterDto
.
getUsername
();
entRegisterDto
.
setPhone
(
phone
);
}
JSONObject
j
=
aliyunSMS
.
yzm
(
entRegisterDto
,
entRegisterDto
.
getTc
(),
code
);
//
String bizId = (String) j.get("BizId");
//
Integer type = entRegisterDto.getMessageType();
JSONObject
j
=
aliyunSMS
.
authCode
(
entRegisterDto
,
entRegisterDto
.
getTc
(),
code
);
//
String bizId = (String) j.get("BizId");
//
Integer type = entRegisterDto.getMessageType();
// 获取当前日期的字符串格式
String
today
=
DateUtil
.
today
();
// yyyy-MM-dd
...
...
@@ -167,6 +166,39 @@ public class LoginController {
* System.out.println(111); }
*/
@PostMapping
(
value
=
"/updatePwd"
)
@ApiOperation
(
value
=
"4.修改密码(新)"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
4
)
public
Result
<
String
>
updatepwd
(
@RequestBody
EntRegisterDto
entRegisterDto
)
{
String
oldPwd
=
entRegisterDto
.
getOldPwd
();
// 输入的原密码
String
pw
=
entRegisterDto
.
getPw
();
// 输入的新密码
String
phone
=
entRegisterDto
.
getPhone
();
// 手机号
String
code
=
entRegisterDto
.
getCode
();
// 验证码
Integer
type
=
entRegisterDto
.
getPwUpdateType
();
// 验证方式
QyzxEmpLogin
qyzxEmpLogin
=
new
LambdaQueryChainWrapper
<
QyzxEmpLogin
>(
qyzxEmpLoginMapper
)
.
eq
(!
StrUtil
.
hasBlank
(
phone
),
QyzxEmpLogin:
:
getPhone
,
phone
).
one
();
// 员工登录表
String
dbPwd
=
qyzxEmpLogin
.
getPw
();
// 数据库原密码
if
(
type
==
1
)
{
if
(!
Md5
.
md5
(
oldPwd
).
equals
(
dbPwd
))
{
return
ResultUtil
.
error
(
"原密码验证失败"
);
}
if
(
pw
.
equals
(
oldPwd
))
{
return
ResultUtil
.
error
(
"新密码与原密码相同,请修改后重试!"
);
}
}
else
{
Object
codeRedis
=
session
.
getAttribute
(
phone
);
if
(!
code
.
equals
(
codeRedis
.
toString
()))
{
return
ResultUtil
.
error
(
"短信验证码错误"
);
}
if
(
Md5
.
md5
(
pw
).
equals
(
dbPwd
))
{
return
ResultUtil
.
error
(
"新密码与原密码相同,请修改后重试!"
);
}
}
qyzxEmpLogin
.
setPw
(
Md5
.
md5
(
pw
));
qyzxEmpLogin
.
updateById
();
return
ResultUtil
.
success
(
"修改成功"
);
}
/**
* 修改密码
*
...
...
@@ -187,7 +219,7 @@ public class LoginController {
if
(
code
==
null
)
{
return
ResultUtil
.
error
(
"请填写验证码"
);
}
if
(
!
code
.
toString
().
equals
(
codeRedis
))
{
if
(!
code
.
toString
().
equals
(
codeRedis
))
{
return
ResultUtil
.
error
(
"验证码不符"
);
}
QyzxEmpLogin
qyzxEmpLogin
=
new
LambdaQueryChainWrapper
<
QyzxEmpLogin
>(
qyzxEmpLoginMapper
)
...
...
@@ -197,10 +229,10 @@ public class LoginController {
qyzxEmpLogin
.
setPw
(
Md5
.
md5
(
pw
));
qyzxEmpLogin
.
updateById
();
return
ResultUtil
.
success
(
"修改密码成功"
);
}
else
{
}
else
{
return
ResultUtil
.
error
(
"修改密码失败,查找不到该人员!"
);
}
}
else
{
}
else
{
if
(
code
==
null
)
{
return
ResultUtil
.
error
(
"请填写原密码"
);
}
...
...
@@ -215,14 +247,14 @@ public class LoginController {
qyzxEmpLogin
.
setPw
(
Md5
.
md5
(
code
));
qyzxEmpLogin
.
updateById
();
return
ResultUtil
.
success
(
"修改密码成功"
);
}
else
{
}
else
{
return
ResultUtil
.
error
(
"原密码有误!请核对重试"
);
}
}
return
ResultUtil
.
error
(
"修改密码失败,查找不到该人员!"
);
}
//return ResultUtil.error("修改密码失败");
//
return ResultUtil.error("修改密码失败");
}
/**
...
...
src/main/java/cn/timer/api/dto/qyzx/EntRegisterDto.java
View file @
19cdac75
...
...
@@ -31,6 +31,9 @@ public class EntRegisterDto implements Serializable {
@ApiModelProperty
(
value
=
"短信时间 "
,
example
=
"20191207"
)
private
String
sendDate
;
@ApiModelProperty
(
value
=
"原密码"
,
example
=
"666666"
)
private
String
oldPwd
;
@ApiModelProperty
(
value
=
"验证码 "
,
example
=
"666666"
)
private
String
code
;
...
...
@@ -40,7 +43,7 @@ public class EntRegisterDto implements Serializable {
@ApiModelProperty
(
value
=
"短信模板:1.身份验证验证码 2.登录确认验证码 3.登录异常验证码 4.用户注册验证码 5.修改密码验证码 6.信息变更验证码 "
,
example
=
"1"
)
private
Integer
tc
;
@ApiModelProperty
(
value
=
"1.
验证码修改密码 2.原密码修改密码
"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"1.
原密码修改 2.验证码修改
"
,
example
=
"1"
)
private
Integer
pwUpdateType
;
}
src/main/java/cn/timer/api/utils/AliyunSMS.java
View file @
19cdac75
package
cn
.
timer
.
api
.
utils
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.CommonRequest
;
import
com.aliyuncs.CommonResponse
;
...
...
@@ -20,6 +22,12 @@ import cn.timer.api.dto.qyzx.EntRegisterDto;
*/
public
class
AliyunSMS
{
final
String
name
=
"TemplateCode"
;
// 模板参数
final
String
regionId
=
"cn-shenzhen"
;
// 地区参数
final
String
projectName
=
"8小时人事管家"
;
// 项目名
final
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
final
String
secret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
/**
*
* @param phone
...
...
@@ -27,9 +35,12 @@ public class AliyunSMS {
* 5."修改密码验证码" 6."信息变更验证码"
*/
@SuppressWarnings
(
"deprecation"
)
public
JSONObject
yzm
(
EntRegisterDto
entRegisterDto
,
Integer
templateCode
,
Integer
code
)
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-shenzhen"
,
"LTAI4FuaShJWQ1dggsFWG5CC"
,
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
);
public
JSONObject
authCode
(
EntRegisterDto
entRegisterDto
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Integer
templateCode
,
Integer
code
)
{
String
phone
=
entRegisterDto
.
getPhone
();
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
regionId
,
accessKeyId
,
secret
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
...
...
@@ -37,37 +48,37 @@ public class AliyunSMS {
request
.
setDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setVersion
(
"2017-05-25"
);
request
.
setAction
(
"SendSms"
);
request
.
putQueryParameter
(
"RegionId"
,
"cn-shenzhen"
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
entRegisterDto
.
getPhone
()
);
request
.
putQueryParameter
(
"SignName"
,
"8小时人事管家"
);
request
.
putQueryParameter
(
"RegionId"
,
regionId
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
phone
);
request
.
putQueryParameter
(
"SignName"
,
projectName
);
switch
(
templateCode
)
{
// 1."身份验证验证码"
case
1
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485364"
);
request
.
putQueryParameter
(
name
,
"SMS_178485364"
);
break
;
// 2."登录确认验证码"
case
2
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485363"
);
request
.
putQueryParameter
(
name
,
"SMS_178485363"
);
break
;
// 3."登录异常验证码"
case
3
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485362"
);
request
.
putQueryParameter
(
name
,
"SMS_178485362"
);
break
;
// 4."用户注册验证码"
case
4
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485361"
);
request
.
putQueryParameter
(
name
,
"SMS_178485361"
);
break
;
// 5."修改密码验证码"
case
5
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485360"
);
request
.
putQueryParameter
(
name
,
"SMS_178485360"
);
break
;
// 6."信息变更验证码"
case
6
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485359"
);
request
.
putQueryParameter
(
name
,
"SMS_178485359"
);
break
;
default
:
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_178485364"
);
request
.
putQueryParameter
(
name
,
"SMS_178485364"
);
}
// 【8小时人事管家】验证码934169,您正在尝试修改登录密码,请妥善保管账户信息。
request
.
putQueryParameter
(
"TemplateParam"
,
"{\"code\":\""
+
code
+
"\"}"
);
...
...
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