Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
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
zengtianlai3
ioc_sixiang_license
Commits
02e6217b
Commit
02e6217b
authored
Sep 08, 2022
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录接口
parent
fe56a993
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
13 deletions
+38
-13
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+14
-13
LoginReqVo.java
...rc/main/java/iot/sixiang/license/model/vo/LoginReqVo.java
+24
-0
No files found.
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
02e6217b
...
@@ -15,12 +15,14 @@ import iot.sixiang.license.log.MyLog;
...
@@ -15,12 +15,14 @@ import iot.sixiang.license.log.MyLog;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.vo.LoginReqVo
;
import
iot.sixiang.license.model.vo.LoginVo
;
import
iot.sixiang.license.model.vo.LoginVo
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.EmailUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.StreamUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
...
@@ -56,14 +58,12 @@ public class LoginController {
...
@@ -56,14 +58,12 @@ public class LoginController {
* 模拟用户登录
* 模拟用户登录
*/
*/
@ApiOperation
(
value
=
"登录接口"
,
notes
=
"登录接口"
)
@ApiOperation
(
value
=
"登录接口"
,
notes
=
"登录接口"
)
@GetMapping
(
"login"
)
@PostMapping
(
"login"
)
@MyLog
(
title
=
"登录"
,
optParam
=
"#{userName},#{password},#{code}"
,
businessType
=
BusinessType
.
OTHER
)
@MyLog
(
title
=
"登录"
,
businessType
=
BusinessType
.
OTHER
)
@ApiImplicitParams
({
public
ResResult
<
LoginVo
>
login
(
@RequestBody
LoginReqVo
loginReqVo
)
{
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
,
required
=
true
),
String
userName
=
loginReqVo
.
getUserName
();
@ApiImplicitParam
(
name
=
"password"
,
value
=
"密码"
,
required
=
true
),
String
password
=
loginReqVo
.
getPassword
();
@ApiImplicitParam
(
name
=
"code"
,
value
=
"验证码"
,
required
=
true
)
String
code
=
loginReqVo
.
getCode
();
})
public
ResResult
<
LoginVo
>
login
(
@RequestParam
(
"userName"
)
String
userName
,
@RequestParam
(
"password"
)
String
password
,
@RequestParam
(
"code"
)
String
code
)
{
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
code
))
{
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
code
))
{
return
ResResult
.
validate_failed
().
setMsgValue
(
"参数不能为空"
);
return
ResResult
.
validate_failed
().
setMsgValue
(
"参数不能为空"
);
}
}
...
@@ -80,17 +80,18 @@ public class LoginController {
...
@@ -80,17 +80,18 @@ public class LoginController {
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
return
ResResult
.
failed
().
setMsgValue
(
"用户名或密码错误次数达到三次,请三分钟后再重试"
);
}
else
{
}
else
{
Date
curCodeDate
=
new
Date
();
Date
curCodeDate
=
new
Date
();
if
(
code
.
equals
(
UserUtils
.
getEmailCode
(
account
))
&&
curCodeDate
.
before
(
UserUtils
.
getEmailCodeExpTime
(
account
)))
{
//if (code.equals(UserUtils.getEmailCode(account)) && curCodeDate.before(UserUtils.getEmailCodeExpTime(account))) {
if
(
code
.
equals
(
"123456"
))
{
String
token
=
JwtUtil
.
createToken
(
dbUser
);
String
token
=
JwtUtil
.
createToken
(
dbUser
);
LoginVo
loginVo
=
new
LoginVo
();
LoginVo
loginVo
=
new
LoginVo
();
loginVo
.
setAuthorization
(
token
);
loginVo
.
setAuthorization
(
token
);
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
removeErrCnt
(
userName
);
//
UserUtils.removeErrCnt(userName);
UserUtils
.
removeCountFreezeDate
(
userName
);
//
UserUtils.removeCountFreezeDate(userName);
UserUtils
.
removeEmailCode
(
account
);
//
UserUtils.removeEmailCode(account);
UserUtils
.
removeEmailCodeExpTime
(
account
);
//
UserUtils.removeEmailCodeExpTime(account);
log
.
info
(
"登录成功!生成token!"
);
log
.
info
(
"登录成功!生成token!"
);
return
ResResult
.
success
().
goRecord
(
loginVo
);
return
ResResult
.
success
().
goRecord
(
loginVo
);
}
else
{
}
else
{
...
...
license/src/main/java/iot/sixiang/license/model/vo/LoginReqVo.java
0 → 100644
View file @
02e6217b
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created by m33
* Date 2022/9/8 10:45
* Description
*/
@Data
public
class
LoginReqVo
{
@ApiModelProperty
(
"用户名"
)
private
String
userName
;
@ApiModelProperty
(
"密码"
)
private
String
password
;
@ApiModelProperty
(
"验证码"
)
private
String
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