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
c7941f86
Commit
c7941f86
authored
Apr 07, 2021
by
wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
0ad7338e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
121 deletions
+126
-121
WebLogAspect.java
...a/cn/wisenergy/chnmuseum/party/core/aop/WebLogAspect.java
+106
-106
TUser.java
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
+1
-1
TOrganServiceImpl.java
...nergy/chnmuseum/party/service/impl/TOrganServiceImpl.java
+1
-1
LoginController.java
...nergy/chnmuseum/party/web/controller/LoginController.java
+9
-4
TBoardStatisticController.java
...useum/party/web/controller/TBoardStatisticController.java
+8
-8
TOrganController.java
...ergy/chnmuseum/party/web/controller/TOrganController.java
+1
-1
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/core/aop/WebLogAspect.java
View file @
c7941f86
package
cn
.
wisenergy
.
chnmuseum
.
party
.
core
.
aop
;
import
cn.wisenergy.chnmuseum.party.common.util.NetWorkUtil
;
import
cn.wisenergy.chnmuseum.party.core.annotations.OperationLog
;
import
cn.wisenergy.chnmuseum.party.web.controller.SysLogController
;
import
org.apache.shiro.SecurityUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.*
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
@Aspect
@Component
public
class
WebLogAspect
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
WebLogAspect
.
class
);
@Autowired
private
SysLogController
sysLogController
;
@Pointcut
(
"execution (public * cn.wisenergy.chnmuseum.party.web.controller.*.*(..))"
)
public
void
methodCutPoint
()
{
}
@Before
(
"methodCutPoint()"
)
public
void
doBefore
()
{
// 接收到请求,记录请求内容
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
LOGGER
.
info
(
"URL : "
+
request
.
getRequestURL
().
toString
());
LOGGER
.
info
(
"HTTP_METHOD : "
+
request
.
getMethod
());
LOGGER
.
info
(
"IP : "
+
NetWorkUtil
.
getLoggableAddress
(
request
));
}
// @After("methodCutPoint()")
public
void
doAfter
()
{
System
.
out
.
println
(
"后面"
);
}
@AfterReturning
(
pointcut
=
"methodCutPoint()"
,
returning
=
"result"
)
public
void
doAfterReturning
(
JoinPoint
joinPoint
,
Object
result
)
{
if
(
result
!=
null
){
// 处理完请求,返回内容
LOGGER
.
info
(
"RESPONSE : "
+
result
.
toString
());
// 这里记录日志 , 这里处理的内容会切入controller中
}
}
@Transactional
@Around
(
"methodCutPoint()"
)
public
Object
doAroud
(
ProceedingJoinPoint
proceedingJoinPoint
)
throws
Throwable
{
MethodSignature
signature
=
(
MethodSignature
)
proceedingJoinPoint
.
getSignature
();
// 获取被拦截的方法
Method
method
=
signature
.
getMethod
();
if
(
isRecordLog
(
method
)
&&
isLogin
()){
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
//日志内容
String
content
=
""
;
//获取注解的值
OperationLog
annotation
=
method
.
getAnnotation
(
OperationLog
.
class
);
if
(
annotation
!=
null
){
content
=
annotation
.
value
();
}
//插入到系统日志表
this
.
sysLogController
.
insertSysLog
(
content
,
null
);
}
return
proceedingJoinPoint
.
proceed
();
}
/**
* 判断这个方法是否需要记录日志
* @param method
* @return
*/
private
boolean
isRecordLog
(
Method
method
)
{
boolean
result
=
false
;
if
(
method
.
isAnnotationPresent
(
OperationLog
.
class
))
{
result
=
true
;
}
return
result
;
}
/**
* 判断是否已经登录
* @return
*/
private
boolean
isLogin
()
{
return
SecurityUtils
.
getSubject
().
getPrincipal
()
!=
null
;
}
}
\ No newline at end of file
//package cn.wisenergy.chnmuseum.party.core.aop;
//
//import cn.wisenergy.chnmuseum.party.common.util.NetWorkUtil;
//import cn.wisenergy.chnmuseum.party.core.annotations.OperationLog;
//import cn.wisenergy.chnmuseum.party.web.controller.SysLogController;
//import org.apache.shiro.SecurityUtils;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//import java.lang.reflect.Method;
//
//@Aspect
//@Component
//public class WebLogAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(WebLogAspect.class);
//
// @Autowired
// private SysLogController sysLogController;
//
// @Pointcut("execution (public * cn.wisenergy.chnmuseum.party.web.controller.*.*(..))")
// public void methodCutPoint() {
// }
//
// @Before("methodCutPoint()")
// public void doBefore() {
// // 接收到请求,记录请求内容
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
//
// LOGGER.info("URL : " + request.getRequestURL().toString());
// LOGGER.info("HTTP_METHOD : " + request.getMethod());
// LOGGER.info("IP : " + NetWorkUtil.getLoggableAddress(request));
// }
//
// // @After("methodCutPoint()")
// public void doAfter() {
// System.out.println("后面");
// }
//
// @AfterReturning(pointcut = "methodCutPoint()", returning = "result")
// public void doAfterReturning(JoinPoint joinPoint, Object result) {
// if(result != null){
// // 处理完请求,返回内容
// LOGGER.info("RESPONSE : " + result.toString());
// // 这里记录日志 , 这里处理的内容会切入controller中
// }
//
// }
//
// @Transactional
// @Around("methodCutPoint()")
// public Object doAroud(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
//
// MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature();
// // 获取被拦截的方法
// Method method = signature.getMethod();
// if(isRecordLog(method) && isLogin()){
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
// //日志内容
// String content = "";
// //获取注解的值
// OperationLog annotation = method.getAnnotation(OperationLog.class);
// if(annotation != null){
// content = annotation.value();
// }
// //插入到系统日志表
// this.sysLogController.insertSysLog(content,null);
// }
//
// return proceedingJoinPoint.proceed();
// }
//
// /**
// * 判断这个方法是否需要记录日志
// * @param method
// * @return
// */
// private boolean isRecordLog(Method method) {
// boolean result = false;
// if (method.isAnnotationPresent(OperationLog.class)) {
// result = true;
// }
// return result;
// }
//
// /**
// * 判断是否已经登录
// * @return
// */
// private boolean isLogin() {
// return SecurityUtils.getSubject().getPrincipal() != null;
// }
//
//}
\ No newline at end of file
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
View file @
c7941f86
...
...
@@ -117,7 +117,7 @@ public class TUser implements Serializable {
@TableField
(
"real_name"
)
private
String
realName
;
@ApiModelProperty
(
"类型 1.平台账号 2.用户账号 3.机顶盒账号 4.运维账号"
)
@ApiModelProperty
(
"类型 1.平台账号 2.用户账号 3.机顶盒账号 4.运维账号
5.统计账号
"
)
@TableField
(
"type"
)
private
String
type
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TOrganServiceImpl.java
View file @
c7941f86
...
...
@@ -102,7 +102,7 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
public
TOrgan
selectById
(
String
id
)
{
TOrgan
organ
=
organMapper
.
getById
(
id
);
String
s
=
areaMapper
.
selectParent
(
organ
.
getAreaId
());
List
<
TOrgan
>
list1
=
list
(
new
UpdateWrapper
<
TOrgan
>().
eq
(
"parent_id"
,
organ
.
get
Parent
Id
()));
List
<
TOrgan
>
list1
=
list
(
new
UpdateWrapper
<
TOrgan
>().
eq
(
"parent_id"
,
organ
.
getId
()));
organ
.
setAreas
(
Arrays
.
asList
(
s
.
split
(
","
)));
organ
.
setChildren
(
list1
);
return
organ
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LoginController.java
View file @
c7941f86
...
...
@@ -138,7 +138,7 @@ public class LoginController extends BaseController {
user
=
userService
.
selectByUsername
(
username
);
if
(
user
==
null
)
{
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"用户名
或密码
不正确!"
);
resultMap
.
put
(
"message"
,
"用户名不正确!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
...
...
@@ -160,15 +160,20 @@ public class LoginController extends BaseController {
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时,设置用户被锁定一小时
//计数大于5时,设置用户被锁定12小时
//测试设置5000次
int
i
=
5000
;
String
s
=
opsForValue
.
get
(
SHIRO_LOGIN_COUNT
+
username
);
if
(
StringUtils
.
isNotBlank
(
s
))
{
if
(
Integer
.
parseInt
(
s
)
>=
5
)
{
if
(
Integer
.
parseInt
(
s
)
>=
i
)
{
opsForValue
.
set
(
SHIRO_IS_LOCK
+
username
,
"LOCK"
);
stringRedisTemplate
.
expire
(
SHIRO_IS_LOCK
+
username
,
12
,
TimeUnit
.
HOURS
);
}
}
throw
new
IncorrectCredentialsException
(
"用户名或密码不正确!"
);
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"密码不正确,您还有"
+(
i
-
Integer
.
valueOf
(
s
))+
"次机会!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
List
<
Role
>
roles
=
roleService
.
selectRoleByUserId
(
user
.
getId
());
List
<
String
>
list1
=
new
ArrayList
<>();
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TBoardStatisticController.java
View file @
c7941f86
...
...
@@ -57,7 +57,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getBoardSurvey"
)
@RequiresPermissions
(
"t:board:statistic:survey"
)
@ApiOperation
(
value
=
"获取展板统计概况"
,
notes
=
"获取展板统计概况"
)
@MethodLog
(
operModule
=
OperModule
.
OVERVIEW
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.OVERVIEW, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getBoardSurvey
(
TBoardSurvey
survey
)
{
TBoardSurvey
result
=
this
.
tBoardStatisticService
.
getBoardSurvey
(
survey
);
...
...
@@ -72,7 +72,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getBoardRankPageList"
)
@RequiresPermissions
(
"t:board:statistic:rankPage"
)
@ApiOperation
(
value
=
"获取展板播放排行"
,
notes
=
"获取展板播放排行"
)
@MethodLog
(
operModule
=
OperModule
.
OVERVIEW
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.OVERVIEW, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getBoardRankPageList
(
TBoardPlayRank
rank
)
{
Page
<
TBoardPlayRank
>
page
=
this
.
tBoardStatisticService
.
getBoardRankPageList
(
getPage
(),
rank
);
...
...
@@ -89,7 +89,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getBoardTrendPageList"
)
@RequiresPermissions
(
"t:board:statistic:trendPage"
)
@ApiOperation
(
value
=
"获取展板播放趋势"
,
notes
=
"获取展板播放趋势"
)
@MethodLog
(
operModule
=
OperModule
.
OVERVIEW
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.OVERVIEW, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getBoardTrendPageList
(
TBoardPlayTrend
trend
)
{
// 如果查询日志为空,则默认当月
if
(
StringUtils
.
isEmpty
(
trend
.
getPlayDate
())){
...
...
@@ -119,7 +119,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getBoardDistrictPageList"
)
@RequiresPermissions
(
"t:board:statistic:districtPage"
)
@ApiOperation
(
value
=
"获取地区展板播统计"
,
notes
=
"获取地区展板播统计"
)
@MethodLog
(
operModule
=
OperModule
.
OVERVIEW
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.OVERVIEW, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getBoardDistrictPageList
(
TDistrictBoardStatistic
district
)
{
Page
<
TDistrictBoardStatistic
>
page
=
this
.
tBoardStatisticService
.
getBoardDistrictPageList
(
getPage
(),
district
);
...
...
@@ -137,7 +137,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getBoardProvincePlayTotalList"
)
@RequiresPermissions
(
"t:board:statistic:provPlayList"
)
@ApiOperation
(
value
=
"获取省级展板播放统计"
,
notes
=
"获取省级展板播放统计"
)
@MethodLog
(
operModule
=
OperModule
.
OVERVIEW
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.OVERVIEW, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getBoardProvincePlayTotalList
(
String
organId
)
{
List
list
=
this
.
tBoardStatisticService
.
getBoardProvincePlayTotalList
(
organId
);
...
...
@@ -152,7 +152,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getInteractionFrequencyPageList"
)
@RequiresPermissions
(
"t:board:statistic:districtPage"
)
@ApiOperation
(
value
=
"获取互动频次统计信息"
,
notes
=
"获取互动频次统计信息"
)
@MethodLog
(
operModule
=
OperModule
.
OVERVIEW
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.OVERVIEW, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getInteractionFrequencyPageList
(
String
frequencyDate
)
{
if
(
StringUtils
.
isEmpty
(
frequencyDate
)){
frequencyDate
=
DateUtil
.
getCurrentDate
(
"yyyyMM"
);
...
...
@@ -187,7 +187,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getBoardPageList"
)
@RequiresPermissions
(
"t:board:statistic:Page"
)
@ApiOperation
(
value
=
"获取展板播放趋势"
,
notes
=
"获取展板播放趋势"
)
@MethodLog
(
operModule
=
OperModule
.
TEND
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.TEND, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getBoardPageList
(
TBoardPlayTrend
trend
)
{
// 如果查询日志为空,则默认当月
if
(
StringUtils
.
isEmpty
(
trend
.
getPlayDate
())){
...
...
@@ -218,7 +218,7 @@ public class TBoardStatisticController extends BaseController {
@PostMapping
(
"/getInteractionPageList"
)
@RequiresPermissions
(
"t:interaction:statistic:districtPage"
)
@ApiOperation
(
value
=
"获取互动频次统计信息"
,
notes
=
"获取互动频次统计信息"
)
@MethodLog
(
operModule
=
OperModule
.
INTERACTION
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.INTERACTION, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getInteractionPageList
(
String
frequencyDate
)
{
if
(
StringUtils
.
isEmpty
(
frequencyDate
)){
frequencyDate
=
DateUtil
.
getCurrentDate
(
"yyyyMM"
);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TOrganController.java
View file @
c7941f86
...
...
@@ -78,7 +78,7 @@ public class TOrganController extends BaseController {
ew
.
eq
(
"is_deleted"
,
0
);
ew
.
eq
(
"name"
,
organ
.
getName
());
List
<
TOrgan
>
list
=
this
.
tOrganService
.
list
(
ew
);
if
(
list
!=
null
&&
list
.
get
(
0
)!=
null
)
{
if
(
list
!=
null
&&
list
.
size
()>
0
&&
list
.
get
(
0
)!=
null
)
{
HashMap
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"resultCode"
,
"500"
);
resultMap
.
put
(
"message"
,
"机构名称不能重复!"
);
...
...
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