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
c674d9bf
Commit
c674d9bf
authored
Jun 09, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改驼峰命名变量
parent
8e9e0707
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
17 deletions
+18
-17
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+5
-5
OperateController.java
...ava/iot/sixiang/license/controller/OperateController.java
+6
-6
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+3
-2
JwtUtil.java
license/src/main/java/iot/sixiang/license/jwt/JwtUtil.java
+1
-1
LoginUser.java
license/src/main/java/iot/sixiang/license/jwt/LoginUser.java
+3
-3
No files found.
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
c674d9bf
...
...
@@ -36,11 +36,11 @@ public class LoginController {
public
ResResult
login
(
@RequestParam
(
"userName"
)
String
userName
,
@RequestParam
(
"password"
)
String
password
)
{
// @RequestBody JSONObject jsonObject
LoginUser
user
=
new
LoginUser
();
user
.
setUser
_n
ame
(
userName
);
user
.
setUser
N
ame
(
userName
);
user
.
setPassword
(
password
);
for
(
LoginUser
dbUser
:
userMap
.
values
())
{
if
(
dbUser
.
getUser
_name
().
equals
(
user
.
getUser_n
ame
())
&&
dbUser
.
getPassword
().
equals
(
user
.
getPassword
()))
{
if
(
dbUser
.
getUser
Name
().
equals
(
user
.
getUserN
ame
())
&&
dbUser
.
getPassword
().
equals
(
user
.
getPassword
()))
{
log
.
info
(
"登录成功!生成token!"
);
String
token
=
JwtUtil
.
createToken
(
dbUser
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
@@ -56,11 +56,11 @@ public class LoginController {
public
ResResult
logout
(
@RequestParam
(
"userName"
)
String
userName
,
@RequestParam
(
"password"
)
String
password
)
{
// @RequestBody JSONObject jsonObject
LoginUser
user
=
new
LoginUser
();
user
.
setUser
_n
ame
(
userName
);
user
.
setUser
N
ame
(
userName
);
user
.
setPassword
(
password
);
for
(
LoginUser
dbUser
:
userMap
.
values
())
{
if
(
dbUser
.
getUser
_name
().
equals
(
user
.
getUser_n
ame
())
&&
dbUser
.
getPassword
().
equals
(
user
.
getPassword
()))
{
if
(
dbUser
.
getUser
Name
().
equals
(
user
.
getUserN
ame
())
&&
dbUser
.
getPassword
().
equals
(
user
.
getPassword
()))
{
log
.
info
(
"登录成功!生成token!"
);
String
token
=
JwtUtil
.
createToken
(
dbUser
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
@@ -69,6 +69,6 @@ public class LoginController {
return
ResResult
.
success
().
record
(
map
);
}
}
return
ResResult
.
fail
().
msg
(
"
user_name or password is error
"
);
return
ResResult
.
fail
().
msg
(
"
用户名或密码错误
"
);
}
}
license/src/main/java/iot/sixiang/license/controller/OperateController.java
View file @
c674d9bf
...
...
@@ -20,14 +20,14 @@ public class OperateController {
List
<
JSONObject
>
list
=
new
ArrayList
<>();
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"server
_i
p"
,
"192.168.1.11"
);
obj
.
put
(
"server
_s
am"
,
100
);
obj
.
put
(
"online
_c
ount"
,
55
);
obj
.
put
(
"server
I
p"
,
"192.168.1.11"
);
obj
.
put
(
"server
S
am"
,
100
);
obj
.
put
(
"online
C
ount"
,
55
);
list
.
add
(
obj
);
JSONObject
obj2
=
new
JSONObject
();
obj2
.
put
(
"server
_i
p"
,
"192.168.1.12"
);
obj2
.
put
(
"server
_s
am"
,
100
);
obj2
.
put
(
"online
_c
ount"
,
55
);
obj2
.
put
(
"server
I
p"
,
"192.168.1.12"
);
obj2
.
put
(
"server
S
am"
,
100
);
obj2
.
put
(
"online
C
ount"
,
55
);
list
.
add
(
obj2
);
return
ResResult
.
success
().
record
(
list
);
}
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
c674d9bf
...
...
@@ -7,6 +7,7 @@ import iot.sixiang.license.model.ResResult;
import
lombok.extern.slf4j.Slf4j
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -60,10 +61,10 @@ public class JwtFilter implements Filter {
return
;
}
String
userName
=
userData
.
get
(
"user
_n
ame"
).
asString
();
String
userName
=
userData
.
get
(
"user
N
ame"
).
asString
();
String
password
=
userData
.
get
(
"password"
).
asString
();
//拦截器 拿到用户信息,放到request中
request
.
setAttribute
(
"user
_n
ame"
,
userName
);
request
.
setAttribute
(
"user
N
ame"
,
userName
);
request
.
setAttribute
(
"password"
,
password
);
filterChain
.
doFilter
(
servletRequest
,
servletResponse
);
}
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtUtil.java
View file @
c674d9bf
...
...
@@ -35,7 +35,7 @@ public class JwtUtil {
String
token
=
JWT
.
create
()
.
withHeader
(
map
)
//添加头部
//可以把数据存在claim中
.
withClaim
(
"user
_name"
,
user
.
getUser_n
ame
())
.
withClaim
(
"user
Name"
,
user
.
getUserN
ame
())
.
withClaim
(
"password"
,
user
.
getPassword
())
.
withExpiresAt
(
expireDate
)
//超时设置,设置过期的日期
.
withIssuedAt
(
new
Date
())
//签发时间
...
...
license/src/main/java/iot/sixiang/license/jwt/LoginUser.java
View file @
c674d9bf
...
...
@@ -4,14 +4,14 @@ import lombok.Data;
@Data
public
class
LoginUser
{
private
String
user
_n
ame
;
private
String
user
N
ame
;
private
String
password
;
public
LoginUser
()
{
}
public
LoginUser
(
String
user
_n
ame
,
String
password
)
{
this
.
user
_name
=
user_n
ame
;
public
LoginUser
(
String
user
N
ame
,
String
password
)
{
this
.
user
Name
=
userN
ame
;
this
.
password
=
password
;
}
}
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