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.User;
import io.metersphere.request.group.EditGroupRequest;
import io.metersphere.request.member.QueryMemberRequest;
import io.metersphere.dto.RelatedSource;
import io.metersphere.dto.UserGroupDTO;
import io.metersphere.dto.UserGroupInfoDTO;
import io.metersphere.request.group.EditGroupRequest;
import io.metersphere.request.member.QueryMemberRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -32,4 +32,6 @@ public interface BaseUserGroupMapper {
List<UserGroupInfoDTO> getUserGroupInfoByProjectId(String projectId);
List<User> getProjectMemberOption(@Param("projectId") String projectId);
List<String> getProjectUserId(String projectId);
}

View File

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

View File

@ -23,6 +23,7 @@ import io.metersphere.log.vo.system.SystemReference;
import io.metersphere.metadata.service.FileMetadataService;
import io.metersphere.request.AddProjectRequest;
import io.metersphere.request.ProjectRequest;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -30,8 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import jakarta.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@ -387,4 +386,9 @@ public class BaseProjectService {
public List<String> getPage(long pageNum, long 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;
@Resource
private NotificationService notificationService;
@Resource
private BaseProjectService baseProjectService;
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultSortOrder(request.getOrders()));
@ -1009,7 +1011,7 @@ public class PerformanceTestService {
if (BooleanUtils.toBoolean(reviewLoadTestScript.getTypeValue())) {
ProjectApplication loadTestScriptReviewerConfig = baseProjectApplicationService.getProjectApplication(
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);
if (isSend) {
Notification notification = new Notification();

View File

@ -592,22 +592,16 @@
<script>
import MsContainer from "metersphere-frontend/src/components/MsContainer";
import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer";
import { getCurrentProjectID } from "metersphere-frontend/src/utils/token";
import { hasLicense } from "metersphere-frontend/src/utils/permission";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {hasLicense} from "metersphere-frontend/src/utils/permission";
import AppManageItem from "./AppManageItem";
import TimingItem from "./TimingItem";
import ReviewerConfig from "@/business/menu/appmanage/ReviewerConfig.vue";
import { getProjectUsers } from "metersphere-frontend/src/api/user";
import { genTcpMockPort } from "../../../api/project";
import {
batchModifyAppSetting,
getProjectAppSetting,
} from "../../../api/app-setting";
import { PROJECT_APP_SETTING } from "../../../common/js/constants";
import {
getSystemBaseSetting,
getTestResourcePools,
} from "metersphere-frontend/src/api/system";
import {getProjectUsers} from "metersphere-frontend/src/api/user";
import {genTcpMockPort} from "../../../api/project";
import {batchModifyAppSetting, getProjectAppSetting,} from "../../../api/app-setting";
import {PROJECT_APP_SETTING} from "../../../common/js/constants";
import {getTestResourcePools,} from "metersphere-frontend/src/api/system";
export default {
name: "appManage",
@ -907,6 +901,16 @@ export default {
selectUserInProject() {
getProjectUsers().then((res) => {
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", "");
}
});
},
},