fix(缺陷管理): 缺陷分享链接删除添加校验

--bug=1036436 --user=宋昌昌 【缺陷管理】分享缺陷,缺陷被删除,打开分享链接页面错误 https://www.tapd.cn/55049933/s/1476141
This commit is contained in:
song-cc-rock 2024-03-15 16:27:46 +08:00 committed by Craftsman
parent 78d8e0d4d6
commit f00c9080e9
16 changed files with 78 additions and 18 deletions

View File

@ -116,6 +116,13 @@ public class BugController {
return bugService.addOrUpdate(request, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), true); return bugService.addOrUpdate(request, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), true);
} }
@GetMapping("/check-exist/{id}")
@Operation(summary = "缺陷管理-列表-校验缺陷是否存在")
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)
public boolean check(@PathVariable String id) {
return bugService.checkExist(id);
}
@GetMapping("/get/{id}") @GetMapping("/get/{id}")
@Operation(summary = "缺陷管理-列表-查看缺陷(详情&&编辑&&复制)") @Operation(summary = "缺陷管理-列表-查看缺陷(详情&&编辑&&复制)")
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ) @RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)

View File

@ -567,7 +567,7 @@ public class BugAttachmentService {
*/ */
private FileLogRecord createFileLogRecord(String operator, String projectId){ private FileLogRecord createFileLogRecord(String operator, String projectId){
return FileLogRecord.builder() return FileLogRecord.builder()
.logModule(OperationLogModule.BUG_MANAGEMENT) .logModule(OperationLogModule.BUG_MANAGEMENT_INDEX)
.operator(operator) .operator(operator)
.projectId(projectId) .projectId(projectId)
.build(); .build();

View File

@ -39,7 +39,7 @@ public class BugHistoryService {
*/ */
public List<OperationHistoryDTO> list(OperationHistoryRequest request) { public List<OperationHistoryDTO> list(OperationHistoryRequest request) {
OperationHistoryExample example = new OperationHistoryExample(); OperationHistoryExample example = new OperationHistoryExample();
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andModuleEqualTo(OperationLogModule.BUG_MANAGEMENT) example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andModuleIn(List.of(OperationLogModule.BUG_MANAGEMENT_INDEX, OperationLogModule.BUG_MANAGEMENT_RECYCLE))
.andSourceIdEqualTo(request.getSourceId()); .andSourceIdEqualTo(request.getSourceId());
List<OperationHistory> history = operationHistoryMapper.selectByExample(example); List<OperationHistory> history = operationHistoryMapper.selectByExample(example);
if (CollectionUtils.isEmpty(history)) { if (CollectionUtils.isEmpty(history)) {

View File

@ -39,7 +39,7 @@ public class BugLogService {
* @return 日志 * @return 日志
*/ */
public LogDTO addLog(BugEditRequest request, List<MultipartFile> files) { public LogDTO addLog(BugEditRequest request, List<MultipartFile> files) {
LogDTO dto = new LogDTO(request.getProjectId(), null, null, null, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT, request.getTitle()); LogDTO dto = new LogDTO(request.getProjectId(), null, null, null, OperationLogType.ADD.name(), OperationLogModule.BUG_MANAGEMENT_CREATE, request.getTitle());
dto.setHistory(true); dto.setHistory(true);
dto.setPath("/bug/add"); dto.setPath("/bug/add");
dto.setMethod(HttpMethodConstants.POST.name()); dto.setMethod(HttpMethodConstants.POST.name());
@ -56,7 +56,7 @@ public class BugLogService {
*/ */
public LogDTO updateLog(BugEditRequest request, List<MultipartFile> files) { public LogDTO updateLog(BugEditRequest request, List<MultipartFile> files) {
BugDTO history = getOriginalValue(request.getId()); BugDTO history = getOriginalValue(request.getId());
LogDTO dto = new LogDTO(request.getProjectId(), null, request.getId(), null, OperationLogType.UPDATE.name(), OperationLogModule.BUG_MANAGEMENT, request.getTitle()); LogDTO dto = new LogDTO(request.getProjectId(), null, request.getId(), null, OperationLogType.UPDATE.name(), OperationLogModule.BUG_MANAGEMENT_UPDATE, request.getTitle());
dto.setHistory(true); dto.setHistory(true);
dto.setPath("/bug/update"); dto.setPath("/bug/update");
dto.setMethod(HttpMethodConstants.POST.name()); dto.setMethod(HttpMethodConstants.POST.name());
@ -74,7 +74,7 @@ public class BugLogService {
public LogDTO deleteLog(String id) { public LogDTO deleteLog(String id) {
Bug bug = bugMapper.selectByPrimaryKey(id); Bug bug = bugMapper.selectByPrimaryKey(id);
if (bug != null) { if (bug != null) {
LogDTO dto = new LogDTO(bug.getProjectId(), null, bug.getId(), null, OperationLogType.DELETE.name(), OperationLogModule.BUG_MANAGEMENT, bug.getTitle()); LogDTO dto = new LogDTO(bug.getProjectId(), null, bug.getId(), null, OperationLogType.DELETE.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, bug.getTitle());
dto.setPath("/bug/delete"); dto.setPath("/bug/delete");
dto.setMethod(HttpMethodConstants.GET.name()); dto.setMethod(HttpMethodConstants.GET.name());
dto.setOriginalValue(JSON.toJSONBytes(bug)); dto.setOriginalValue(JSON.toJSONBytes(bug));
@ -92,7 +92,7 @@ public class BugLogService {
public LogDTO recoverLog(String id) { public LogDTO recoverLog(String id) {
Bug bug = bugMapper.selectByPrimaryKey(id); Bug bug = bugMapper.selectByPrimaryKey(id);
if (bug != null) { if (bug != null) {
LogDTO dto = new LogDTO(bug.getProjectId(), null, bug.getId(), null, OperationLogType.RECOVER.name(), OperationLogModule.BUG_MANAGEMENT, bug.getTitle()); LogDTO dto = new LogDTO(bug.getProjectId(), null, bug.getId(), null, OperationLogType.RECOVER.name(), OperationLogModule.BUG_MANAGEMENT_RECYCLE, bug.getTitle());
dto.setPath("/bug/trash/recover"); dto.setPath("/bug/trash/recover");
dto.setMethod(HttpMethodConstants.GET.name()); dto.setMethod(HttpMethodConstants.GET.name());
dto.setOriginalValue(JSON.toJSONBytes(bug)); dto.setOriginalValue(JSON.toJSONBytes(bug));

View File

@ -85,6 +85,9 @@ public class BugNoticeService {
public BugNoticeDTO getNoticeById(String id) { public BugNoticeDTO getNoticeById(String id) {
// 缺陷基础信息 // 缺陷基础信息
BugDTO bugDTO = bugLogService.getOriginalValue(id); BugDTO bugDTO = bugLogService.getOriginalValue(id);
if (bugDTO == null) {
return null;
}
// 构建通知对象 // 构建通知对象
BugNoticeDTO notice = new BugNoticeDTO(); BugNoticeDTO notice = new BugNoticeDTO();
BeanUtils.copyBean(notice, bugDTO); BeanUtils.copyBean(notice, bugDTO);

View File

@ -31,7 +31,7 @@ public class BugRelateCaseLogService {
public LogDTO getRelateLog(String id) { public LogDTO getRelateLog(String id) {
BugRelationCase bugRelationCase = bugRelationCaseMapper.selectByPrimaryKey(id); BugRelationCase bugRelationCase = bugRelationCaseMapper.selectByPrimaryKey(id);
BugRelateCaseDTO relateCase = extBugRelateCaseMapper.getRelateCase(bugRelationCase.getCaseId(), bugRelationCase.getCaseType()); BugRelateCaseDTO relateCase = extBugRelateCaseMapper.getRelateCase(bugRelationCase.getCaseId(), bugRelationCase.getCaseType());
LogDTO dto = new LogDTO(relateCase.getProjectId(), null, null, null, OperationLogType.DISASSOCIATE.name(), OperationLogModule.BUG_MANAGEMENT, relateCase.getRelateCaseName()); LogDTO dto = new LogDTO(relateCase.getProjectId(), null, null, null, OperationLogType.DISASSOCIATE.name(), OperationLogModule.BUG_MANAGEMENT_INDEX, relateCase.getRelateCaseName());
dto.setPath("/bug/un-relate"); dto.setPath("/bug/un-relate");
dto.setMethod(HttpMethodConstants.GET.name()); dto.setMethod(HttpMethodConstants.GET.name());
dto.setModifiedValue(JSON.toJSONBytes(relateCase)); dto.setModifiedValue(JSON.toJSONBytes(relateCase));

View File

@ -843,6 +843,17 @@ public class BugService {
return bugs.get(0); return bugs.get(0);
} }
/**
* 校验缺陷是否存在并返回
* @param id 缺陷ID
* @return 缺陷
*/
public boolean checkExist(String id) {
BugExample bugExample = new BugExample();
bugExample.createCriteria().andIdEqualTo(id).andDeletedEqualTo(false);
return bugMapper.countByExample(bugExample) > 0;
}
/** /**
* 处理保存自定义字段信息 * 处理保存自定义字段信息
* *
@ -1322,7 +1333,7 @@ public class BugService {
*/ */
private FileLogRecord createFileLogRecord(String operator, String projectId){ private FileLogRecord createFileLogRecord(String operator, String projectId){
return FileLogRecord.builder() return FileLogRecord.builder()
.logModule(OperationLogModule.BUG_MANAGEMENT) .logModule(OperationLogModule.BUG_MANAGEMENT_INDEX)
.operator(operator) .operator(operator)
.projectId(projectId) .projectId(projectId)
.build(); .build();
@ -1511,7 +1522,7 @@ public class BugService {
List<Bug> bugs = bugMapper.selectByExample(example); List<Bug> bugs = bugMapper.selectByExample(example);
List<LogDTO> logs = new ArrayList<>(); List<LogDTO> logs = new ArrayList<>();
bugs.forEach(bug -> { bugs.forEach(bug -> {
LogDTO log = new LogDTO(bug.getProjectId(), project.getOrganizationId(), bug.getId(), null, operationType, OperationLogModule.BUG_MANAGEMENT, bug.getTitle()); LogDTO log = new LogDTO(bug.getProjectId(), project.getOrganizationId(), bug.getId(), null, operationType, OperationLogModule.BUG_MANAGEMENT_INDEX, bug.getTitle());
log.setPath(path); log.setPath(path);
log.setMethod(HttpMethodConstants.POST.name()); log.setMethod(HttpMethodConstants.POST.name());
if (batchUpdate) { if (batchUpdate) {

View File

@ -91,6 +91,7 @@ public class BugControllerTests extends BaseTest {
public static final String BUG_EXPORT_COLUMNS = "/bug/export/columns/%s"; public static final String BUG_EXPORT_COLUMNS = "/bug/export/columns/%s";
public static final String BUG_EXPORT = "/bug/export"; public static final String BUG_EXPORT = "/bug/export";
public static final String BUG_CURRENT_PLATFORM = "/bug/current-platform/%s"; public static final String BUG_CURRENT_PLATFORM = "/bug/current-platform/%s";
public static final String BUG_EXIST_CHECK = "/bug/check-exist/%s";
@Resource @Resource
private PluginService pluginService; private PluginService pluginService;
@ -474,6 +475,12 @@ public class BugControllerTests extends BaseTest {
this.requestGetWithOk(String.format(BUG_CURRENT_PLATFORM, "default-project-for-bug")); this.requestGetWithOk(String.format(BUG_CURRENT_PLATFORM, "default-project-for-bug"));
} }
@Test
@Order(16)
void testCheckBugExist() throws Exception {
this.requestGetWithOk(String.format(BUG_EXIST_CHECK, "default-project-for-bug-not-exist"));
}
@Test @Test
@Order(90) @Order(90)
void testDeleteBugSuccess() throws Exception { void testDeleteBugSuccess() throws Exception {

View File

@ -6,5 +6,5 @@ INSERT INTO bug (id, num, title, handle_users, handle_user, create_user, create_
('bug-history-id', 100000, 'default-bug', 'oasis', 'oasis', 'admin', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, '100001100001', 'bug-template-id', 'Local', 'open', null, null, 1, 5000); ('bug-history-id', 100000, 'default-bug', 'oasis', 'oasis', 'admin', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, 'admin', UNIX_TIMESTAMP() * 1000, '100001100001', 'bug-template-id', 'Local', 'open', null, null, 1, 5000);
INSERT INTO operation_history (`id`, `project_id`, `create_time`, `create_user`, `source_id`, `type`, `module`, `ref_id`) VALUES INSERT INTO operation_history (`id`, `project_id`, `create_time`, `create_user`, `source_id`, `type`, `module`, `ref_id`) VALUES
(1, '100001100001', 1706079964322, 'admin', 'bug-history-id', 'ADD', 'BUG_MANAGEMENT', NULL), (1, '100001100001', 1706079964322, 'admin', 'bug-history-id', 'ADD', 'BUG_MANAGEMENT_INDEX', NULL),
(2, '100001100001', 1706079964322, 'admin', 'bug-history-id', 'ADD', 'BUG_MANAGEMENT', NULL); (2, '100001100001', 1706079964322, 'admin', 'bug-history-id', 'ADD', 'BUG_MANAGEMENT_RECYCLE', NULL);

View File

@ -143,7 +143,10 @@ public class OperationLogModule {
//接口管理-环境 //接口管理-环境
public static final String API_DEFINITION_ENVIRONMENT = "API_DEFINITION_ENVIRONMENT"; public static final String API_DEFINITION_ENVIRONMENT = "API_DEFINITION_ENVIRONMENT";
// 缺陷管理 // 缺陷管理
public static final String BUG_MANAGEMENT = "BUG_MANAGEMENT"; public static final String BUG_MANAGEMENT_INDEX = "BUG_MANAGEMENT_BUG_INDEX";
public static final String BUG_MANAGEMENT_RECYCLE = "BUG_MANAGEMENT_BUG_RECYCLE";
public static final String BUG_MANAGEMENT_CREATE = "BUG_MANAGEMENT_BUG_INDEX_CREATE";
public static final String BUG_MANAGEMENT_UPDATE = "BUG_MANAGEMENT_BUG_INDEX_UPDATE";
//测试计划 //测试计划
public static final String TEST_PLAN = "TEST_PLAN"; public static final String TEST_PLAN = "TEST_PLAN";
public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE"; public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE";

View File

@ -7,6 +7,14 @@ import { BugEditFormObject, BugListItem, BugOptionListItem } from '@/models/bug-
import { AssociatedList, DemandItem, OperationFile } from '@/models/caseManagement/featureCase'; import { AssociatedList, DemandItem, OperationFile } from '@/models/caseManagement/featureCase';
import { CommonList, TableQueryParams, TemplateOption } from '@/models/common'; import { CommonList, TableQueryParams, TemplateOption } from '@/models/common';
/**
*
*
*/
export function checkBugExist(id: string) {
return MSR.get({ url: `${bugURL.checkBugExist}${id}` });
}
/** /**
* *
* @param data * @param data

View File

@ -1,4 +1,5 @@
export const getPlatform = '/bug/current-platform/'; export const getPlatform = '/bug/current-platform/';
export const checkBugExist = '/bug/check-exist/';
export const postTableListUrl = '/bug/page'; export const postTableListUrl = '/bug/page';
export const postUpdateBugUrl = '/bug/update'; export const postUpdateBugUrl = '/bug/update';
export const postBatchUpdateBugUrl = '/bug/batch-update'; export const postBatchUpdateBugUrl = '/bug/batch-update';

View File

@ -230,6 +230,7 @@
import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue'; import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue';
import { import {
checkBugExist,
deleteBatchBug, deleteBatchBug,
deleteSingleBug, deleteSingleBug,
exportBug, exportBug,
@ -647,10 +648,27 @@
} }
}; };
const handleShowDetail = (id: string, rowIndex: number) => { const checkBug = async (id: string) => {
detailVisible.value = true; const res = await checkBugExist(id);
activeDetailId.value = id; return res;
activeCaseIndex.value = rowIndex; };
const handleShowDetail = async (id: string, rowIndex: number) => {
const exist = await checkBug(id);
if (!exist) {
// ,
Message.error(t('bugManagement.detail.notExist'));
const query = { ...route.query };
delete query.id;
await router.push({
name: RouteEnum.BUG_MANAGEMENT_INDEX,
query,
});
} else {
detailVisible.value = true;
activeDetailId.value = id;
activeCaseIndex.value = rowIndex;
}
}; };
const handleCopy = (record: BugListItem) => { const handleCopy = (record: BugListItem) => {
@ -728,7 +746,6 @@
const setCurrentPlatform = async () => { const setCurrentPlatform = async () => {
const res = await getPlatform(projectId.value); const res = await getPlatform(projectId.value);
currentPlatform.value = res; currentPlatform.value = res;
console.log(currentPlatform.value);
}; };
const moreActionList: ActionsItem[] = [ const moreActionList: ActionsItem[] = [

View File

@ -57,6 +57,7 @@ export default {
cannotBeNull: 'is empty', cannotBeNull: 'is empty',
}, },
detail: { detail: {
notExist: 'Bug not exist',
title: '【{id}】{name}', title: '【{id}】{name}',
apiCase: 'API Case', apiCase: 'API Case',
scenarioCase: 'Scenario Case', scenarioCase: 'Scenario Case',

View File

@ -57,6 +57,7 @@ export default {
cannotBeNull: '不能为空', cannotBeNull: '不能为空',
}, },
detail: { detail: {
notExist: '缺陷不存在',
title: '【{id}】{name}', title: '【{id}】{name}',
apiCase: '接口用例', apiCase: '接口用例',
scenarioCase: '场景用例', scenarioCase: '场景用例',

View File

@ -80,6 +80,7 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useUserStore from '@/store/modules/user/index'; import useUserStore from '@/store/modules/user/index';
import { openWindow } from '@/utils/index'; import { openWindow } from '@/utils/index';
import { hasAnyPermission } from '@/utils/permission';
import type { SkipTitle, StepListType } from '@/models/setting/serviceIntegration'; import type { SkipTitle, StepListType } from '@/models/setting/serviceIntegration';
import { SettingRouteEnum } from '@/enums/routeEnum'; import { SettingRouteEnum } from '@/enums/routeEnum';
@ -87,7 +88,7 @@
const userStore = useUserStore(); const userStore = useUserStore();
const isHasSystemPermission = computed(() => { const isHasSystemPermission = computed(() => {
return userStore.isAdmin; return hasAnyPermission(['SYSTEM_PLUGIN:READ']);
}); });
const { t } = useI18n(); const { t } = useI18n();