Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
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
a5ddfc3e
Commit
a5ddfc3e
authored
Apr 13, 2021
by
wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
c1560baa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
39 deletions
+101
-39
TUser.java
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
+2
-2
ChinaMobileRestApiController.java
...um/party/web/controller/ChinaMobileRestApiController.java
+15
-15
LoginController.java
...nergy/chnmuseum/party/web/controller/LoginController.java
+20
-20
TBoxOperationController.java
...nmuseum/party/web/controller/TBoxOperationController.java
+5
-0
TUserController.java
...nergy/chnmuseum/party/web/controller/TUserController.java
+58
-1
RoleMapper.xml
src/main/resources/mapper/RoleMapper.xml
+1
-1
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
View file @
a5ddfc3e
...
...
@@ -83,11 +83,11 @@ public class TUser implements Serializable {
private
Boolean
permanent
;
@ApiModelProperty
(
"生效日期"
)
@TableField
(
"effective_date"
)
@TableField
(
value
=
"effective_date"
,
updateStrategy
=
FieldStrategy
.
IGNORED
)
private
LocalDate
effectiveDate
;
@ApiModelProperty
(
"失效日期"
)
@TableField
(
"exired_date"
)
@TableField
(
value
=
"exired_date"
,
updateStrategy
=
FieldStrategy
.
IGNORED
)
private
LocalDate
exiredDate
;
@ApiModelProperty
(
value
=
"状态"
,
allowableValues
=
"启用 ENABLE, 禁用DISABLE"
)
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/ChinaMobileRestApiController.java
View file @
a5ddfc3e
...
...
@@ -171,12 +171,12 @@ public class ChinaMobileRestApiController extends BaseController {
try
{
//访问一次,计数一次
ValueOperations
<
String
,
String
>
opsForValue
=
stringRedisTemplate
.
opsForValue
();
if
(
"LOCK"
.
equals
(
opsForValue
.
get
(
SHIRO_IS_LOCK
+
username
)))
{
resultMap
.
put
(
"resultCode"
,
"400"
);
resultMap
.
put
(
"message"
,
"由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员,联系电话:13924551212,邮箱:325346534@zh.com。"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
//
ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue();
//
if ("LOCK".equals(opsForValue.get(SHIRO_IS_LOCK + username))) {
//
resultMap.put("resultCode", "400");
//
resultMap.put("message", "由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员,联系电话:13924551212,邮箱:325346534@zh.com。");
//
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
//
}
user
=
userService
.
selectByUsername
(
username
);
if
(
user
==
null
)
{
resultMap
.
put
(
"resultCode"
,
"500"
);
...
...
@@ -206,15 +206,15 @@ public class ChinaMobileRestApiController extends BaseController {
byte
[]
salt
=
user
.
getPasswordSalt
();
if
(!
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
)).
equals
(
new
String
(
user
.
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
);
}
}
//
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
(
"用户名或密码不正确!"
);
}
String
token
=
JwtTokenUtil
.
sign
(
username
,
user
.
getId
());
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LoginController.java
View file @
a5ddfc3e
...
...
@@ -125,12 +125,12 @@ public class LoginController extends BaseController {
try
{
//访问一次,计数一次
ValueOperations
<
String
,
String
>
opsForValue
=
stringRedisTemplate
.
opsForValue
();
if
(
"LOCK"
.
equals
(
opsForValue
.
get
(
SHIRO_IS_LOCK
+
username
)))
{
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员。"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
//
ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue();
//
if ("LOCK".equals(opsForValue.get(SHIRO_IS_LOCK + username))) {
//
resultMap.put("resultCode", "500");
//
resultMap.put("message", "由于密码输入错误次数大于5次,12小时内帐号已禁止登录!请您联系相关管理人员。");
//
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
//
}
user
=
userService
.
selectByUsername
(
username
);
if
(
user
==
null
)
{
...
...
@@ -156,20 +156,21 @@ public class LoginController extends BaseController {
byte
[]
salt
=
user
.
getPasswordSalt
();
String
s1
=
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
));
if
(!
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
)).
equals
(
new
String
(
user
.
getPasswordHash
())))
{
opsForValue
.
increment
(
SHIRO_LOGIN_COUNT
+
username
,
1
);
//计数大于5时,设置用户被锁定12小时
//测试设置5000次
int
i
=
5000
;
String
s
=
opsForValue
.
get
(
SHIRO_LOGIN_COUNT
+
username
);
if
(
StringUtils
.
isNotBlank
(
s
))
{
if
(
Integer
.
parseInt
(
s
)
>=
i
)
{
opsForValue
.
set
(
SHIRO_IS_LOCK
+
username
,
"LOCK"
);
stringRedisTemplate
.
expire
(
SHIRO_IS_LOCK
+
username
,
12
,
TimeUnit
.
HOURS
);
}
}
//
opsForValue.increment(SHIRO_LOGIN_COUNT + username, 1);
//
//计数大于5时,设置用户被锁定12小时
//
//
//测试设置5000次
//
int i = 5000;
//
String s = opsForValue.get(SHIRO_LOGIN_COUNT + username);
//
if (StringUtils.isNotBlank(s)) {
//
if (Integer.parseInt(s) >= i) {
//
opsForValue.set(SHIRO_IS_LOCK + username, "LOCK");
//
stringRedisTemplate.expire(SHIRO_IS_LOCK + username, 12, TimeUnit.HOURS);
//
}
//
}
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"密码不正确,您还有"
+
(
i
-
Integer
.
parseInt
(
s
))
+
"次机会!"
);
resultMap
.
put
(
"message"
,
"密码不正确!"
);
// resultMap.put("message", "密码不正确,您还有" + (i - Integer.parseInt(s)) + "次机会!");
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
List
<
Role
>
roles
=
roleService
.
selectRoleByUserId
(
user
.
getId
());
...
...
@@ -192,7 +193,6 @@ public class LoginController extends BaseController {
String
token
=
JwtTokenUtil
.
sign
(
username
,
user
.
getId
());
// 将token信息存入Redis
stringRedisTemplate
.
opsForValue
().
set
(
SHIRO_JWT_TOKEN
+
token
,
user
.
getId
(),
12
,
TimeUnit
.
HOURS
);
resultMap
.
put
(
"user"
,
user
);
resultMap
.
put
(
"token"
,
token
);
resultMap
.
put
(
"menuList"
,
userMenuPerms
);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TBoxOperationController.java
View file @
a5ddfc3e
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil
;
import
cn.wisenergy.chnmuseum.party.common.log.MethodLog
;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
...
...
@@ -19,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresAuthentication
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
...
...
@@ -47,6 +49,9 @@ public class TBoxOperationController extends BaseController {
@Resource
private
TUserServiceImpl
userService
;
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TUserController.java
View file @
a5ddfc3e
...
...
@@ -19,6 +19,7 @@ import cn.wisenergy.chnmuseum.party.service.impl.AuditServiceImpl;
import
cn.wisenergy.chnmuseum.party.service.impl.TBoxOperationServiceImpl
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -337,7 +338,6 @@ public class TUserController extends BaseController {
return
resultMap
;
}
}
// user.setUserName(StringUtils.trimToNull(user.getUserName()));
// user.setPassword(StringUtils.trimToNull(user.getPassword()));
// user.setRealName(StringUtils.trimToNull(user.getRealName()));
...
...
@@ -831,5 +831,62 @@ public class TUserController extends BaseController {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
@OperationLog
(
"修改成员信息"
)
@ApiOperation
(
value
=
"编辑用户信息"
)
@PutMapping
(
value
=
"/boxUpdate"
)
@RequiresAuthentication
//@RequiresPermissions("/user/boxUpdate")
@MethodLog
(
operModule
=
OperModule
.
STBBASE
,
operType
=
OperType
.
UPDATE
)
public
Map
<
String
,
Object
>
boxUpdate
(
@RequestBody
TUser
user
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
try
{
boolean
ret
=
false
;
if
(
StringUtils
.
isNotBlank
(
user
.
getOrgName
()))
{
QueryWrapper
<
TUser
>
ew
=
new
QueryWrapper
<>();
ew
.
eq
(
"is_deleted"
,
false
);
ew
.
eq
(
"type"
,
"3"
);
ew
.
eq
(
"user_name"
,
user
.
getOrgName
());
TUser
one
=
userService
.
getOne
(
ew
);
one
.
setPermanent
(
false
);
one
.
setEffectiveDate
(
null
);
one
.
setExiredDate
(
null
);
if
(
user
.
getPermanent
()!=
null
){
one
.
setPermanent
(
user
.
getPermanent
());
}
if
(
user
.
getEffectiveDate
()!=
null
){
one
.
setEffectiveDate
(
user
.
getEffectiveDate
());
}
if
(
user
.
getExiredDate
()!=
null
){
one
.
setExiredDate
(
user
.
getExiredDate
());
}
user
=
one
;
ret
=
userService
.
updateById
(
user
);
}
else
{
// 更新失败, 400
resultMap
.
put
(
"resultCode"
,
"400"
);
resultMap
.
put
(
"message"
,
"请选择用户"
);
return
resultMap
;
}
if
(!
ret
)
{
// 更新失败, 500
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
return
resultMap
;
}
// 204
resultMap
.
put
(
"resultCode"
,
"200"
);
resultMap
.
put
(
"message"
,
"更新成功"
);
return
resultMap
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"更新错误!"
,
e
);
}
// 500
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
return
resultMap
;
}
}
src/main/resources/mapper/RoleMapper.xml
View file @
a5ddfc3e
...
...
@@ -21,7 +21,7 @@
r.*
from t_user u
left join t_user_role_link ur on ur.user_id = u.id
left
join t_role r on ur.role_id = r.id
inner
join t_role r on ur.role_id = r.id
where u.id = #{id}
</select>
...
...
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