Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
Project
Project
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
liqin
chnmuseum-party
Commits
4898c489
Commit
4898c489
authored
Mar 19, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
b237704a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
33 deletions
+114
-33
HttpResult.java
...a/cn/wisenergy/chnmuseum/party/common/mvc/HttpResult.java
+27
-29
Asset.java
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
+1
-1
AssetType.java
...in/java/cn/wisenergy/chnmuseum/party/model/AssetType.java
+1
-1
CopyrightOwner.java
...va/cn/wisenergy/chnmuseum/party/model/CopyrightOwner.java
+1
-1
LoginController.java
...nergy/chnmuseum/party/web/controller/LoginController.java
+84
-1
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/common/mvc/HttpResult.java
View file @
4898c489
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
mvc
;
public
class
HttpResult
{
public
class
HttpResult
<
T
>
{
// 响应的状态码
private
int
c
ode
;
private
Integer
resultC
ode
;
// 响应的响应信息
private
String
m
sg
;
private
String
m
essage
;
// 响应的响应体
private
Object
body
;
private
T
data
;
public
HttpResult
()
{
}
public
HttpResult
(
int
code
,
String
msg
)
{
this
.
code
=
c
ode
;
this
.
m
sg
=
msg
;
public
HttpResult
(
Integer
resultCode
,
String
message
)
{
this
.
resultCode
=
resultC
ode
;
this
.
m
essage
=
message
;
}
public
HttpResult
(
int
code
,
Object
body
)
{
this
.
code
=
c
ode
;
this
.
body
=
body
;
public
HttpResult
(
Integer
resultCode
,
T
data
)
{
this
.
resultCode
=
resultC
ode
;
this
.
data
=
data
;
}
public
int
getCode
()
{
return
code
;
public
HttpResult
(
Integer
resultCode
,
String
message
,
T
data
)
{
this
.
resultCode
=
resultCode
;
this
.
message
=
message
;
this
.
data
=
data
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
c
ode
;
public
Integer
getResultCode
(
)
{
return
resultC
ode
;
}
public
String
getMsg
(
)
{
return
msg
;
public
void
setResultCode
(
Integer
resultCode
)
{
this
.
resultCode
=
resultCode
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
public
String
getMessage
(
)
{
return
message
;
}
public
Object
getBody
(
)
{
return
body
;
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
void
setBody
(
Object
body
)
{
this
.
body
=
body
;
public
T
getData
(
)
{
return
data
;
}
@Override
public
String
toString
()
{
return
"{"
+
"\"code\":"
+
code
+
", \"msg\":"
+
"\""
+
msg
+
"\""
+
", \"body\":"
+
body
+
'}'
;
public
void
setData
(
T
data
)
{
this
.
data
=
data
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
View file @
4898c489
...
...
@@ -28,7 +28,7 @@ import java.time.LocalDateTime;
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"asset"
)
@ApiModel
(
value
=
"视频"
,
description
=
"视频"
)
@ApiModel
(
value
=
"视频"
,
description
=
"视频
1
"
)
public
class
Asset
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/model/AssetType.java
View file @
4898c489
...
...
@@ -28,7 +28,7 @@ import java.time.LocalDateTime;
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"asset_type"
)
@ApiModel
(
value
=
"视频分类"
,
description
=
"视频分类"
)
@ApiModel
(
value
=
"视频分类"
,
description
=
"视频分类
1
"
)
public
class
AssetType
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/model/CopyrightOwner.java
View file @
4898c489
...
...
@@ -30,7 +30,7 @@ import java.util.List;
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"copyright_owner"
)
@ApiModel
(
value
=
"版权方"
,
description
=
"版权方"
)
@ApiModel
(
value
=
"版权方"
,
description
=
"版权方
1
"
)
public
class
CopyrightOwner
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LoginController.java
View file @
4898c489
...
...
@@ -3,6 +3,7 @@ package cn.wisenergy.chnmuseum.party.web.controller;
import
cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService
;
import
cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil
;
import
cn.wisenergy.chnmuseum.party.common.checkcode.SpecCaptcha
;
import
cn.wisenergy.chnmuseum.party.common.mvc.HttpResult
;
import
cn.wisenergy.chnmuseum.party.model.Employee
;
import
cn.wisenergy.chnmuseum.party.model.Menu
;
import
cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl
;
...
...
@@ -180,8 +181,90 @@ public class LoginController {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
/**
* 管理员ajax登录请求 后端用户登录
*
* @param username
* @param password
* @return
*/
@RequestMapping
(
value
=
"login"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
login
(
@RequestParam
(
value
=
"username"
)
String
username
,
@RequestParam
(
value
=
"password"
)
String
password
,
@RequestParam
(
value
=
"boxNo"
)
String
boxNo
,
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<>();
Employee
employee
;
if
(
StringUtils
.
isNoneBlank
(
username
))
{
//访问一次,计数一次
ValueOperations
<
String
,
String
>
opsForValue
=
stringRedisTemplate
.
opsForValue
();
if
(
"LOCK"
.
equals
(
opsForValue
.
get
(
SHIRO_IS_LOCK
+
username
)))
{
resultMap
.
put
(
"status"
,
400
);
resultMap
.
put
(
"message"
,
"由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员,联系电话:13924551212,邮箱:325346534@zh.com。"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
employee
=
employeeService
.
selectByUsername
(
username
);
if
(
employee
==
null
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"message"
,
"用户名或密码不正确!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
if
(!
employee
.
getStatus
())
{
throw
new
DisabledAccountException
(
"此帐号已禁用,请联系管理员!"
);
}
if
(!
employee
.
getAllowLogin
())
{
throw
new
DisabledAccountException
(
"您无权访问,请联系管理员!"
);
}
try
{
byte
[]
salt
=
employee
.
getPasswordSalt
();
if
(!
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
)).
equals
(
new
String
(
employee
.
getPasswordHash
())))
{
opsForValue
.
increment
(
SHIRO_LOGIN_COUNT
+
username
,
1
);
//计数大于5时,设置用户被锁定一小时
String
s
=
opsForValue
.
get
(
SHIRO_LOGIN_COUNT
+
username
);
if
(
StringUtils
.
isNotBlank
(
s
))
{
if
(
Integer
.
parseInt
(
s
)
>=
5
)
{
opsForValue
.
set
(
SHIRO_IS_LOCK
+
username
,
"LOCK"
);
stringRedisTemplate
.
expire
(
SHIRO_IS_LOCK
+
username
,
12
,
TimeUnit
.
HOURS
);
}
}
throw
new
IncorrectCredentialsException
(
"用户名或密码不正确!"
);
}
//获取当前用户角色拥有菜单
List
<
Menu
>
userMenuPerms
=
this
.
menuService
.
getUserMenuPerms
(
employee
.
getRoleId
());
//登录时插入系统日志
String
operationContent
=
username
+
"登录本系统"
;
if
(
employee
.
getBankBranchName
()
!=
null
)
{
operationContent
+=
",归属网点"
+
employee
.
getBankBranchName
();
}
this
.
sysLogController
.
insertSysLog
(
operationContent
,
username
);
String
token
=
JwtTokenUtil
.
sign
(
username
,
employee
.
getId
());
// 将token信息存入Redis
stringRedisTemplate
.
opsForValue
().
set
(
SHIRO_JWT_TOKEN
+
token
,
employee
.
getId
(),
240
,
TimeUnit
.
MINUTES
);
resultMap
.
put
(
"employee"
,
employee
);
resultMap
.
put
(
"token"
,
token
);
new
HttpResult
()
resultMap
.
put
(
"resultCode"
,
200
);
resultMap
.
put
(
"message"
,
"成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"message"
,
e
.
getMessage
());
}
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
@RequestMapping
(
value
=
"logout"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
Void
>
logout
(
@RequestParam
(
required
=
true
)
String
token
)
{
public
ResponseEntity
<
Void
>
logout
(
@RequestParam
(
value
=
"token"
)
String
token
)
{
try
{
if
(
StringUtils
.
isNotBlank
(
token
))
{
SecurityUtils
.
getSubject
().
logout
();
...
...
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