Merge pull request 'clay' (#15) from clay into master
Reviewed-on: http://git.feashow.cn/clay/fateverse/pulls/15
This commit is contained in:
@@ -12,11 +12,15 @@
|
||||
<artifactId>common-dubbo</artifactId>
|
||||
|
||||
<properties>
|
||||
<dubbo.version>3.0.3</dubbo.version>
|
||||
<dubbo.version>3.2.0</dubbo.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- Dubbo Nacos registry dependency -->
|
||||
<dependency>
|
||||
<groupId>cn.fateverse</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-registry-nacos</artifactId>
|
||||
@@ -45,6 +49,12 @@
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
<version>${dubbo.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--dubbo sentinel 适配器-->
|
||||
<!-- <dependency>-->
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.fateverse.common.log.service.OperationService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,13 +18,13 @@ import org.springframework.context.annotation.Bean;
|
||||
public class LogAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public LogAspect logAspect(){
|
||||
public LogAspect logAspect() {
|
||||
return new LogAspect();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OperationService operationService(OperationProperties properties) {
|
||||
return new OperationService(properties);
|
||||
public OperationService operationService(OperationProperties properties, Environment environment) {
|
||||
return new OperationService(properties, environment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,12 @@ import com.alibaba.fastjson2.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -35,14 +37,23 @@ public class OperationService {
|
||||
@DubboReference
|
||||
private DubboLogService logService;
|
||||
|
||||
|
||||
private final String applicationName;
|
||||
|
||||
private final OperationProperties properties;
|
||||
|
||||
|
||||
private final List<OperationLog> operationLogListCache;
|
||||
|
||||
public OperationService(OperationProperties properties) {
|
||||
public OperationService(OperationProperties properties, Environment environment) {
|
||||
this.properties = properties;
|
||||
this.operationLogListCache = new ArrayList<>(properties.getCacheSize());
|
||||
String applicationName = environment.getProperty("spring.application.name");
|
||||
if (ObjectUtils.isEmpty(applicationName)) {
|
||||
log.error("applicationName can not be null");
|
||||
throw new RuntimeException("applicationName can not be null");
|
||||
}
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +73,7 @@ public class OperationService {
|
||||
@Async
|
||||
public void asyncExecute(OperationLog operationLog, Object jsonResult, Throwable e, Long time) {
|
||||
operationLog.setState(BusinessState.SUCCESS.ordinal());
|
||||
operationLog.setApplicationName(applicationName);
|
||||
// 返回参数
|
||||
if (jsonResult instanceof Result) {
|
||||
Result<Object> result = (Result<Object>) jsonResult;
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.seata</groupId>
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--Token生成与解析-->
|
||||
<dependency>
|
||||
|
||||
@@ -27,6 +27,12 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Sentinel Gateway -->
|
||||
<dependency>
|
||||
|
||||
@@ -27,6 +27,11 @@ public class OperationLog implements Serializable {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 应用名称
|
||||
*/
|
||||
private String applicationName;
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.fateverse.log.query;
|
||||
|
||||
import cn.fateverse.common.core.entity.QueryTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -12,7 +11,6 @@ import lombok.Data;
|
||||
* @Version: V2.0
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("日志查询实体")
|
||||
public class OperationLogQuery extends QueryTime {
|
||||
|
||||
/**
|
||||
@@ -20,6 +18,8 @@ public class OperationLogQuery extends QueryTime {
|
||||
*/
|
||||
private String title;
|
||||
|
||||
private String applicationName;
|
||||
|
||||
/**
|
||||
* 操作人员
|
||||
*/
|
||||
|
||||
@@ -32,6 +32,8 @@ public class OperationLogVo implements Serializable {
|
||||
*/
|
||||
private String title;
|
||||
|
||||
private String applicationName;
|
||||
|
||||
/**
|
||||
* 业务类型(0其它 1新增 2修改 3删除)
|
||||
*/
|
||||
@@ -111,6 +113,7 @@ public class OperationLogVo implements Serializable {
|
||||
public static OperationLogVo toOperationLogVo(OperationLog operationLog) {
|
||||
return OperationLogVo.builder()
|
||||
.operId(operationLog.getOperId())
|
||||
.applicationName(operationLog.getApplicationName())
|
||||
.title(operationLog.getTitle())
|
||||
.businessType(operationLog.getBusinessType())
|
||||
.method(operationLog.getMethod())
|
||||
|
||||
@@ -2,12 +2,9 @@ package cn.fateverse.log.controller;
|
||||
|
||||
import cn.fateverse.common.core.result.Result;
|
||||
import cn.fateverse.common.core.result.page.TableDataInfo;
|
||||
import cn.fateverse.common.security.annotation.Anonymity;
|
||||
import cn.fateverse.log.query.OperationLogQuery;
|
||||
import cn.fateverse.log.service.OperationService;
|
||||
import cn.fateverse.log.vo.OperationLogVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -19,7 +16,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @author Clay
|
||||
* @date 2022/11/1
|
||||
*/
|
||||
@Api(tags = "操作日志管理")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/log")
|
||||
@@ -31,13 +27,7 @@ public class OperationLogController {
|
||||
this.operationService = operationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operationLogQuery
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Anonymity
|
||||
@ApiOperation("查询日志信息")
|
||||
@PreAuthorize("@ss.hasPermission('admin:log:list')")
|
||||
public Result<TableDataInfo<OperationLogVo>> SearchLog(OperationLogQuery operationLogQuery) {
|
||||
TableDataInfo<OperationLogVo> dataTable = operationService.search(operationLogQuery);
|
||||
@@ -45,7 +35,6 @@ public class OperationLogController {
|
||||
}
|
||||
|
||||
@GetMapping("/{operId}")
|
||||
@ApiOperation("查询日志信息")
|
||||
@PreAuthorize("@ss.hasPermission('admin:log:list')")
|
||||
public Result<OperationLogVo> SearchLog(@PathVariable Long operId) {
|
||||
OperationLogVo operationLogVo = operationService.select(operId);
|
||||
@@ -53,7 +42,6 @@ public class OperationLogController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/{operIds}")
|
||||
@ApiOperation("操作日志删除")
|
||||
@PreAuthorize("@ss.hasPermission('admin:log:del')")
|
||||
public Result<Integer> OperationInfoRemove(@PathVariable Long[] operIds) {
|
||||
if (operIds.length == 0) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<resultMap type="cn.fateverse.log.entity.OperationLog" id="OperationLogResult">
|
||||
<id property="operId" column="oper_id"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="applicationName" column="application_name"/>
|
||||
<result property="businessType" column="business_type"/>
|
||||
<result property="method" column="method"/>
|
||||
<result property="requestMethod" column="request_method"/>
|
||||
@@ -24,15 +25,35 @@
|
||||
<result property="consumeTime" column="consume_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSql">
|
||||
select oper_id,
|
||||
title,
|
||||
application_name,
|
||||
business_type,
|
||||
method,
|
||||
request_method,
|
||||
operator_type,
|
||||
oper_name,
|
||||
dept_name,
|
||||
oper_url,
|
||||
oper_ip,
|
||||
oper_location,
|
||||
state,
|
||||
oper_time,
|
||||
consume_time
|
||||
from sys_operation_log
|
||||
</sql>
|
||||
|
||||
|
||||
<insert id="batchSave">
|
||||
insert into sys_operation_log
|
||||
(oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip,
|
||||
(oper_id, title, application_name, business_type, method, request_method, operator_type, oper_name, dept_name,
|
||||
oper_url, oper_ip,
|
||||
oper_location, oper_param, json_result, state, error_msg, error_stack_trace, oper_time, consume_time)
|
||||
values
|
||||
<foreach collection="list" item="log" separator=",">
|
||||
(#{log.operId}, #{log.title}, #{log.businessType}, #{log.method}, #{log.requestMethod}, #{log.operatorType},
|
||||
#{log.operName},
|
||||
(#{log.operId}, #{log.title}, #{log.applicationName}, #{log.businessType}, #{log.method},
|
||||
#{log.requestMethod}, #{log.operatorType},#{log.operName},
|
||||
#{log.deptName}, #{log.operUrl}, #{log.operIp}, #{log.operLocation}, #{log.operParam}, #{log.jsonResult},
|
||||
#{log.state}, #{log.errorMsg},
|
||||
#{log.errorStackTrace}, #{log.operTime}, #{log.consumeTime})
|
||||
@@ -41,15 +62,16 @@
|
||||
|
||||
<select id="searchSubQuery" resultMap="OperationLogResult"
|
||||
parameterType="cn.fateverse.log.query.OperationLogQuery">
|
||||
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url,
|
||||
oper_ip, oper_location, state, oper_time, consume_time
|
||||
from sys_operation_log
|
||||
<include refid="selectSql"/>
|
||||
<where>
|
||||
oper_id >= (select oper_id from sys_operation_log
|
||||
<where>
|
||||
<if test="operation.title !=null and operation.title !=''">
|
||||
and title like concat('%',#{operation.title},'%')
|
||||
</if>
|
||||
<if test="operation.applicationName !=null and operation.applicationName !=''">
|
||||
and application_name like concat('%',#{operation.applicationName},'%')
|
||||
</if>
|
||||
<if test="operation.operName !=null and operation.operName !=''">
|
||||
and oper_name like concat('%',#{operation.operName},'%')
|
||||
</if>
|
||||
@@ -71,6 +93,9 @@
|
||||
<if test="operation.title !=null and operation.title !=''">
|
||||
and title like concat('%',#{operation.title},'%')
|
||||
</if>
|
||||
<if test="operation.applicationName !=null and operation.applicationName !=''">
|
||||
and application_name like concat('%',#{operation.applicationName},'%')
|
||||
</if>
|
||||
<if test="operation.operName !=null and operation.operName !=''">
|
||||
and oper_name like concat('%',#{operation.operName},'%')
|
||||
</if>
|
||||
@@ -93,13 +118,14 @@
|
||||
|
||||
<select id="search" resultMap="OperationLogResult"
|
||||
parameterType="cn.fateverse.log.query.OperationLogQuery">
|
||||
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url,
|
||||
oper_ip, oper_location, state, oper_time, consume_time
|
||||
from sys_operation_log
|
||||
<include refid="selectSql"/>
|
||||
<where>
|
||||
<if test="operation.title !=null and operation.title !=''">
|
||||
and title like concat('%',#{operation.title},'%')
|
||||
</if>
|
||||
<if test="operation.applicationName !=null and operation.applicationName !=''">
|
||||
and application_name like concat('%',#{operation.applicationName},'%')
|
||||
</if>
|
||||
<if test="operation.operName !=null and operation.operName !=''">
|
||||
and oper_name like concat('%',#{operation.operName},'%')
|
||||
</if>
|
||||
@@ -125,6 +151,9 @@
|
||||
<if test="operation.title !=null and operation.title !=''">
|
||||
and title like concat('%',#{operation.title},'%')
|
||||
</if>
|
||||
<if test="operation.applicationName !=null and operation.applicationName !=''">
|
||||
and application_name like concat('%',#{operation.applicationName},'%')
|
||||
</if>
|
||||
<if test="operation.operName !=null and operation.operName !=''">
|
||||
and oper_name like concat('%',#{operation.operName},'%')
|
||||
</if>
|
||||
@@ -153,6 +182,7 @@
|
||||
<select id="selectById" resultMap="OperationLogResult">
|
||||
select oper_id,
|
||||
title,
|
||||
application_name,
|
||||
business_type,
|
||||
method,
|
||||
request_method,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.fateverse.workflow.entity.dto;
|
||||
|
||||
import cn.fateverse.workflow.entity.ProcessListener;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
Reference in New Issue
Block a user