Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
shr-server
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
inroi
shr-server
Commits
6a1a6460
提交
6a1a6460
authored
4月 21, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
5a027702
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
16 行增加
和
52 行删除
+16
-52
LogAop.java
src/main/java/com/shr/aop/LogAop.java
+1
-1
HttpContext.java
src/main/java/com/shr/common/HttpContext.java
+1
-2
SpringContextHolder.java
src/main/java/com/shr/common/SpringContextHolder.java
+1
-4
RestResponse.java
src/main/java/com/shr/common/response/RestResponse.java
+2
-0
ShrException.java
src/main/java/com/shr/exception/ShrException.java
+1
-0
BlogExceptionHandler.java
src/main/java/com/shr/handler/BlogExceptionHandler.java
+1
-2
LogManager.java
src/main/java/com/shr/log/LogManager.java
+1
-3
LogFactory.java
src/main/java/com/shr/log/factory/LogFactory.java
+2
-0
LogTaskFactory.java
src/main/java/com/shr/log/factory/LogTaskFactory.java
+4
-0
JsonUtil.java
src/main/java/com/shr/utils/JsonUtil.java
+1
-5
StringUtil.java
src/main/java/com/shr/utils/StringUtil.java
+1
-35
没有找到文件。
src/main/java/com/shr/aop/LogAop.java
浏览文件 @
6a1a6460
...
...
@@ -32,6 +32,7 @@ public class LogAop {
private
Logger
log
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Pointcut
(
value
=
"@annotation(com.shr.annotion.AccessLog)"
)
public
void
cutService
()
{
}
...
...
@@ -67,7 +68,6 @@ public class LogAop {
LogManager
.
me
().
executeLog
(
LogTaskFactory
.
log
(
content
,
systemType
,
new
Gson
().
toJson
(
result
)));
}
private
String
getSystemType
(
ProceedingJoinPoint
point
)
{
Object
[]
args
=
point
.
getArgs
();
Object
[]
arguments
=
new
Object
[
args
.
length
];
...
...
src/main/java/com/shr/common/HttpContext.java
浏览文件 @
6a1a6460
...
...
@@ -15,7 +15,6 @@ public class HttpContext {
/**
* 获取当前请求的Request对象
*
*/
public
static
HttpServletRequest
getRequest
()
{
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
...
...
@@ -28,7 +27,6 @@ public class HttpContext {
/**
* 获取当前请求的Response对象
*
*/
public
static
HttpServletResponse
getResponse
()
{
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
...
...
@@ -39,4 +37,5 @@ public class HttpContext {
}
}
}
src/main/java/com/shr/common/SpringContextHolder.java
浏览文件 @
6a1a6460
...
...
@@ -10,6 +10,7 @@ import org.springframework.context.ApplicationContextAware;
* @author Inori
*/
public
class
SpringContextHolder
implements
ApplicationContextAware
{
private
static
ApplicationContext
applicationContext
;
...
...
@@ -18,26 +19,22 @@ public class SpringContextHolder implements ApplicationContextAware {
SpringContextHolder
.
applicationContext
=
applicationContext
;
}
public
static
ApplicationContext
getApplicationContext
()
{
assertApplicationContext
();
return
applicationContext
;
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
getBean
(
String
beanName
)
{
assertApplicationContext
();
return
(
T
)
applicationContext
.
getBean
(
beanName
);
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
requiredType
)
{
assertApplicationContext
();
return
applicationContext
.
getBean
(
requiredType
);
}
private
static
void
assertApplicationContext
()
{
if
(
SpringContextHolder
.
applicationContext
==
null
)
{
throw
new
RuntimeException
(
"applicationContext属性为null,请检查是否注入了SpringContextHolder!"
);
...
...
src/main/java/com/shr/common/response/RestResponse.java
浏览文件 @
6a1a6460
...
...
@@ -80,4 +80,6 @@ public class RestResponse {
public
void
setData
(
Object
data
)
{
this
.
data
=
data
;
}
}
src/main/java/com/shr/exception/ShrException.java
浏览文件 @
6a1a6460
...
...
@@ -13,6 +13,7 @@ public class ShrException extends RuntimeException {
*/
private
Integer
code
;
public
ShrException
(
String
message
)
{
super
(
message
);
}
...
...
src/main/java/com/shr/handler/BlogExceptionHandler.java
浏览文件 @
6a1a6460
...
...
@@ -31,6 +31,7 @@ public class BlogExceptionHandler {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BlogExceptionHandler
.
class
);
/**
* 参数校验异常
*/
...
...
@@ -50,7 +51,6 @@ public class BlogExceptionHandler {
return
RestResponse
.
fail
(
errorMsg
);
}
/**
* 运行时异常
*/
...
...
@@ -63,7 +63,6 @@ public class BlogExceptionHandler {
return
new
ErrorResponseData
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
(),
e
.
getMessage
(),
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
(),
request
.
getRequestURI
());
}
/**
* SHR返回异常
*/
...
...
src/main/java/com/shr/log/LogManager.java
浏览文件 @
6a1a6460
...
...
@@ -12,6 +12,7 @@ import java.util.concurrent.TimeUnit;
* @author Inori
*/
public
class
LogManager
{
/**
* 日志记录操作延时
*/
...
...
@@ -19,7 +20,6 @@ public class LogManager {
public
static
LogManager
logManager
=
new
LogManager
();
/**
* 异步操作记录日志的线程池
*/
...
...
@@ -29,12 +29,10 @@ public class LogManager {
private
LogManager
()
{
}
public
static
LogManager
me
()
{
return
logManager
;
}
public
void
executeLog
(
TimerTask
task
)
{
executor
.
schedule
(
task
,
OPERATE_DELAY_TIME
,
TimeUnit
.
MILLISECONDS
);
}
...
...
src/main/java/com/shr/log/factory/LogFactory.java
浏览文件 @
6a1a6460
...
...
@@ -24,4 +24,6 @@ public class LogFactory {
log
.
setCreateTime
(
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
return
log
;
}
}
src/main/java/com/shr/log/factory/LogTaskFactory.java
浏览文件 @
6a1a6460
...
...
@@ -15,9 +15,12 @@ import java.util.TimerTask;
* @author Inori
*/
public
class
LogTaskFactory
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
LogTaskFactory
.
class
);
private
static
LogMapper
logMapper
=
SpringContextHolder
.
getBean
(
LogMapper
.
class
);
public
static
TimerTask
log
(
final
String
content
,
final
String
systemType
,
final
String
result
)
{
return
new
TimerTask
()
{
@Override
...
...
@@ -32,4 +35,5 @@ public class LogTaskFactory {
};
}
}
src/main/java/com/shr/utils/JsonUtil.java
浏览文件 @
6a1a6460
...
...
@@ -18,6 +18,7 @@ import java.util.Map;
*/
@Slf4j
public
class
JsonUtil
{
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
...
...
@@ -36,7 +37,6 @@ public class JsonUtil {
}
}
public
static
<
T
>
T
toBean
(
String
json
,
Class
<
T
>
tClass
)
{
try
{
return
MAPPER
.
readValue
(
json
,
tClass
);
...
...
@@ -52,7 +52,6 @@ public class JsonUtil {
}
}
public
static
<
T
>
String
listToJson
(
List
<
T
>
list
)
{
if
(
null
!=
list
&&
list
.
size
()
>
0
)
{
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
list
);
...
...
@@ -61,7 +60,6 @@ public class JsonUtil {
return
""
;
}
public
static
<
E
>
List
<
E
>
toList
(
String
json
,
Class
<
E
>
eClass
)
{
try
{
return
MAPPER
.
readValue
(
json
,
MAPPER
.
getTypeFactory
().
constructCollectionType
(
List
.
class
,
eClass
));
...
...
@@ -71,7 +69,6 @@ public class JsonUtil {
}
}
public
static
<
K
,
V
>
Map
<
K
,
V
>
toMap
(
String
json
,
Class
<
K
>
kClass
,
Class
<
V
>
vClass
)
{
try
{
return
MAPPER
.
readValue
(
json
,
MAPPER
.
getTypeFactory
().
constructMapType
(
Map
.
class
,
kClass
,
vClass
));
...
...
@@ -81,7 +78,6 @@ public class JsonUtil {
}
}
public
static
<
T
>
T
nativeRead
(
String
json
,
TypeReference
<
T
>
type
)
{
try
{
return
MAPPER
.
readValue
(
json
,
type
);
...
...
src/main/java/com/shr/utils/StringUtil.java
浏览文件 @
6a1a6460
...
...
@@ -3,8 +3,6 @@ package com.shr.utils;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* 字符串工具类
...
...
@@ -12,6 +10,7 @@ import java.util.regex.Pattern;
* @author ruoyi
*/
public
class
StringUtil
extends
org
.
apache
.
commons
.
lang3
.
StringUtils
{
/**
* 空字符串
*/
...
...
@@ -22,11 +21,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
*/
private
static
final
char
SEPARATOR
=
'_'
;
/**
* 正则验证字符串是否是数字
*/
private
static
final
Pattern
NUM_PATTERN
=
Pattern
.
compile
(
"^[0-9]*$"
);
/**
* 获取参数不为空值
...
...
@@ -38,7 +32,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
value
!=
null
?
value
:
defaultValue
;
}
/**
* * 判断一个Collection是否为空, 包含List,Set,Queue
*
...
...
@@ -49,7 +42,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
isNull
(
coll
)
||
coll
.
isEmpty
();
}
/**
* * 判断一个Collection是否非空,包含List,Set,Queue
*
...
...
@@ -60,7 +52,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
!
isEmpty
(
coll
);
}
/**
* * 判断一个对象数组是否为空
*
...
...
@@ -71,7 +62,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
isNull
(
objects
)
||
(
objects
.
length
==
0
);
}
/**
* * 判断一个对象数组是否非空
*
...
...
@@ -82,7 +72,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
!
isEmpty
(
objects
);
}
/**
* * 判断一个Map是否为空
*
...
...
@@ -93,7 +82,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
isNull
(
map
)
||
map
.
isEmpty
();
}
/**
* * 判断一个Map是否为空
*
...
...
@@ -104,7 +92,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
!
isEmpty
(
map
);
}
/**
* * 判断一个字符串是否为空串
*
...
...
@@ -115,7 +102,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
isNull
(
str
)
||
NULL_STRING
.
equals
(
str
.
trim
());
}
/**
* * 判断一个字符串是否为非空串
*
...
...
@@ -126,7 +112,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
!
isEmpty
(
str
);
}
/**
* * 判断一个对象是否为空
*
...
...
@@ -137,7 +122,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
object
==
null
;
}
/**
* * 判断一个对象是否非空
*
...
...
@@ -148,7 +132,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
!
isNull
(
object
);
}
/**
* * 判断一个对象是否是数组类型(Java基本型别的数组)
*
...
...
@@ -159,7 +142,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
isNotNull
(
object
)
&&
object
.
getClass
().
isArray
();
}
/**
* 去空格
*/
...
...
@@ -167,7 +149,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
(
str
==
null
?
""
:
str
.
trim
());
}
/**
* 截取字符串
*
...
...
@@ -194,7 +175,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
str
.
substring
(
start
);
}
/**
* 截取字符串
*
...
...
@@ -233,7 +213,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
str
.
substring
(
start
,
end
);
}
/**
* 下划线转驼峰命名
*/
...
...
@@ -273,7 +252,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
sb
.
toString
();
}
/**
* 是否包含字符串
*
...
...
@@ -292,7 +270,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
false
;
}
/**
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
*
...
...
@@ -323,7 +300,6 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
return
result
.
toString
();
}
/**
* 驼峰式命名法 例如:user_name->userName
*/
...
...
@@ -350,13 +326,4 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
}
/**
* 判断字符串是否是数字
*/
public
static
boolean
isStr2Num
(
String
str
)
{
Matcher
matcher
=
NUM_PATTERN
.
matcher
(
str
);
return
matcher
.
matches
();
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论