Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
d87bf527
Commit
d87bf527
authored
May 13, 2020
by
tangzhaoqian
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
操作日志功能
parent
4438e7e1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1783 additions
and
35 deletions
+1783
-35
src/main/java/cn/timer/api/aspect/LogAspect.java
+235
-0
src/main/java/cn/timer/api/aspect/lang/annotation/Log.java
+42
-0
src/main/java/cn/timer/api/aspect/lang/enums/BusinessStatus.java
+20
-0
src/main/java/cn/timer/api/aspect/lang/enums/BusinessType.java
+59
-0
src/main/java/cn/timer/api/aspect/lang/enums/OperatorType.java
+24
-0
src/main/java/cn/timer/api/bean/qyzx/QyzxOperLog.java
+96
-0
src/main/java/cn/timer/api/config/enums/HttpMethod.java
+36
-0
src/main/java/cn/timer/api/config/thread/ThreadPoolConfig.java
+63
-0
src/main/java/cn/timer/api/controller/LoginController.java
+18
-30
src/main/java/cn/timer/api/controller/qyzx/QyzxController.java
+27
-3
src/main/java/cn/timer/api/controller/qyzx/service/QyzxOperLogService.java
+52
-0
src/main/java/cn/timer/api/controller/qyzx/service/QyzxOperLogServiceImpl.java
+80
-0
src/main/java/cn/timer/api/controller/spmk/SpmkController.java
+11
-2
src/main/java/cn/timer/api/dao/qyzx/QyzxOperLogMapper.java
+52
-0
src/main/java/cn/timer/api/dto/qyzx/QyzxOperLogQuaryDto.java
+38
-0
src/main/java/cn/timer/api/manager/AsyncManager.java
+61
-0
src/main/java/cn/timer/api/manager/ShutdownManager.java
+39
-0
src/main/java/cn/timer/api/manager/factory/AsyncFactory.java
+51
-0
src/main/java/cn/timer/api/utils/AddressUtils.java
+41
-0
src/main/java/cn/timer/api/utils/HttpUtils.java
+249
-0
src/main/java/cn/timer/api/utils/LogUtils.java
+18
-0
src/main/java/cn/timer/api/utils/ServletUtils.java
+138
-0
src/main/java/cn/timer/api/utils/SpringUtils.java
+114
-0
src/main/java/cn/timer/api/utils/Threads.java
+99
-0
src/main/java/cn/timer/api/utils/UserIp.java
+120
-0
src/main/resources/mapping/qyzx/QyzxOperLogMapper.xml
+0
-0
No files found.
src/main/java/cn/timer/api/aspect/LogAspect.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
aspect
;
import
java.lang.reflect.Method
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.TimerTask
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.HandlerMapping
;
import
com.alibaba.fastjson.JSON
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.timer.api.aspect.lang.annotation.Log
;
import
cn.timer.api.aspect.lang.enums.BusinessStatus
;
import
cn.timer.api.bean.qyzx.QyzxEmpLogin
;
import
cn.timer.api.bean.qyzx.QyzxOperLog
;
import
cn.timer.api.config.enums.HttpMethod
;
import
cn.timer.api.manager.AsyncManager
;
import
cn.timer.api.manager.factory.AsyncFactory
;
import
cn.timer.api.utils.ServletUtils
;
import
cn.timer.api.utils.UserIp
;
/**
* 操作日志记录处理
*
* @author Tang
*/
@Aspect
@Component
public
class
LogAspect
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LogAspect
.
class
);
@Resource
private
HttpSession
session
;
// 配置织入点
@Pointcut
(
"@annotation(cn.timer.api.aspect.lang.annotation.Log)"
)
public
void
logPointCut
()
{
}
/**
* 处理完请求后执行
*
* @param joinPoint 切点
*/
@AfterReturning
(
pointcut
=
"logPointCut()"
,
returning
=
"jsonResult"
)
public
void
doAfterReturning
(
JoinPoint
joinPoint
,
Object
jsonResult
)
{
handleLog
(
joinPoint
,
null
,
jsonResult
);
}
/**
* 拦截异常操作
*
* @param joinPoint 切点
* @param e 异常
*/
@AfterThrowing
(
value
=
"logPointCut()"
,
throwing
=
"e"
)
public
void
doAfterThrowing
(
JoinPoint
joinPoint
,
Exception
e
)
{
handleLog
(
joinPoint
,
e
,
null
);
}
protected
void
handleLog
(
final
JoinPoint
joinPoint
,
final
Exception
e
,
Object
jsonResult
)
{
try
{
// 获得注解
Log
controllerLog
=
getAnnotationLog
(
joinPoint
);
if
(
controllerLog
==
null
)
{
return
;
}
// 获取当前的用户
// LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
QyzxEmpLogin
eld
=
(
QyzxEmpLogin
)
session
.
getAttribute
(
"ui"
);
// *========数据库日志=========*//
QyzxOperLog
operLog
=
new
QyzxOperLog
();
operLog
.
setOrgCode
(
eld
.
getOrgId
());
operLog
.
setEmpNum
(
eld
.
getId
());
// 请求的地址
String
ip
=
UserIp
.
getIpAddr
(
ServletUtils
.
getRequest
());
operLog
.
setOperIp
(
ip
);
// 返回参数
String
jsonResultStr
=
JSON
.
toJSONString
(
jsonResult
);
operLog
.
setJsonResult
(
jsonResultStr
.
length
()
<=
10000
?
jsonResultStr
:
""
);
operLog
.
setOperUrl
(
ServletUtils
.
getRequest
().
getRequestURI
());
if
(
eld
!=
null
)
{
operLog
.
setOperName
(
eld
.
getUsername
());
}
if
(
e
!=
null
)
{
operLog
.
setStatus
(
BusinessStatus
.
FAIL
.
ordinal
());
operLog
.
setErrorMsg
(
StrUtil
.
sub
(
e
.
getMessage
(),
0
,
2000
));
}
else
{
operLog
.
setStatus
(
BusinessStatus
.
SUCCESS
.
ordinal
());
}
// 设置方法名称
String
className
=
joinPoint
.
getTarget
().
getClass
().
getName
();
String
methodName
=
joinPoint
.
getSignature
().
getName
();
operLog
.
setMethod
(
className
+
"."
+
methodName
+
"()"
);
// 设置请求方式
operLog
.
setRequestMethod
(
ServletUtils
.
getRequest
().
getMethod
());
operLog
.
setOperTime
(
new
Date
());
// 处理设置注解上的参数
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
);
// 保存数据库
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordOper
(
operLog
));
}
catch
(
Exception
exp
)
{
// 记录本地异常日志
log
.
error
(
"==前置通知异常=="
);
log
.
error
(
"异常信息:{}"
,
exp
.
getMessage
());
exp
.
printStackTrace
();
}
}
/**
* 获取注解中对方法的描述信息 用于Controller层注解
*
* @param log 日志
* @param operLog 操作日志
* @throws Exception
*/
public
void
getControllerMethodDescription
(
JoinPoint
joinPoint
,
Log
log
,
QyzxOperLog
operLog
)
throws
Exception
{
// 设置action动作
operLog
.
setBusinessType
(
log
.
businessType
().
ordinal
());
// 设置标题
operLog
.
setTitle
(
log
.
title
());
// 设置操作人类别
operLog
.
setOperatorType
(
log
.
operatorType
().
ordinal
());
// 是否需要保存request,参数和值
if
(
log
.
isSaveRequestData
())
{
// 获取参数的信息,传入到数据库中。
setRequestValue
(
joinPoint
,
operLog
);
}
}
/**
* 获取请求的参数,放到log中
*
* @param operLog 操作日志
* @throws Exception 异常
*/
private
void
setRequestValue
(
JoinPoint
joinPoint
,
QyzxOperLog
operLog
)
throws
Exception
{
String
requestMethod
=
operLog
.
getRequestMethod
();
if
(
HttpMethod
.
PUT
.
name
().
equals
(
requestMethod
)
||
HttpMethod
.
POST
.
name
().
equals
(
requestMethod
))
{
// JSONObject jsonObj = JSONUtil.parseObj(joinPoint.getArgs());
String
params
=
argsArrayToString
(
joinPoint
.
getArgs
());
operLog
.
setOperParam
(
StrUtil
.
sub
(
params
,
0
,
10000
));
}
else
{
Map
<?,
?>
paramsMap
=
(
Map
<?,
?>)
ServletUtils
.
getRequest
().
getAttribute
(
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
);
operLog
.
setOperParam
(
StrUtil
.
sub
(
paramsMap
.
toString
(),
0
,
10000
));
}
}
/**
* 是否存在注解,如果存在就获取
*/
private
Log
getAnnotationLog
(
JoinPoint
joinPoint
)
throws
Exception
{
Signature
signature
=
joinPoint
.
getSignature
();
MethodSignature
methodSignature
=
(
MethodSignature
)
signature
;
Method
method
=
methodSignature
.
getMethod
();
if
(
method
!=
null
)
{
return
method
.
getAnnotation
(
Log
.
class
);
}
return
null
;
}
/**
* 参数拼装
*/
private
String
argsArrayToString
(
Object
[]
paramsArray
)
{
String
params
=
""
;
if
(
paramsArray
!=
null
&&
paramsArray
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
paramsArray
.
length
;
i
++)
{
if
(!
isFilterObject
(
paramsArray
[
i
]))
{
Object
jsonObj
=
JSON
.
toJSON
(
paramsArray
[
i
]);
params
+=
jsonObj
.
toString
()
+
" "
;
}
}
}
return
params
.
trim
();
}
/**
* 判断是否需要过滤的对象。
*
* @param o 对象信息。
* @return 如果是需要过滤的对象,则返回true;否则返回false。
*/
public
boolean
isFilterObject
(
final
Object
o
)
{
return
o
instanceof
MultipartFile
||
o
instanceof
HttpServletRequest
||
o
instanceof
HttpServletResponse
;
}
}
src/main/java/cn/timer/api/aspect/lang/annotation/Log.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
aspect
.
lang
.
annotation
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
cn.timer.api.aspect.lang.enums.BusinessType
;
import
cn.timer.api.aspect.lang.enums.OperatorType
;
/**
* 自定义操作日志记录注解
*
* @author ruoyi
*
*/
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
Log
{
/**
* 模块
*/
public
String
title
()
default
""
;
/**
* 功能
*/
public
BusinessType
businessType
()
default
BusinessType
.
OTHER
;
/**
* 操作人类别
*/
public
OperatorType
operatorType
()
default
OperatorType
.
MANAGE
;
/**
* 是否保存请求的参数
*/
public
boolean
isSaveRequestData
()
default
true
;
}
src/main/java/cn/timer/api/aspect/lang/enums/BusinessStatus.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
aspect
.
lang
.
enums
;
/**
* 操作状态
*
* @author ruoyi
*
*/
public
enum
BusinessStatus
{
/**
* 成功
*/
SUCCESS
,
/**
* 失败
*/
FAIL
,
}
src/main/java/cn/timer/api/aspect/lang/enums/BusinessType.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
aspect
.
lang
.
enums
;
/**
* 业务操作类型
*
* @author Tang
*/
public
enum
BusinessType
{
/**
* 其它
*/
OTHER
,
/**
* 新增
*/
INSERT
,
/**
* 修改
*/
UPDATE
,
/**
* 删除
*/
DELETE
,
/**
* 授权
*/
GRANT
,
/**
* 导出
*/
EXPORT
,
/**
* 导入
*/
IMPORT
,
/**
* 强退
*/
FORCE
,
/**
* 生成代码
*/
GENCODE
,
/**
* 清空数据
*/
CLEAN
,
}
src/main/java/cn/timer/api/aspect/lang/enums/OperatorType.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
aspect
.
lang
.
enums
;
/**
* 操作人类别
*
* @author ruoyi
*/
public
enum
OperatorType
{
/**
* 其它
*/
OTHER
,
/**
* 后台用户
*/
MANAGE
,
/**
* 手机端用户
*/
MOBILE
}
src/main/java/cn/timer/api/bean/qyzx/QyzxOperLog.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
bean
.
qyzx
;
import
java.util.Date
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* 操作日志记录表 oper_log
*
* @author Tang
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
(
toBuilder
=
true
)
@Table
(
name
=
"qyzx_oper_log"
)
@ApiModel
(
"操作日志"
)
public
class
QyzxOperLog
extends
Model
<
QyzxOperLog
>{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
/** 日志主键 */
@Id
@GeneratedValue
@TableId
(
type
=
IdType
.
AUTO
)
@ApiModelProperty
(
value
=
"编号"
,
example
=
"101"
)
private
Integer
operId
;
@ApiModelProperty
(
value
=
"企业id"
,
example
=
"101"
)
private
Integer
orgCode
;
@ApiModelProperty
(
value
=
"员工id"
,
example
=
"101"
)
private
Integer
empNum
;
@ApiModelProperty
(
value
=
"标题 "
,
example
=
"操作模块"
)
private
String
title
;
@ApiModelProperty
(
value
=
"业务类型(0其它 1新增 2修改 3删除)"
,
example
=
"101"
)
private
Integer
businessType
;
@ApiModelProperty
(
value
=
"请求方法"
,
example
=
"请求方法"
)
private
String
method
;
@ApiModelProperty
(
value
=
"请求方式"
,
example
=
"请求方式"
)
private
String
requestMethod
;
@ApiModelProperty
(
value
=
"操作类别(0其它 1后台用户 2手机端用户)"
,
example
=
"101"
)
private
Integer
operatorType
;
@ApiModelProperty
(
value
=
"操作人员"
,
example
=
"操作人员"
)
private
String
operName
;
@ApiModelProperty
(
value
=
"部门名称"
,
example
=
"部门名称"
)
private
String
deptName
;
@ApiModelProperty
(
value
=
"请求url"
,
example
=
"请求url"
)
private
String
operUrl
;
@ApiModelProperty
(
value
=
"操作地址"
,
example
=
"操作地址"
)
private
String
operIp
;
@ApiModelProperty
(
value
=
"操作地点"
,
example
=
"操作地点"
)
private
String
operLocation
;
@ApiModelProperty
(
value
=
"请求参数"
,
example
=
"请求参数"
)
private
String
operParam
;
@ApiModelProperty
(
value
=
"返回参数"
,
example
=
"返回参数"
)
private
String
jsonResult
;
@ApiModelProperty
(
value
=
"操作状态(0正常 1异常)"
,
example
=
"101"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"错误消息"
,
example
=
"错误消息"
)
private
String
errorMsg
;
@ApiModelProperty
(
value
=
"操作时间"
,
example
=
"操作时间"
)
private
Date
operTime
;
}
src/main/java/cn/timer/api/config/enums/HttpMethod.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
config
.
enums
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.lang.Nullable
;
/**
* 请求方式
*
* @author ruoyi
*/
public
enum
HttpMethod
{
GET
,
HEAD
,
POST
,
PUT
,
PATCH
,
DELETE
,
OPTIONS
,
TRACE
;
private
static
final
Map
<
String
,
HttpMethod
>
mappings
=
new
HashMap
<>(
16
);
static
{
for
(
HttpMethod
httpMethod
:
values
())
{
mappings
.
put
(
httpMethod
.
name
(),
httpMethod
);
}
}
@Nullable
public
static
HttpMethod
resolve
(
@Nullable
String
method
)
{
return
(
method
!=
null
?
mappings
.
get
(
method
)
:
null
);
}
public
boolean
matches
(
String
method
)
{
return
(
this
==
resolve
(
method
));
}
}
src/main/java/cn/timer/api/config/thread/ThreadPoolConfig.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
config
.
thread
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
cn.timer.api.utils.Threads
;
/**
* 线程池配置
*
* @author Tang
**/
@Configuration
public
class
ThreadPoolConfig
{
// 核心线程池大小
private
int
corePoolSize
=
50
;
// 最大可创建的线程数
private
int
maxPoolSize
=
200
;
// 队列最大长度
private
int
queueCapacity
=
1000
;
// 线程池维护线程所允许的空闲时间
private
int
keepAliveSeconds
=
300
;
@Bean
(
name
=
"threadPoolTaskExecutor"
)
public
ThreadPoolTaskExecutor
threadPoolTaskExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setMaxPoolSize
(
maxPoolSize
);
executor
.
setCorePoolSize
(
corePoolSize
);
executor
.
setQueueCapacity
(
queueCapacity
);
executor
.
setKeepAliveSeconds
(
keepAliveSeconds
);
// 线程池对拒绝任务(无线程可用)的处理策略
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
return
executor
;
}
/**
* 执行周期性或定时任务
*/
@Bean
(
name
=
"scheduledExecutorService"
)
protected
ScheduledExecutorService
scheduledExecutorService
()
{
return
new
ScheduledThreadPoolExecutor
(
corePoolSize
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"schedule-pool-%d"
).
daemon
(
true
).
build
())
{
@Override
protected
void
afterExecute
(
Runnable
r
,
Throwable
t
)
{
super
.
afterExecute
(
r
,
t
);
Threads
.
printException
(
r
,
t
);
}
};
}
}
src/main/java/cn/timer/api/controller/LoginController.java
View file @
d87bf527
...
...
@@ -28,6 +28,8 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.timer.api.aspect.lang.annotation.Log
;
import
cn.timer.api.aspect.lang.enums.BusinessType
;
import
cn.timer.api.bean.qyzx.QyzxEmpEntAsso
;
import
cn.timer.api.bean.qyzx.QyzxEmpLogin
;
import
cn.timer.api.bean.qyzx.QyzxEntInfoM
;
...
...
@@ -121,29 +123,6 @@ public class LoginController {
@Value
(
"${config-8timer.Aliyun.expirationTime_pri}"
)
private
String
expirationTime_pri
;
@GetMapping
(
value
=
"/test"
)
public
Map
<
String
,
Object
>
test
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"1"
,
offset
);
map
.
put
(
"2"
,
PROJECT_NAME
);
map
.
put
(
"3"
,
REGION_ID
);
map
.
put
(
"4"
,
ACCESSKEY_ID
);
map
.
put
(
"5"
,
SECRET
);
// map.put("6", host);
// map.put("7", PROJECT_ID);
// map.put("8", PROJECT_SECRET);
map
.
put
(
"9"
,
endpoint
);
map
.
put
(
"10"
,
accessKeyId
);
map
.
put
(
"11"
,
accessKeySecret
);
map
.
put
(
"12"
,
bucketName
);
map
.
put
(
"13"
,
bucketName_pri
);
map
.
put
(
"14"
,
project_package
);
map
.
put
(
"15"
,
expirationTime
);
map
.
put
(
"16"
,
expirationTime_pri
);
map
.
put
(
"test1"
,
max
);
return
map
;
}
@Autowired
private
HttpSession
session
;
...
...
@@ -168,6 +147,7 @@ public class LoginController {
@PostMapping
(
value
=
"/sendcode"
)
@ApiOperation
(
value
=
"1.发送验证码"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
1
)
@Log
(
title
=
"发送验证码"
,
businessType
=
BusinessType
.
UPDATE
)
public
Result
<
String
>
sendCode
(
@RequestBody
EntRegisterDto
entRegisterDto
)
{
String
phone
=
entRegisterDto
.
getPhone
();
...
...
@@ -307,6 +287,7 @@ public class LoginController {
@PostMapping
(
value
=
"/updatePwd"
)
@ApiOperation
(
value
=
"4.修改密码(新)"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
4
)
@Log
(
title
=
"修改密码"
,
businessType
=
BusinessType
.
UPDATE
)
public
Result
<
String
>
updatepwd
(
@RequestBody
EntRegisterDto
entRegisterDto
)
{
String
oldPwd
=
entRegisterDto
.
getOldPwd
();
// 输入的原密码
String
pw
=
entRegisterDto
.
getPw
();
// 输入的新密码
...
...
@@ -344,8 +325,8 @@ public class LoginController {
* @return
*/
@PostMapping
(
value
=
"/updatepassword"
)
@ApiOperation
(
value
=
"
4
.修改密码"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
4
)
@ApiOperation
(
value
=
"
3
.修改密码"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
3
)
public
Result
<
String
>
updatepassword
(
@RequestBody
EntRegisterDto
entRegisterDto
)
{
String
phone
=
entRegisterDto
.
getPhone
();
String
pw
=
entRegisterDto
.
getPw
();
...
...
@@ -402,7 +383,8 @@ public class LoginController {
* @return
*/
@PostMapping
(
value
=
"/updatephone"
)
@ApiOperation
(
value
=
"修改手机号/用户名"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"5.修改手机号/用户名"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
5
)
public
Result
<
String
>
updatephone
(
@CurrentUser
UserBean
userBean
,
@RequestBody
EntRegisterDto
entRegisterDto
)
{
/*
...
...
@@ -447,7 +429,9 @@ public class LoginController {
* @return
*/
@PostMapping
(
value
=
"/register"
)
@ApiOperation
(
value
=
"注册企业"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"6.注册企业"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
6
)
@Log
(
title
=
"企业注册"
,
businessType
=
BusinessType
.
INSERT
)
public
Result
<
String
>
register
(
@RequestBody
EntRegisterDto
entRegisterDto
)
{
// 事务回滚
/*
...
...
@@ -540,7 +524,9 @@ public class LoginController {
* @return
*/
@PostMapping
(
value
=
"/code"
)
@ApiOperation
(
value
=
"验证码登录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"7.验证码登录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
7
)
@Log
(
title
=
"用户登录"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
QyzxEmpLogin
>
codelogin
(
@RequestBody
EntRegisterDto
entRegisterDto
,
HttpServletRequest
request
)
{
String
code
=
entRegisterDto
.
getCode
();
...
...
@@ -614,7 +600,7 @@ public class LoginController {
.
and
(
i
->
i
.
in
(
ZzglAuth:
:
getBmgwId
,
list
.
toArray
()));
List
<
ZzglAuth
>
zas
=
ZzglAuth
.
builder
().
build
().
selectList
(
wp
);
List
<
String
>
menus
=
new
ArrayList
<>();
zas
.
stream
().
forEach
(
o
->
menus
.
add
(
o
.
getMenuId
()));
zas
.
stream
().
forEach
(
o
->
menus
.
add
(
"b"
+
o
.
getMenuId
()));
qyzxEmpLogin1
.
setMenus
(
menus
);
}
}
...
...
@@ -636,7 +622,9 @@ public class LoginController {
* @return
*/
@PostMapping
(
value
=
"/password"
)
@ApiOperation
(
value
=
"密码登录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"8.密码登录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
8
)
@Log
(
title
=
"用户登录"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
QyzxEmpLogin
>
passwordlogin
(
@RequestBody
EntRegisterDto
entRegisterDto
,
HttpServletRequest
request
)
{
String
phone
=
entRegisterDto
.
getPhone
();
...
...
src/main/java/cn/timer/api/controller/qyzx/QyzxController.java
View file @
d87bf527
...
...
@@ -32,8 +32,10 @@ import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import
cn.timer.api.bean.qyzx.QyzxFeebackAccessory
;
import
cn.timer.api.bean.qyzx.QyzxInvoiceUsual
;
import
cn.timer.api.bean.qyzx.QyzxLogBuy
;
import
cn.timer.api.bean.qyzx.QyzxOperLog
;
import
cn.timer.api.bean.qyzx.QyzxPayServe
;
import
cn.timer.api.bean.qyzx.QyzxSuggestionFeeback
;
import
cn.timer.api.bean.spmk.SpmkApproveSummary
;
import
cn.timer.api.bean.zzgl.ZzglAuth
;
import
cn.timer.api.bean.zzgl.ZzglBmgwM
;
import
cn.timer.api.config.annotation.CurrentUser
;
...
...
@@ -46,6 +48,7 @@ import cn.timer.api.dao.qyzx.QyzxEntInfoMMapper;
import
cn.timer.api.dao.qyzx.QyzxFeebackAccessoryMapper
;
import
cn.timer.api.dao.qyzx.QyzxInvoiceUsualMapper
;
import
cn.timer.api.dao.qyzx.QyzxLogBuyMapper
;
import
cn.timer.api.dao.qyzx.QyzxOperLogMapper
;
import
cn.timer.api.dao.qyzx.QyzxPayServeMapper
;
import
cn.timer.api.dao.qyzx.QyzxSuggestionFeebackMapper
;
import
cn.timer.api.dao.zzgl.ZzglBmgwMMapper
;
...
...
@@ -55,6 +58,7 @@ import cn.timer.api.dto.qyzx.AttaFpglQueryDto;
import
cn.timer.api.dto.qyzx.EntauthDto
;
import
cn.timer.api.dto.qyzx.FeebackDto
;
import
cn.timer.api.dto.qyzx.LogBuyDto
;
import
cn.timer.api.dto.qyzx.QyzxOperLogQuaryDto
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
import
cn.timer.api.utils.aliyun.OSSUtil
;
...
...
@@ -65,9 +69,6 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
@Api
(
tags
=
"4.0企业中心"
)
// @RequestMapping(value = "/qyzx", produces = { "application/json",
// "multipart/form-data", "form-data" }, consumes = { "application/json",
// "multipart/form-data" })
@RequestMapping
(
value
=
"/qyzx"
,
produces
=
{
"application/json"
})
public
class
QyzxController
{
@Autowired
...
...
@@ -515,4 +516,27 @@ public class QyzxController {
return
ResultUtil
.
data
(
page1
,
qyzxEmpEntAssoMapper
.
adminlist
(
page1
,
userBean
.
getOrgCode
()),
"获取账号"
);
}
@Autowired
private
QyzxOperLogMapper
qyzxOperLogMapper
;
/**
* 查询-操作日志
*
* @param
* @return
*/
@PostMapping
(
value
=
"/select_oper_log"
)
@ApiOperation
(
value
=
"查询-操作日志"
,
httpMethod
=
"POST"
,
notes
=
"查询-操作日志"
)
public
Result
<
Object
>
selectOperLog
(
@CurrentUser
UserBean
userBean
,
@RequestBody
QyzxOperLogQuaryDto
qyzxOperLogQuaryDto
)
{
IPage
<
QyzxOperLog
>
page
=
new
Page
<
QyzxOperLog
>(
qyzxOperLogQuaryDto
.
getCurrentPage
()
==
null
?
1
:
qyzxOperLogQuaryDto
.
getCurrentPage
(),
qyzxOperLogQuaryDto
.
getTotalPage
()
==
null
?
10
:
qyzxOperLogQuaryDto
.
getTotalPage
());
qyzxOperLogQuaryDto
.
setOrgCode
(
userBean
.
getOrgCode
());
IPage
<
QyzxOperLog
>
pages
=
qyzxOperLogMapper
.
selectPageByQuery
(
page
,
qyzxOperLogQuaryDto
);
List
<
QyzxOperLog
>
listOl
=
pages
.
getRecords
();
return
ResultUtil
.
data
(
pages
,
listOl
,
"操作成功!"
);
}
}
src/main/java/cn/timer/api/controller/qyzx/service/QyzxOperLogService.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
controller
.
qyzx
.
service
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
cn.timer.api.bean.qyzx.QyzxOperLog
;
import
cn.timer.api.dto.qyzx.QyzxOperLogQuaryDto
;
/**
* 操作日志 服务层
*
* @author ruoyi
*/
public
interface
QyzxOperLogService
{
/**
* 新增操作日志
*
* @param operLog 操作日志对象
*/
public
void
insertOperlog
(
QyzxOperLog
operLog
);
/**
* 查询系统操作日志集合
*
* @param operLog 操作日志对象
* @return 操作日志集合
*/
public
IPage
<
QyzxOperLog
>
selectPageByQuery
(
IPage
<
QyzxOperLog
>
page
,
QyzxOperLogQuaryDto
operLog
);
/**
* 批量删除系统操作日志
*
* @param operIds 需要删除的操作日志ID
* @return 结果
*/
public
int
deleteOperLogByIds
(
List
<
QyzxOperLog
>
idList
);
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
public
QyzxOperLog
selectOperLogById
(
Long
operId
);
/**
* 清空操作日志
*/
public
void
cleanOperLog
();
}
src/main/java/cn/timer/api/controller/qyzx/service/QyzxOperLogServiceImpl.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
controller
.
qyzx
.
service
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
cn.timer.api.bean.qyzx.QyzxOperLog
;
import
cn.timer.api.dao.qyzx.QyzxOperLogMapper
;
import
cn.timer.api.dto.qyzx.QyzxOperLogQuaryDto
;
/**
* 操作日志 服务层处理
*
* @author Tang
*/
@Service
public
class
QyzxOperLogServiceImpl
implements
QyzxOperLogService
{
@Autowired
private
QyzxOperLogMapper
operLogMapper
;
/**
* 新增操作日志
*
* @param operLog 操作日志对象
*/
@Override
public
void
insertOperlog
(
QyzxOperLog
operLog
)
{
operLogMapper
.
insert
(
operLog
);
}
/**
* 查询系统操作日志集合
*
* @param operLog 操作日志对象
* @return 操作日志集合
*/
@Override
public
IPage
<
QyzxOperLog
>
selectPageByQuery
(
IPage
<
QyzxOperLog
>
page
,
QyzxOperLogQuaryDto
operLog
)
{
return
operLogMapper
.
selectPageByQuery
(
page
,
operLog
);
}
/**
* 批量删除系统操作日志
*
* @param operIds 需要删除的操作日志ID
* @return 结果
*/
public
int
deleteOperLogByIds
(
List
<
QyzxOperLog
>
idList
)
{
return
operLogMapper
.
deleteBatchIds
(
idList
);
}
/**
* 查询操作日志详细
*
* @param operId 操作ID
* @return 操作日志对象
*/
@Override
public
QyzxOperLog
selectOperLogById
(
Long
operId
)
{
return
operLogMapper
.
selectById
(
operId
);
}
/**
* 清空操作日志
*/
@Override
public
void
cleanOperLog
()
{
operLogMapper
.
delete
(
null
);
}
}
src/main/java/cn/timer/api/controller/spmk/SpmkController.java
View file @
d87bf527
...
...
@@ -30,6 +30,8 @@ import cn.hutool.core.lang.Console;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.timer.api.aspect.lang.annotation.Log
;
import
cn.timer.api.aspect.lang.enums.BusinessType
;
import
cn.timer.api.bean.spmk.SpmkApprovalG
;
import
cn.timer.api.bean.spmk.SpmkApprovalTemplate
;
import
cn.timer.api.bean.spmk.SpmkApprovalTemplateG
;
...
...
@@ -440,6 +442,7 @@ public class SpmkController {
@ApiOperation
(
value
=
"17.发起审批"
,
httpMethod
=
"POST"
,
notes
=
"发起审批"
)
@ApiOperationSupport
(
order
=
17
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Log
(
title
=
"审批-发起审批"
,
businessType
=
BusinessType
.
INSERT
)
public
Result
<
Object
>
saveCa
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
SpmkApproveSummaryDto
spmkApproveSummaryDto
)
throws
Exception
{
YgglMainEmp
ygglMainEmp
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>()
.
lambda
()
...
...
@@ -507,6 +510,7 @@ public class SpmkController {
@PostMapping
(
value
=
"/select_approve_summary"
)
@ApiOperation
(
value
=
"18.审批汇总"
,
httpMethod
=
"POST"
,
notes
=
"审批汇总"
)
@ApiOperationSupport
(
order
=
18
)
@Log
(
title
=
"审批-审批汇总"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectAs
(
@CurrentUser
UserBean
userBean
,
@RequestBody
SummaryQueryDto
summaryQueryDto
)
{
IPage
<
SpmkApproveSummary
>
page
=
new
Page
<
SpmkApproveSummary
>(
...
...
@@ -542,6 +546,7 @@ public class SpmkController {
@GetMapping
(
value
=
"/select_approve_detail/{id}"
)
@ApiOperation
(
value
=
"19.审批详情"
,
httpMethod
=
"GET"
,
notes
=
"审批详情"
)
@ApiOperationSupport
(
order
=
19
)
@Log
(
title
=
"审批-审批详情"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectAd
(
@PathVariable
(
required
=
true
)
Integer
id
)
{
SpmkApproveDetail
ad
=
spmkApproveDetailMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveDetail
>().
lambda
().
eq
(
SpmkApproveDetail:
:
getApproveSummaryId
,
id
));
...
...
@@ -568,6 +573,7 @@ public class SpmkController {
@ApiOperation
(
value
=
"20.审批人审批"
,
httpMethod
=
"POST"
,
notes
=
"审批人审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
20
)
@Log
(
title
=
"审批-审批流程"
,
businessType
=
BusinessType
.
UPDATE
)
// @BindingResultCtrol(title = "审批人审批")
public
Result
<
Object
>
approving
(
@Validated
@RequestBody
ApprovingDto
approvingDto
)
throws
Exception
{
SpmkApproveDetail
ad
=
SpmkApproveDetail
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SpmkApproveDetail
>()
...
...
@@ -634,11 +640,12 @@ public class SpmkController {
//TODO 我审批的/抄送我的
/**
* 查询列表-我审批的/抄送我的-分页
* 查询列表-我
发起的/我
审批的/抄送我的-分页
*/
@PostMapping
(
value
=
"/select_my_approve"
)
@ApiOperation
(
value
=
"21.查询列表-我审批的/抄送我的-分页"
,
httpMethod
=
"POST"
,
notes
=
"查询列表-我审批的-关键字、审批状态、发起时间-分页"
)
@ApiOperation
(
value
=
"21.查询列表-我
发起的/我
审批的/抄送我的-分页"
,
httpMethod
=
"POST"
,
notes
=
"查询列表-我审批的-关键字、审批状态、发起时间-分页"
)
@ApiOperationSupport
(
order
=
21
)
@Log
(
title
=
"审批-我发起的/我审批的/抄送我的"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectMyAs
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
MySummaryQueryDto
mySummaryQueryDto
)
throws
MethodArgumentNotValidException
{
IPage
<
SpmkApproveSummary
>
page
=
new
Page
<
SpmkApproveSummary
>(
mySummaryQueryDto
.
getCurrentPage
()
==
null
?
1
:
mySummaryQueryDto
.
getCurrentPage
(),
...
...
@@ -660,6 +667,7 @@ public class SpmkController {
@ApiOperation
(
value
=
"22.撤销审批"
,
httpMethod
=
"PUT"
,
notes
=
"撤销审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
22
)
@Log
(
title
=
"审批-撤销审批"
,
businessType
=
BusinessType
.
UPDATE
)
public
Result
<
Object
>
revokeApproval
(
@PathVariable
Integer
id
)
throws
Exception
{
SpmkApproveSummary
as
=
spmkApproveSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveSummary
>()
...
...
@@ -677,6 +685,7 @@ public class SpmkController {
@DeleteMapping
(
value
=
"/delete_approval/{id}"
)
@ApiOperation
(
value
=
"23.删除-审批(发起的审批)-根据审批汇总id"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批(发起的审批)-根据审批汇总id"
)
@ApiOperationSupport
(
order
=
23
)
@Log
(
title
=
"审批-删除审批"
,
businessType
=
BusinessType
.
DELETE
)
public
Result
<
Object
>
deleteApprovalData
(
@PathVariable
Integer
id
){
List
<
SpmkApproveExecuteRecord
>
listAer
=
spmkApproveExecuteRecordMapper
.
selectList
(
new
QueryWrapper
<
SpmkApproveExecuteRecord
>()
.
lambda
()
...
...
src/main/java/cn/timer/api/dao/qyzx/QyzxOperLogMapper.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
dao
.
qyzx
;
import
org.apache.ibatis.annotations.Param
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
cn.timer.api.bean.qyzx.QyzxOperLog
;
import
cn.timer.api.dto.qyzx.QyzxOperLogQuaryDto
;
/**
* 操作日志 数据层
*
* @author ruoyi
*/
public
interface
QyzxOperLogMapper
extends
BaseMapper
<
QyzxOperLog
>
{
// /**
// * 新增操作日志
// *
// * @param operLog 操作日志对象
// */
// public void insertOperlog(QyzxOperLog operLog);
//
/**
* 查询系统操作日志集合
*
* @param operLog 操作日志对象
* @return 操作日志集合
*/
public
IPage
<
QyzxOperLog
>
selectPageByQuery
(
IPage
<
QyzxOperLog
>
page
,
@Param
(
"param"
)
QyzxOperLogQuaryDto
operLog
);
//
// /**
// * 批量删除系统操作日志
// *
// * @param operIds 需要删除的操作日志ID
// * @return 结果
// */
// public int deleteOperLogByIds(Long[] operIds);
//
// /**
// * 查询操作日志详细
// *
// * @param operId 操作ID
// * @return 操作日志对象
// */
// public QyzxOperLog selectOperLogById(Long operId);
//
// /**
// * 清空操作日志
// */
// public void cleanOperLog();
}
src/main/java/cn/timer/api/dto/qyzx/QyzxOperLogQuaryDto.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
dto
.
qyzx
;
import
cn.timer.api.dto.spmk.MySummaryQueryDto
;
import
cn.timer.api.utils.Page
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
QyzxOperLogQuaryDto
extends
Page
{
@ApiModelProperty
(
value
=
"标题/操作人员/编号"
,
example
=
"1"
)
private
String
query
;
@ApiModelProperty
(
value
=
"企业id"
,
example
=
"101"
)
private
Integer
orgCode
;
@ApiModelProperty
(
value
=
"业务类型(0其它 1新增 2修改 3删除)"
,
example
=
"101"
)
private
Integer
businessType
;
@ApiModelProperty
(
value
=
"操作类别(0其它 1后台用户 2手机端用户)"
,
example
=
"101"
)
private
Integer
operatorType
;
@ApiModelProperty
(
value
=
"请求方式"
,
example
=
"请求方式"
)
private
String
requestMethod
;
@ApiModelProperty
(
value
=
"开始时间 "
,
example
=
"2000-10-10 10:10:10"
)
private
String
startTime
;
@ApiModelProperty
(
value
=
"结束时间 "
,
example
=
"2020-10-10 10:10:10"
)
private
String
endTime
;
}
src/main/java/cn/timer/api/manager/AsyncManager.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
manager
;
import
java.util.TimerTask
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
cn.timer.api.utils.SpringUtils
;
import
cn.timer.api.utils.Threads
;
/**
* 异步任务管理器
*
* @author Tang
*/
public
class
AsyncManager
{
/**
* 操作延迟10毫秒
*/
private
final
int
OPERATE_DELAY_TIME
=
10
;
/**
* 异步操作任务调度线程池
*/
private
ScheduledExecutorService
executor
=
SpringUtils
.
getBean
(
"scheduledExecutorService"
);
/**
* 单例模式
*/
private
AsyncManager
(){}
private
static
AsyncManager
me
;
static
{
me
=
new
AsyncManager
();
}
public
static
AsyncManager
me
()
{
return
me
;
}
/**
* 执行任务
*
* @param task 任务
*/
public
void
execute
(
TimerTask
task
)
{
executor
.
schedule
(
task
,
OPERATE_DELAY_TIME
,
TimeUnit
.
MILLISECONDS
);
}
/**
* 停止任务线程池
*/
public
void
shutdown
()
{
Threads
.
shutdownAndAwaitTermination
(
executor
);
}
}
src/main/java/cn/timer/api/manager/ShutdownManager.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
manager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PreDestroy
;
/**
* 确保应用退出时能关闭后台线程
*
* @author Tang
*/
@Component
public
class
ShutdownManager
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
"sys-user"
);
@PreDestroy
public
void
destroy
()
{
shutdownAsyncManager
();
}
/**
* 停止异步执行任务
*/
private
void
shutdownAsyncManager
()
{
try
{
logger
.
info
(
"====关闭后台任务任务线程池===="
);
AsyncManager
.
me
().
shutdown
();
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
src/main/java/cn/timer/api/manager/factory/AsyncFactory.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
manager
.
factory
;
import
java.util.TimerTask
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
cn.hutool.extra.spring.SpringUtil
;
import
cn.timer.api.bean.qyzx.QyzxOperLog
;
import
cn.timer.api.controller.qyzx.service.QyzxOperLogService
;
import
cn.timer.api.utils.AddressUtils
;
import
cn.timer.api.utils.SpringUtils
;
/**
* 异步工厂(产生任务用)
*
* @author Tang
*/
public
class
AsyncFactory
{
/**
* 记录登陆信息
*
* @param username 用户名
* @param status 状态
* @param message 消息
* @param args 列表
* @return 任务task
*/
// public static TimerTask recordLogininfor(final String username, final String status, final String message,final Object... args){}
/**
* 操作日志记录
*
* @param operLog 操作日志信息
* @return 任务task
*/
public
static
TimerTask
recordOper
(
final
QyzxOperLog
operLog
)
{
return
new
TimerTask
()
{
@Override
public
void
run
()
{
// 远程查询操作地点
operLog
.
setOperLocation
(
AddressUtils
.
getRealAddressByIP
(
operLog
.
getOperIp
()));
SpringUtils
.
getBean
(
QyzxOperLogService
.
class
).
insertOperlog
(
operLog
);
}
};
}
}
src/main/java/cn/timer/api/utils/AddressUtils.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.alibaba.fastjson.JSONObject
;
import
cn.hutool.core.util.StrUtil
;
/**
* 获取地址类
*
* @author Tang
*/
public
class
AddressUtils
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
AddressUtils
.
class
);
public
static
final
String
IP_URL
=
"http://ip.taobao.com/service/getIpInfo.php"
;
public
static
String
getRealAddressByIP
(
String
ip
)
{
String
address
=
"XX XX"
;
// 内网不查询
if
(
UserIp
.
internalIp
(
ip
))
{
return
"内网IP"
;
}
String
rspStr
=
HttpUtils
.
sendPost
(
IP_URL
,
"ip="
+
ip
);
if
(
StrUtil
.
isEmpty
(
rspStr
))
{
log
.
error
(
"获取地理位置异常 {}"
,
ip
);
return
address
;
}
JSONObject
obj
=
JSONObject
.
parseObject
(
rspStr
);
JSONObject
data
=
obj
.
getObject
(
"data"
,
JSONObject
.
class
);
String
region
=
data
.
getString
(
"region"
);
String
city
=
data
.
getString
(
"city"
);
address
=
region
+
" "
+
city
;
return
address
;
}
}
src/main/java/cn/timer/api/utils/HttpUtils.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
utils
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.net.ConnectException
;
import
java.net.SocketTimeoutException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.security.cert.X509Certificate
;
import
javax.net.ssl.HostnameVerifier
;
import
javax.net.ssl.HttpsURLConnection
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.SSLSession
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* 通用http发送方法
*
* @author ruoyi
*/
public
class
HttpUtils
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
HttpUtils
.
class
);
/**
* 向指定 URL 发送GET方法的请求
*
* @param url 发送请求的 URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public
static
String
sendGet
(
String
url
,
String
param
)
{
StringBuilder
result
=
new
StringBuilder
();
BufferedReader
in
=
null
;
try
{
String
urlNameString
=
url
+
"?"
+
param
;
log
.
info
(
"sendGet - {}"
,
urlNameString
);
URL
realUrl
=
new
URL
(
urlNameString
);
URLConnection
connection
=
realUrl
.
openConnection
();
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
connection
.
connect
();
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
log
.
info
(
"recv - {}"
,
result
);
}
catch
(
ConnectException
e
)
{
log
.
error
(
"调用HttpUtils.sendGet ConnectException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
SocketTimeoutException
e
)
{
log
.
error
(
"调用HttpUtils.sendGet SocketTimeoutException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
IOException
e
)
{
log
.
error
(
"调用HttpUtils.sendGet IOException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"调用HttpsUtil.sendGet Exception, url="
+
url
+
",param="
+
param
,
e
);
}
finally
{
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"调用in.close Exception, url="
+
url
+
",param="
+
param
,
ex
);
}
}
return
result
.
toString
();
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url 发送请求的 URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public
static
String
sendPost
(
String
url
,
String
param
)
{
PrintWriter
out
=
null
;
BufferedReader
in
=
null
;
StringBuilder
result
=
new
StringBuilder
();
try
{
String
urlNameString
=
url
+
"?"
+
param
;
log
.
info
(
"sendPost - {}"
,
urlNameString
);
URL
realUrl
=
new
URL
(
urlNameString
);
URLConnection
conn
=
realUrl
.
openConnection
();
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
conn
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
conn
.
setRequestProperty
(
"contentType"
,
"utf-8"
);
conn
.
setDoOutput
(
true
);
conn
.
setDoInput
(
true
);
out
=
new
PrintWriter
(
conn
.
getOutputStream
());
out
.
print
(
param
);
out
.
flush
();
in
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"utf-8"
));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
log
.
info
(
"recv - {}"
,
result
);
}
catch
(
ConnectException
e
)
{
log
.
error
(
"调用HttpUtils.sendPost ConnectException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
SocketTimeoutException
e
)
{
log
.
error
(
"调用HttpUtils.sendPost SocketTimeoutException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
IOException
e
)
{
log
.
error
(
"调用HttpUtils.sendPost IOException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"调用HttpsUtil.sendPost Exception, url="
+
url
+
",param="
+
param
,
e
);
}
finally
{
try
{
if
(
out
!=
null
)
{
out
.
close
();
}
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
IOException
ex
)
{
log
.
error
(
"调用in.close Exception, url="
+
url
+
",param="
+
param
,
ex
);
}
}
return
result
.
toString
();
}
public
static
String
sendSSLPost
(
String
url
,
String
param
)
{
StringBuilder
result
=
new
StringBuilder
();
String
urlNameString
=
url
+
"?"
+
param
;
try
{
log
.
info
(
"sendSSLPost - {}"
,
urlNameString
);
SSLContext
sc
=
SSLContext
.
getInstance
(
"SSL"
);
sc
.
init
(
null
,
new
TrustManager
[]
{
new
TrustAnyTrustManager
()
},
new
java
.
security
.
SecureRandom
());
URL
console
=
new
URL
(
urlNameString
);
HttpsURLConnection
conn
=
(
HttpsURLConnection
)
console
.
openConnection
();
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
conn
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
conn
.
setRequestProperty
(
"contentType"
,
"utf-8"
);
conn
.
setDoOutput
(
true
);
conn
.
setDoInput
(
true
);
conn
.
setSSLSocketFactory
(
sc
.
getSocketFactory
());
conn
.
setHostnameVerifier
(
new
TrustAnyHostnameVerifier
());
conn
.
connect
();
InputStream
is
=
conn
.
getInputStream
();
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
is
));
String
ret
=
""
;
while
((
ret
=
br
.
readLine
())
!=
null
)
{
if
(
ret
!=
null
&&
!
ret
.
trim
().
equals
(
""
))
{
result
.
append
(
new
String
(
ret
.
getBytes
(
"ISO-8859-1"
),
"utf-8"
));
}
}
log
.
info
(
"recv - {}"
,
result
);
conn
.
disconnect
();
br
.
close
();
}
catch
(
ConnectException
e
)
{
log
.
error
(
"调用HttpUtils.sendSSLPost ConnectException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
SocketTimeoutException
e
)
{
log
.
error
(
"调用HttpUtils.sendSSLPost SocketTimeoutException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
IOException
e
)
{
log
.
error
(
"调用HttpUtils.sendSSLPost IOException, url="
+
url
+
",param="
+
param
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"调用HttpsUtil.sendSSLPost Exception, url="
+
url
+
",param="
+
param
,
e
);
}
return
result
.
toString
();
}
private
static
class
TrustAnyTrustManager
implements
X509TrustManager
{
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
{
}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
X509Certificate
[]
{};
}
}
private
static
class
TrustAnyHostnameVerifier
implements
HostnameVerifier
{
@Override
public
boolean
verify
(
String
hostname
,
SSLSession
session
)
{
return
true
;
}
}
}
\ No newline at end of file
src/main/java/cn/timer/api/utils/LogUtils.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
utils
;
/**
* 处理并记录日志文件
*
* @author ruoyi
*/
public
class
LogUtils
{
public
static
String
getBlock
(
Object
msg
)
{
if
(
msg
==
null
)
{
msg
=
""
;
}
return
"["
+
msg
.
toString
()
+
"]"
;
}
}
src/main/java/cn/timer/api/utils/ServletUtils.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
utils
;
import
java.io.IOException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.util.StrUtil
;
/**
* 客户端工具类
*
* @author ruoyi
*/
public
class
ServletUtils
{
/**
* 获取String参数
*/
public
static
String
getParameter
(
String
name
)
{
return
getRequest
().
getParameter
(
name
);
}
/**
* 获取String参数
*/
public
static
String
getParameter
(
String
name
,
String
defaultValue
)
{
return
Convert
.
toStr
(
getRequest
().
getParameter
(
name
),
defaultValue
);
}
/**
* 获取Integer参数
*/
public
static
Integer
getParameterToInt
(
String
name
)
{
return
Convert
.
toInt
(
getRequest
().
getParameter
(
name
));
}
/**
* 获取Integer参数
*/
public
static
Integer
getParameterToInt
(
String
name
,
Integer
defaultValue
)
{
return
Convert
.
toInt
(
getRequest
().
getParameter
(
name
),
defaultValue
);
}
/**
* 获取request
*/
public
static
HttpServletRequest
getRequest
()
{
return
getRequestAttributes
().
getRequest
();
}
/**
* 获取response
*/
public
static
HttpServletResponse
getResponse
()
{
return
getRequestAttributes
().
getResponse
();
}
/**
* 获取session
*/
public
static
HttpSession
getSession
()
{
return
getRequest
().
getSession
();
}
public
static
ServletRequestAttributes
getRequestAttributes
()
{
RequestAttributes
attributes
=
RequestContextHolder
.
getRequestAttributes
();
return
(
ServletRequestAttributes
)
attributes
;
}
/**
* 将字符串渲染到客户端
*
* @param response 渲染对象
* @param string 待渲染的字符串
* @return null
*/
public
static
String
renderString
(
HttpServletResponse
response
,
String
string
)
{
try
{
response
.
setStatus
(
200
);
response
.
setContentType
(
"application/json"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
getWriter
().
print
(
string
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 是否是Ajax异步请求
*
* @param request
*/
public
static
boolean
isAjaxRequest
(
HttpServletRequest
request
)
{
String
accept
=
request
.
getHeader
(
"accept"
);
if
(
accept
!=
null
&&
accept
.
indexOf
(
"application/json"
)
!=
-
1
)
{
return
true
;
}
String
xRequestedWith
=
request
.
getHeader
(
"X-Requested-With"
);
if
(
xRequestedWith
!=
null
&&
xRequestedWith
.
indexOf
(
"XMLHttpRequest"
)
!=
-
1
)
{
return
true
;
}
String
uri
=
request
.
getRequestURI
();
if
(
StrUtil
.
containsAnyIgnoreCase
(
uri
,
".json"
,
".xml"
))
{
return
true
;
}
String
ajax
=
request
.
getParameter
(
"__ajax"
);
if
(
StrUtil
.
containsAnyIgnoreCase
(
ajax
,
"json"
,
"xml"
))
{
return
true
;
}
return
false
;
}
}
src/main/java/cn/timer/api/utils/SpringUtils.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
utils
;
import
org.springframework.aop.framework.AopContext
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.config.BeanFactoryPostProcessor
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.stereotype.Component
;
/**
* spring工具类 方便在非spring管理环境中获取bean
*
* @author ruoyi
*/
@Component
public
final
class
SpringUtils
implements
BeanFactoryPostProcessor
{
/** Spring应用上下文环境 */
private
static
ConfigurableListableBeanFactory
beanFactory
;
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
throws
BeansException
{
SpringUtils
.
beanFactory
=
beanFactory
;
}
/**
* 获取对象
*
* @param name
* @return Object 一个以所给名字注册的bean的实例
* @throws org.springframework.beans.BeansException
*
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
getBean
(
String
name
)
throws
BeansException
{
return
(
T
)
beanFactory
.
getBean
(
name
);
}
/**
* 获取类型为requiredType的对象
*
* @param clz
* @return
* @throws org.springframework.beans.BeansException
*
*/
public
static
<
T
>
T
getBean
(
Class
<
T
>
clz
)
throws
BeansException
{
T
result
=
(
T
)
beanFactory
.
getBean
(
clz
);
return
result
;
}
/**
* 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
*
* @param name
* @return boolean
*/
public
static
boolean
containsBean
(
String
name
)
{
return
beanFactory
.
containsBean
(
name
);
}
/**
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
*
* @param name
* @return boolean
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
*
*/
public
static
boolean
isSingleton
(
String
name
)
throws
NoSuchBeanDefinitionException
{
return
beanFactory
.
isSingleton
(
name
);
}
/**
* @param name
* @return Class 注册对象的类型
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
*
*/
public
static
Class
<?>
getType
(
String
name
)
throws
NoSuchBeanDefinitionException
{
return
beanFactory
.
getType
(
name
);
}
/**
* 如果给定的bean名字在bean定义中有别名,则返回这些别名
*
* @param name
* @return
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
*
*/
public
static
String
[]
getAliases
(
String
name
)
throws
NoSuchBeanDefinitionException
{
return
beanFactory
.
getAliases
(
name
);
}
/**
* 获取aop代理对象
*
* @param invoker
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
getAopProxy
(
T
invoker
)
{
return
(
T
)
AopContext
.
currentProxy
();
}
}
src/main/java/cn/timer/api/utils/Threads.java
0 → 100644
View file @
d87bf527
package
cn
.
timer
.
api
.
utils
;
import
java.util.concurrent.CancellationException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* 线程相关工具类.
*
* @author Tang
*/
public
class
Threads
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Threads
.
class
);
/**
* sleep等待,单位为毫秒
*/
public
static
void
sleep
(
long
milliseconds
)
{
try
{
Thread
.
sleep
(
milliseconds
);
}
catch
(
InterruptedException
e
)
{
return
;
}
}
/**
* 停止线程池
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
* 如果仍人超時,則強制退出.
* 另对在shutdown时线程本身被调用中断做了处理.
*/
public
static
void
shutdownAndAwaitTermination
(
ExecutorService
pool
)
{
if
(
pool
!=
null
&&
!
pool
.
isShutdown
())
{
pool
.
shutdown
();
try
{
if
(!
pool
.
awaitTermination
(
120
,
TimeUnit
.
SECONDS
))
{
pool
.
shutdownNow
();
if
(!
pool
.
awaitTermination
(
120
,
TimeUnit
.
SECONDS
))
{
logger
.
info
(
"Pool did not terminate"
);
}
}
}
catch
(
InterruptedException
ie
)
{
pool
.
shutdownNow
();
Thread
.
currentThread
().
interrupt
();
}
}
}
/**
* 打印线程异常信息
*/
public
static
void
printException
(
Runnable
r
,
Throwable
t
)
{
if
(
t
==
null
&&
r
instanceof
Future
<?>)
{
try
{
Future
<?>
future
=
(
Future
<?>)
r
;
if
(
future
.
isDone
())
{
future
.
get
();
}
}
catch
(
CancellationException
ce
)
{
t
=
ce
;
}
catch
(
ExecutionException
ee
)
{
t
=
ee
.
getCause
();
}
catch
(
InterruptedException
ie
)
{
Thread
.
currentThread
().
interrupt
();
}
}
if
(
t
!=
null
)
{
logger
.
error
(
t
.
getMessage
(),
t
);
}
}
}
src/main/java/cn/timer/api/utils/UserIp.java
View file @
d87bf527
...
...
@@ -11,6 +11,7 @@ import java.util.regex.Pattern;
import
javax.servlet.http.HttpServletRequest
;
import
cn.hutool.core.util.StrUtil
;
import
nl.bitwalker.useragentutils.Browser
;
import
nl.bitwalker.useragentutils.OperatingSystem
;
import
nl.bitwalker.useragentutils.UserAgent
;
...
...
@@ -185,6 +186,125 @@ public class UserIp {
return
strings
;
}
/**
* 将IPv4地址转换成字节
*
* @param text IPv4地址
* @return byte 字节
*/
public
static
byte
[]
textToNumericFormatV4
(
String
text
)
{
if
(
text
.
length
()
==
0
)
{
return
null
;
}
byte
[]
bytes
=
new
byte
[
4
];
String
[]
elements
=
text
.
split
(
"\\."
,
-
1
);
try
{
long
l
;
int
i
;
switch
(
elements
.
length
)
{
case
1
:
l
=
Long
.
parseLong
(
elements
[
0
]);
if
((
l
<
0L
)
||
(
l
>
4294967295L
))
return
null
;
bytes
[
0
]
=
(
byte
)
(
int
)
(
l
>>
24
&
0xFF
);
bytes
[
1
]
=
(
byte
)
(
int
)
((
l
&
0xFFFFFF
)
>>
16
&
0xFF
);
bytes
[
2
]
=
(
byte
)
(
int
)
((
l
&
0xFFFF
)
>>
8
&
0xFF
);
bytes
[
3
]
=
(
byte
)
(
int
)
(
l
&
0xFF
);
break
;
case
2
:
l
=
Integer
.
parseInt
(
elements
[
0
]);
if
((
l
<
0L
)
||
(
l
>
255L
))
return
null
;
bytes
[
0
]
=
(
byte
)
(
int
)
(
l
&
0xFF
);
l
=
Integer
.
parseInt
(
elements
[
1
]);
if
((
l
<
0L
)
||
(
l
>
16777215L
))
return
null
;
bytes
[
1
]
=
(
byte
)
(
int
)
(
l
>>
16
&
0xFF
);
bytes
[
2
]
=
(
byte
)
(
int
)
((
l
&
0xFFFF
)
>>
8
&
0xFF
);
bytes
[
3
]
=
(
byte
)
(
int
)
(
l
&
0xFF
);
break
;
case
3
:
for
(
i
=
0
;
i
<
2
;
++
i
)
{
l
=
Integer
.
parseInt
(
elements
[
i
]);
if
((
l
<
0L
)
||
(
l
>
255L
))
return
null
;
bytes
[
i
]
=
(
byte
)
(
int
)
(
l
&
0xFF
);
}
l
=
Integer
.
parseInt
(
elements
[
2
]);
if
((
l
<
0L
)
||
(
l
>
65535L
))
return
null
;
bytes
[
2
]
=
(
byte
)
(
int
)
(
l
>>
8
&
0xFF
);
bytes
[
3
]
=
(
byte
)
(
int
)
(
l
&
0xFF
);
break
;
case
4
:
for
(
i
=
0
;
i
<
4
;
++
i
)
{
l
=
Integer
.
parseInt
(
elements
[
i
]);
if
((
l
<
0L
)
||
(
l
>
255L
))
return
null
;
bytes
[
i
]
=
(
byte
)
(
int
)
(
l
&
0xFF
);
}
break
;
default
:
return
null
;
}
}
catch
(
NumberFormatException
e
)
{
return
null
;
}
return
bytes
;
}
public
static
boolean
internalIp
(
String
ip
)
{
byte
[]
addr
=
textToNumericFormatV4
(
ip
);
return
internalIp
(
addr
)
||
"127.0.0.1"
.
equals
(
ip
);
}
private
static
boolean
internalIp
(
byte
[]
addr
)
{
if
(
StrUtil
.
isEmptyIfStr
(
addr
)
||
addr
.
length
<
2
)
{
return
true
;
}
final
byte
b0
=
addr
[
0
];
final
byte
b1
=
addr
[
1
];
// 10.x.x.x/8
final
byte
SECTION_1
=
0x0A
;
// 172.16.x.x/12
final
byte
SECTION_2
=
(
byte
)
0xAC
;
final
byte
SECTION_3
=
(
byte
)
0x10
;
final
byte
SECTION_4
=
(
byte
)
0x1F
;
// 192.168.x.x/16
final
byte
SECTION_5
=
(
byte
)
0xC0
;
final
byte
SECTION_6
=
(
byte
)
0xA8
;
switch
(
b0
)
{
case
SECTION_1:
return
true
;
case
SECTION_2:
if
(
b1
>=
SECTION_3
&&
b1
<=
SECTION_4
)
{
return
true
;
}
case
SECTION_5:
switch
(
b1
)
{
case
SECTION_6:
return
true
;
}
default
:
return
false
;
}
}
public
static
String
getMACAddress
(
String
ip
)
throws
Exception
{
...
...
src/main/resources/mapping/qyzx/QyzxOperLogMapper.xml
0 → 100644
View file @
d87bf527
This diff is collapsed.
Click to expand it.
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