Browse Source

[Improvement][Audit] Change time to create_time (#15846)

* change time to create_time

* update

* update
3.2.2-release-bak
旺阳 8 months ago committed by GitHub
parent
commit
f99d3f1ed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/OperatorUtils.java
  2. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/AuditDto.java
  3. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AuditServiceImpl.java
  4. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AuditLog.java
  5. 8
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AuditLogMapper.xml
  6. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  7. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  8. 2
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
  9. 2
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/mysql/dolphinscheduler_ddl.sql
  10. 19
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/postgresql/dolphinscheduler_ddl.sql
  11. 2
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AuditLogMapperTest.java
  12. 2
      dolphinscheduler-ui/src/views/monitor/statistics/audit-log/use-table.ts

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/OperatorUtils.java

@ -65,7 +65,7 @@ public class OperatorUtils {
auditLog.setModelType(auditType.getAuditModelType().getName());
auditLog.setOperationType(auditType.getAuditOperationType().getName());
auditLog.setDescription(apiDescription);
auditLog.setTime(new Date());
auditLog.setCreateTime(new Date());
auditLogList.add(auditLog);
return auditLogList;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/AuditDto.java

@ -34,7 +34,7 @@ public class AuditDto {
private String operation;
private Date time;
private Date createTime;
private String description;

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AuditServiceImpl.java

@ -129,7 +129,7 @@ public class AuditServiceImpl extends BaseServiceImpl implements AuditService {
auditDto.setLatency(String.valueOf(auditLog.getLatency()));
auditDto.setDetail(auditLog.getDetail());
auditDto.setDescription(auditLog.getDescription());
auditDto.setTime(auditLog.getTime());
auditDto.setCreateTime(auditLog.getCreateTime());
return auditDto;
}
}

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AuditLog.java

@ -67,7 +67,7 @@ public class AuditLog {
/**
* operation time
*/
private Date time;
private Date createTime;
private String detail;

8
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AuditLogMapper.xml

@ -19,10 +19,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.AuditLogMapper">
<sql id="baseSql">
id, user_id, model_type, operation_type, model_id, model_name, time, detail, description, latency
id, user_id, model_type, operation_type, model_id, model_name, create_time, detail, description, latency
</sql>
<sql id="baseSqlV2">
${alias}.id, ${alias}.user_id, ${alias}.model_type, ${alias}.operation_type, ${alias}.model_id, ${alias}.model_name, ${alias}.time, ${alias}.detail, ${alias}.description, ${alias}.latency
${alias}.id, ${alias}.user_id, ${alias}.model_type, ${alias}.operation_type, ${alias}.model_id, ${alias}.model_name, ${alias}.create_time, ${alias}.detail, ${alias}.description, ${alias}.latency
</sql>
<select id="queryAuditLog" resultType="org.apache.dolphinscheduler.dao.entity.AuditLog">
@ -36,7 +36,7 @@
join t_ds_user u on log.user_id = u.id
where 1 = 1
<if test="startDate != null">
and log.time > #{startDate} and log.time <![CDATA[ <=]]> #{endDate}
and log.create_time > #{startDate} and log.create_time <![CDATA[ <=]]> #{endDate}
</if>
<if test="modelTypeList != null and modelTypeList.size() > 0">
and log.model_type in
@ -56,7 +56,7 @@
<if test="modelName != null and modelName != ''">
and log.model_name like concat ('%', #{modelName}, '%')
</if>
order by log.time desc
order by log.create_time desc
</select>
</mapper>

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

@ -2027,7 +2027,7 @@ CREATE TABLE t_ds_audit_log
description varchar(255) NOT NULL,
latency int(11) NOT NULL,
detail varchar(255) DEFAULT NULL,
time timestamp NULL DEFAULT CURRENT_TIMESTAMP,
create_time timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

@ -2016,7 +2016,7 @@ CREATE TABLE `t_ds_audit_log` (
`description` varchar(100) DEFAULT NULL COMMENT 'api description',
`latency` int(11) DEFAULT NULL COMMENT 'api cost milliseconds',
`detail` varchar(100) DEFAULT NULL COMMENT 'object change detail',
`time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'operation time',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'operation time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT= 1 DEFAULT CHARSET=utf8 COLLATE = utf8_bin;

2
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

@ -2001,7 +2001,7 @@ CREATE TABLE t_ds_audit_log (
description VARCHAR(255) NOT NULL,
latency int NOT NULL,
detail VARCHAR(255) DEFAULT NULL,
time timestamp DEFAULT NULL ,
create_time timestamp DEFAULT NULL ,
PRIMARY KEY (id)
);

2
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/mysql/dolphinscheduler_ddl.sql

@ -47,7 +47,7 @@ drop resource_type, drop operation, drop resource_id,
add `description` varchar(100) DEFAULT NULL COMMENT 'api description',
add `latency` int(11) DEFAULT NULL COMMENT 'api cost milliseconds',
add `detail` varchar(100) DEFAULT NULL COMMENT 'object change detail',
MODIFY COLUMN `time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT "operation time";
CHANGE COLUMN `time` `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT "operation time";
END IF;
END;
d//

19
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/postgresql/dolphinscheduler_ddl.sql

@ -40,15 +40,16 @@ BEGIN
WHERE table_name = 't_ds_audit_log'
AND column_name = 'resource_type')
THEN
ALTER TABLE t_ds_audit_log
drop resource_type, drop operation, drop resource_id,
add model_id bigint NOT NULL,
add model_name VARCHAR(255) NOT NULL,
add model_type VARCHAR(255) NOT NULL,
add operation_type VARCHAR(255) NOT NULL,
add description VARCHAR(255) NOT NULL,
add latency int NOT NULL,
add detail VARCHAR(255) DEFAULT NULL;
ALTER TABLE t_ds_audit_log
drop resource_type, drop operation, drop resource_id,
add model_id bigint NOT NULL,
add model_name VARCHAR(255) NOT NULL,
add model_type VARCHAR(255) NOT NULL,
add operation_type VARCHAR(255) NOT NULL,
add description VARCHAR(255) NOT NULL,
add latency int NOT NULL,
add detail VARCHAR(255) DEFAULT NULL;
ALTER TABLE t_ds_audit_log RENAME COLUMN "time" TO "create_time";
END IF;
END;
$$ LANGUAGE plpgsql;

2
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AuditLogMapperTest.java

@ -49,7 +49,7 @@ public class AuditLogMapperTest extends BaseDaoTest {
auditLog.setModelName("name");
auditLog.setDetail("detail");
auditLog.setLatency(1L);
auditLog.setTime(new Date());
auditLog.setCreateTime(new Date());
auditLog.setModelType(objectType.getName());
auditLog.setOperationType(AuditOperationType.CREATE.getName());
auditLog.setModelId(1L);

2
dolphinscheduler-ui/src/views/monitor/statistics/audit-log/use-table.ts

@ -98,7 +98,7 @@ export function useTable() {
},
{
title: t('monitor.audit_log.create_time'),
key: 'time',
key: 'createTime',
...COLUMN_WIDTH_CONFIG['time']
}
]

Loading…
Cancel
Save