feat(接口测试): 引入公共脚本的表格增加创建人筛选
--bug=1037457 --user=宋天阳 【接口测试】定义-调试-后置-脚本操作-插入公共脚本-创建人没有筛选功能 https://www.tapd.cn/55049933/s/1481281
This commit is contained in:
parent
f385215320
commit
7df04bc7bb
|
@ -3,6 +3,7 @@ package io.metersphere.project.controller;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.page.PageMethod;
|
import com.github.pagehelper.page.PageMethod;
|
||||||
import io.metersphere.project.domain.CustomFunction;
|
import io.metersphere.project.domain.CustomFunction;
|
||||||
|
import io.metersphere.project.dto.customfunction.CustomFuncColumnsOptionDTO;
|
||||||
import io.metersphere.project.dto.customfunction.CustomFunctionDTO;
|
import io.metersphere.project.dto.customfunction.CustomFunctionDTO;
|
||||||
import io.metersphere.project.dto.customfunction.request.CustomFunctionPageRequest;
|
import io.metersphere.project.dto.customfunction.request.CustomFunctionPageRequest;
|
||||||
import io.metersphere.project.dto.customfunction.request.CustomFunctionRequest;
|
import io.metersphere.project.dto.customfunction.request.CustomFunctionRequest;
|
||||||
|
@ -48,6 +49,14 @@ public class CustomFunctionController {
|
||||||
return PageUtils.setPageInfo(page, customFunctionService.getPage(request));
|
return PageUtils.setPageInfo(page, customFunctionService.getPage(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/columns-option/{projectId}")
|
||||||
|
@Operation(summary = "项目管理-公共脚本-请求头筛选相关选项")
|
||||||
|
@RequiresPermissions(PermissionConstants.PROJECT_CUSTOM_FUNCTION_READ)
|
||||||
|
@CheckOwner(resourceId = "#projectId", resourceType = "project")
|
||||||
|
public CustomFuncColumnsOptionDTO getColumnsOption(@PathVariable String projectId) {
|
||||||
|
return customFunctionService.getColumnsOption(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/detail/{id}")
|
@GetMapping("/detail/{id}")
|
||||||
@Operation(summary = "项目管理-公共脚本-脚本详情")
|
@Operation(summary = "项目管理-公共脚本-脚本详情")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_CUSTOM_FUNCTION_READ)
|
@RequiresPermissions(PermissionConstants.PROJECT_CUSTOM_FUNCTION_READ)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package io.metersphere.project.dto.customfunction;
|
||||||
|
|
||||||
|
import io.metersphere.plugin.platform.dto.SelectOption;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CustomFuncColumnsOptionDTO {
|
||||||
|
@Schema(description = "用户相关的下拉选项")
|
||||||
|
List<SelectOption> userOption;
|
||||||
|
}
|
|
@ -54,6 +54,10 @@
|
||||||
and c.status in
|
and c.status in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
|
<when test="key=='createUser'">
|
||||||
|
and c.create_user in
|
||||||
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package io.metersphere.project.service;
|
package io.metersphere.project.service;
|
||||||
|
|
||||||
|
import io.metersphere.plugin.platform.dto.SelectOption;
|
||||||
import io.metersphere.project.domain.CustomFunction;
|
import io.metersphere.project.domain.CustomFunction;
|
||||||
import io.metersphere.project.domain.CustomFunctionBlob;
|
import io.metersphere.project.domain.CustomFunctionBlob;
|
||||||
import io.metersphere.project.domain.CustomFunctionBlobExample;
|
import io.metersphere.project.domain.CustomFunctionBlobExample;
|
||||||
import io.metersphere.project.domain.CustomFunctionExample;
|
import io.metersphere.project.domain.CustomFunctionExample;
|
||||||
|
import io.metersphere.project.dto.ProjectUserDTO;
|
||||||
|
import io.metersphere.project.dto.customfunction.CustomFuncColumnsOptionDTO;
|
||||||
import io.metersphere.project.dto.customfunction.CustomFunctionDTO;
|
import io.metersphere.project.dto.customfunction.CustomFunctionDTO;
|
||||||
import io.metersphere.project.dto.customfunction.request.CustomFunctionPageRequest;
|
import io.metersphere.project.dto.customfunction.request.CustomFunctionPageRequest;
|
||||||
import io.metersphere.project.dto.customfunction.request.CustomFunctionRequest;
|
import io.metersphere.project.dto.customfunction.request.CustomFunctionRequest;
|
||||||
|
@ -13,6 +16,7 @@ import io.metersphere.project.enums.result.ProjectResultCode;
|
||||||
import io.metersphere.project.mapper.CustomFunctionBlobMapper;
|
import io.metersphere.project.mapper.CustomFunctionBlobMapper;
|
||||||
import io.metersphere.project.mapper.CustomFunctionMapper;
|
import io.metersphere.project.mapper.CustomFunctionMapper;
|
||||||
import io.metersphere.project.mapper.ExtCustomFunctionMapper;
|
import io.metersphere.project.mapper.ExtCustomFunctionMapper;
|
||||||
|
import io.metersphere.project.request.ProjectMemberRequest;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
|
@ -35,6 +39,9 @@ import java.util.Optional;
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class CustomFunctionService {
|
public class CustomFunctionService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ProjectMemberService projectMemberService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
CustomFunctionMapper customFunctionMapper;
|
CustomFunctionMapper customFunctionMapper;
|
||||||
|
|
||||||
|
@ -184,4 +191,18 @@ public class CustomFunctionService {
|
||||||
.andIdIn(commonScriptIds);
|
.andIdIn(commonScriptIds);
|
||||||
return customFunctionMapper.selectByExample(example);
|
return customFunctionMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CustomFuncColumnsOptionDTO getColumnsOption(String projectId) {
|
||||||
|
ProjectMemberRequest request = new ProjectMemberRequest();
|
||||||
|
request.setProjectId(projectId);
|
||||||
|
List<ProjectUserDTO> projectMembers = projectMemberService.listMember(request);
|
||||||
|
List<SelectOption> selectOptions = projectMembers.stream().map(user -> {
|
||||||
|
SelectOption option = new SelectOption();
|
||||||
|
option.setText(user.getName());
|
||||||
|
option.setValue(user.getId());
|
||||||
|
return option;
|
||||||
|
}).toList();
|
||||||
|
return new CustomFuncColumnsOptionDTO(selectOptions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,6 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: LAN
|
* @author: LAN
|
||||||
|
@ -50,6 +48,8 @@ public class CustomFunctionControllerTests extends BaseTest {
|
||||||
private static final String DETAIL = BASE_PATH + "detail/";
|
private static final String DETAIL = BASE_PATH + "detail/";
|
||||||
private static final String STATUS = BASE_PATH + "status";
|
private static final String STATUS = BASE_PATH + "status";
|
||||||
|
|
||||||
|
private static final String COLUMNS_OPTION = BASE_PATH + "columns-option/";
|
||||||
|
|
||||||
private static CustomFunction customFunction;
|
private static CustomFunction customFunction;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -332,6 +332,15 @@ public class CustomFunctionControllerTests extends BaseTest {
|
||||||
request.setFilter(filters);
|
request.setFilter(filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(10)
|
||||||
|
public void columnsOption() throws Exception {
|
||||||
|
// @@请求成功
|
||||||
|
this.requestGetWithOk(COLUMNS_OPTION + DEFAULT_PROJECT_ID);
|
||||||
|
// @@校验权限
|
||||||
|
requestGetPermissionTest(PermissionConstants.PROJECT_CUSTOM_FUNCTION_READ, COLUMNS_OPTION + "/" + DEFAULT_PROJECT_ID);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(11)
|
@Order(11)
|
||||||
public void testUncoveredFunc() {
|
public void testUncoveredFunc() {
|
||||||
|
|
|
@ -359,8 +359,11 @@ public class UserService {
|
||||||
*/
|
*/
|
||||||
private void checkProcessUserAndThrowException(List<String> userIdList, String operatorId, String operatorName, String exceptionMessage) {
|
private void checkProcessUserAndThrowException(List<String> userIdList, String operatorId, String operatorName, String exceptionMessage) {
|
||||||
for (String userId : userIdList) {
|
for (String userId : userIdList) {
|
||||||
if (StringUtils.equalsAny(userId, "admin", operatorId)) {
|
//当前用户或admin不能被操作
|
||||||
|
if (StringUtils.equals(userId, operatorId)) {
|
||||||
throw new MSException(exceptionMessage + ":" + operatorName);
|
throw new MSException(exceptionMessage + ":" + operatorName);
|
||||||
|
} else if (StringUtils.equals(userId, "admin")) {
|
||||||
|
throw new MSException(exceptionMessage + ": admin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
GetCommonScriptDetailUrl,
|
GetCommonScriptDetailUrl,
|
||||||
GetCommonScriptPageUrl,
|
GetCommonScriptPageUrl,
|
||||||
GetCommonScriptStatusUrl,
|
GetCommonScriptStatusUrl,
|
||||||
|
GetCustomFuncColumnsOptionUrl,
|
||||||
GetFormApiImportModuleCountUrl,
|
GetFormApiImportModuleCountUrl,
|
||||||
GetFormApiImportPageListUrl,
|
GetFormApiImportPageListUrl,
|
||||||
GetFormApiImportUrl,
|
GetFormApiImportUrl,
|
||||||
|
@ -21,6 +22,7 @@ import type {
|
||||||
CommonScriptItem,
|
CommonScriptItem,
|
||||||
TestScriptType,
|
TestScriptType,
|
||||||
} from '@/models/projectManagement/commonScript';
|
} from '@/models/projectManagement/commonScript';
|
||||||
|
import { CustomFuncColumnOptionItem } from '@/models/projectManagement/commonScript';
|
||||||
|
|
||||||
// 获取公共脚本列表
|
// 获取公共脚本列表
|
||||||
export function getCommonScriptPage(data: TableQueryParams) {
|
export function getCommonScriptPage(data: TableQueryParams) {
|
||||||
|
@ -56,6 +58,13 @@ export function getInsertCommonScriptPage(data: TableQueryParams) {
|
||||||
return MSR.post<CommonList<CommonScriptItem[]>>({ url: GetInsertCommonScriptPageUrl, data });
|
return MSR.post<CommonList<CommonScriptItem[]>>({ url: GetInsertCommonScriptPageUrl, data });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表格筛选字段的数据查询
|
||||||
|
*/
|
||||||
|
export function getCustomFuncColumnOption(projectId: string) {
|
||||||
|
return MSR.get<CustomFuncColumnOptionItem>({ url: `${GetCustomFuncColumnsOptionUrl}${projectId}` });
|
||||||
|
}
|
||||||
|
|
||||||
// 获取从Api导入
|
// 获取从Api导入
|
||||||
export function getFormApiImportModule(data: TableQueryParams) {
|
export function getFormApiImportModule(data: TableQueryParams) {
|
||||||
return MSR.post<ModulesTreeType[]>({ url: GetFormApiImportUrl, data });
|
return MSR.post<ModulesTreeType[]>({ url: GetFormApiImportUrl, data });
|
||||||
|
|
|
@ -12,6 +12,9 @@ export const DeleteCommonScriptUrl = '/project/custom/func/delete';
|
||||||
export const GetCommonScriptStatusUrl = '/project/custom/func/status';
|
export const GetCommonScriptStatusUrl = '/project/custom/func/status';
|
||||||
// 插入公共脚
|
// 插入公共脚
|
||||||
export const GetInsertCommonScriptPageUrl = '/project/custom/func/page';
|
export const GetInsertCommonScriptPageUrl = '/project/custom/func/page';
|
||||||
|
|
||||||
|
export const GetCustomFuncColumnsOptionUrl = '/project/custom/func/columns-option/';
|
||||||
|
|
||||||
// 获取公共脚本从Api导入
|
// 获取公共脚本从Api导入
|
||||||
export const GetFormApiImportUrl = '/api/definition/module/tree';
|
export const GetFormApiImportUrl = '/api/definition/module/tree';
|
||||||
// 获取从api导入列表
|
// 获取从api导入列表
|
||||||
|
|
|
@ -60,6 +60,20 @@
|
||||||
</a-popover>
|
</a-popover>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template #createUserFilter="{ columnConfig }">
|
||||||
|
<TableFilter
|
||||||
|
v-model:visible="createUserFilterVisible"
|
||||||
|
v-model:status-filters="createUserFilterValue"
|
||||||
|
:title="(columnConfig.title as string)"
|
||||||
|
:list="createUserFilterOptions"
|
||||||
|
value-key="value"
|
||||||
|
@search="initData()"
|
||||||
|
>
|
||||||
|
<template #item="{ item }">
|
||||||
|
{{ item.text }}
|
||||||
|
</template>
|
||||||
|
</TableFilter>
|
||||||
|
</template>
|
||||||
<template #status="{ record }">
|
<template #status="{ record }">
|
||||||
<MsTag v-if="record.status === 'PASSED'" type="success" theme="light">{{
|
<MsTag v-if="record.status === 'PASSED'" type="success" theme="light">{{
|
||||||
t('project.commonScript.testsPass')
|
t('project.commonScript.testsPass')
|
||||||
|
@ -93,11 +107,17 @@
|
||||||
import type { MsTableColumn } from '@/components/pure/ms-table/type';
|
import type { MsTableColumn } from '@/components/pure/ms-table/type';
|
||||||
import useTable from '@/components/pure/ms-table/useTable';
|
import useTable from '@/components/pure/ms-table/useTable';
|
||||||
import MsTag from '@/components/pure/ms-tag/ms-tag.vue';
|
import MsTag from '@/components/pure/ms-tag/ms-tag.vue';
|
||||||
|
import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue';
|
||||||
|
|
||||||
import { addOrUpdateCommonScriptReq, getInsertCommonScriptPage } from '@/api/modules/project-management/commonScript';
|
import {
|
||||||
|
addOrUpdateCommonScriptReq,
|
||||||
|
getCustomFuncColumnOption,
|
||||||
|
getInsertCommonScriptPage,
|
||||||
|
} from '@/api/modules/project-management/commonScript';
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
import useAppStore from '@/store/modules/app';
|
import useAppStore from '@/store/modules/app';
|
||||||
|
|
||||||
|
import { BugOptionItem } from '@/models/bug-management';
|
||||||
import type { AddOrUpdateCommonScript, ParamsRequestType } from '@/models/projectManagement/commonScript';
|
import type { AddOrUpdateCommonScript, ParamsRequestType } from '@/models/projectManagement/commonScript';
|
||||||
|
|
||||||
import Message from '@arco-design/web-vue/es/message';
|
import Message from '@arco-design/web-vue/es/message';
|
||||||
|
@ -131,7 +151,9 @@
|
||||||
emit('update:visible', val);
|
emit('update:visible', val);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const createUserFilterOptions = ref<BugOptionItem[]>([]);
|
||||||
|
const createUserFilterVisible = ref(false);
|
||||||
|
const createUserFilterValue = ref<string[]>([]);
|
||||||
const keyword = ref<string>('');
|
const keyword = ref<string>('');
|
||||||
|
|
||||||
const columns: MsTableColumn = [
|
const columns: MsTableColumn = [
|
||||||
|
@ -169,6 +191,7 @@
|
||||||
{
|
{
|
||||||
title: 'project.commonScript.createUser',
|
title: 'project.commonScript.createUser',
|
||||||
dataIndex: 'createUserName',
|
dataIndex: 'createUserName',
|
||||||
|
titleSlotName: 'createUserFilter',
|
||||||
showInTable: true,
|
showInTable: true,
|
||||||
width: 200,
|
width: 200,
|
||||||
showDrag: true,
|
showDrag: true,
|
||||||
|
@ -238,6 +261,9 @@
|
||||||
keyword: keyword.value,
|
keyword: keyword.value,
|
||||||
projectId: currentProjectId.value,
|
projectId: currentProjectId.value,
|
||||||
type: props.scriptLanguage,
|
type: props.scriptLanguage,
|
||||||
|
filter: {
|
||||||
|
createUser: createUserFilterValue.value,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
loadList();
|
loadList();
|
||||||
}
|
}
|
||||||
|
@ -301,11 +327,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function initFilterOptions() {
|
||||||
|
const res = await getCustomFuncColumnOption(appStore.currentProjectId);
|
||||||
|
createUserFilterOptions.value = res.userOption;
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.visible,
|
() => props.visible,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
resetSelector();
|
resetSelector();
|
||||||
|
initFilterOptions();
|
||||||
initData();
|
initData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ export interface CommonScriptMenu {
|
||||||
command?: string;
|
command?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CustomFuncColumnOptionItem {
|
||||||
|
userOption: {
|
||||||
|
value: string; // 缺陷id
|
||||||
|
text: string; // 缺陷编号
|
||||||
|
}[]; // 用户相关下拉选项
|
||||||
|
}
|
||||||
// 脚本列表
|
// 脚本列表
|
||||||
export interface CommonScriptItem {
|
export interface CommonScriptItem {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
Loading…
Reference in New Issue