fix(接口测试): 接口测试关联文件列表增加模块列,如果是Git文件还会在文件名称后面展示分支

--bug=1025343 --user=宋天阳
[项目管理]
github#23586git文件上传不同分支,同一路径文件拉取失败报文件已存在
https://www.tapd.cn/55049933/s/1362041
This commit is contained in:
song-tianyang 2023-04-12 23:25:00 +08:00 committed by 建国
parent 085e069cb7
commit 1831344840
6 changed files with 120 additions and 7 deletions

View File

@ -28,6 +28,23 @@
@refresh="getProjectFiles"
ref="table">
<ms-table-column prop="name" show-overflow-tooltip :min-width="150" :label="$t('load_test.file_name')">
<template v-slot="scope">
<span v-if="scope.row.storage !== 'GIT'">
{{ scope.row.name }}
</span>
<div v-else>
<span>
{{ scope.row.name }}
</span>
<ms-tag effect="plain" class="ms-tags" :content="parseGitBranch(scope.row.attachInfo)" />
</div>
</template>
</ms-table-column>
<ms-table-column
prop="moduleName"
show-overflow-tooltip
:min-width="150"
:label="$t('project.project_file.file_module_type.module')">
</ms-table-column>
<ms-table-column
sortable
@ -37,7 +54,7 @@
:label="$t('load_test.file_type')">
</ms-table-column>
<ms-table-column prop="description" :min-width="100" :label="$t('group.description')"> </ms-table-column>
<ms-table-column prop="description" :min-width="100" :label="$t('group.description')"></ms-table-column>
<ms-table-column prop="tags" width="100px" :show-overflow-tooltip="false" :label="$t('commons.tag')">
<template v-slot:default="scope">
@ -60,7 +77,7 @@
<ms-table-column sortable prop="createUser" :min-width="100" :label="$t('commons.create_user')">
</ms-table-column>
<ms-table-column sortable prop="updateUser" :min-width="100" :label="$t('ui.update_user')"> </ms-table-column>
<ms-table-column sortable prop="updateUser" :min-width="100" :label="$t('ui.update_user')"></ms-table-column>
<ms-table-column sortable :label="$t('commons.update_time')" :min-width="150" fixed="right" prop="updateTime">
<template v-slot="scope">
@ -136,6 +153,11 @@ export default {
},
created() {},
methods: {
parseGitBranch(attachInfo) {
let branch = 'master';
branch = JSON.parse(attachInfo)['branch'];
return branch;
},
submit() {
if (this.$refs.table.selectRows && this.$refs.table.selectRows.size > 0) {
this.$emit('checkRows', this.$refs.table.selectRows);

View File

@ -1,6 +1,7 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.FileMetadataWithBLOBs;
import io.metersphere.dto.FileMetadataDTO;
import io.metersphere.metadata.vo.MoveFIleMetadataRequest;
import io.metersphere.request.QueryProjectFileRequest;
import org.apache.ibatis.annotations.Param;
@ -11,6 +12,8 @@ import java.util.Map;
public interface BaseFileMetadataMapper {
List<FileMetadataWithBLOBs> getProjectFiles(@Param("projectId") String projectId, @Param("request") QueryProjectFileRequest request);
List<FileMetadataDTO> getFileMetadataByProject(@Param("projectId") String projectId, @Param("request") QueryProjectFileRequest request);
List<String> getTypes();
void move(@Param("request") MoveFIleMetadataRequest request);

View File

@ -63,6 +63,71 @@
</foreach>
</if>
</select>
<select id="getFileMetadataByProject" resultType="io.metersphere.dto.FileMetadataDTO">
SELECT file_metadata.*,file_module.name AS moduleName FROM file_metadata
INNER JOIN file_module ON file_metadata.module_id = file_module.id
WHERE file_metadata.project_id = #{projectId,jdbcType=VARCHAR} AND file_metadata.type != 'RSA_KEY' AND file_metadata.latest IS TRUE
<if test="request.name != null and request.name !=''">
AND ( file_metadata.name LIKE CONCAT('%', #{request.name}, '%')
OR file_metadata.tags LIKE CONCAT('%', #{request.name}, '%')
OR file_metadata.description LIKE CONCAT('%', #{request.name}, '%')
OR file_metadata.create_user LIKE CONCAT('%', #{request.name}, '%'))
</if>
<if test="request.moduleId != null and request.moduleId !=''">
AND file_metadata.module_id = #{request.moduleId}
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key=='type'">
and file_metadata.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='createUser'">
and file_metadata.create_user in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='moduleIds'">
and file_metadata.module_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
<if test="order.name == 'name'">
file_metadata.name ${order.type}
</if>
<if test="order.name == 'type'">
file_metadata.type ${order.type}
</if>
<if test="order.name == 'create_user'">
file_metadata.create_user ${order.type}
</if>
<if test="order.name == 'update_user'">
file_metadata.update_user ${order.type}
</if>
<if test="order.name == 'create_time'">
file_metadata.create_time ${order.type}
</if>
<if test="order.name == 'update_time'">
file_metadata.update_time ${order.type}
</if>
</foreach>
</if>
</select>
<select id="getTypes" resultType="java.lang.String">
SELECT type
FROM file_metadata

View File

@ -0,0 +1,9 @@
package io.metersphere.dto;
import io.metersphere.base.domain.FileMetadataWithBLOBs;
import lombok.Data;
@Data
public class FileMetadataDTO extends FileMetadataWithBLOBs {
private String moduleName;
}

View File

@ -8,6 +8,7 @@ import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.FileMetadataDTO;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.metadata.service.FileMetadataService;
import io.metersphere.metadata.vo.DownloadRequest;
@ -15,13 +16,13 @@ import io.metersphere.metadata.vo.DumpFileRequest;
import io.metersphere.metadata.vo.FileMetadataCreateRequest;
import io.metersphere.metadata.vo.MoveFIleMetadataRequest;
import io.metersphere.request.QueryProjectFileRequest;
import jakarta.annotation.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.annotation.Resource;
import java.util.List;
@RequestMapping("/file/metadata")
@ -36,11 +37,11 @@ public class FileMetadataController {
}
@PostMapping("/project/{projectId}/{goPage}/{pageSize}")
public Pager<List<FileMetadataWithBLOBs>> getProjectFiles(@PathVariable String projectId,
@PathVariable int goPage, @PathVariable int pageSize,
@RequestBody QueryProjectFileRequest request) {
public Pager<List<FileMetadataDTO>> getProjectFiles(@PathVariable String projectId,
@PathVariable int goPage, @PathVariable int pageSize,
@RequestBody QueryProjectFileRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, fileMetadataService.getProjectFiles(projectId, request));
return PageUtils.setPageInfo(page, fileMetadataService.getFileMetadataByProject(projectId, request));
}
@PostMapping(value = "/create")

View File

@ -16,6 +16,7 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.AttachmentBodyFile;
import io.metersphere.dto.FileInfoDTO;
import io.metersphere.dto.FileMetadataDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
@ -165,6 +166,18 @@ public class FileMetadataService {
return saveFile(file, fileMetadata);
}
public List<FileMetadataDTO> getFileMetadataByProject(String projectId, QueryProjectFileRequest request) {
if (CollectionUtils.isEmpty(request.getOrders())) {
OrderRequest req = new OrderRequest();
req.setName("update_time");
req.setType("desc");
request.setOrders(new ArrayList<>() {{
this.add(req);
}});
}
return baseFileMetadataMapper.getFileMetadataByProject(projectId, request);
}
public List<FileMetadataWithBLOBs> getProjectFiles(String projectId, QueryProjectFileRequest request) {
if (CollectionUtils.isEmpty(request.getOrders())) {
OrderRequest req = new OrderRequest();