Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
d7a8f77c
Commit
d7a8f77c
authored
Nov 30, 2020
by
周健威
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev-chw' into dev-chw
parents
10fc4c07
742aa3f8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
335 additions
and
11 deletions
+335
-11
HttpContextUtils.java
...github/wxiaoqi/security/common/util/HttpContextUtils.java
+14
-0
IPUtils.java
...java/com/github/wxiaoqi/security/common/util/IPUtils.java
+27
-0
SysLog.java
...rc/main/java/com/xxfc/platform/vehicle/entity/SysLog.java
+92
-0
GlobalLog.java
...rc/main/java/com/xxfc/platform/vehicle/aop/GlobalLog.java
+13
-0
LogAspect.java
...rc/main/java/com/xxfc/platform/vehicle/aop/LogAspect.java
+101
-0
SysLogBiz.java
...rc/main/java/com/xxfc/platform/vehicle/biz/SysLogBiz.java
+56
-0
VehicleApplyBiz.java
...n/java/com/xxfc/platform/vehicle/biz/VehicleApplyBiz.java
+18
-11
SysLogMapper.java
...n/java/com/xxfc/platform/vehicle/mapper/SysLogMapper.java
+10
-0
AppVehicleController.java
.../com/xxfc/platform/vehicle/rest/AppVehicleController.java
+2
-0
AdminVehicleController.java
...c/platform/vehicle/rest/admin/AdminVehicleController.java
+2
-0
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/HttpContextUtils.java
0 → 100644
View file @
d7a8f77c
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
public
class
HttpContextUtils
{
public
static
HttpServletRequest
getHttpServletRequest
()
{
return
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/IPUtils.java
0 → 100644
View file @
d7a8f77c
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
;
import
javax.servlet.http.HttpServletRequest
;
public
class
IPUtils
{
/**
* 获取IP地址
*
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
*/
public
static
String
getIpAddr
(
HttpServletRequest
request
)
{
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
}
return
"0:0:0:0:0:0:0:1"
.
equals
(
ip
)
?
"127.0.0.1"
:
ip
;
}
}
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/entity/SysLog.java
0 → 100644
View file @
d7a8f77c
package
com
.
xxfc
.
platform
.
vehicle
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
/**
* @author hezhen
* @email 939961241@qq.com
* @date 2017-08-15 08:03:41
*/
@Data
@Table
(
name
=
"sys_log"
)
public
class
SysLog
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
(
generator
=
"JDBC"
)
@ApiModelProperty
(
"主键"
)
private
Long
id
;
@Column
(
name
=
"vehicle_id"
)
@ApiModelProperty
(
"商品id"
)
private
String
vehicleId
;
@Column
(
name
=
"comapny_id"
)
@ApiModelProperty
(
"公司id"
)
private
Integer
comapnyId
;
@Column
(
name
=
"type"
)
@ApiModelProperty
(
"操作类型:1-商家;2-运营平台;3-特惠"
)
private
Integer
type
;
@Column
(
name
=
"operate_type"
)
@ApiModelProperty
(
"操作类型:1-上架;2-下架"
)
private
Integer
operateType
;
@Column
(
name
=
"operation"
)
@ApiModelProperty
(
"描述"
)
private
String
operation
;
@Column
(
name
=
"time"
)
@ApiModelProperty
(
"操作时间"
)
private
Long
time
;
@Column
(
name
=
"method"
)
@ApiModelProperty
(
"方法"
)
private
String
method
;
@Column
(
name
=
"params"
)
@ApiModelProperty
(
"参数"
)
private
String
params
;
@Column
(
name
=
"ip"
)
@ApiModelProperty
(
"Ip"
)
private
String
ip
;
@Column
(
name
=
"crt_user"
)
@ApiModelProperty
(
"用户id"
)
private
String
crtUser
;
@Column
(
name
=
"crt_time"
)
@ApiModelProperty
(
"创建时间"
)
private
Long
crtTime
;
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/aop/GlobalLog.java
0 → 100644
View file @
d7a8f77c
package
com
.
xxfc
.
platform
.
vehicle
.
aop
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
METHOD
)
public
@interface
GlobalLog
{
int
type
()
default
0
;
String
value
()
default
""
;
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/aop/LogAspect.java
0 → 100644
View file @
d7a8f77c
package
com
.
xxfc
.
platform
.
vehicle
.
aop
;
import
com.github.wxiaoqi.security.common.util.HttpContextUtils
;
import
com.github.wxiaoqi.security.common.util.IPUtils
;
import
com.xxfc.platform.vehicle.biz.SysLogBiz
;
import
com.xxfc.platform.vehicle.entity.SysLog
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
import
com.xxfc.platform.vehicle.entity.VehicleApply
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.LocalVariableTableParameterNameDiscoverer
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
@Aspect
@Component
public
class
LogAspect
{
@Autowired
SysLogBiz
sysLogBiz
;
@Pointcut
(
"@annotation(com.xxfc.platform.vehicle.aop.GlobalLog)"
)
public
void
pointcut
()
{
}
@Around
(
"pointcut()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
{
Object
result
=
null
;
long
beginTime
=
System
.
currentTimeMillis
();
try
{
// 执行方法
result
=
point
.
proceed
();
// 执行时长(毫秒)
long
time
=
System
.
currentTimeMillis
()
-
beginTime
;
// 保存日志
saveLog
(
point
,
time
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
private
void
saveLog
(
ProceedingJoinPoint
joinPoint
,
long
time
)
{
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
Method
method
=
signature
.
getMethod
();
SysLog
sysLog
=
new
SysLog
();
GlobalLog
logAnnotation
=
method
.
getAnnotation
(
GlobalLog
.
class
);
if
(
logAnnotation
!=
null
)
{
// 注解上的描述
sysLog
.
setOperation
(
logAnnotation
.
value
());
sysLog
.
setType
(
logAnnotation
.
type
());
}
// 请求的方法名
String
className
=
joinPoint
.
getTarget
().
getClass
().
getName
();
String
methodName
=
signature
.
getName
();
sysLog
.
setMethod
(
className
+
"."
+
methodName
+
"()"
);
// 请求的方法参数值
Object
[]
args
=
joinPoint
.
getArgs
();
// 请求的方法参数名称
LocalVariableTableParameterNameDiscoverer
u
=
new
LocalVariableTableParameterNameDiscoverer
();
String
[]
paramNames
=
u
.
getParameterNames
(
method
);
if
(
args
!=
null
&&
paramNames
!=
null
)
{
String
vehicleId
=
null
;
String
params
=
""
;
Integer
state
=
0
;
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
params
+=
" "
+
paramNames
[
i
]
+
": "
+
args
[
i
];
if
(
paramNames
[
i
].
contains
(
"vehicle"
)){
Vehicle
vehicle
=
(
Vehicle
)
args
[
i
];
vehicleId
=
vehicle
.
getId
();
state
=
vehicle
.
getState
();
}
else
if
(
paramNames
[
i
].
contains
(
"vehicleApply"
)){
VehicleApply
vehicleApply
=
(
VehicleApply
)
args
[
i
];
vehicleId
=
vehicleApply
.
getVehicleId
();
state
=
1
;
}
}
sysLog
.
setParams
(
params
);
sysLog
.
setVehicleId
(
vehicleId
);
sysLog
.
setOperateType
(
state
);
}
// 获取request
HttpServletRequest
request
=
HttpContextUtils
.
getHttpServletRequest
();
// 设置IP地址
sysLog
.
setIp
(
IPUtils
.
getIpAddr
(
request
));
sysLog
.
setTime
(
time
);
// 保存系统日志
sysLogBiz
.
addLog
(
sysLog
);
}
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/SysLogBiz.java
0 → 100644
View file @
d7a8f77c
package
com
.
xxfc
.
platform
.
vehicle
.
biz
;
import
com.github.wxiaoqi.security.common.biz.BaseBiz
;
import
com.github.wxiaoqi.security.common.exception.BaseException
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.vehicle.entity.SysLog
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
import
com.xxfc.platform.vehicle.entity.VehicleUseTime
;
import
com.xxfc.platform.vehicle.mapper.SysLogMapper
;
import
com.xxfc.platform.vehicle.mapper.VehicleUseTimeMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.List
;
@Service
@Slf4j
public
class
SysLogBiz
extends
BaseBiz
<
SysLogMapper
,
SysLog
>
{
@Autowired
VehicleBiz
vehicleBiz
;
public
void
addLog
(
SysLog
sysLog
){
String
vehicleId
=
sysLog
.
getVehicleId
();
if
(
StringUtils
.
isBlank
(
vehicleId
)
){
throw
new
BaseException
(
"参数不能为空"
,
ResultCode
.
FAILED_CODE
);
}
Vehicle
vehicle
=
vehicleBiz
.
selectById
(
vehicleId
);
if
(
vehicle
==
null
){
throw
new
BaseException
(
"商品不存在"
,
ResultCode
.
FAILED_CODE
);
}
sysLog
.
setComapnyId
(
vehicle
.
getManageCompanyId
());
insertSelective
(
sysLog
);
}
}
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleApplyBiz.java
View file @
d7a8f77c
...
@@ -14,6 +14,7 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode;
...
@@ -14,6 +14,7 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.xxfc.platform.universal.dto.SmsTemplateDTO
;
import
com.xxfc.platform.universal.dto.SmsTemplateDTO
;
import
com.xxfc.platform.universal.feign.ThirdFeign
;
import
com.xxfc.platform.universal.feign.ThirdFeign
;
import
com.xxfc.platform.vehicle.aop.GlobalLog
;
import
com.xxfc.platform.vehicle.entity.BranchCompany
;
import
com.xxfc.platform.vehicle.entity.BranchCompany
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
import
com.xxfc.platform.vehicle.entity.VehicleApply
;
import
com.xxfc.platform.vehicle.entity.VehicleApply
;
...
@@ -150,23 +151,29 @@ public class VehicleApplyBiz extends BaseBiz<VehicleApplyMapper, VehicleApply>{
...
@@ -150,23 +151,29 @@ public class VehicleApplyBiz extends BaseBiz<VehicleApplyMapper, VehicleApply>{
if
(
vehicleApply
==
null
){
if
(
vehicleApply
==
null
){
throw
new
BaseException
(
"申请记录不存在"
,
ResultCode
.
FAILED_CODE
);
throw
new
BaseException
(
"申请记录不存在"
,
ResultCode
.
FAILED_CODE
);
}
}
String
vehicleId
=
vehicleBiz
.
addOrUpd
(
vehicleApply
);
String
vehicleId
=
vehicleBiz
.
addOrUpd
(
vehicleApply
);
if
(
StringUtils
.
isNotBlank
(
vehicleId
)){
if
(
StringUtils
.
isNotBlank
(
vehicleId
)){
VehicleApply
vehicleApply1
=
new
VehicleApply
();
vehicleApply
.
setVehicleId
(
vehicleId
);
vehicleApply1
.
setId
(
vehicleApply
.
getId
());
updVehicleApply
(
vehicleApply
);
vehicleApply1
.
setVehicleId
(
vehicleId
);
updateSelectiveById
(
vehicleApply1
);
String
extensionList
=
vehicleApply
.
getExtensionList
();
if
(
StringUtils
.
isNotBlank
(
extensionList
)){
extensionBiz
.
saveOrUpd
(
vehicleId
,
extensionList
);
}
}
}
}
}
sendSms
(
vehicleApply
);
sendSms
(
vehicleApply
);
}
}
@GlobalLog
(
type
=
2
,
value
=
"运营平台审核自动上架"
)
public
void
updVehicleApply
(
VehicleApply
vehicleApply
){
VehicleApply
vehicleApply1
=
new
VehicleApply
();
vehicleApply1
.
setId
(
vehicleApply
.
getId
());
vehicleApply1
.
setVehicleId
(
vehicleApply
.
getVehicleId
());
updateSelectiveById
(
vehicleApply1
);
String
extensionList
=
vehicleApply
.
getExtensionList
();
if
(
StringUtils
.
isNotBlank
(
extensionList
)){
extensionBiz
.
saveOrUpd
(
vehicleApply
.
getVehicleId
(),
extensionList
);
}
}
public
void
sendSms
(
VehicleApply
vehicleApply
){
public
void
sendSms
(
VehicleApply
vehicleApply
){
try
{
try
{
//发送短信通知用户
//发送短信通知用户
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/mapper/SysLogMapper.java
0 → 100644
View file @
d7a8f77c
package
com
.
xxfc
.
platform
.
vehicle
.
mapper
;
import
com.xxfc.platform.vehicle.entity.SysLog
;
import
tk.mybatis.mapper.additional.idlist.SelectByIdListMapper
;
import
tk.mybatis.mapper.common.Mapper
;
public
interface
SysLogMapper
extends
Mapper
<
SysLog
>,
SelectByIdListMapper
<
SysLog
,
Long
>
{
}
\ No newline at end of file
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/AppVehicleController.java
View file @
d7a8f77c
...
@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.rest;
...
@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.rest;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.github.wxiaoqi.security.common.util.process.ResultCode
;
import
com.xxfc.platform.vehicle.aop.GlobalLog
;
import
com.xxfc.platform.vehicle.biz.VehicleApplyBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleApplyBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleBiz
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
...
@@ -56,6 +57,7 @@ public class AppVehicleController extends BaseController<VehicleBiz> {
...
@@ -56,6 +57,7 @@ public class AppVehicleController extends BaseController<VehicleBiz> {
@PostMapping
(
"updVehicle"
)
@PostMapping
(
"updVehicle"
)
@ApiModelProperty
(
"更新商品信息"
)
@ApiModelProperty
(
"更新商品信息"
)
@GlobalLog
(
type
=
1
,
value
=
"商家操作上下架"
)
public
ObjectRestResponse
updVehicle
(
@RequestBody
Vehicle
vehicle
)
{
public
ObjectRestResponse
updVehicle
(
@RequestBody
Vehicle
vehicle
)
{
return
baseBiz
.
updState
(
vehicle
);
return
baseBiz
.
updState
(
vehicle
);
}
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/admin/AdminVehicleController.java
View file @
d7a8f77c
...
@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
...
@@ -5,6 +5,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import
com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface
;
import
com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.vehicle.aop.GlobalLog
;
import
com.xxfc.platform.vehicle.biz.VehicleBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleExtensionBiz
;
import
com.xxfc.platform.vehicle.biz.VehicleExtensionBiz
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
import
com.xxfc.platform.vehicle.entity.Vehicle
;
...
@@ -73,6 +74,7 @@ public class AdminVehicleController extends BaseController<VehicleBiz>{
...
@@ -73,6 +74,7 @@ public class AdminVehicleController extends BaseController<VehicleBiz>{
@PostMapping
(
"/unauth/app/updVehicleFeign"
)
@PostMapping
(
"/unauth/app/updVehicleFeign"
)
@IgnoreUserToken
@IgnoreUserToken
@ApiModelProperty
(
"更新商品信息Feign"
)
@ApiModelProperty
(
"更新商品信息Feign"
)
@GlobalLog
(
type
=
3
,
value
=
"特惠租车上下架商品"
)
public
ObjectRestResponse
updVehicleFeign
(
@RequestBody
Vehicle
vehicle
)
{
public
ObjectRestResponse
updVehicleFeign
(
@RequestBody
Vehicle
vehicle
)
{
baseBiz
.
updateSelectiveById
(
vehicle
);
baseBiz
.
updateSelectiveById
(
vehicle
);
return
ObjectRestResponse
.
succ
();
return
ObjectRestResponse
.
succ
();
...
...
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