fix(性能测试): 性能测试脚本审核人被移除项目时不再触发审核通知

--bug=1026309 --user=宋天阳 【性能测试】审核人从项目成员删除-仍能收到消息通知-且点击通知名称跳转的性能场景实际不存在
https://www.tapd.cn/55049933/s/1373024
This commit is contained in:
song-tianyang 2023-05-18 20:02:10 +08:00 committed by 建国
parent 34542c2579
commit a7333e60d8
5 changed files with 41 additions and 25 deletions

View File

@ -2,11 +2,11 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.Group; import io.metersphere.base.domain.Group;
import io.metersphere.base.domain.User; import io.metersphere.base.domain.User;
import io.metersphere.request.group.EditGroupRequest;
import io.metersphere.request.member.QueryMemberRequest;
import io.metersphere.dto.RelatedSource; import io.metersphere.dto.RelatedSource;
import io.metersphere.dto.UserGroupDTO; import io.metersphere.dto.UserGroupDTO;
import io.metersphere.dto.UserGroupInfoDTO; import io.metersphere.dto.UserGroupInfoDTO;
import io.metersphere.request.group.EditGroupRequest;
import io.metersphere.request.member.QueryMemberRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -32,4 +32,6 @@ public interface BaseUserGroupMapper {
List<UserGroupInfoDTO> getUserGroupInfoByProjectId(String projectId); List<UserGroupInfoDTO> getUserGroupInfoByProjectId(String projectId);
List<User> getProjectMemberOption(@Param("projectId") String projectId); List<User> getProjectMemberOption(@Param("projectId") String projectId);
List<String> getProjectUserId(String projectId);
} }

View File

@ -95,12 +95,16 @@
</select> </select>
<select id="getProjectMemberOption" resultType="io.metersphere.base.domain.User"> <select id="getProjectMemberOption" resultType="io.metersphere.base.domain.User">
SELECT DISTINCT * SELECT DISTINCT *
FROM ( FROM (SELECT u.id, u.name, u.email
SELECT u.id, u.name, u.email
FROM user_group FROM user_group
JOIN `user` u ON user_group.user_id = u.id JOIN `user` u ON user_group.user_id = u.id
WHERE user_group.source_id = #{projectId} WHERE user_group.source_id = #{projectId}
ORDER BY user_group.update_time DESC ORDER BY user_group.update_time DESC) temp
) temp </select>
<select id="getProjectUserId" resultType="java.lang.String">
SELECT DISTINCT USER.id
FROM USER
JOIN user_group ug ON USER.id = ug.user_id
WHERE ug.source_id = #{0}
</select> </select>
</mapper> </mapper>

View File

@ -23,6 +23,7 @@ import io.metersphere.log.vo.system.SystemReference;
import io.metersphere.metadata.service.FileMetadataService; import io.metersphere.metadata.service.FileMetadataService;
import io.metersphere.request.AddProjectRequest; import io.metersphere.request.AddProjectRequest;
import io.metersphere.request.ProjectRequest; import io.metersphere.request.ProjectRequest;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,8 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import jakarta.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -387,4 +386,9 @@ public class BaseProjectService {
public List<String> getPage(long pageNum, long pageSize) { public List<String> getPage(long pageNum, long pageSize) {
return baseProjectMapper.selectPage(pageNum, pageSize); return baseProjectMapper.selectPage(pageNum, pageSize);
} }
public boolean isProjectMember(String projectId, String userId) {
List<String> projectUserId = baseUserGroupMapper.getProjectUserId(projectId);
return projectUserId.contains(userId);
}
} }

View File

@ -101,6 +101,8 @@ public class PerformanceTestService {
private BaseProjectApplicationService baseProjectApplicationService; private BaseProjectApplicationService baseProjectApplicationService;
@Resource @Resource
private NotificationService notificationService; private NotificationService notificationService;
@Resource
private BaseProjectService baseProjectService;
public List<LoadTestDTO> list(QueryTestPlanRequest request) { public List<LoadTestDTO> list(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
@ -1009,7 +1011,7 @@ public class PerformanceTestService {
if (BooleanUtils.toBoolean(reviewLoadTestScript.getTypeValue())) { if (BooleanUtils.toBoolean(reviewLoadTestScript.getTypeValue())) {
ProjectApplication loadTestScriptReviewerConfig = baseProjectApplicationService.getProjectApplication( ProjectApplication loadTestScriptReviewerConfig = baseProjectApplicationService.getProjectApplication(
projectId, ProjectApplicationType.PERFORMANCE_SCRIPT_REVIEWER.name()); projectId, ProjectApplicationType.PERFORMANCE_SCRIPT_REVIEWER.name());
if (StringUtils.isNotEmpty(loadTestScriptReviewerConfig.getTypeValue())) { if (StringUtils.isNotEmpty(loadTestScriptReviewerConfig.getTypeValue()) && baseProjectService.isProjectMember(projectId, loadTestScriptReviewerConfig.getTypeValue())) {
boolean isSend = this.isSendScriptReviewMessage(fileMetadataList, files); boolean isSend = this.isSendScriptReviewMessage(fileMetadataList, files);
if (isSend) { if (isSend) {
Notification notification = new Notification(); Notification notification = new Notification();

View File

@ -599,15 +599,9 @@ import TimingItem from "./TimingItem";
import ReviewerConfig from "@/business/menu/appmanage/ReviewerConfig.vue"; import ReviewerConfig from "@/business/menu/appmanage/ReviewerConfig.vue";
import {getProjectUsers} from "metersphere-frontend/src/api/user"; import {getProjectUsers} from "metersphere-frontend/src/api/user";
import {genTcpMockPort} from "../../../api/project"; import {genTcpMockPort} from "../../../api/project";
import { import {batchModifyAppSetting, getProjectAppSetting,} from "../../../api/app-setting";
batchModifyAppSetting,
getProjectAppSetting,
} from "../../../api/app-setting";
import {PROJECT_APP_SETTING} from "../../../common/js/constants"; import {PROJECT_APP_SETTING} from "../../../common/js/constants";
import { import {getTestResourcePools,} from "metersphere-frontend/src/api/system";
getSystemBaseSetting,
getTestResourcePools,
} from "metersphere-frontend/src/api/system";
export default { export default {
name: "appManage", name: "appManage",
@ -907,6 +901,16 @@ export default {
selectUserInProject() { selectUserInProject() {
getProjectUsers().then((res) => { getProjectUsers().then((res) => {
this.userInProject = res.data; this.userInProject = res.data;
//
let isExist = false;
this.userInProject.forEach((item) => {
if (item.id === this.config.performanceScriptReviewer) {
isExist = true;
}
});
if (!isExist) {
this.$set(this.config, "performanceScriptReviewer", "");
}
}); });
}, },
}, },