refactor(操作日志): 操作日志和操作资源的关系解耦

This commit is contained in:
fit2-zhao 2022-01-25 18:43:22 +08:00 committed by fit2-zhao
parent 257420dadf
commit 89fd47bace
10 changed files with 754 additions and 71 deletions

View File

@ -0,0 +1,15 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class OperatingLogResource implements Serializable {
private String id;
private String operatingLogId;
private String sourceId;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,410 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class OperatingLogResourceExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public OperatingLogResourceExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andOperatingLogIdIsNull() {
addCriterion("operating_log_id is null");
return (Criteria) this;
}
public Criteria andOperatingLogIdIsNotNull() {
addCriterion("operating_log_id is not null");
return (Criteria) this;
}
public Criteria andOperatingLogIdEqualTo(String value) {
addCriterion("operating_log_id =", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdNotEqualTo(String value) {
addCriterion("operating_log_id <>", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdGreaterThan(String value) {
addCriterion("operating_log_id >", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdGreaterThanOrEqualTo(String value) {
addCriterion("operating_log_id >=", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdLessThan(String value) {
addCriterion("operating_log_id <", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdLessThanOrEqualTo(String value) {
addCriterion("operating_log_id <=", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdLike(String value) {
addCriterion("operating_log_id like", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdNotLike(String value) {
addCriterion("operating_log_id not like", value, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdIn(List<String> values) {
addCriterion("operating_log_id in", values, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdNotIn(List<String> values) {
addCriterion("operating_log_id not in", values, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdBetween(String value1, String value2) {
addCriterion("operating_log_id between", value1, value2, "operatingLogId");
return (Criteria) this;
}
public Criteria andOperatingLogIdNotBetween(String value1, String value2) {
addCriterion("operating_log_id not between", value1, value2, "operatingLogId");
return (Criteria) this;
}
public Criteria andSourceIdIsNull() {
addCriterion("source_id is null");
return (Criteria) this;
}
public Criteria andSourceIdIsNotNull() {
addCriterion("source_id is not null");
return (Criteria) this;
}
public Criteria andSourceIdEqualTo(String value) {
addCriterion("source_id =", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdNotEqualTo(String value) {
addCriterion("source_id <>", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdGreaterThan(String value) {
addCriterion("source_id >", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdGreaterThanOrEqualTo(String value) {
addCriterion("source_id >=", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdLessThan(String value) {
addCriterion("source_id <", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdLessThanOrEqualTo(String value) {
addCriterion("source_id <=", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdLike(String value) {
addCriterion("source_id like", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdNotLike(String value) {
addCriterion("source_id not like", value, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdIn(List<String> values) {
addCriterion("source_id in", values, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdNotIn(List<String> values) {
addCriterion("source_id not in", values, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdBetween(String value1, String value2) {
addCriterion("source_id between", value1, value2, "sourceId");
return (Criteria) this;
}
public Criteria andSourceIdNotBetween(String value1, String value2) {
addCriterion("source_id not between", value1, value2, "sourceId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,31 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.OperatingLogResource;
import io.metersphere.base.domain.OperatingLogResourceExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface OperatingLogResourceMapper {
long countByExample(OperatingLogResourceExample example);
int deleteByExample(OperatingLogResourceExample example);
int deleteByPrimaryKey(String id);
int insert(OperatingLogResource record);
int insertSelective(OperatingLogResource record);
List<OperatingLogResource> selectByExample(OperatingLogResourceExample example);
OperatingLogResource selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") OperatingLogResource record, @Param("example") OperatingLogResourceExample example);
int updateByExample(@Param("record") OperatingLogResource record, @Param("example") OperatingLogResourceExample example);
int updateByPrimaryKeySelective(OperatingLogResource record);
int updateByPrimaryKey(OperatingLogResource record);
}

View File

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.OperatingLogResourceMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.OperatingLogResource">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="operating_log_id" jdbcType="VARCHAR" property="operatingLogId" />
<result column="source_id" jdbcType="VARCHAR" property="sourceId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, operating_log_id, source_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.OperatingLogResourceExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from operating_log_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from operating_log_resource
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from operating_log_resource
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.OperatingLogResourceExample">
delete from operating_log_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.OperatingLogResource">
insert into operating_log_resource (id, operating_log_id, source_id
)
values (#{id,jdbcType=VARCHAR}, #{operatingLogId,jdbcType=VARCHAR}, #{sourceId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.OperatingLogResource">
insert into operating_log_resource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="operatingLogId != null">
operating_log_id,
</if>
<if test="sourceId != null">
source_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="operatingLogId != null">
#{operatingLogId,jdbcType=VARCHAR},
</if>
<if test="sourceId != null">
#{sourceId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.OperatingLogResourceExample" resultType="java.lang.Long">
select count(*) from operating_log_resource
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update operating_log_resource
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.operatingLogId != null">
operating_log_id = #{record.operatingLogId,jdbcType=VARCHAR},
</if>
<if test="record.sourceId != null">
source_id = #{record.sourceId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update operating_log_resource
set id = #{record.id,jdbcType=VARCHAR},
operating_log_id = #{record.operatingLogId,jdbcType=VARCHAR},
source_id = #{record.sourceId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.OperatingLogResource">
update operating_log_resource
<set>
<if test="operatingLogId != null">
operating_log_id = #{operatingLogId,jdbcType=VARCHAR},
</if>
<if test="sourceId != null">
source_id = #{sourceId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.OperatingLogResource">
update operating_log_resource
set operating_log_id = #{operatingLogId,jdbcType=VARCHAR},
source_id = #{sourceId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -7,7 +7,7 @@
t.id,
t.project_id,
t.oper_user,
t.source_id,
t3.source_id,
t.oper_type,
t.oper_module,
t.oper_title,
@ -19,6 +19,7 @@
LEFT JOIN `user` t1 ON t.oper_user = t1.id
LEFT JOIN project t2 ON t.project_id = t2.id
LEFT JOIN workspace w on t2.workspace_id = w.id
INNER JOIN operating_log_resource t3 ON t.id = t3.operating_log_id
<where>
(
<if test="request.projectIds != null and request.projectIds.size > 0 ">
@ -53,6 +54,8 @@
<select id="findBySourceId" resultType="io.metersphere.log.vo.OperatingLogDTO">
SELECT tt.*, t1.NAME userName,t2.`name` projectName
from (
SELECT
t.id,
t.project_id,
@ -62,27 +65,20 @@
t.oper_module,
t.oper_title,
t.oper_time,
t.oper_content,
t1.NAME userName,
t2.`name` projectName
t.oper_content
FROM
operating_log t
LEFT JOIN `user` t1 ON t.oper_user = t1.id
LEFT JOIN project t2 ON t.project_id = t2.id
LEFT JOIN workspace w on t2.workspace_id = w.id
INNER JOIN operating_log_resource t3 ON t.id = t3.operating_log_id
<where>
t.oper_type in ('UPDATE','BATCH_UPDATE')
<if test="request.modules != null and request.modules.size > 0 ">
and t.oper_module in
<foreach collection="request.modules" item="module" separator="," open="(" close=")">
#{module}
</foreach>
</if>
and t.oper_content is not null
<if test="request.sourceId != null and request.sourceId != ''">
and t.source_id like #{request.sourceId, jdbcType=VARCHAR}
and t3.source_id = #{request.sourceId, jdbcType=VARCHAR}
</if>
</where>
order by t.oper_time desc
order by t.oper_time desc limit 100
)tt
LEFT JOIN `user` t1 ON tt.oper_user = t1.id
LEFT JOIN project t2 ON tt.project_id = t2.id
</select>
</mapper>

View File

@ -78,7 +78,6 @@ public class MsLogAspect {
Object[] args = joinPoint.getArgs();
MsAuditLog msLog = method.getAnnotation(MsAuditLog.class);
if (msLog != null && StringUtils.isNotEmpty(msLog.beforeEvent())) {
// 操作内容
//获取方法参数名
String[] params = discoverer.getParameterNames(method);
//将参数纳入Spring管理
@ -107,7 +106,7 @@ public class MsLogAspect {
}
}
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error("操作日志写入异常:" + joinPoint.getSignature());
}
}
@ -256,17 +255,14 @@ public class MsLogAspect {
}
String path = request.getServletPath();
if (StringUtils.isNotEmpty(msOperLog.getSourceId()) && msOperLog.getSourceId().length() > 6000) {
msOperLog.setSourceId(msOperLog.getSourceId().substring(0, 5999));
}
if (StringUtils.isNotEmpty(msOperLog.getOperTitle()) && msOperLog.getOperTitle().length() > 6000) {
msOperLog.setOperTitle(msOperLog.getOperTitle().substring(0, 5999));
}
msOperLog.setOperPath(path);
operatingLogService.create(msOperLog);
operatingLogService.create(msOperLog, msOperLog.getSourceId());
}
} catch (Exception e) {
LogUtil.error(e);
LogUtil.error("操作日志写入异常:" + joinPoint.getSignature());
}
}
}

View File

@ -2,6 +2,7 @@ package io.metersphere.log.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.OperatingLogWithBLOBs;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.log.service.OperatingLogService;
@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
@RestController
@RequestMapping(value = "/operating/log")
@ -35,4 +37,11 @@ public class OperatingLogController {
return operatingLogService.findBySourceId(request);
}
@PostMapping("/save")
public void save(@RequestBody OperatingLogWithBLOBs msOperLog) {
//保存获取的操作
msOperLog.setId(UUID.randomUUID().toString());
String sourceIds = msOperLog.getSourceId();
operatingLogService.create(msOperLog, sourceIds);
}
}

View File

@ -1,8 +1,10 @@
package io.metersphere.log.service;
import com.alibaba.fastjson.JSON;
import io.metersphere.base.domain.OperatingLogResource;
import io.metersphere.base.domain.OperatingLogWithBLOBs;
import io.metersphere.base.mapper.OperatingLogMapper;
import io.metersphere.base.mapper.OperatingLogResourceMapper;
import io.metersphere.base.mapper.ext.ExtOperatingLogMapper;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.log.vo.OperatingLogDTO;
@ -10,12 +12,17 @@ import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.OperatingLogRequest;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Service
@Transactional(rollbackFor = Exception.class)
@ -24,9 +31,36 @@ public class OperatingLogService {
private OperatingLogMapper operatingLogMapper;
@Resource
private ExtOperatingLogMapper extOperatingLogMapper;
@Resource
private SqlSessionFactory sqlSessionFactory;
public void create(OperatingLogWithBLOBs log) {
public void create(OperatingLogWithBLOBs log, String sourceIds) {
log.setSourceId("");
operatingLogMapper.insert(log);
System.out.println(JSON.toJSONString(log));
if (StringUtils.isNotEmpty(sourceIds)) {
List<String> ids = new ArrayList<>();
if (sourceIds.startsWith("[")) {
ids = JSON.parseObject(sourceIds, List.class);
} else {
ids.add(sourceIds.replace("\"", ""));
}
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
OperatingLogResourceMapper batchMapper = sqlSession.getMapper(OperatingLogResourceMapper.class);
if (CollectionUtils.isNotEmpty(ids)) {
ids.forEach(item -> {
OperatingLogResource resource = new OperatingLogResource();
resource.setId(UUID.randomUUID().toString());
resource.setOperatingLogId(log.getId());
resource.setSourceId(item);
batchMapper.insert(resource);
});
sqlSession.flushStatements();
if (sqlSession != null && sqlSessionFactory != null) {
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
}
}
}
}
public List<OperatingLogDTO> list(OperatingLogRequest request) {
@ -48,7 +82,6 @@ public class OperatingLogService {
}
public List<OperatingLogDTO> findBySourceId(OperatingLogRequest request) {
request.setSourceId("%" + request.getSourceId() + "%");
List<OperatingLogDTO> logWithBLOBs = extOperatingLogMapper.findBySourceId(request);
List<OperatingLogDTO> dtos = new ArrayList<>();
if (CollectionUtils.isNotEmpty(logWithBLOBs)) {

View File

@ -0,0 +1,11 @@
ALTER TABLE `operating_log` ADD INDEX oper_time_index ( `oper_time` );
CREATE TABLE `operating_log_resource`
(
`id` varchar(50) NOT NULL COMMENT 'ID',
`operating_log_id` varchar(50) NOT NULL COMMENT 'Operating log ID',
`source_id` varchar(50) NOT NULL COMMENT 'operating source id',
PRIMARY KEY (`id`),
KEY `operating_log_id_index` (`operating_log_id`),
KEY `source_id_index` (`source_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci;

View File

@ -1,5 +1,5 @@
<template>
<div v-loading="result.loading">
<div>
<el-card class="table-card">
<template v-slot:header>
<div style="font-size: 16px;margin-bottom: 20px;margin-left: 10px">
@ -86,7 +86,7 @@
</div>
</template>
<el-table border class="adjust-table" :data="tableData" ref="operLog"
:height="screenHeight">
:height="screenHeight" v-loading="loading">
<el-table-column prop="operTime" :label="$t('operating_log.time')">
<template v-slot:default="scope">
<span>{{ scope.row.operTime | timestampFormatDate }}</span>
@ -159,6 +159,7 @@ export default {
LOG_TYPE_MAP: new LOG_TYPE_MAP(this),
LOG_MODULE_MAP: new LOG_MODULE_MAP(this),
sysList:new SYSLIST(),
loading: false
}
},
mounted() {
@ -269,11 +270,11 @@ export default {
this.condition.operModule = this.condition.operModules[1];
}
let url = "/operating/log/list/" + this.currentPage + "/" + this.pageSize;
this.result.loading = true;
this.loading = true;
this.$post(url, this.condition, response => {
this.tableData = response.data.listObject;
this.total = response.data.itemCount;
this.result.loading = false;
this.loading = false;
})
},