feat(系统设置): 系统日志后台接口
This commit is contained in:
parent
9c4244ea2a
commit
dfea1f83f9
|
@ -5,9 +5,8 @@ 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;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OperationLog implements Serializable {
|
||||
|
@ -21,6 +20,11 @@ public class OperationLog implements Serializable {
|
|||
@Size(min = 1, max = 50, message = "{operation_log.project_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String projectId;
|
||||
|
||||
@Schema(title = "组织id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{operation_log.organization_id.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 50, message = "{operation_log.organization_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String organizationId;
|
||||
|
||||
@Schema(title = "操作时间")
|
||||
private Long createTime;
|
||||
|
||||
|
@ -43,7 +47,7 @@ public class OperationLog implements Serializable {
|
|||
@Schema(title = "操作模块/api/case/scenario/ui")
|
||||
private String module;
|
||||
|
||||
@Schema(title = "操作内容")
|
||||
@Schema(title = "操作详情")
|
||||
private String content;
|
||||
|
||||
@Schema(title = "操作路径")
|
||||
|
|
|
@ -244,6 +244,76 @@ public class OperationLogExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdIsNull() {
|
||||
addCriterion("organization_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdIsNotNull() {
|
||||
addCriterion("organization_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdEqualTo(String value) {
|
||||
addCriterion("organization_id =", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdNotEqualTo(String value) {
|
||||
addCriterion("organization_id <>", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdGreaterThan(String value) {
|
||||
addCriterion("organization_id >", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("organization_id >=", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdLessThan(String value) {
|
||||
addCriterion("organization_id <", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("organization_id <=", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdLike(String value) {
|
||||
addCriterion("organization_id like", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdNotLike(String value) {
|
||||
addCriterion("organization_id not like", value, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdIn(List<String> values) {
|
||||
addCriterion("organization_id in", values, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdNotIn(List<String> values) {
|
||||
addCriterion("organization_id not in", values, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdBetween(String value1, String value2) {
|
||||
addCriterion("organization_id between", value1, value2, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrganizationIdNotBetween(String value1, String value2) {
|
||||
addCriterion("organization_id not between", value1, value2, "organizationId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<resultMap id="BaseResultMap" type="io.metersphere.sdk.domain.OperationLog">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||
<result column="source_id" jdbcType="VARCHAR" property="sourceId" />
|
||||
|
@ -72,8 +73,8 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, create_time, create_user, source_id, `method`, `type`, `module`,
|
||||
content, `path`
|
||||
id, project_id, organization_id, create_time, create_user, source_id, `method`, `type`,
|
||||
`module`, content, `path`
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.sdk.domain.OperationLogExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -106,14 +107,14 @@
|
|||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.sdk.domain.OperationLog">
|
||||
insert into operation_log (id, project_id, create_time,
|
||||
create_user, source_id, `method`,
|
||||
`type`, `module`, content,
|
||||
`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}, #{content,jdbcType=VARCHAR},
|
||||
#{path,jdbcType=VARCHAR})
|
||||
insert into operation_log (id, project_id, organization_id,
|
||||
create_time, create_user, source_id,
|
||||
`method`, `type`, `module`,
|
||||
content, `path`)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{sourceId,jdbcType=VARCHAR},
|
||||
#{method,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{module,jdbcType=VARCHAR},
|
||||
#{content,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.sdk.domain.OperationLog">
|
||||
insert into operation_log
|
||||
|
@ -124,6 +125,9 @@
|
|||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
organization_id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
|
@ -156,6 +160,9 @@
|
|||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
#{organizationId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
|
@ -197,6 +204,9 @@
|
|||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.organizationId != null">
|
||||
organization_id = #{record.organizationId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
|
@ -230,6 +240,7 @@
|
|||
update operation_log
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
organization_id = #{record.organizationId,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||
source_id = #{record.sourceId,jdbcType=VARCHAR},
|
||||
|
@ -248,6 +259,9 @@
|
|||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="organizationId != null">
|
||||
organization_id = #{organizationId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
|
@ -278,6 +292,7 @@
|
|||
<update id="updateByPrimaryKey" parameterType="io.metersphere.sdk.domain.OperationLog">
|
||||
update operation_log
|
||||
set project_id = #{projectId,jdbcType=VARCHAR},
|
||||
organization_id = #{organizationId,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
create_user = #{createUser,jdbcType=VARCHAR},
|
||||
source_id = #{sourceId,jdbcType=VARCHAR},
|
||||
|
|
|
@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS operation_log
|
|||
(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '主键',
|
||||
`project_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '项目id',
|
||||
`organization_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',
|
||||
|
|
|
@ -16,8 +16,9 @@ public class LogDTO extends OperationLog {
|
|||
|
||||
public LogDTO() {
|
||||
}
|
||||
public LogDTO(String projectId, String sourceId, String createUser, String type, String module, String content) {
|
||||
public LogDTO(String projectId, String organizationId, String sourceId, String createUser, String type, String module, String content) {
|
||||
this.setProjectId(projectId);
|
||||
this.setOrganizationId(organizationId);
|
||||
this.setSourceId(sourceId);
|
||||
this.setCreateUser(createUser);
|
||||
this.setType(type);
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package io.metersphere.sdk.log.service;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.domain.OperationLogBlob;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.mapper.OperationLogBlobMapper;
|
||||
import io.metersphere.sdk.mapper.OperationLogMapper;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.log.vo.OperationLogRequest;
|
||||
import io.metersphere.sdk.log.vo.OperationLogResponse;
|
||||
import io.metersphere.sdk.mapper.*;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.Organization;
|
||||
import io.metersphere.system.domain.User;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -15,7 +21,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -27,6 +35,18 @@ public class OperationLogService {
|
|||
@Resource
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
@Resource
|
||||
private BaseOperationLogMapper baseOperationLogMapper;
|
||||
|
||||
@Resource
|
||||
private BaseUserMapper baseUserMapper;
|
||||
|
||||
@Resource
|
||||
private BaseProjectMapper baseProjectMapper;
|
||||
|
||||
@Resource
|
||||
private BaseOrganizationMapper baseOrganizationMapper;
|
||||
|
||||
public void add(LogDTO log) {
|
||||
if (StringUtils.isBlank(log.getProjectId())) {
|
||||
log.setProjectId("none");
|
||||
|
@ -72,4 +92,34 @@ public class OperationLogService {
|
|||
blob.setModifiedValue(item.getModifiedValue());
|
||||
logBlobMapper.insert(blob);
|
||||
}
|
||||
|
||||
|
||||
public List<OperationLogResponse> list(OperationLogRequest request) {
|
||||
int compare = Long.compare(request.getStartTime(), request.getEndTime());
|
||||
if (compare > 0) {
|
||||
throw new MSException(Translator.get("startTime_must_be_less_than_endTime"));
|
||||
}
|
||||
List<OperationLogResponse> list = baseOperationLogMapper.list(request);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list) && !"system".equals(request.getLevel())) {
|
||||
List<String> userIds = list.stream().map(OperationLogResponse::getCreateUser).collect(Collectors.toList());
|
||||
List<String> projectIds = list.stream().map(OperationLogResponse::getProjectId).collect(Collectors.toList());
|
||||
List<String> organizationIds = list.stream().map(OperationLogResponse::getOrganizationId).collect(Collectors.toList());
|
||||
List<User> userList = baseUserMapper.selectUserByIdList(userIds);
|
||||
Map<String, String> userMap = userList.stream().collect(Collectors.toMap(User::getId, User::getName));
|
||||
List<Project> projects = baseProjectMapper.selectProjectByIdList(projectIds);
|
||||
Map<String, String> projectMap = projects.stream().collect(Collectors.toMap(Project::getId, Project::getName));
|
||||
List<Organization> organizations = baseOrganizationMapper.selectOrganizationByIdList(organizationIds);
|
||||
Map<String, String> organizationMap = organizations.stream().collect(Collectors.toMap(Organization::getId, Organization::getName));
|
||||
list.forEach(item -> {
|
||||
item.setUserName(userMap.getOrDefault(item.getCreateUser(), StringUtils.EMPTY));
|
||||
item.setProjectName(projectMap.getOrDefault(item.getProjectId(), StringUtils.EMPTY));
|
||||
item.setOrganizationName(organizationMap.getOrDefault(item.getOrganizationId(), StringUtils.EMPTY));
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package io.metersphere.sdk.log.vo;
|
||||
|
||||
import io.metersphere.sdk.dto.BasePageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OperationLogRequest extends BasePageRequest {
|
||||
|
||||
@Schema(title = "操作人")
|
||||
private String operUser;
|
||||
|
||||
|
||||
@Schema(title = "开始日期")
|
||||
@NotNull(message = "{start_time_is_null}")
|
||||
private Long startTime;
|
||||
@Schema(title = "结束日期")
|
||||
@NotNull(message = "{end_time_is_null}")
|
||||
private Long endTime;
|
||||
|
||||
@Schema(title = "项目id")
|
||||
private List<String> projectIds;
|
||||
|
||||
@Schema(title = "组织id")
|
||||
private List<String> organizationIds;
|
||||
|
||||
@Schema(title = "操作类型")
|
||||
private String type;
|
||||
|
||||
|
||||
@Schema(title = "操作对象")
|
||||
private String module;
|
||||
|
||||
@Schema(title = "名称")
|
||||
private String content;
|
||||
|
||||
private String level;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package io.metersphere.sdk.log.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OperationLogResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
//操作人
|
||||
private String createUser;
|
||||
private String userName;
|
||||
|
||||
//操作范围
|
||||
private String projectId;
|
||||
private String projectName;
|
||||
|
||||
private String organizationId;
|
||||
private String organizationName;
|
||||
|
||||
//操作对象
|
||||
private String module;
|
||||
|
||||
//操作类型
|
||||
private String type;
|
||||
|
||||
//名称
|
||||
private String content;
|
||||
|
||||
//创建时间
|
||||
private Long createTime;
|
||||
|
||||
|
||||
private String sourceId;
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.sdk.mapper;
|
||||
|
||||
|
||||
import io.metersphere.sdk.log.vo.OperationLogRequest;
|
||||
import io.metersphere.sdk.log.vo.OperationLogResponse;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BaseOperationLogMapper {
|
||||
|
||||
List<OperationLogResponse> list(@Param("request") OperationLogRequest request);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?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.sdk.mapper.BaseOperationLogMapper">
|
||||
|
||||
<select id="list" resultType="io.metersphere.sdk.log.vo.OperationLogResponse">
|
||||
SELECT
|
||||
t.id,
|
||||
t.project_id,
|
||||
t.organization_id,
|
||||
t.create_time,
|
||||
t.create_user,
|
||||
t.type,
|
||||
t.content
|
||||
FROM
|
||||
operation_log t
|
||||
<where>
|
||||
<if test="request.operUser != null and request.operUser != ''">
|
||||
AND t.create_user = #{request.operUser, jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="request.startTime != null and request.endTime != null">
|
||||
AND t.create_time BETWEEN #{request.startTime} AND #{request.endTime}
|
||||
</if>
|
||||
<if test="request.level != null and request.level != 'system'">
|
||||
AND t.project_id != 'system'
|
||||
</if>
|
||||
<if test="request.projectIds != null and request.projectIds.size > 0 ">
|
||||
AND t.project_id IN
|
||||
<foreach collection="request.projectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.organizationIds != null and request.organizationIds.size > 0 ">
|
||||
AND t.organization_id IN
|
||||
<foreach collection="request.organizationIds" item="organizationId" separator="," open="(" close=")">
|
||||
#{organizationId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.type != null and request.type != ''">
|
||||
AND t.type = #{request.type, jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="request.module != null and request.module != ''">
|
||||
AND t.module = #{module, jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="request.content != null and request.content != ''">
|
||||
AND t.content like #{request.content, jdbcType=VARCHAR}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.oper_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,10 @@
|
|||
package io.metersphere.sdk.mapper;
|
||||
|
||||
import io.metersphere.system.domain.Organization;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BaseOrganizationMapper {
|
||||
|
||||
List<Organization> selectOrganizationByIdList(List<String> organizationIds);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?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.sdk.mapper.BaseOrganizationMapper">
|
||||
|
||||
<select id="selectOrganizationByIdList" resultType="io.metersphere.system.domain.Organization">
|
||||
SELECT id, name
|
||||
FROM organization
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="id" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
|
@ -2,7 +2,10 @@ package io.metersphere.sdk.mapper;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BaseProjectMapper {
|
||||
Project selectOne();
|
||||
|
||||
List<Project> selectProjectByIdList(List<String> projectIds);
|
||||
}
|
||||
|
|
|
@ -6,4 +6,14 @@
|
|||
FROM project
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectProjectByIdList" resultType="io.metersphere.project.domain.Project">
|
||||
SELECT id, name
|
||||
FROM project
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="id" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
|
@ -24,4 +24,6 @@ public interface BaseUserMapper {
|
|||
List<User> selectByKeyword(String keyword);
|
||||
|
||||
List<String> selectUnDeletedUserIdByIdList(@Param("idList") List<String> userIdList);
|
||||
|
||||
List<User> selectUserByIdList(List<String> userIds);
|
||||
}
|
||||
|
|
|
@ -67,4 +67,14 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectUserByIdList" resultType="io.metersphere.system.domain.User">
|
||||
SELECT id, name
|
||||
FROM user
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="id" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
|
@ -217,6 +217,7 @@ public class SystemParameterService {
|
|||
public LogDTO addLog(List<SystemParameter> systemParameter) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
"system-parameter",
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -232,6 +233,7 @@ public class SystemParameterService {
|
|||
public LogDTO updateLog(List<SystemParameter> systemParameter) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
"system-parameter",
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
|
|
@ -256,6 +256,7 @@ public class TestResourcePoolService {
|
|||
public LogDTO addLog(TestResourcePoolRequest request) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -273,6 +274,7 @@ public class TestResourcePoolService {
|
|||
if (pool != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
id,
|
||||
pool.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
|
@ -293,6 +295,7 @@ public class TestResourcePoolService {
|
|||
if (pool != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
pool.getId(),
|
||||
pool.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
|
|
@ -58,6 +58,10 @@ related_case_del_fail_suffix=TestCase, please disassociate first
|
|||
jmx_content_valid=JMX content is invalid
|
||||
container_delete_fail=The container failed to stop, please try again
|
||||
load_test_report_file_not_exist=There is no JTL file in the current report, please wait or execute it again to get it
|
||||
startTime_must_be_less_than_endTime=Start time must be less than end time
|
||||
start_time_is_null=Start time cannot be null
|
||||
end_time_is_null=End time cannot be null
|
||||
|
||||
#organization
|
||||
organization_not_exists=Organization is not exists
|
||||
#test resource pool
|
||||
|
|
|
@ -58,6 +58,9 @@ related_case_del_fail_suffix=测试用例,请先解除关联
|
|||
jmx_content_valid=JMX 内容无效,请检查
|
||||
container_delete_fail=容器由于网络原因停止失败,请重试
|
||||
load_test_report_file_not_exist=当前报告没有JTL文件,请等待或重新执行以便获取
|
||||
startTime_must_be_less_than_endTime=开始日期必须小于结束日期
|
||||
start_time_is_null=开始日期不能为空
|
||||
end_time_is_null=结束日期不能为空
|
||||
|
||||
organization_not_exists=工作空间不存在
|
||||
#test resource pool
|
||||
|
|
|
@ -58,6 +58,10 @@ related_case_del_fail_suffix=測試用例,請先解除關聯
|
|||
jmx_content_valid=JMX 內容無效,請檢查
|
||||
container_delete_fail=容器由於網絡原因停止失敗,請重試
|
||||
load_test_report_file_not_exist=當前報告沒有JTL文件,請等待或重新執行以便獲取
|
||||
startTime_must_be_less_than_endTime=開始日期必須小於結束日期
|
||||
start_time_is_null=開始日期不能為空
|
||||
end_time_is_null=結束日期不能為空
|
||||
|
||||
#organization
|
||||
organization_not_exists=工作空間不存在
|
||||
#test resource pool
|
||||
|
|
|
@ -44,14 +44,16 @@ notification.resource_name.length_range=Notification resource name must be betwe
|
|||
novice_statistics.id.not_blank=Novice statistics id must not be blank
|
||||
novice_statistics.guide_step.not_blank=Novice statistics guide step must not be blank
|
||||
novice_statistics.guide_step.length_range=Novice statistics guide step must be between {min} and {max} characters long
|
||||
operating_log.id.not_blank=Operating log id must not be blank
|
||||
operating_log.project_id.not_blank=Operating log project id must not be blank
|
||||
operating_log.project_id.length_range=Operating log project id must be between {min} and {max} characters long
|
||||
operating_log_resource.id.not_blank=Operating log resource id must not be blank
|
||||
operating_log_resource.operating_log_id.not_blank=Operating log resource operating log id must not be blank
|
||||
operating_log_resource.operating_log_id.length_range=Operating log resource operating log id must be between {min} and {max} characters long
|
||||
operating_log_resource.source_id.not_blank=Operating log resource source id must not be blank
|
||||
operating_log_resource.source_id.length_range=Operating log resource source id must be between {min} and {max} characters long
|
||||
operation_log.id.not_blank=Operating log id must not be blank
|
||||
operation_log.project_id.not_blank=Operating log project id must not be blank
|
||||
operation_log.project_id.length_range=Operating log project id must be between {min} and {max} characters long
|
||||
operation_log.organization_id.not_blank=Operation log organization id must not be blank
|
||||
operation_log_resource.id.not_blank=Operating log resource id must not be blank
|
||||
operation_log.organization_id.length_range=Operation log organization id must be between {min} and {max} characters long
|
||||
operation_log_resource.operating_log_id.not_blank=Operating log resource operating log id must not be blank
|
||||
operation_log_resource.operating_log_id.length_range=Operating log resource operating log id must be between {min} and {max} characters long
|
||||
operation_log_resource.source_id.not_blank=Operating log resource source id must not be blank
|
||||
operation_log_resource.source_id.length_range=Operating log resource source id must be between {min} and {max} characters long
|
||||
plugin.id.not_blank=Plugin id must not be blank
|
||||
plugin.plugin_id.not_blank=Plugin plugin id must not be blank
|
||||
plugin.plugin_id.length_range=Plugin plugin id must be between {min} and {max} characters long
|
||||
|
|
|
@ -44,14 +44,16 @@ notification.resource_name.length_range=消息通知资源名称长度必须在{
|
|||
novice_statistics.id.not_blank=新手村ID不能为空
|
||||
novice_statistics.guide_step.not_blank=新手村步骤不能为空
|
||||
novice_statistics.guide_step.length_range=新手村步骤长度必须在{min}和{max}之间
|
||||
operating_log.id.not_blank=操作日志ID不能为空
|
||||
operating_log.project_id.not_blank=操作日志项目ID不能为空
|
||||
operating_log.project_id.length_range=操作日志项目ID长度必须在{min}和{max}之间
|
||||
operating_log_resource.id.not_blank=操作日志资源ID不能为空
|
||||
operating_log_resource.operating_log_id.not_blank=操作日志资源操作日志ID不能为空
|
||||
operating_log_resource.operating_log_id.length_range=操作日志资源操作日志ID长度必须在{min}和{max}之间
|
||||
operating_log_resource.source_id.not_blank=操作日志资源来源ID不能为空
|
||||
operating_log_resource.source_id.length_range=操作日志资源来源ID长度必须在{min}和{max}之间
|
||||
operation_log.id.not_blank=操作日志ID不能为空
|
||||
operation_log.project_id.not_blank=操作日志项目ID不能为空
|
||||
operation_log.project_id.length_range=操作日志项目ID长度必须在{min}和{max}之间
|
||||
operation_log.organization_id.not_blank=操作日志组织ID不能为空
|
||||
operation_log.organization_id.length_range=操作日志组织ID长度必须在{min}和{max}之间
|
||||
operation_log_resource.id.not_blank=操作日志资源ID不能为空
|
||||
operation_log_resource.operating_log_id.not_blank=操作日志资源操作日志ID不能为空
|
||||
operation_log_resource.operating_log_id.length_range=操作日志资源操作日志ID长度必须在{min}和{max}之间
|
||||
operation_log_resource.source_id.not_blank=操作日志资源来源ID不能为空
|
||||
operation_log_resource.source_id.length_range=操作日志资源来源ID长度必须在{min}和{max}之间
|
||||
plugin.id.not_blank=插件主键不能为空
|
||||
plugin.plugin_id.not_blank=插件ID不能为空
|
||||
plugin.plugin_id.length_range=插件ID长度必须在{min}和{max}之间
|
||||
|
|
|
@ -44,14 +44,16 @@ notification.resource_name.length_range=消息通知資源名稱長度必須在{
|
|||
novice_statistics.id.not_blank=新手村ID不能為空
|
||||
novice_statistics.guide_step.not_blank=新手村步驟不能為空
|
||||
novice_statistics.guide_step.length_range=新手村步驟長度必須在{min}和{max}之間
|
||||
operating_log.id.not_blank=操作日誌ID不能為空
|
||||
operating_log.project_id.not_blank=操作日誌項目ID不能為空
|
||||
operating_log.project_id.length_range=操作日誌項目ID長度必須在{min}和{max}之間
|
||||
operating_log_resource.id.not_blank=操作日誌資源ID不能為空
|
||||
operating_log_resource.operating_log_id.not_blank=操作日誌資源操作日誌ID不能為空
|
||||
operating_log_resource.operating_log_id.length_range=操作日誌資源操作日誌ID長度必須在{min}和{max}之間
|
||||
operating_log_resource.source_id.not_blank=操作日誌資源來源ID不能為空
|
||||
operating_log_resource.source_id.length_range=操作日誌資源來源ID長度必須在{min}和{max}之間
|
||||
operation_log.id.not_blank=操作日誌ID不能為空
|
||||
operation_log.project_id.not_blank=操作日誌項目ID不能為空
|
||||
operation_log.project_id.length_range=操作日誌項目ID長度必須在{min}和{max}之間
|
||||
operation_log.organization_id.not_blank=操作日誌組織ID不能為空
|
||||
operation_log.organization_id.length_range=操作日誌組織ID長度必須在{min}和{max}之間
|
||||
operation_log_resource.id.not_blank=操作日誌資源ID不能為空
|
||||
operation_log_resource.operating_log_id.not_blank=操作日誌資源操作日誌ID不能為空
|
||||
operation_log_resource.operating_log_id.length_range=操作日誌資源操作日誌ID長度必須在{min}和{max}之間
|
||||
operation_log_resource.source_id.not_blank=操作日誌資源來源ID不能為空
|
||||
operation_log_resource.source_id.length_range=操作日誌資源來源ID長度必須在{min}和{max}之間
|
||||
plugin.id.not_blank=插件主鍵不能為空
|
||||
plugin.plugin_id.not_blank=插件ID不能為空
|
||||
plugin.plugin_id.length_range=插件ID長度必須在{min}和{max}之間
|
||||
|
|
|
@ -30,6 +30,7 @@ public class ApiDefinitionLogService {
|
|||
public LogDTO addLog(ApiDefinitionDTO request) {
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
"",
|
||||
request.getId(),
|
||||
request.getCreateUser(),
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -53,6 +54,7 @@ public class ApiDefinitionLogService {
|
|||
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
"",
|
||||
request.getId(),
|
||||
request.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -78,6 +80,7 @@ public class ApiDefinitionLogService {
|
|||
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(request.getId());
|
||||
LogDTO dto = new LogDTO(
|
||||
request.getProjectId(),
|
||||
"",
|
||||
request.getId(),
|
||||
request.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
|
@ -106,6 +109,7 @@ public class ApiDefinitionLogService {
|
|||
apiDefinitions.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
item.getProjectId(),
|
||||
"",
|
||||
item.getId(),
|
||||
item.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
|
@ -132,6 +136,7 @@ public class ApiDefinitionLogService {
|
|||
apiDefinitions.forEach(item -> {
|
||||
LogDTO dto = new LogDTO(
|
||||
item.getProjectId(),
|
||||
"",
|
||||
item.getId(),
|
||||
item.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
|
||||
import io.metersphere.sdk.log.service.OperationLogService;
|
||||
import io.metersphere.sdk.log.vo.OperationLogRequest;
|
||||
import io.metersphere.sdk.log.vo.OperationLogResponse;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDto;
|
||||
import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse;
|
||||
import io.metersphere.system.service.OrganizationService;
|
||||
import io.metersphere.system.service.SystemProjectService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/operating/log")
|
||||
public class OperationLogController {
|
||||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
|
||||
@Resource
|
||||
private SystemProjectService systemProjectService;
|
||||
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
|
||||
@GetMapping("/get/options")
|
||||
@Operation(summary = "获取组织/项目级联下拉框选项")
|
||||
@RequiresPermissions(value = {PermissionConstants.SYSTEM_OPERATING_LOG_READ, PermissionConstants.ORGANIZATION_OPERATING_LOG_READ}, logical = Logical.OR)
|
||||
public OrganizationProjectOptionsResponse getOptions() {
|
||||
|
||||
//获取全部组织
|
||||
List<OrganizationProjectOptionsDto> organizationList = organizationService.getOrganizationOptions();
|
||||
//获取全部项目
|
||||
List<OrganizationProjectOptionsDto> projectList = systemProjectService.getprojectOptions();
|
||||
|
||||
OrganizationProjectOptionsResponse optionsResponse = new OrganizationProjectOptionsResponse();
|
||||
optionsResponse.setOrganizationList(organizationList);
|
||||
optionsResponse.setProjectList(projectList);
|
||||
|
||||
return optionsResponse;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "操作日志列表查询")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_OPERATING_LOG_READ)
|
||||
public Pager<List<OperationLogResponse>> list(@Validated @RequestBody OperationLogRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
return PageUtils.setPageInfo(page, operationLogService.list(request));
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ import io.metersphere.sdk.log.constants.OperationLogType;
|
|||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.UserBatchCreateDTO;
|
||||
import io.metersphere.system.dto.UserRoleOption;
|
||||
import io.metersphere.system.dto.request.UserChangeEnableRequest;
|
||||
|
@ -23,8 +24,10 @@ import io.metersphere.system.service.GlobalUserRoleService;
|
|||
import io.metersphere.system.service.UserService;
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -92,4 +95,11 @@ public class UserController {
|
|||
public UserBatchProcessResponse deleteUser(@Validated @RequestBody UserChangeEnableRequest userBatchProcessRequest) {
|
||||
return userService.deleteUser(userBatchProcessRequest.getUserIdList());
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "系统/组织日志页面,获取用户列表")
|
||||
@RequiresPermissions(value = {PermissionConstants.SYSTEM_OPERATING_LOG_READ, PermissionConstants.ORGANIZATION_OPERATING_LOG_READ}, logical = Logical.OR)
|
||||
public List<User> getUserList() {
|
||||
return userService.getUserList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package io.metersphere.system.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrganizationProjectOptionsDto {
|
||||
String id;
|
||||
String name;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.system.dto.response;
|
||||
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDto;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OrganizationProjectOptionsResponse {
|
||||
|
||||
List<OrganizationProjectOptionsDto> organizationList;
|
||||
List<OrganizationProjectOptionsDto> projectList;
|
||||
}
|
|
@ -2,6 +2,7 @@ package io.metersphere.system.mapper;
|
|||
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.OrganizationDTO;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDto;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.request.OrganizationDeleteRequest;
|
||||
import io.metersphere.system.request.OrganizationRequest;
|
||||
|
@ -59,4 +60,10 @@ public interface ExtOrganizationMapper {
|
|||
* @return 组织管理员数据
|
||||
*/
|
||||
List<User> getOrgAdminList(String orgId);
|
||||
|
||||
/**
|
||||
* 获取组织列表(下拉框)
|
||||
* @return 组织列表数据
|
||||
*/
|
||||
List<OrganizationProjectOptionsDto> selectOrganizationOptions();
|
||||
}
|
||||
|
|
|
@ -90,4 +90,8 @@
|
|||
join `user` u on urr.user_id = u.id
|
||||
where urr.role_id = 'org_admin'and urr.source_id = #{orgId}
|
||||
</select>
|
||||
|
||||
<select id="selectOrganizationOptions" resultType="io.metersphere.system.dto.OrganizationProjectOptionsDto">
|
||||
select id, name from organization order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -2,6 +2,7 @@ package io.metersphere.system.mapper;
|
|||
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDto;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.request.ProjectMemberRequest;
|
||||
import io.metersphere.system.request.ProjectRequest;
|
||||
|
@ -16,4 +17,6 @@ public interface ExtSystemProjectMapper {
|
|||
List<ProjectDTO> getProjectList(@Param("request") ProjectRequest request);
|
||||
|
||||
List<User> getProjectAdminList(String projectId);
|
||||
|
||||
List<OrganizationProjectOptionsDto> selectProjectOptions();
|
||||
}
|
||||
|
|
|
@ -59,4 +59,9 @@
|
|||
and user_role_relation.role_id = 'project_admin'
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectProjectOptions" resultType="io.metersphere.system.dto.OrganizationProjectOptionsDto">
|
||||
select id, name from project order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -30,6 +30,7 @@ public class AuthSourceLogService {
|
|||
public LogDTO addLog(AuthSourceRequest request) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -53,6 +54,7 @@ public class AuthSourceLogService {
|
|||
if (authSource != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -72,6 +74,7 @@ public class AuthSourceLogService {
|
|||
if (authSource != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
id,
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -99,6 +102,7 @@ public class AuthSourceLogService {
|
|||
}
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
authSource.getId(),
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
|
|
|
@ -36,6 +36,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService {
|
|||
public LogDTO addLog(UserRoleUpdateRequest request) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -57,6 +58,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService {
|
|||
if (userRole != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
userRole.getId(),
|
||||
userRole.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -76,6 +78,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService {
|
|||
if (userRole != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
request.getUserRoleId(),
|
||||
userRole.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -104,6 +107,7 @@ public class GlobalUserRoleLogService extends BaseUserRoleService {
|
|||
}
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
userRole.getId(),
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
|
|
|
@ -33,6 +33,7 @@ public class GlobalUserRoleRelationLogService extends BaseUserRoleRelationServic
|
|||
public LogDTO addLog(GlobalUserRoleRelationUpdateRequest request) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -56,6 +57,7 @@ public class GlobalUserRoleRelationLogService extends BaseUserRoleRelationServic
|
|||
if (userRoleRelation != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
id,
|
||||
userRoleRelation.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.sdk.util.BeanUtils;
|
|||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.dto.OrganizationDTO;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDto;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.mapper.ExtOrganizationMapper;
|
||||
import io.metersphere.system.mapper.OrganizationMapper;
|
||||
|
@ -107,4 +108,9 @@ public class OrganizationService{
|
|||
});
|
||||
return organizationDTOS;
|
||||
}
|
||||
|
||||
|
||||
public List<OrganizationProjectOptionsDto> getOrganizationOptions() {
|
||||
return extOrganizationMapper.selectOrganizationOptions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class SystemProjectLogService {
|
|||
public LogDTO addLog(AddProjectRequest project) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
|
@ -51,6 +52,7 @@ public class SystemProjectLogService {
|
|||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
project.getId(),
|
||||
project.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -70,6 +72,7 @@ public class SystemProjectLogService {
|
|||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
project.getId(),
|
||||
project.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -96,6 +99,7 @@ public class SystemProjectLogService {
|
|||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
id,
|
||||
project.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
|
|
|
@ -12,6 +12,7 @@ import io.metersphere.sdk.util.Translator;
|
|||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRoleRelation;
|
||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDto;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
|
@ -225,4 +226,8 @@ public class SystemProjectService {
|
|||
userGroupExample.createCriteria().andSourceIdEqualTo(projectId);
|
||||
userRoleRelationMapper.deleteByExample(userGroupExample);
|
||||
}
|
||||
|
||||
public List<OrganizationProjectOptionsDto> getprojectOptions() {
|
||||
return extSystemProjectMapper.selectProjectOptions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class UserRoleRelationService {
|
|||
LogDTO log = new LogDTO();
|
||||
log.setId(UUID.randomUUID().toString());
|
||||
log.setProjectId("system");
|
||||
log.setOrganizationId("");
|
||||
log.setType(operationType);
|
||||
log.setCreateUser(operator);
|
||||
log.setModule(OperationLogModule.SYSTEM_USER);
|
||||
|
|
|
@ -65,6 +65,7 @@ public class UserService {
|
|||
log.setId(UUID.randomUUID().toString());
|
||||
log.setCreateUser(user.getCreateUser());
|
||||
log.setProjectId("system");
|
||||
log.setOrganizationId("");
|
||||
log.setType(OperationLogType.ADD.name());
|
||||
log.setModule(OperationLogModule.SYSTEM_USER);
|
||||
log.setMethod("addUser");
|
||||
|
@ -290,6 +291,7 @@ public class UserService {
|
|||
if (user != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
request.getId(),
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
|
@ -312,6 +314,7 @@ public class UserService {
|
|||
|
||||
LogDTO dto = new LogDTO(
|
||||
"system",
|
||||
"",
|
||||
user.getId(),
|
||||
user.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
|
@ -326,4 +329,10 @@ public class UserService {
|
|||
});
|
||||
return logDTOList;
|
||||
}
|
||||
|
||||
public List<User> getUserList() {
|
||||
UserExample example = new UserExample();
|
||||
example.setOrderByClause("update_time desc");
|
||||
return userMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
import base.BaseTest;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.log.vo.OperationLogRequest;
|
||||
import io.metersphere.system.controller.param.OperationLogRequestDefinition;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
import org.springframework.test.context.jdbc.SqlConfig;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class OperationLogControllerTests extends BaseTest {
|
||||
|
||||
public static final String OPERATION_LOG_LIST = "/operating/log/list";
|
||||
|
||||
public static final String OPTIONS_LIST = "/operating/log/get/options";
|
||||
|
||||
|
||||
public static final String USER_LIST = "/system/user/list";
|
||||
|
||||
public static final String SYSTEM = "system";
|
||||
public static final String ORGANIZATION = "organization";
|
||||
|
||||
|
||||
/**
|
||||
* 系统级别 查询 用例
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Order(1)
|
||||
@Sql(scripts = {"/dml/init_operation_log_test.sql"},
|
||||
config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED),
|
||||
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
|
||||
public void testSystemOperationLogList() throws Exception {
|
||||
//系统级别 全部
|
||||
OperationLogRequest request = buildParam(SYSTEM);
|
||||
this.requestPostWithOkAndReturn(OPERATION_LOG_LIST, request);
|
||||
|
||||
// @@异常参数校验
|
||||
updatedGroupParamValidateTest(OperationLogRequestDefinition.class, OPERATION_LOG_LIST);
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPERATION_LOG_LIST, request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 组织级别 查询 用例
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testOrganizationOperationLogList() throws Exception {
|
||||
OperationLogRequest request = buildParam(ORGANIZATION);
|
||||
//组织级别 全部
|
||||
this.requestPostWithOkAndReturn(OPERATION_LOG_LIST, request);
|
||||
|
||||
//组织级别 指定组织查询
|
||||
request.setOrganizationIds(Arrays.asList("organization_id_001","organization_id_002"));
|
||||
this.requestPostWithOkAndReturn(OPERATION_LOG_LIST, request);
|
||||
|
||||
// @@异常参数校验
|
||||
updatedGroupParamValidateTest(OperationLogRequestDefinition.class, OPERATION_LOG_LIST);
|
||||
// @@校验权限
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPERATION_LOG_LIST, request);
|
||||
}
|
||||
|
||||
|
||||
//TODO 项目级别 查询 用例
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testGetOptions() throws Exception {
|
||||
this.requestGetWithOkAndReturn(OPTIONS_LIST);
|
||||
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPTIONS_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testUserList() throws Exception {
|
||||
this.requestGetWithOkAndReturn(USER_LIST);
|
||||
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_OPERATING_LOG_READ, OPTIONS_LIST);
|
||||
}
|
||||
|
||||
//TODO 异常用例补充
|
||||
|
||||
|
||||
private OperationLogRequest buildParam(String level) {
|
||||
OperationLogRequest request = new OperationLogRequest();
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(10);
|
||||
request.setStartTime(1689131059000l);
|
||||
request.setEndTime(1689149059000l);
|
||||
request.setLevel(level);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest;
|
|||
import io.metersphere.system.request.OrganizationUserRoleMemberRequest;
|
||||
import io.metersphere.utils.JsonUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
|
@ -284,10 +285,13 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
// 返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= request.getPageSize());
|
||||
// 返回值中取出第一条数据, 并判断是否包含关键字default
|
||||
User user = JSON.parseArray(JSON.toJSONString(pageData.getList()), User.class).get(0);
|
||||
List<User> userList = JSON.parseArray(JSON.toJSONString(pageData.getList()), User.class);
|
||||
if(CollectionUtils.isNotEmpty(userList)) {
|
||||
User user = userList.get(0);
|
||||
Assertions.assertTrue(StringUtils.contains(user.getName(), request.getUserName())
|
||||
|| StringUtils.contains(user.getId(), request.getUserName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
|
@ -341,7 +345,7 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
OrganizationUserRoleMemberEditRequest request = new OrganizationUserRoleMemberEditRequest();
|
||||
request.setOrganizationId("default-organization-2");
|
||||
request.setUserRoleId("default-org-role-id-3");
|
||||
request.setUserId("default-admin");
|
||||
request.setUserId("admin");
|
||||
this.requestPost(ORGANIZATION_USER_ROLE_REMOVE_MEMBER, request, status().isOk());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package io.metersphere.system.controller.param;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class OperationLogRequestDefinition {
|
||||
|
||||
|
||||
private String operUser;
|
||||
|
||||
|
||||
@NotNull(message = "{start_time_is_null}")
|
||||
private Long startTime;
|
||||
@NotNull(message = "{end_time_is_null}")
|
||||
private Long endTime;
|
||||
|
||||
private List<String> projectIds;
|
||||
|
||||
private List<String> organizationIds;
|
||||
|
||||
private String type;
|
||||
|
||||
|
||||
private String module;
|
||||
|
||||
private String content;
|
||||
|
||||
private String level;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
-- 模拟数据
|
||||
INSERT INTO organization (id, num, name, description, create_user, update_user, create_time, update_time) VALUES ('organization_id_001', 100010, '测试日志组织', '测试日志的组织', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('project_id_001', 100010, 'organization_id_001', '测试日志项目', '测试日志的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
|
||||
-- 初始化日志记录
|
||||
INSERT INTO operation_log(`id`, `project_id`, `organization_id`, `create_time`, `create_user`, `source_id`, `method`, `type`, `module`, `content`, `path`) VALUES (uuid(), 'system', '', 1689141859000, 'admin', '1', 'post', 'add', 'SYSTEM_PARAMETER_SETTING', '认证配置', '/system/authsource/add');
|
||||
INSERT INTO operation_log(`id`, `project_id`, `organization_id`, `create_time`, `create_user`, `source_id`, `method`, `type`, `module`, `content`, `path`) VALUES (uuid(), '', 'organization_id_001', 1689141859000, 'admin', '1', 'post', 'add', 'SYSTEM_PARAMETER_SETTING', '认证配置', '/system/authsource/add');
|
||||
INSERT INTO operation_log(`id`, `project_id`, `organization_id`, `create_time`, `create_user`, `source_id`, `method`, `type`, `module`, `content`, `path`) VALUES (uuid(), 'project_id_001', 'organization_id_001', 1689141859000, 'admin', '1', 'post', 'add', 'SYSTEM_PARAMETER_SETTING', '认证配置', '/system/authsource/add');
|
||||
|
Loading…
Reference in New Issue