diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml index c6b09927f8..a410a9f08a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml @@ -12,15 +12,11 @@ upper (t.oper_module) oper_module , t.oper_title, t.oper_time, - t1.NAME userName, t2.`name` projectName , - t2.workspace_id workspace_id , - w.name workspaceName + t2.workspace_id workspace_id FROM operating_log t - LEFT JOIN `user` t1 ON t.oper_user = t1.id LEFT JOIN project t2 ON t.project_id = t2.id - LEFT JOIN workspace w on t2.workspace_id = w.id LEFT JOIN operating_log_resource t3 ON t.id = t3.operating_log_id @@ -29,19 +25,8 @@ #{projectId} - - t2.workspace_id in - - #{workspaceId} - - - - or t.project_id is null - or t.project_id = "" - - and (t.oper_user like #{request.operUser, jdbcType=VARCHAR} or t1.name like - #{request.operUser, jdbcType=VARCHAR}) + and t.oper_user like #{request.operUser, jdbcType=VARCHAR} and t.project_id = #{request.projectId} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java index 513592e81e..2265bb8ddd 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java @@ -1,6 +1,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.base.domain.Project; +import io.metersphere.base.domain.Workspace; import io.metersphere.controller.request.ProjectRequest; import io.metersphere.dto.ProjectDTO; import org.apache.ibatis.annotations.MapKey; @@ -28,6 +29,9 @@ public interface ExtProjectMapper { @MapKey("id") Map queryNameByIds(@Param("ids") List ids); + @MapKey("id") + Map queryWorkspaceNameByProjectIds(@Param("ids") List ids); + Project selectProjectByResourceId(@Param("resourceId") String resourceId); long getProjectMemberSize(@Param("projectId") String projectId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index a7d6181e4a..6d9086704a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -280,6 +280,15 @@ + INSERT INTO message_task (id, type, event, user_id, task_type, webhook, identification, is_set, project_id, diff --git a/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java index 8bc61b3dad..a601564831 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java @@ -3,6 +3,7 @@ package io.metersphere.commons.utils; import io.metersphere.base.domain.Project; import io.metersphere.base.domain.ProjectVersion; import io.metersphere.base.domain.User; +import io.metersphere.base.domain.Workspace; import io.metersphere.commons.exception.MSException; import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.controller.request.OrderRequest; @@ -135,6 +136,21 @@ public class ServiceUtils { return nameMap; } + public static Map getWorkspaceNameByProjectIds(List projectIds) { + ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class); + HashMap nameMap = new HashMap<>(); + + if (!CollectionUtils.isEmpty(projectIds)) { + Map workspaceMap = projectService.getWorkspaceNameByProjectIds(projectIds); + workspaceMap.forEach((k, v) -> { + nameMap.put(k, v.getName()); + }); + return nameMap; + } + + return nameMap; + } + public static Map getProjectMap(List ids) { ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class); if (!CollectionUtils.isEmpty(ids)) { diff --git a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java index 389b12409d..530978f72a 100644 --- a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java +++ b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java @@ -37,6 +37,7 @@ public class WorkspaceController { PermissionConstants.SYSTEM_GROUP_READ_EDIT, PermissionConstants.SYSTEM_USER_READ_CREATE, PermissionConstants.SYSTEM_USER_READ_EDIT, + PermissionConstants.SYSTEM_WORKSPACE_READ }, logical = Logical.OR) public List getWorkspaceList() { return workspaceService.getWorkspaceList(new WorkspaceRequest()); diff --git a/backend/src/main/java/io/metersphere/log/service/OperatingLogService.java b/backend/src/main/java/io/metersphere/log/service/OperatingLogService.java index 0bd385e5be..41d64529a6 100644 --- a/backend/src/main/java/io/metersphere/log/service/OperatingLogService.java +++ b/backend/src/main/java/io/metersphere/log/service/OperatingLogService.java @@ -7,6 +7,7 @@ import io.metersphere.base.mapper.OperatingLogMapper; import io.metersphere.base.mapper.OperatingLogResourceMapper; import io.metersphere.base.mapper.ext.ExtOperatingLogMapper; import io.metersphere.commons.utils.BeanUtils; +import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.i18n.Translator; import io.metersphere.log.vo.OperatingLogDTO; import io.metersphere.log.vo.OperatingLogDetails; @@ -23,7 +24,9 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; +import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) @@ -68,7 +71,18 @@ public class OperatingLogService { request.setStartTime(request.getTimes().get(0)); request.setEndTime(request.getTimes().get(1)); } - return extOperatingLogMapper.list(request); + List list = extOperatingLogMapper.list(request); + if (CollectionUtils.isNotEmpty(list)) { + List userIds = list.stream().map(OperatingLogDTO::getOperUser).collect(Collectors.toList()); + List projectIds = list.stream().map(OperatingLogDTO::getProjectId).collect(Collectors.toList()); + Map userNameMap = ServiceUtils.getUserNameMap(userIds); + Map workspaceNameMap = ServiceUtils.getWorkspaceNameByProjectIds(projectIds); + for (OperatingLogDTO dto : list) { + dto.setUserName(userNameMap.getOrDefault(dto.getOperUser(), "")); + dto.setWorkspaceName(workspaceNameMap.getOrDefault(dto.getProjectId(), "")); + } + } + return list; } public OperatingLogDTO get(String id) { diff --git a/backend/src/main/java/io/metersphere/log/vo/OperatingLogDTO.java b/backend/src/main/java/io/metersphere/log/vo/OperatingLogDTO.java index 45c9d0e8b1..77204cb35f 100644 --- a/backend/src/main/java/io/metersphere/log/vo/OperatingLogDTO.java +++ b/backend/src/main/java/io/metersphere/log/vo/OperatingLogDTO.java @@ -33,4 +33,6 @@ public class OperatingLogDTO implements Serializable { private String operContent; private OperatingLogDetails details; + + private String projectId; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 77f277d22c..ae2b0653ea 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -812,6 +812,13 @@ public class ProjectService { return extProjectMapper.queryNameByIds(ids); } + public Map getWorkspaceNameByProjectIds(List projectIds) { + if (projectIds.isEmpty()) { + return new HashMap<>(0); + } + return extProjectMapper.queryWorkspaceNameByProjectIds(projectIds); + } + public void openMockTcp(Project project) { if (project == null) { MSException.throwException("Project not found!"); diff --git a/frontend/src/business/components/project/menu/Log.vue b/frontend/src/business/components/project/menu/Log.vue index c1f03022ef..120f528040 100644 --- a/frontend/src/business/components/project/menu/Log.vue +++ b/frontend/src/business/components/project/menu/Log.vue @@ -257,7 +257,7 @@ export default { }, reset() { let projectIds = this.condition.projectIds; - this.condition = {projectIds: projectIds, projectId: getCurrentProjectID()}; + this.condition = {projectIds: projectIds, projectId: getCurrentProjectID(), times: [new Date().getTime() - 3600 * 1000 * 24 * 7, new Date().getTime()]}; this.initTableData(); }, initProject(url) { diff --git a/frontend/src/business/components/settings/operatinglog/OperatingLog.vue b/frontend/src/business/components/settings/operatinglog/OperatingLog.vue index 5c3d891b27..bc8daa9661 100644 --- a/frontend/src/business/components/settings/operatinglog/OperatingLog.vue +++ b/frontend/src/business/components/settings/operatinglog/OperatingLog.vue @@ -43,7 +43,7 @@ - @@ -301,11 +301,11 @@ export default { }, reset() { let projectIds = this.condition.projectIds; - this.condition = {projectIds: projectIds}; + this.condition = {projectIds: projectIds, times: [new Date().getTime() - 3600 * 1000 * 24 * 7, new Date().getTime()]}; this.initTableData(); }, getWorkSpaceList() { - this.$get("/workspace/list/userworkspace", response => { + this.$get("/workspace/list", response => { let workspaceList = response.data; let workspaceIds = []; if (workspaceList) {