diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLog.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLog.java deleted file mode 100644 index 4559fe9a56..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLog.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.metersphere.system.domain; - -import io.metersphere.validation.groups.*; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; -import java.io.Serializable; -import lombok.Data; - -@Data -public class OperatingLog implements Serializable { - @Schema(title = "ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{operating_log.id.not_blank}", groups = {Updated.class}) - @Size(min = 1, max = 50, message = "{operating_log.id.length_range}", groups = {Created.class, Updated.class}) - private String id; - - @Schema(title = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{operating_log.project_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{operating_log.project_id.length_range}", groups = {Created.class, Updated.class}) - private String projectId; - - @Schema(title = "operating method") - private String operMethod; - - @Schema(title = "创建人") - private String createUser; - - @Schema(title = "操作人") - private String operUser; - - @Schema(title = "资源ID") - private String sourceId; - - @Schema(title = "操作类型") - private String operType; - - @Schema(title = "操作模块") - private String operModule; - - @Schema(title = "操作标题") - private String operTitle; - - @Schema(title = "操作路径") - private String operPath; - - @Schema(title = "操作时间", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "{operating_log.oper_time.not_blank}", groups = {Created.class}) - private Long operTime; - - @Schema(title = "操作内容") - private byte[] operContent; - - @Schema(title = "操作参数") - private byte[] operParams; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogResource.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogResource.java deleted file mode 100644 index cad67a0cf6..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogResource.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.metersphere.system.domain; - -import io.metersphere.validation.groups.*; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; -import java.io.Serializable; -import lombok.Data; - -@Data -public class OperatingLogResource implements Serializable { - @Schema(title = "ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{operating_log_resource.id.not_blank}", groups = {Updated.class}) - @Size(min = 1, max = 50, message = "{operating_log_resource.id.length_range}", groups = {Created.class, Updated.class}) - private String id; - - @Schema(title = "Operating log ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{operating_log_resource.operating_log_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{operating_log_resource.operating_log_id.length_range}", groups = {Created.class, Updated.class}) - private String operatingLogId; - - @Schema(title = "operating source id", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{operating_log_resource.source_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{operating_log_resource.source_id.length_range}", groups = {Created.class, Updated.class}) - private String sourceId; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogResourceExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogResourceExample.java deleted file mode 100644 index 7f5a96f4f4..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogResourceExample.java +++ /dev/null @@ -1,410 +0,0 @@ -package io.metersphere.system.domain; - -import java.util.ArrayList; -import java.util.List; - -public class OperatingLogResourceExample { - protected String orderByClause; - - protected boolean distinct; - - protected List oredCriteria; - - public OperatingLogResourceExample() { - oredCriteria = new ArrayList(); - } - - 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 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 criteria; - - protected GeneratedCriteria() { - super(); - criteria = new ArrayList(); - } - - public boolean isValid() { - return criteria.size() > 0; - } - - public List getAllCriteria() { - return criteria; - } - - public List 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 values) { - addCriterion("id in", values, "id"); - return (Criteria) this; - } - - public Criteria andIdNotIn(List 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 values) { - addCriterion("operating_log_id in", values, "operatingLogId"); - return (Criteria) this; - } - - public Criteria andOperatingLogIdNotIn(List 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 values) { - addCriterion("source_id in", values, "sourceId"); - return (Criteria) this; - } - - public Criteria andSourceIdNotIn(List 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); - } - } -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperationLog.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperationLog.java new file mode 100644 index 0000000000..1830516b5c --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperationLog.java @@ -0,0 +1,53 @@ +package io.metersphere.system.domain; + +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class OperationLog implements Serializable { + @Schema(title = "主键", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{operation_log.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{operation_log.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(title = "项目id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{operation_log.project_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{operation_log.project_id.length_range}", groups = {Created.class, Updated.class}) + private String projectId; + + @Schema(title = "操作时间") + private Long createTime; + + @Schema(title = "操作人") + private String createUser; + + @Schema(title = "资源id") + private String sourceId; + + @Schema(title = "操作方法", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{operation_log.method.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{operation_log.method.length_range}", groups = {Created.class, Updated.class}) + private String method; + + @Schema(title = "操作类型/add/update/delete", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{operation_log.type.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 20, message = "{operation_log.type.length_range}", groups = {Created.class, Updated.class}) + private String type; + + @Schema(title = "操作模块/api/case/scenario/ui") + private String module; + + @Schema(title = "操作详情") + private String details; + + @Schema(title = "操作路径") + private String path; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperationLogExample.java similarity index 59% rename from backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogExample.java rename to backend/framework/domain/src/main/java/io/metersphere/system/domain/OperationLogExample.java index debd54ed83..a113007a82 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperatingLogExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/OperationLogExample.java @@ -3,14 +3,14 @@ package io.metersphere.system.domain; import java.util.ArrayList; import java.util.List; -public class OperatingLogExample { +public class OperationLogExample { protected String orderByClause; protected boolean distinct; protected List oredCriteria; - public OperatingLogExample() { + public OperationLogExample() { oredCriteria = new ArrayList(); } @@ -244,73 +244,63 @@ public class OperatingLogExample { return (Criteria) this; } - public Criteria andOperMethodIsNull() { - addCriterion("oper_method is null"); + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); return (Criteria) this; } - public Criteria andOperMethodIsNotNull() { - addCriterion("oper_method is not null"); + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); return (Criteria) this; } - public Criteria andOperMethodEqualTo(String value) { - addCriterion("oper_method =", value, "operMethod"); + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); return (Criteria) this; } - public Criteria andOperMethodNotEqualTo(String value) { - addCriterion("oper_method <>", value, "operMethod"); + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); return (Criteria) this; } - public Criteria andOperMethodGreaterThan(String value) { - addCriterion("oper_method >", value, "operMethod"); + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); return (Criteria) this; } - public Criteria andOperMethodGreaterThanOrEqualTo(String value) { - addCriterion("oper_method >=", value, "operMethod"); + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); return (Criteria) this; } - public Criteria andOperMethodLessThan(String value) { - addCriterion("oper_method <", value, "operMethod"); + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); return (Criteria) this; } - public Criteria andOperMethodLessThanOrEqualTo(String value) { - addCriterion("oper_method <=", value, "operMethod"); + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); return (Criteria) this; } - public Criteria andOperMethodLike(String value) { - addCriterion("oper_method like", value, "operMethod"); + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); return (Criteria) this; } - public Criteria andOperMethodNotLike(String value) { - addCriterion("oper_method not like", value, "operMethod"); + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); return (Criteria) this; } - public Criteria andOperMethodIn(List values) { - addCriterion("oper_method in", values, "operMethod"); + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); return (Criteria) this; } - public Criteria andOperMethodNotIn(List values) { - addCriterion("oper_method not in", values, "operMethod"); - return (Criteria) this; - } - - public Criteria andOperMethodBetween(String value1, String value2) { - addCriterion("oper_method between", value1, value2, "operMethod"); - return (Criteria) this; - } - - public Criteria andOperMethodNotBetween(String value1, String value2) { - addCriterion("oper_method not between", value1, value2, "operMethod"); + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); return (Criteria) this; } @@ -384,76 +374,6 @@ public class OperatingLogExample { return (Criteria) this; } - public Criteria andOperUserIsNull() { - addCriterion("oper_user is null"); - return (Criteria) this; - } - - public Criteria andOperUserIsNotNull() { - addCriterion("oper_user is not null"); - return (Criteria) this; - } - - public Criteria andOperUserEqualTo(String value) { - addCriterion("oper_user =", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserNotEqualTo(String value) { - addCriterion("oper_user <>", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserGreaterThan(String value) { - addCriterion("oper_user >", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserGreaterThanOrEqualTo(String value) { - addCriterion("oper_user >=", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserLessThan(String value) { - addCriterion("oper_user <", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserLessThanOrEqualTo(String value) { - addCriterion("oper_user <=", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserLike(String value) { - addCriterion("oper_user like", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserNotLike(String value) { - addCriterion("oper_user not like", value, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserIn(List values) { - addCriterion("oper_user in", values, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserNotIn(List values) { - addCriterion("oper_user not in", values, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserBetween(String value1, String value2) { - addCriterion("oper_user between", value1, value2, "operUser"); - return (Criteria) this; - } - - public Criteria andOperUserNotBetween(String value1, String value2) { - addCriterion("oper_user not between", value1, value2, "operUser"); - return (Criteria) this; - } - public Criteria andSourceIdIsNull() { addCriterion("source_id is null"); return (Criteria) this; @@ -524,343 +444,353 @@ public class OperatingLogExample { return (Criteria) this; } - public Criteria andOperTypeIsNull() { - addCriterion("oper_type is null"); + public Criteria andMethodIsNull() { + addCriterion("`method` is null"); return (Criteria) this; } - public Criteria andOperTypeIsNotNull() { - addCriterion("oper_type is not null"); + public Criteria andMethodIsNotNull() { + addCriterion("`method` is not null"); return (Criteria) this; } - public Criteria andOperTypeEqualTo(String value) { - addCriterion("oper_type =", value, "operType"); + public Criteria andMethodEqualTo(String value) { + addCriterion("`method` =", value, "method"); return (Criteria) this; } - public Criteria andOperTypeNotEqualTo(String value) { - addCriterion("oper_type <>", value, "operType"); + public Criteria andMethodNotEqualTo(String value) { + addCriterion("`method` <>", value, "method"); return (Criteria) this; } - public Criteria andOperTypeGreaterThan(String value) { - addCriterion("oper_type >", value, "operType"); + public Criteria andMethodGreaterThan(String value) { + addCriterion("`method` >", value, "method"); return (Criteria) this; } - public Criteria andOperTypeGreaterThanOrEqualTo(String value) { - addCriterion("oper_type >=", value, "operType"); + public Criteria andMethodGreaterThanOrEqualTo(String value) { + addCriterion("`method` >=", value, "method"); return (Criteria) this; } - public Criteria andOperTypeLessThan(String value) { - addCriterion("oper_type <", value, "operType"); + public Criteria andMethodLessThan(String value) { + addCriterion("`method` <", value, "method"); return (Criteria) this; } - public Criteria andOperTypeLessThanOrEqualTo(String value) { - addCriterion("oper_type <=", value, "operType"); + public Criteria andMethodLessThanOrEqualTo(String value) { + addCriterion("`method` <=", value, "method"); return (Criteria) this; } - public Criteria andOperTypeLike(String value) { - addCriterion("oper_type like", value, "operType"); + public Criteria andMethodLike(String value) { + addCriterion("`method` like", value, "method"); return (Criteria) this; } - public Criteria andOperTypeNotLike(String value) { - addCriterion("oper_type not like", value, "operType"); + public Criteria andMethodNotLike(String value) { + addCriterion("`method` not like", value, "method"); return (Criteria) this; } - public Criteria andOperTypeIn(List values) { - addCriterion("oper_type in", values, "operType"); + public Criteria andMethodIn(List values) { + addCriterion("`method` in", values, "method"); return (Criteria) this; } - public Criteria andOperTypeNotIn(List values) { - addCriterion("oper_type not in", values, "operType"); + public Criteria andMethodNotIn(List values) { + addCriterion("`method` not in", values, "method"); return (Criteria) this; } - public Criteria andOperTypeBetween(String value1, String value2) { - addCriterion("oper_type between", value1, value2, "operType"); + public Criteria andMethodBetween(String value1, String value2) { + addCriterion("`method` between", value1, value2, "method"); return (Criteria) this; } - public Criteria andOperTypeNotBetween(String value1, String value2) { - addCriterion("oper_type not between", value1, value2, "operType"); + public Criteria andMethodNotBetween(String value1, String value2) { + addCriterion("`method` not between", value1, value2, "method"); return (Criteria) this; } - public Criteria andOperModuleIsNull() { - addCriterion("oper_module is null"); + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); return (Criteria) this; } - public Criteria andOperModuleIsNotNull() { - addCriterion("oper_module is not null"); + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); return (Criteria) this; } - public Criteria andOperModuleEqualTo(String value) { - addCriterion("oper_module =", value, "operModule"); + public Criteria andTypeEqualTo(String value) { + addCriterion("`type` =", value, "type"); return (Criteria) this; } - public Criteria andOperModuleNotEqualTo(String value) { - addCriterion("oper_module <>", value, "operModule"); + public Criteria andTypeNotEqualTo(String value) { + addCriterion("`type` <>", value, "type"); return (Criteria) this; } - public Criteria andOperModuleGreaterThan(String value) { - addCriterion("oper_module >", value, "operModule"); + public Criteria andTypeGreaterThan(String value) { + addCriterion("`type` >", value, "type"); return (Criteria) this; } - public Criteria andOperModuleGreaterThanOrEqualTo(String value) { - addCriterion("oper_module >=", value, "operModule"); + public Criteria andTypeGreaterThanOrEqualTo(String value) { + addCriterion("`type` >=", value, "type"); return (Criteria) this; } - public Criteria andOperModuleLessThan(String value) { - addCriterion("oper_module <", value, "operModule"); + public Criteria andTypeLessThan(String value) { + addCriterion("`type` <", value, "type"); return (Criteria) this; } - public Criteria andOperModuleLessThanOrEqualTo(String value) { - addCriterion("oper_module <=", value, "operModule"); + public Criteria andTypeLessThanOrEqualTo(String value) { + addCriterion("`type` <=", value, "type"); return (Criteria) this; } - public Criteria andOperModuleLike(String value) { - addCriterion("oper_module like", value, "operModule"); + public Criteria andTypeLike(String value) { + addCriterion("`type` like", value, "type"); return (Criteria) this; } - public Criteria andOperModuleNotLike(String value) { - addCriterion("oper_module not like", value, "operModule"); + public Criteria andTypeNotLike(String value) { + addCriterion("`type` not like", value, "type"); return (Criteria) this; } - public Criteria andOperModuleIn(List values) { - addCriterion("oper_module in", values, "operModule"); + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); return (Criteria) this; } - public Criteria andOperModuleNotIn(List values) { - addCriterion("oper_module not in", values, "operModule"); + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); return (Criteria) this; } - public Criteria andOperModuleBetween(String value1, String value2) { - addCriterion("oper_module between", value1, value2, "operModule"); + public Criteria andTypeBetween(String value1, String value2) { + addCriterion("`type` between", value1, value2, "type"); return (Criteria) this; } - public Criteria andOperModuleNotBetween(String value1, String value2) { - addCriterion("oper_module not between", value1, value2, "operModule"); + public Criteria andTypeNotBetween(String value1, String value2) { + addCriterion("`type` not between", value1, value2, "type"); return (Criteria) this; } - public Criteria andOperTitleIsNull() { - addCriterion("oper_title is null"); + public Criteria andModuleIsNull() { + addCriterion("`module` is null"); return (Criteria) this; } - public Criteria andOperTitleIsNotNull() { - addCriterion("oper_title is not null"); + public Criteria andModuleIsNotNull() { + addCriterion("`module` is not null"); return (Criteria) this; } - public Criteria andOperTitleEqualTo(String value) { - addCriterion("oper_title =", value, "operTitle"); + public Criteria andModuleEqualTo(String value) { + addCriterion("`module` =", value, "module"); return (Criteria) this; } - public Criteria andOperTitleNotEqualTo(String value) { - addCriterion("oper_title <>", value, "operTitle"); + public Criteria andModuleNotEqualTo(String value) { + addCriterion("`module` <>", value, "module"); return (Criteria) this; } - public Criteria andOperTitleGreaterThan(String value) { - addCriterion("oper_title >", value, "operTitle"); + public Criteria andModuleGreaterThan(String value) { + addCriterion("`module` >", value, "module"); return (Criteria) this; } - public Criteria andOperTitleGreaterThanOrEqualTo(String value) { - addCriterion("oper_title >=", value, "operTitle"); + public Criteria andModuleGreaterThanOrEqualTo(String value) { + addCriterion("`module` >=", value, "module"); return (Criteria) this; } - public Criteria andOperTitleLessThan(String value) { - addCriterion("oper_title <", value, "operTitle"); + public Criteria andModuleLessThan(String value) { + addCriterion("`module` <", value, "module"); return (Criteria) this; } - public Criteria andOperTitleLessThanOrEqualTo(String value) { - addCriterion("oper_title <=", value, "operTitle"); + public Criteria andModuleLessThanOrEqualTo(String value) { + addCriterion("`module` <=", value, "module"); return (Criteria) this; } - public Criteria andOperTitleLike(String value) { - addCriterion("oper_title like", value, "operTitle"); + public Criteria andModuleLike(String value) { + addCriterion("`module` like", value, "module"); return (Criteria) this; } - public Criteria andOperTitleNotLike(String value) { - addCriterion("oper_title not like", value, "operTitle"); + public Criteria andModuleNotLike(String value) { + addCriterion("`module` not like", value, "module"); return (Criteria) this; } - public Criteria andOperTitleIn(List values) { - addCriterion("oper_title in", values, "operTitle"); + public Criteria andModuleIn(List values) { + addCriterion("`module` in", values, "module"); return (Criteria) this; } - public Criteria andOperTitleNotIn(List values) { - addCriterion("oper_title not in", values, "operTitle"); + public Criteria andModuleNotIn(List values) { + addCriterion("`module` not in", values, "module"); return (Criteria) this; } - public Criteria andOperTitleBetween(String value1, String value2) { - addCriterion("oper_title between", value1, value2, "operTitle"); + public Criteria andModuleBetween(String value1, String value2) { + addCriterion("`module` between", value1, value2, "module"); return (Criteria) this; } - public Criteria andOperTitleNotBetween(String value1, String value2) { - addCriterion("oper_title not between", value1, value2, "operTitle"); + public Criteria andModuleNotBetween(String value1, String value2) { + addCriterion("`module` not between", value1, value2, "module"); return (Criteria) this; } - public Criteria andOperPathIsNull() { - addCriterion("oper_path is null"); + public Criteria andDetailsIsNull() { + addCriterion("details is null"); return (Criteria) this; } - public Criteria andOperPathIsNotNull() { - addCriterion("oper_path is not null"); + public Criteria andDetailsIsNotNull() { + addCriterion("details is not null"); return (Criteria) this; } - public Criteria andOperPathEqualTo(String value) { - addCriterion("oper_path =", value, "operPath"); + public Criteria andDetailsEqualTo(String value) { + addCriterion("details =", value, "details"); return (Criteria) this; } - public Criteria andOperPathNotEqualTo(String value) { - addCriterion("oper_path <>", value, "operPath"); + public Criteria andDetailsNotEqualTo(String value) { + addCriterion("details <>", value, "details"); return (Criteria) this; } - public Criteria andOperPathGreaterThan(String value) { - addCriterion("oper_path >", value, "operPath"); + public Criteria andDetailsGreaterThan(String value) { + addCriterion("details >", value, "details"); return (Criteria) this; } - public Criteria andOperPathGreaterThanOrEqualTo(String value) { - addCriterion("oper_path >=", value, "operPath"); + public Criteria andDetailsGreaterThanOrEqualTo(String value) { + addCriterion("details >=", value, "details"); return (Criteria) this; } - public Criteria andOperPathLessThan(String value) { - addCriterion("oper_path <", value, "operPath"); + public Criteria andDetailsLessThan(String value) { + addCriterion("details <", value, "details"); return (Criteria) this; } - public Criteria andOperPathLessThanOrEqualTo(String value) { - addCriterion("oper_path <=", value, "operPath"); + public Criteria andDetailsLessThanOrEqualTo(String value) { + addCriterion("details <=", value, "details"); return (Criteria) this; } - public Criteria andOperPathLike(String value) { - addCriterion("oper_path like", value, "operPath"); + public Criteria andDetailsLike(String value) { + addCriterion("details like", value, "details"); return (Criteria) this; } - public Criteria andOperPathNotLike(String value) { - addCriterion("oper_path not like", value, "operPath"); + public Criteria andDetailsNotLike(String value) { + addCriterion("details not like", value, "details"); return (Criteria) this; } - public Criteria andOperPathIn(List values) { - addCriterion("oper_path in", values, "operPath"); + public Criteria andDetailsIn(List values) { + addCriterion("details in", values, "details"); return (Criteria) this; } - public Criteria andOperPathNotIn(List values) { - addCriterion("oper_path not in", values, "operPath"); + public Criteria andDetailsNotIn(List values) { + addCriterion("details not in", values, "details"); return (Criteria) this; } - public Criteria andOperPathBetween(String value1, String value2) { - addCriterion("oper_path between", value1, value2, "operPath"); + public Criteria andDetailsBetween(String value1, String value2) { + addCriterion("details between", value1, value2, "details"); return (Criteria) this; } - public Criteria andOperPathNotBetween(String value1, String value2) { - addCriterion("oper_path not between", value1, value2, "operPath"); + public Criteria andDetailsNotBetween(String value1, String value2) { + addCriterion("details not between", value1, value2, "details"); return (Criteria) this; } - public Criteria andOperTimeIsNull() { - addCriterion("oper_time is null"); + public Criteria andPathIsNull() { + addCriterion("`path` is null"); return (Criteria) this; } - public Criteria andOperTimeIsNotNull() { - addCriterion("oper_time is not null"); + public Criteria andPathIsNotNull() { + addCriterion("`path` is not null"); return (Criteria) this; } - public Criteria andOperTimeEqualTo(Long value) { - addCriterion("oper_time =", value, "operTime"); + public Criteria andPathEqualTo(String value) { + addCriterion("`path` =", value, "path"); return (Criteria) this; } - public Criteria andOperTimeNotEqualTo(Long value) { - addCriterion("oper_time <>", value, "operTime"); + public Criteria andPathNotEqualTo(String value) { + addCriterion("`path` <>", value, "path"); return (Criteria) this; } - public Criteria andOperTimeGreaterThan(Long value) { - addCriterion("oper_time >", value, "operTime"); + public Criteria andPathGreaterThan(String value) { + addCriterion("`path` >", value, "path"); return (Criteria) this; } - public Criteria andOperTimeGreaterThanOrEqualTo(Long value) { - addCriterion("oper_time >=", value, "operTime"); + public Criteria andPathGreaterThanOrEqualTo(String value) { + addCriterion("`path` >=", value, "path"); return (Criteria) this; } - public Criteria andOperTimeLessThan(Long value) { - addCriterion("oper_time <", value, "operTime"); + public Criteria andPathLessThan(String value) { + addCriterion("`path` <", value, "path"); return (Criteria) this; } - public Criteria andOperTimeLessThanOrEqualTo(Long value) { - addCriterion("oper_time <=", value, "operTime"); + public Criteria andPathLessThanOrEqualTo(String value) { + addCriterion("`path` <=", value, "path"); return (Criteria) this; } - public Criteria andOperTimeIn(List values) { - addCriterion("oper_time in", values, "operTime"); + public Criteria andPathLike(String value) { + addCriterion("`path` like", value, "path"); return (Criteria) this; } - public Criteria andOperTimeNotIn(List values) { - addCriterion("oper_time not in", values, "operTime"); + public Criteria andPathNotLike(String value) { + addCriterion("`path` not like", value, "path"); return (Criteria) this; } - public Criteria andOperTimeBetween(Long value1, Long value2) { - addCriterion("oper_time between", value1, value2, "operTime"); + public Criteria andPathIn(List values) { + addCriterion("`path` in", values, "path"); return (Criteria) this; } - public Criteria andOperTimeNotBetween(Long value1, Long value2) { - addCriterion("oper_time not between", value1, value2, "operTime"); + public Criteria andPathNotIn(List values) { + addCriterion("`path` not in", values, "path"); + return (Criteria) this; + } + + public Criteria andPathBetween(String value1, String value2) { + addCriterion("`path` between", value1, value2, "path"); + return (Criteria) this; + } + + public Criteria andPathNotBetween(String value1, String value2) { + addCriterion("`path` not between", value1, value2, "path"); return (Criteria) this; } } diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogMapper.java deleted file mode 100644 index 7aab0f8328..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.metersphere.system.mapper; - -import io.metersphere.system.domain.OperatingLog; -import io.metersphere.system.domain.OperatingLogExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; - -public interface OperatingLogMapper { - long countByExample(OperatingLogExample example); - - int deleteByExample(OperatingLogExample example); - - int deleteByPrimaryKey(String id); - - int insert(OperatingLog record); - - int insertSelective(OperatingLog record); - - List selectByExampleWithBLOBs(OperatingLogExample example); - - List selectByExample(OperatingLogExample example); - - OperatingLog selectByPrimaryKey(String id); - - int updateByExampleSelective(@Param("record") OperatingLog record, @Param("example") OperatingLogExample example); - - int updateByExampleWithBLOBs(@Param("record") OperatingLog record, @Param("example") OperatingLogExample example); - - int updateByExample(@Param("record") OperatingLog record, @Param("example") OperatingLogExample example); - - int updateByPrimaryKeySelective(OperatingLog record); - - int updateByPrimaryKeyWithBLOBs(OperatingLog record); - - int updateByPrimaryKey(OperatingLog record); -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogMapper.xml deleted file mode 100644 index cd95518689..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogMapper.xml +++ /dev/null @@ -1,392 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - id, project_id, oper_method, create_user, oper_user, source_id, oper_type, oper_module, - oper_title, oper_path, oper_time - - - oper_content, oper_params - - - - - - delete from operating_log - where id = #{id,jdbcType=VARCHAR} - - - delete from operating_log - - - - - - insert into operating_log (id, project_id, oper_method, - create_user, oper_user, source_id, - oper_type, oper_module, oper_title, - oper_path, oper_time, oper_content, - oper_params) - values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{operMethod,jdbcType=VARCHAR}, - #{createUser,jdbcType=VARCHAR}, #{operUser,jdbcType=VARCHAR}, #{sourceId,jdbcType=VARCHAR}, - #{operType,jdbcType=VARCHAR}, #{operModule,jdbcType=VARCHAR}, #{operTitle,jdbcType=VARCHAR}, - #{operPath,jdbcType=VARCHAR}, #{operTime,jdbcType=BIGINT}, #{operContent,jdbcType=LONGVARBINARY}, - #{operParams,jdbcType=LONGVARBINARY}) - - - insert into operating_log - - - id, - - - project_id, - - - oper_method, - - - create_user, - - - oper_user, - - - source_id, - - - oper_type, - - - oper_module, - - - oper_title, - - - oper_path, - - - oper_time, - - - oper_content, - - - oper_params, - - - - - #{id,jdbcType=VARCHAR}, - - - #{projectId,jdbcType=VARCHAR}, - - - #{operMethod,jdbcType=VARCHAR}, - - - #{createUser,jdbcType=VARCHAR}, - - - #{operUser,jdbcType=VARCHAR}, - - - #{sourceId,jdbcType=VARCHAR}, - - - #{operType,jdbcType=VARCHAR}, - - - #{operModule,jdbcType=VARCHAR}, - - - #{operTitle,jdbcType=VARCHAR}, - - - #{operPath,jdbcType=VARCHAR}, - - - #{operTime,jdbcType=BIGINT}, - - - #{operContent,jdbcType=LONGVARBINARY}, - - - #{operParams,jdbcType=LONGVARBINARY}, - - - - - - update operating_log - - - id = #{record.id,jdbcType=VARCHAR}, - - - project_id = #{record.projectId,jdbcType=VARCHAR}, - - - oper_method = #{record.operMethod,jdbcType=VARCHAR}, - - - create_user = #{record.createUser,jdbcType=VARCHAR}, - - - oper_user = #{record.operUser,jdbcType=VARCHAR}, - - - source_id = #{record.sourceId,jdbcType=VARCHAR}, - - - oper_type = #{record.operType,jdbcType=VARCHAR}, - - - oper_module = #{record.operModule,jdbcType=VARCHAR}, - - - oper_title = #{record.operTitle,jdbcType=VARCHAR}, - - - oper_path = #{record.operPath,jdbcType=VARCHAR}, - - - oper_time = #{record.operTime,jdbcType=BIGINT}, - - - oper_content = #{record.operContent,jdbcType=LONGVARBINARY}, - - - oper_params = #{record.operParams,jdbcType=LONGVARBINARY}, - - - - - - - - update operating_log - set id = #{record.id,jdbcType=VARCHAR}, - project_id = #{record.projectId,jdbcType=VARCHAR}, - oper_method = #{record.operMethod,jdbcType=VARCHAR}, - create_user = #{record.createUser,jdbcType=VARCHAR}, - oper_user = #{record.operUser,jdbcType=VARCHAR}, - source_id = #{record.sourceId,jdbcType=VARCHAR}, - oper_type = #{record.operType,jdbcType=VARCHAR}, - oper_module = #{record.operModule,jdbcType=VARCHAR}, - oper_title = #{record.operTitle,jdbcType=VARCHAR}, - oper_path = #{record.operPath,jdbcType=VARCHAR}, - oper_time = #{record.operTime,jdbcType=BIGINT}, - oper_content = #{record.operContent,jdbcType=LONGVARBINARY}, - oper_params = #{record.operParams,jdbcType=LONGVARBINARY} - - - - - - update operating_log - set id = #{record.id,jdbcType=VARCHAR}, - project_id = #{record.projectId,jdbcType=VARCHAR}, - oper_method = #{record.operMethod,jdbcType=VARCHAR}, - create_user = #{record.createUser,jdbcType=VARCHAR}, - oper_user = #{record.operUser,jdbcType=VARCHAR}, - source_id = #{record.sourceId,jdbcType=VARCHAR}, - oper_type = #{record.operType,jdbcType=VARCHAR}, - oper_module = #{record.operModule,jdbcType=VARCHAR}, - oper_title = #{record.operTitle,jdbcType=VARCHAR}, - oper_path = #{record.operPath,jdbcType=VARCHAR}, - oper_time = #{record.operTime,jdbcType=BIGINT} - - - - - - update operating_log - - - project_id = #{projectId,jdbcType=VARCHAR}, - - - oper_method = #{operMethod,jdbcType=VARCHAR}, - - - create_user = #{createUser,jdbcType=VARCHAR}, - - - oper_user = #{operUser,jdbcType=VARCHAR}, - - - source_id = #{sourceId,jdbcType=VARCHAR}, - - - oper_type = #{operType,jdbcType=VARCHAR}, - - - oper_module = #{operModule,jdbcType=VARCHAR}, - - - oper_title = #{operTitle,jdbcType=VARCHAR}, - - - oper_path = #{operPath,jdbcType=VARCHAR}, - - - oper_time = #{operTime,jdbcType=BIGINT}, - - - oper_content = #{operContent,jdbcType=LONGVARBINARY}, - - - oper_params = #{operParams,jdbcType=LONGVARBINARY}, - - - where id = #{id,jdbcType=VARCHAR} - - - update operating_log - set project_id = #{projectId,jdbcType=VARCHAR}, - oper_method = #{operMethod,jdbcType=VARCHAR}, - create_user = #{createUser,jdbcType=VARCHAR}, - oper_user = #{operUser,jdbcType=VARCHAR}, - source_id = #{sourceId,jdbcType=VARCHAR}, - oper_type = #{operType,jdbcType=VARCHAR}, - oper_module = #{operModule,jdbcType=VARCHAR}, - oper_title = #{operTitle,jdbcType=VARCHAR}, - oper_path = #{operPath,jdbcType=VARCHAR}, - oper_time = #{operTime,jdbcType=BIGINT}, - oper_content = #{operContent,jdbcType=LONGVARBINARY}, - oper_params = #{operParams,jdbcType=LONGVARBINARY} - where id = #{id,jdbcType=VARCHAR} - - - update operating_log - set project_id = #{projectId,jdbcType=VARCHAR}, - oper_method = #{operMethod,jdbcType=VARCHAR}, - create_user = #{createUser,jdbcType=VARCHAR}, - oper_user = #{operUser,jdbcType=VARCHAR}, - source_id = #{sourceId,jdbcType=VARCHAR}, - oper_type = #{operType,jdbcType=VARCHAR}, - oper_module = #{operModule,jdbcType=VARCHAR}, - oper_title = #{operTitle,jdbcType=VARCHAR}, - oper_path = #{operPath,jdbcType=VARCHAR}, - oper_time = #{operTime,jdbcType=BIGINT} - where id = #{id,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogResourceMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogResourceMapper.java deleted file mode 100644 index b7bc154a3e..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogResourceMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.metersphere.system.mapper; - -import io.metersphere.system.domain.OperatingLogResource; -import io.metersphere.system.domain.OperatingLogResourceExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; - -public interface OperatingLogResourceMapper { - long countByExample(OperatingLogResourceExample example); - - int deleteByExample(OperatingLogResourceExample example); - - int deleteByPrimaryKey(String id); - - int insert(OperatingLogResource record); - - int insertSelective(OperatingLogResource record); - - List 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); -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogResourceMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogResourceMapper.xml deleted file mode 100644 index b974822dc4..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperatingLogResourceMapper.xml +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - id, operating_log_id, source_id - - - - - delete from operating_log_resource - where id = #{id,jdbcType=VARCHAR} - - - delete from operating_log_resource - - - - - - insert into operating_log_resource (id, operating_log_id, source_id - ) - values (#{id,jdbcType=VARCHAR}, #{operatingLogId,jdbcType=VARCHAR}, #{sourceId,jdbcType=VARCHAR} - ) - - - insert into operating_log_resource - - - id, - - - operating_log_id, - - - source_id, - - - - - #{id,jdbcType=VARCHAR}, - - - #{operatingLogId,jdbcType=VARCHAR}, - - - #{sourceId,jdbcType=VARCHAR}, - - - - - - update operating_log_resource - - - id = #{record.id,jdbcType=VARCHAR}, - - - operating_log_id = #{record.operatingLogId,jdbcType=VARCHAR}, - - - source_id = #{record.sourceId,jdbcType=VARCHAR}, - - - - - - - - update operating_log_resource - set id = #{record.id,jdbcType=VARCHAR}, - operating_log_id = #{record.operatingLogId,jdbcType=VARCHAR}, - source_id = #{record.sourceId,jdbcType=VARCHAR} - - - - - - update operating_log_resource - - - operating_log_id = #{operatingLogId,jdbcType=VARCHAR}, - - - source_id = #{sourceId,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=VARCHAR} - - - update operating_log_resource - set operating_log_id = #{operatingLogId,jdbcType=VARCHAR}, - source_id = #{sourceId,jdbcType=VARCHAR} - where id = #{id,jdbcType=VARCHAR} - - \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperationLogMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperationLogMapper.java new file mode 100644 index 0000000000..29ec3c7738 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperationLogMapper.java @@ -0,0 +1,30 @@ +package io.metersphere.system.mapper; + +import io.metersphere.system.domain.OperationLog; +import io.metersphere.system.domain.OperationLogExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface OperationLogMapper { + long countByExample(OperationLogExample example); + + int deleteByExample(OperationLogExample example); + + int deleteByPrimaryKey(String id); + + int insert(OperationLog record); + + int insertSelective(OperationLog record); + + List selectByExample(OperationLogExample example); + + OperationLog selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") OperationLog record, @Param("example") OperationLogExample example); + + int updateByExample(@Param("record") OperationLog record, @Param("example") OperationLogExample example); + + int updateByPrimaryKeySelective(OperationLog record); + + int updateByPrimaryKey(OperationLog record); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperationLogMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperationLogMapper.xml new file mode 100644 index 0000000000..b03b447908 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/OperationLogMapper.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, project_id, create_time, create_user, source_id, `method`, `type`, `module`, + details, `path` + + + + + delete from operation_log + where id = #{id,jdbcType=VARCHAR} + + + delete from operation_log + + + + + + insert into operation_log (id, project_id, create_time, + create_user, source_id, `method`, + `type`, `module`, details, + `path`) + values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, + #{createUser,jdbcType=VARCHAR}, #{sourceId,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, + #{type,jdbcType=VARCHAR}, #{module,jdbcType=VARCHAR}, #{details,jdbcType=VARCHAR}, + #{path,jdbcType=VARCHAR}) + + + insert into operation_log + + + id, + + + project_id, + + + create_time, + + + create_user, + + + source_id, + + + `method`, + + + `type`, + + + `module`, + + + details, + + + `path`, + + + + + #{id,jdbcType=VARCHAR}, + + + #{projectId,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{createUser,jdbcType=VARCHAR}, + + + #{sourceId,jdbcType=VARCHAR}, + + + #{method,jdbcType=VARCHAR}, + + + #{type,jdbcType=VARCHAR}, + + + #{module,jdbcType=VARCHAR}, + + + #{details,jdbcType=VARCHAR}, + + + #{path,jdbcType=VARCHAR}, + + + + + + update operation_log + + + id = #{record.id,jdbcType=VARCHAR}, + + + project_id = #{record.projectId,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + create_user = #{record.createUser,jdbcType=VARCHAR}, + + + source_id = #{record.sourceId,jdbcType=VARCHAR}, + + + `method` = #{record.method,jdbcType=VARCHAR}, + + + `type` = #{record.type,jdbcType=VARCHAR}, + + + `module` = #{record.module,jdbcType=VARCHAR}, + + + details = #{record.details,jdbcType=VARCHAR}, + + + `path` = #{record.path,jdbcType=VARCHAR}, + + + + + + + + update operation_log + set id = #{record.id,jdbcType=VARCHAR}, + project_id = #{record.projectId,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR}, + source_id = #{record.sourceId,jdbcType=VARCHAR}, + `method` = #{record.method,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=VARCHAR}, + `module` = #{record.module,jdbcType=VARCHAR}, + details = #{record.details,jdbcType=VARCHAR}, + `path` = #{record.path,jdbcType=VARCHAR} + + + + + + update operation_log + + + project_id = #{projectId,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + create_user = #{createUser,jdbcType=VARCHAR}, + + + source_id = #{sourceId,jdbcType=VARCHAR}, + + + `method` = #{method,jdbcType=VARCHAR}, + + + `type` = #{type,jdbcType=VARCHAR}, + + + `module` = #{module,jdbcType=VARCHAR}, + + + details = #{details,jdbcType=VARCHAR}, + + + `path` = #{path,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + update operation_log + set project_id = #{projectId,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR}, + source_id = #{sourceId,jdbcType=VARCHAR}, + `method` = #{method,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=VARCHAR}, + `module` = #{module,jdbcType=VARCHAR}, + details = #{details,jdbcType=VARCHAR}, + `path` = #{path,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_ddl.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_ddl.sql index d304675cfe..ffddda7f16 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_ddl.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_ddl.sql @@ -120,46 +120,29 @@ CREATE TABLE novice_statistics DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '新手村'; -DROP TABLE IF EXISTS operating_log; -CREATE TABLE operating_log -( - `id` VARCHAR(50) NOT NULL COMMENT 'ID', - `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID', - `oper_method` VARCHAR(500) COMMENT 'operating method', - `create_user` VARCHAR(100) COMMENT '创建人', - `oper_user` VARCHAR(50) COMMENT '操作人', - `source_id` VARCHAR(6000) COMMENT '资源ID', - `oper_type` VARCHAR(100) COMMENT '操作类型', - `oper_module` VARCHAR(100) COMMENT '操作模块', - `oper_title` VARCHAR(6000) COMMENT '操作标题', - `oper_path` VARCHAR(500) COMMENT '操作路径', - `oper_content` LONGBLOB COMMENT '操作内容', - `oper_params` LONGBLOB COMMENT '操作参数', - `oper_time` BIGINT NOT NULL COMMENT '操作时间', - PRIMARY KEY (id) +DROP TABLE IF EXISTS operation_log; +CREATE TABLE operation_log( + `id` VARCHAR(50) NOT NULL COMMENT '主键' , + `project_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '项目id' , + `create_time` BIGINT NOT NULL COMMENT '操作时间' , + `create_user` VARCHAR(50) COMMENT '操作人' , + `source_id` VARCHAR(50) COMMENT '资源id' , + `method` VARCHAR(255) NOT NULL COMMENT '操作方法' , + `type` VARCHAR(20) NOT NULL COMMENT '操作类型/add/update/delete' , + `module` VARCHAR(20) COMMENT '操作模块/api/case/scenario/ui' , + `details` VARCHAR(1000) COMMENT '操作详情' , + `path` VARCHAR(255) COMMENT '操作路径' , + PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作日志'; - -CREATE INDEX idx_oper_module ON operating_log (`oper_module`); -CREATE INDEX idx_oper_project_id ON operating_log (`project_id`); -CREATE INDEX idx_oper_time_index ON operating_log (`oper_time`); - -DROP TABLE IF EXISTS operating_log_resource; -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) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT = '操作日志关系记录'; - - -CREATE INDEX operating_log_id_index ON operating_log_resource (`operating_log_id`); -CREATE INDEX source_id_index ON operating_log_resource (`source_id`); +CREATE INDEX idx_create_time ON operation_log(`create_time`); +CREATE INDEX idx_create_user ON operation_log(`create_user`); +CREATE INDEX idx_method ON operation_log(`method`); +CREATE INDEX idx_module ON operation_log(`module`); +CREATE INDEX idx_project_id ON operation_log(`project_id`); +CREATE INDEX idx_type ON operation_log(`type`); DROP TABLE IF EXISTS plugin; CREATE TABLE plugin diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java index a82025da65..a0720dd4de 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java @@ -18,8 +18,6 @@ public class SystemInterceptor { configList.add(new MybatisInterceptorConfig(TestResource.class, "configuration", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(AuthSource.class, "configuration", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(NoviceStatistics.class, "dataOption", CompressUtils.class, "zip", "unzip")); - configList.add(new MybatisInterceptorConfig(OperatingLog.class, "operContent", CompressUtils.class, "zip", "unzip")); - configList.add(new MybatisInterceptorConfig(OperatingLog.class, "operParams", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(PluginBlob.class, "formOption", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(PluginBlob.class, "formScript", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(ServiceIntegration.class, "configuration", CompressUtils.class, "zip", "unzip")); diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/RequestLog.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/RequestLog.java new file mode 100644 index 0000000000..49c10c022d --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/annotation/RequestLog.java @@ -0,0 +1,76 @@ +package io.metersphere.sdk.log.annotation; + +import io.metersphere.sdk.log.constants.OperationLogModule; +import io.metersphere.sdk.log.constants.OperationLogType; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +/** + * 操作日志注解类 + * @author mr.zhao + */ +public @interface RequestLog { + /** + * 功能模块 + * + * @return + */ + String module() default OperationLogModule.UNKNOWN_MODULE; + + /** + * 项目 + * + * @return + */ + String projectId() default "default"; + + /** + * 操作类型 + * + * @return + */ + OperationLogType type() default OperationLogType.SELECT; + + /** + * 资源ID + */ + String sourceId() default ""; + + /** + * 创建用户 + * + * @return + */ + String createUser() default ""; + + /** + * 操作内容 + * + * @return + */ + String details() default ""; + + /** + * 是否是批量删除操作 + * + * @return + */ + boolean isBatch() default false; + + /** + * 操作前触发内容 + * + * @return + */ + String event() default ""; + + /** + * 传入执行类 + * + * @return + */ + Class[] msClass() default {}; +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java new file mode 100644 index 0000000000..f4c46bd52f --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/aspect/OperationLogAspect.java @@ -0,0 +1,216 @@ +package io.metersphere.sdk.log.aspect; + +import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.service.OperationLogService; +import io.metersphere.sdk.util.LogUtils; +import io.metersphere.sdk.util.SessionUtils; +import io.metersphere.system.domain.OperationLog; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import org.apache.commons.lang3.StringUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.context.ApplicationContext; +import org.springframework.core.StandardReflectionParameterNameDiscoverer; +import org.springframework.expression.EvaluationContext; +import org.springframework.expression.Expression; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +/** + * 系统日志:切面处理类 + */ +@Aspect +@Component +public class OperationLogAspect { + /** + * 解析spell表达式 + */ + ExpressionParser parser = new SpelExpressionParser(); + /** + * 将方法参数纳入Spring管理 + */ + private final StandardReflectionParameterNameDiscoverer + discoverer = new StandardReflectionParameterNameDiscoverer(); + @Resource + private ApplicationContext applicationContext; + + @Resource + private OperationLogService operationLogService; + + private ThreadLocal> beforeValue = new ThreadLocal<>(); + private ThreadLocal localUser = new ThreadLocal<>(); + + private final String[] methodNames = new String[]{"delete", "update", "add"}; + + /** + * 定义切点 @Pointcut 在注解的位置切入代码 + */ + @Pointcut("@annotation(io.metersphere.sdk.log.annotation.RequestLog)") + public void logPointCut() { + } + + @Before("logPointCut()") + public void before(JoinPoint joinPoint) { + try { + //从切面织入点处通过反射机制获取织入点处的方法 + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + //获取切入点所在的方法 + Method method = signature.getMethod(); + RequestLog msLog = method.getAnnotation(RequestLog.class); + if (msLog != null && StringUtils.isNotEmpty(msLog.event())) { + //获取参数对象数组 + Object[] args = joinPoint.getArgs(); + //获取方法参数名 + String[] params = discoverer.getParameterNames(method); + //将参数纳入Spring管理 + EvaluationContext context = new StandardEvaluationContext(); + for (int len = 0; len < params.length; len++) { + context.setVariable(params[len], args[len]); + } + boolean isNext = false; + for (Class clazz : msLog.msClass()) { + if (clazz.getName().endsWith("SessionUtils")) { + localUser.set(SessionUtils.getUserId()); + continue; + } + context.setVariable("msClass", applicationContext.getBean(clazz)); + isNext = true; + } + if (isNext) { + Expression expression = parser.parseExpression(msLog.event()); + List beforeContent = expression.getValue(context, List.class); + beforeValue.set(beforeContent); + } + } + } catch (Exception e) { + LogUtils.error("操作日志写入异常:" + joinPoint.getSignature()); + } + } + + public boolean isMatch(String keyword) { + return Arrays.stream(methodNames) + .anyMatch(input -> input.contains(keyword)); + } + + private void add(OperationLog operationLog, RequestLog msLog, JoinPoint joinPoint) { + //从切面织入点处通过反射机制获取织入点处的方法 + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + //获取切入点所在的方法 + Method method = signature.getMethod(); + //获取参数对象数组 + Object[] args = joinPoint.getArgs(); + // 操作类型 + operationLog.setType(msLog.type().name()); + // 创建用户 + if (StringUtils.isNotBlank(msLog.createUser())) { + operationLog.setCreateUser(msLog.createUser()); + } + // 项目ID + operationLog.setProjectId(msLog.projectId()); + operationLog.setModule(msLog.module()); + //获取方法参数名 + String[] params = discoverer.getParameterNames(method); + //将参数纳入Spring管理 + EvaluationContext context = new StandardEvaluationContext(); + for (int len = 0; len < params.length; len++) { + context.setVariable(params[len], args[len]); + } + for (Class clazz : msLog.msClass()) { + context.setVariable("msClass", applicationContext.getBean(clazz)); + } + // 批量编辑操作 + if (msLog.isBatch()) { + operationLogService.batchAdd(beforeValue.get()); + return; + } + // 项目ID表达式 + try { + Expression titleExp = parser.parseExpression(msLog.projectId()); + String project = titleExp.getValue(context, String.class); + operationLog.setProjectId(project); + } catch (Exception e) { + operationLog.setProjectId(msLog.projectId()); + } + // 标题 + if (StringUtils.isNotEmpty(msLog.details())) { + String details = msLog.details(); + try { + Expression titleExp = parser.parseExpression(details); + details = titleExp.getValue(context, String.class); + operationLog.setDetails(details); + } catch (Exception e) { + operationLog.setDetails(details); + } + } + // 资源ID + if (StringUtils.isNotEmpty(msLog.sourceId())) { + try { + String sourceId = msLog.sourceId(); + Expression titleExp = parser.parseExpression(sourceId); + sourceId = titleExp.getValue(context, String.class); + operationLog.setSourceId(sourceId); + } catch (Exception e) { + operationLog.setSourceId(msLog.sourceId()); + } + } + if (StringUtils.isBlank(operationLog.getCreateUser())) { + operationLog.setCreateUser(localUser.get()); + } + operationLogService.add(operationLog); + } + + /** + * 切面 配置通知 + */ + @AfterReturning(value = "logPointCut()", returning = "result") + public void saveLog(JoinPoint joinPoint, Object result) { + try { + //从切面织入点处通过反射机制获取织入点处的方法 + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + //获取切入点所在的方法 + Method method = signature.getMethod(); + //保存日志 + OperationLog operationLog = new OperationLog(); + //保存获取的操作 + operationLog.setId(UUID.randomUUID().toString()); + String className = joinPoint.getTarget().getClass().getName(); + operationLog.setMethod(StringUtils.join(className, ".", method.getName())); + operationLog.setCreateTime(System.currentTimeMillis()); + operationLog.setCreateUser(SessionUtils.getUserId()); + HttpServletRequest request = ((ServletRequestAttributes) + RequestContextHolder.getRequestAttributes()).getRequest(); + String path = request.getServletPath(); + operationLog.setPath(path); + + // 获取操作 + RequestLog msLog = method.getAnnotation(RequestLog.class); + if (msLog != null) { + add(operationLog, msLog, joinPoint); + } + // 兼容遗漏注解的内容 + else if (isMatch(method.getName())) { + operationLogService.add(operationLog); + } + } catch (Exception e) { + LogUtils.error("操作日志写入异常:", e); + } finally { + localUser.remove(); + beforeValue.remove(); + } + } + +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/constants/OperationLogModule.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/constants/OperationLogModule.java new file mode 100644 index 0000000000..983e96d715 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/constants/OperationLogModule.java @@ -0,0 +1,49 @@ +package io.metersphere.sdk.log.constants; + +public class OperationLogModule { + public static final String UNKNOWN_MODULE = "UNKNOWN_MODULE"; + public static final String SYSTEM_PARAMETER_SETTING = "SYSTEM_PARAMETER_SETTING"; + public static final String SYSTEM_TEST_RESOURCE = "SYSTEM_TEST_RESOURCE"; + public static final String SYSTEM_USER = "SYSTEM_USER"; + public static final String SYSTEM_WORKSPACE = "SYSTEM_WORKSPACE"; + public static final String WORKSPACE_TEMPLATE_SETTINGS = "WORKSPACE_TEMPLATE_SETTINGS"; + public static final String WORKSPACE_MESSAGE_SETTINGS = "WORKSPACE_MESSAGE_SETTINGS"; + public static final String WORKSPACE_TEMPLATE_SETTINGS_FIELD = "WORKSPACE_TEMPLATE_SETTINGS_FIELD"; + public static final String WORKSPACE_TEMPLATE_SETTINGS_ISSUE = "WORKSPACE_TEMPLATE_SETTINGS_ISSUE"; + public static final String WORKSPACE_SERVICE_INTEGRATION = "WORKSPACE_SERVICE_INTEGRATION"; + public static final String WORKSPACE_TEMPLATE_SETTINGS_CASE = "WORKSPACE_TEMPLATE_SETTINGS_CASE"; + public static final String WORKSPACE_TEMPLATE_SETTINGS_API = "WORKSPACE_TEMPLATE_SETTINGS_API"; + public static final String WORKSPACE_MEMBER = "WORKSPACE_MEMBER"; + public static final String API_AUTOMATION = "API_AUTOMATION"; + public static final String API_AUTOMATION_SCHEDULE = "API_AUTOMATION_SCHEDULE"; + public static final String API_AUTOMATION_REPORT = "API_AUTOMATION_REPORT"; + public static final String API_DEFINITION = "API_DEFINITION"; + public static final String API_DEFINITION_CASE = "API_DEFINITION_CASE"; + public static final String TRACK_TEST_PLAN = "TRACK_TEST_PLAN"; + public static final String TRACK_TEST_PLAN_SCHEDULE = "TRACK_TEST_PLAN_SCHEDULE"; + public static final String TRACK_BUG = "TRACK_BUG"; + public static final String TRACK_TEST_CASE_REVIEW = "TRACK_TEST_CASE_REVIEW"; + public static final String TRACK_TEST_CASE = "TRACK_TEST_CASE"; + public static final String TRACK_REPORT = "TRACK_REPORT"; + public static final String AUTH_TITLE = "AUTH_TITLE"; + public static final String PROJECT_PROJECT_JAR = "PROJECT_PROJECT_JAR"; + public static final String PROJECT_ENVIRONMENT_SETTING = "PROJECT_ENVIRONMENT_SETTING"; + public static final String PROJECT_PROJECT_MANAGER = "PROJECT_PROJECT_MANAGER"; + public static final String PROJECT_FILE_MANAGEMENT = "PROJECT_FILE_MANAGEMENT"; + public static final String PROJECT_TEMPLATE_MANAGEMENT = "PROJECT_TEMPLATE_MANAGEMENT"; + public static final String PROJECT_PROJECT_MEMBER = "PROJECT_PROJECT_MEMBER"; + public static final String PERSONAL_INFORMATION_PERSONAL_SETTINGS = "PERSONAL_INFORMATION_PERSONAL_SETTINGS"; + public static final String PERSONAL_INFORMATION_APIKEYS = "PERSONAL_INFORMATION_APIKEYS"; + public static final String GROUP_PERMISSION = "GROUP_PERMISSION"; + public static final String PERFORMANCE_TEST_REPORT = "PERFORMANCE_TEST_REPORT"; + public static final String PERFORMANCE_TEST = "PERFORMANCE_TEST"; + public static final String ERROR_REPORT_LIBRARY = "ERROR_REPORT_LIBRARY"; + public static final String SYSTEM_QUOTA_MANAGEMENT = "SYSTEM_QUOTA_MANAGEMENT"; + public static final String ENTERPRISE_TEST_REPORT = "ENTERPRISE_TEST_REPORT"; + public static final String SYSTEM_AUTHORIZATION_MANAGEMENT = "SYSTEM_AUTHORIZATION_MANAGEMENT"; + public static final String UI_ELEMENT = "UI_ELEMENT"; + public static final String UI_AUTOMATION = "UI_AUTOMATION"; + public static final String UI_AUTOMATION_REPORT = "UI_AUTOMATION_REPORT"; + public static final String UI_AUTOMATION_SCHEDULE = "UI_AUTOMATION_SCHEDULE"; + public static final String PLUGIN_MANAGE = "PLUGIN_MANAGE"; +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/constants/OperationLogType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/constants/OperationLogType.java new file mode 100644 index 0000000000..e3bba40568 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/constants/OperationLogType.java @@ -0,0 +1,17 @@ +package io.metersphere.sdk.log.constants; + +public enum OperationLogType { + ADD, + DELETE, + UPDATE, + DEBUG, + REVIEW, + COPY, + EXECUTE, + SHARE, + RESTORE, + IMPORT, + EXPORT, + LOGIN, + SELECT +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/service/OperationLogService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/service/OperationLogService.java new file mode 100644 index 0000000000..e6d7d3ffaf --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/log/service/OperationLogService.java @@ -0,0 +1,55 @@ +package io.metersphere.sdk.log.service; + +import io.metersphere.system.domain.OperationLog; +import io.metersphere.system.mapper.OperationLogMapper; +import jakarta.annotation.Resource; +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 java.util.List; + +@Service +@Transactional(rollbackFor = Exception.class) +public class OperationLogService { + @Resource + private OperationLogMapper operationLogMapper; + @Resource + private SqlSessionFactory sqlSessionFactory; + + public void add(OperationLog log) { + if (StringUtils.isBlank(log.getProjectId())) { + log.setProjectId("none"); + } + if (StringUtils.isBlank(log.getCreateUser())) { + log.setCreateUser("admin"); + } + // 限制长度 + if (StringUtils.isNotBlank(log.getDetails()) && log.getDetails().length() > 1000) { + log.setDetails(log.getDetails().substring(0, 1000)); + } + operationLogMapper.insert(log); + } + + public void batchAdd(List logs) { + if (CollectionUtils.isEmpty(logs)) { + return; + } + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + OperationLogMapper logMapper = sqlSession.getMapper(OperationLogMapper.class); + if (CollectionUtils.isNotEmpty(logs)) { + logs.forEach(item -> { + logMapper.insert(item); + }); + } + sqlSession.flushStatements(); + if (sqlSession != null && sqlSessionFactory != null) { + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + } + } +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index db68cc540f..adb828c549 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -7,6 +7,9 @@ import io.metersphere.api.dto.definition.ApiDefinitionDTO; import io.metersphere.api.dto.definition.ListRequestDTO; import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.sdk.log.annotation.RequestLog; +import io.metersphere.sdk.log.constants.OperationLogModule; +import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.validation.groups.Created; @@ -29,11 +32,20 @@ public class ApiDefinitionController { @PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_VALUE) @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ_ADD_API) - public ApiDefinitionDTO create(@Validated({Created.class}) @RequestBody ApiDefinitionDTO request, - @RequestParam(value = "files") List bodyFiles) { + @RequestLog(type = OperationLogType.ADD, module = OperationLogModule.API_DEFINITION, + sourceId = "#request.id", projectId = "#request.projectId", details = "#request.name") + public ApiDefinitionDTO add(@Validated({Created.class}) @RequestBody ApiDefinitionDTO request, + @RequestParam(value = "files") List bodyFiles) { return apiDefinitionService.create(request, bodyFiles); } + @PostMapping(value = "/batch-del") + @RequiresPermissions(PermissionConstants.PROJECT_API_REPORT_READ_DELETE) + @RequestLog(isBatch = true, event = "#msClass.getLogs(#ids)", msClass = ApiDefinitionService.class) + public void batchDelete(@RequestBody List ids) { + apiDefinitionService.batchDelete(ids); + } + @PostMapping(value = "/page") @RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) public Pager> list(@Validated @RequestBody ListRequestDTO request) { diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 969f89beb5..6442baf614 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -5,13 +5,19 @@ import io.metersphere.api.domain.ApiDefinitionExample; import io.metersphere.api.dto.definition.ApiDefinitionDTO; import io.metersphere.api.dto.definition.ListRequestDTO; import io.metersphere.api.mapper.ApiDefinitionMapper; +import io.metersphere.sdk.log.constants.OperationLogModule; +import io.metersphere.sdk.log.constants.OperationLogType; +import io.metersphere.system.domain.OperationLog; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotNull; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.util.ArrayList; import java.util.List; +import java.util.UUID; @Service public class ApiDefinitionService { @@ -23,7 +29,6 @@ public class ApiDefinitionService { return request; } - public List list(@NotNull ListRequestDTO request) { ApiDefinitionExample example = new ApiDefinitionExample(); ApiDefinitionExample.Criteria criteria = example.createCriteria(); @@ -42,8 +47,37 @@ public class ApiDefinitionService { if (StringUtils.isNotBlank(request.getProtocol())) { criteria.andProtocolEqualTo(request.getProtocol()); } - - return apiDefinitionMapper.selectByExample(example); } + + public void batchDelete(List ids) { + + } + + /** + * 批量操作日志,由切面触发 + * + * @param ids + */ + public List getLogs(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return new ArrayList<>(); + } + List logs = new ArrayList<>(); + ApiDefinitionExample example = new ApiDefinitionExample(); + example.createCriteria().andIdIn(ids); + List definitions = apiDefinitionMapper.selectByExample(example); + definitions.forEach(definition -> { + OperationLog log = new OperationLog(); + log.setId(UUID.randomUUID().toString()); + log.setCreateUser(definition.getUpdateUser()); + log.setProjectId(definition.getProjectId()); + log.setType(OperationLogType.DELETE.name()); + log.setModule(OperationLogModule.API_DEFINITION); + log.setSourceId(definition.getId()); + log.setDetails(definition.getName()); + logs.add(log); + }); + return logs; + } } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java index 1c2257b351..c8c6ee8517 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java @@ -11,7 +11,6 @@ import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.utils.JsonUtils; import jakarta.annotation.Resource; -import org.junit.Before; import org.junit.jupiter.api.*; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; @@ -24,6 +23,7 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import java.util.ArrayList; import java.util.List; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -39,13 +39,8 @@ public class ApiDefinitionControllerTests { private static String sessionId; private static String csrfToken; - @Before - public void init() { - LogUtils.info("init base api test"); - } - @Test - @Order(0) + @BeforeEach public void login() throws Exception { MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login") .content("{\"username\":\"admin\",\"password\":\"metersphere\"}") @@ -173,4 +168,19 @@ public class ApiDefinitionControllerTests { .andExpect(status().isBadRequest()); } + @Test + @Order(4) + public void testBatchDel() throws Exception { + LogUtils.info("delete api test"); + List tests = new ArrayList<>(); + tests.add("test-api-id"); + + mockMvc.perform(MockMvcRequestBuilders.multipart(prefix + "/batch-del") + .contentType(MediaType.APPLICATION_JSON_VALUE) + .content(JSON.toJSONString(tests)) + .header(SessionConstants.HEADER_TOKEN, sessionId) + .header(SessionConstants.CSRF_TOKEN, csrfToken)) + .andExpect(status().isOk()); + + } }