feat: jar包支持工作空间级别和项目级别可见

This commit is contained in:
chenjianxing 2022-05-12 11:49:49 +08:00 committed by jianxing
parent 7ed233e4ca
commit 878404c1c5
16 changed files with 374 additions and 110 deletions

View File

@ -25,5 +25,9 @@ public class JarConfig implements Serializable {
private Long updateTime;
private String resourceId;
private String resourceType;
private static final long serialVersionUID = 1L;
}

View File

@ -773,6 +773,146 @@ public class JarConfigExample {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andResourceIdIsNull() {
addCriterion("resource_id is null");
return (Criteria) this;
}
public Criteria andResourceIdIsNotNull() {
addCriterion("resource_id is not null");
return (Criteria) this;
}
public Criteria andResourceIdEqualTo(String value) {
addCriterion("resource_id =", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotEqualTo(String value) {
addCriterion("resource_id <>", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdGreaterThan(String value) {
addCriterion("resource_id >", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
addCriterion("resource_id >=", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLessThan(String value) {
addCriterion("resource_id <", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLessThanOrEqualTo(String value) {
addCriterion("resource_id <=", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdLike(String value) {
addCriterion("resource_id like", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotLike(String value) {
addCriterion("resource_id not like", value, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdIn(List<String> values) {
addCriterion("resource_id in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotIn(List<String> values) {
addCriterion("resource_id not in", values, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdBetween(String value1, String value2) {
addCriterion("resource_id between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andResourceIdNotBetween(String value1, String value2) {
addCriterion("resource_id not between", value1, value2, "resourceId");
return (Criteria) this;
}
public Criteria andResourceTypeIsNull() {
addCriterion("resource_type is null");
return (Criteria) this;
}
public Criteria andResourceTypeIsNotNull() {
addCriterion("resource_type is not null");
return (Criteria) this;
}
public Criteria andResourceTypeEqualTo(String value) {
addCriterion("resource_type =", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeNotEqualTo(String value) {
addCriterion("resource_type <>", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeGreaterThan(String value) {
addCriterion("resource_type >", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeGreaterThanOrEqualTo(String value) {
addCriterion("resource_type >=", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeLessThan(String value) {
addCriterion("resource_type <", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeLessThanOrEqualTo(String value) {
addCriterion("resource_type <=", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeLike(String value) {
addCriterion("resource_type like", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeNotLike(String value) {
addCriterion("resource_type not like", value, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeIn(List<String> values) {
addCriterion("resource_type in", values, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeNotIn(List<String> values) {
addCriterion("resource_type not in", values, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeBetween(String value1, String value2) {
addCriterion("resource_type between", value1, value2, "resourceType");
return (Criteria) this;
}
public Criteria andResourceTypeNotBetween(String value1, String value2) {
addCriterion("resource_type not between", value1, value2, "resourceType");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -12,6 +12,8 @@
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="resource_type" jdbcType="VARCHAR" property="resourceType" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -73,7 +75,7 @@
</sql>
<sql id="Base_Column_List">
id, `name`, file_name, creator, modifier, `path`, `enable`, description, create_time,
update_time
update_time, resource_id, resource_type
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.JarConfigExample" resultMap="BaseResultMap">
select
@ -109,11 +111,13 @@
insert into jar_config (id, `name`, file_name,
creator, modifier, `path`,
`enable`, description, create_time,
update_time)
update_time, resource_id, resource_type
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR},
#{enable,jdbcType=BIT}, #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT})
#{updateTime,jdbcType=BIGINT}, #{resourceId,jdbcType=VARCHAR}, #{resourceType,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.JarConfig">
insert into jar_config
@ -148,6 +152,12 @@
<if test="updateTime != null">
update_time,
</if>
<if test="resourceId != null">
resource_id,
</if>
<if test="resourceType != null">
resource_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -180,6 +190,12 @@
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="resourceId != null">
#{resourceId,jdbcType=VARCHAR},
</if>
<if test="resourceType != null">
#{resourceType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.JarConfigExample" resultType="java.lang.Long">
@ -221,6 +237,12 @@
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.resourceId != null">
resource_id = #{record.resourceId,jdbcType=VARCHAR},
</if>
<if test="record.resourceType != null">
resource_type = #{record.resourceType,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -237,7 +259,9 @@
`enable` = #{record.enable,jdbcType=BIT},
description = #{record.description,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
update_time = #{record.updateTime,jdbcType=BIGINT},
resource_id = #{record.resourceId,jdbcType=VARCHAR},
resource_type = #{record.resourceType,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -272,6 +296,12 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="resourceId != null">
resource_id = #{resourceId,jdbcType=VARCHAR},
</if>
<if test="resourceType != null">
resource_type = #{resourceType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -285,7 +315,9 @@
`enable` = #{enable,jdbcType=BIT},
description = #{description,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
update_time = #{updateTime,jdbcType=BIGINT},
resource_id = #{resourceId,jdbcType=VARCHAR},
resource_type = #{resourceType,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,11 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.controller.request.JarConfigRequest;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtJarConfigMapper {
List<JarConfig> list(@Param("request") JarConfigRequest request);
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtJarConfigMapper">
<select id="list" resultType="io.metersphere.base.domain.JarConfig">
select * from jar_config jc
<where>
<if test="request.name != null and request.name != ''">
jc.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.resourceType == 'WORKSPACE'">
and jc.resource_id = #{request.resourceId}
</if>
<if test="request.resourceType == 'PROJECT'">
and (jc.resource_id = #{request.resourceId} or jc.resource_id = #{request.workspaceId})
</if>
</where>
order by update_time desc
</select>
</mapper>

View File

@ -0,0 +1,5 @@
package io.metersphere.commons.constants;
public enum JarConfigResourceType {
WORKSPACE, PROJECT
}

View File

@ -156,23 +156,42 @@ public class FileUtils {
}
for (File file : files) {
//文件要移动的路径
String movePath = targetFile + File.separator + file.getName();
if (file.isDirectory()) {
//如果是目录则递归调用
copyFolder(file.getAbsolutePath(), movePath);
} else {
//如果是文件则复制文件
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(movePath))) {
byte[] b = new byte[1024];
int temp = 0;
while ((temp = in.read(b)) != -1) {
out.write(b, 0, temp);
}
} catch (Exception e) {
LoggerUtil.error(e);
copyFileToDir(file, targetFile);
}
}
public static void copyFileToDir(String filePath, String targetPath) {
//源文件路径
File sourceFile = new File(filePath);
//目标文件夹路径
File targetDir = new File(targetPath);
if (!sourceFile.exists()) {
return;
}
if (!targetDir.exists()) {
targetDir.mkdirs();
}
copyFileToDir(sourceFile, targetDir);
}
private static void copyFileToDir(File file, File targetDir) {
//文件要移动的路径
String movePath = targetDir + File.separator + file.getName();
if (file.isDirectory()) {
//如果是目录则递归调用
copyFolder(file.getAbsolutePath(), movePath);
} else {
//如果是文件则复制文件
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(movePath))) {
byte[] b = new byte[1024];
int temp;
while ((temp = in.read(b)) != -1) {
out.write(b, 0, temp);
}
} catch (Exception e) {
LoggerUtil.error(e);
}
}
}
@ -261,6 +280,14 @@ public class FileUtils {
}
}
public static void deleteDir(String path) {
File file = new File(path);
FileUtil.deleteContents(file);
if (file.exists()) {
file.delete();
}
}
/**
* 获取当前jmx 涉及到的文件

View File

@ -1,12 +1,10 @@
package io.metersphere.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.JarConfig;
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.controller.request.JarConfigRequest;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.JarConfigService;
import org.springframework.web.bind.annotation.*;
@ -23,9 +21,8 @@ public class JarConfigController {
JarConfigService JarConfigService;
@PostMapping("list/{goPage}/{pageSize}")
public Pager<List<JarConfig>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody JarConfig request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, JarConfigService.list(request));
public Pager<List<JarConfig>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody JarConfigRequest request) {
return JarConfigService.list(request, goPage, pageSize);
}
@GetMapping("list/all")
@ -33,11 +30,6 @@ public class JarConfigController {
return JarConfigService.list();
}
@PostMapping("list")
public List<JarConfig> list(@RequestBody JarConfig jarConfig) {
return JarConfigService.searchList(jarConfig);
}
@GetMapping("/get/{id}")
public JarConfig get(@PathVariable String id) {
return JarConfigService.get(id);

View File

@ -0,0 +1,12 @@
package io.metersphere.controller.request;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class JarConfigRequest extends BaseQueryRequest {
private String resourceId;
private String resourceType;
}

View File

@ -154,6 +154,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
initOnceOperate(testReviewTestCaseService::initOrderField, "init.sort.review.test.case");
initOnceOperate(apiDefinitionService::initDefaultModuleId, "init.default.module.id");
initOnceOperate(mockConfigService::initExpectNum, "init.mock.expectNum");
initOnceOperate(jarConfigService::initJarPath, "init.jar.path");
}
/**

View File

@ -1,13 +1,19 @@
package io.metersphere.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.jmeter.NewDriverManager;
import io.metersphere.base.domain.JarConfig;
import io.metersphere.base.domain.JarConfigExample;
import io.metersphere.base.domain.Project;
import io.metersphere.base.mapper.JarConfigMapper;
import io.metersphere.base.mapper.ext.ExtJarConfigMapper;
import io.metersphere.commons.constants.JarConfigResourceType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.FileUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.JarConfigRequest;
import io.metersphere.i18n.Translator;
import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
@ -19,11 +25,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
@ -31,6 +36,12 @@ public class JarConfigService {
private static final String JAR_FILE_DIR = "/opt/metersphere/data/jar";
@Resource
ExtJarConfigMapper extJarConfigMapper;
@Resource
ProjectService projectService;
@Resource
private JarConfigMapper jarConfigMapper;
@ -39,30 +50,16 @@ public class JarConfigService {
return jarConfigMapper.selectByExample(example);
}
public List<JarConfig> list(JarConfig jarConfig) {
JarConfigExample example = new JarConfigExample();
if (StringUtils.isNotBlank(jarConfig.getName())) {
example.createCriteria().andNameLike("%" + jarConfig.getName() + "%");
public Pager<List<JarConfig>> list(JarConfigRequest request, int pageNum, int pageSize) {
if (request.getResourceId() == null || request.getResourceType() == null) {
MSException.throwException("resourceId or resourceType could not be null!");
}
example.setOrderByClause("update_time desc");
return jarConfigMapper.selectByExample(example);
}
public List<JarConfig> searchList(JarConfig jarConfig) {
JarConfigExample nameExample = new JarConfigExample();
JarConfigExample jarExample = new JarConfigExample();
if (StringUtils.isNotBlank(jarConfig.getName())) {
nameExample.createCriteria().andNameLike("%" + jarConfig.getName() + "%");
jarExample.createCriteria().andFileNameLike("%" + jarConfig.getName() + "%");
} // 根据jar包的文件名和自定义名称查找
nameExample.setOrderByClause("update_time desc");
jarExample.setOrderByClause("update_time desc");
List<JarConfig> jarConfigList = jarConfigMapper.selectByExample(jarExample);
// 合并两个查找结果并去重按时间降序
jarConfigList.addAll(jarConfigMapper.selectByExample(nameExample));
jarConfigList = jarConfigList.stream().distinct().collect(Collectors.toList());
Collections.sort(jarConfigList, Comparator.comparing(JarConfig::getUpdateTime).reversed());
return jarConfigList;
if (request.getResourceType().equals(JarConfigResourceType.PROJECT.name())) {
Project project = projectService.getProjectById(request.getResourceId());
request.setWorkspaceId(project.getWorkspaceId());
}
Page<Object> page = PageHelper.startPage(pageNum, pageSize, true);
return PageUtils.setPageInfo(page, extJarConfigMapper.list(request));
}
public JarConfig get(String id) {
@ -70,8 +67,8 @@ public class JarConfigService {
}
public void delete(String id) {
JarConfig JarConfig = jarConfigMapper.selectByPrimaryKey(id);
FileUtils.deleteFile(JarConfig.getPath());
JarConfig jarConfig = jarConfigMapper.selectByPrimaryKey(id);
FileUtils.deleteDir(getJarDir(jarConfig.getId()));
jarConfigMapper.deleteByPrimaryKey(id);
}
@ -83,12 +80,12 @@ public class JarConfigService {
String deletePath = jarConfig.getPath();
if (file != null) {
jarConfig.setFileName(file.getOriginalFilename());
jarConfig.setPath(getJarPath(file));
jarConfig.setPath(getJarPath(file, jarConfig.getId()));
}
jarConfigMapper.updateByPrimaryKey(jarConfig);
if (file != null) {
FileUtils.deleteFile(deletePath);
FileUtils.uploadFile(file, JAR_FILE_DIR);
FileUtils.uploadFile(file, getJarDir(jarConfig.getId()));
NewDriverManager.loadJar(jarConfig.getPath());
}
}
@ -104,16 +101,20 @@ public class JarConfigService {
jarConfig.setEnable(true);// todo 审批机制时需修改
jarConfig.setCreateTime(System.currentTimeMillis());
jarConfig.setUpdateTime(System.currentTimeMillis());
jarConfig.setPath(getJarPath(file));
jarConfig.setPath(getJarPath(file, jarConfig.getId()));
jarConfig.setFileName(file.getOriginalFilename());
jarConfigMapper.insert(jarConfig);
FileUtils.uploadFile(file, JAR_FILE_DIR);
FileUtils.uploadFile(file, getJarDir(jarConfig.getId()));
NewDriverManager.loadJar(jarConfig.getPath());
return jarConfig.getId();
}
public String getJarPath(MultipartFile file) {
return JAR_FILE_DIR + "/" + file.getOriginalFilename();
public String getJarPath(MultipartFile file, String id) {
return JAR_FILE_DIR + "/" + id + "/" + file.getOriginalFilename();
}
public String getJarDir(String id) {
return JAR_FILE_DIR + "/" + id;
}
private void checkExist(JarConfig jarConfig) {
@ -140,4 +141,26 @@ public class JarConfigService {
return null;
}
/**
* 兼容性处理将原来的jar包设置成工作空间级别并拷贝到对应的目录
*/
public void initJarPath() {
List<JarConfig> list = jarConfigMapper.selectByExample(new JarConfigExample());
Set<String> oldFiles = new HashSet<>();
list.forEach(item -> {
try {
String path = item.getPath();
String[] split = path.split("/");
String fileName = split[split.length - 1];
oldFiles.add(fileName);
FileUtils.copyFileToDir(JAR_FILE_DIR + "/" + fileName, getJarDir(item.getId()));
item.setPath(getJarDir(item.getId()) + "/" + fileName);
jarConfigMapper.updateByPrimaryKey(item);
} catch (Exception e) {
LogUtil.error(JSONObject.toJSON(item));
LogUtil.error(e);
}
});
oldFiles.forEach(path -> FileUtils.deleteFile(JAR_FILE_DIR + "/" + path));
}
}

View File

@ -1 +1,13 @@
ALTER TABLE `user` ADD selenium_server varchar(255) DEFAULT '';
-- start 2022.05.11 jar包支持项目级别和工作空间级别可见
ALTER TABLE jar_config ADD resource_id varchar(50) NOT NULL COMMENT '资源所属的工作空间或者项目Id';
ALTER TABLE jar_config ADD resource_type VARCHAR(20) NOT NULL COMMENT '资源的所属范围 WORKSPACEPROJECT';
-- 处理旧数据,把旧数据全部设置成工作空间级别
INSERT INTO jar_config (id, name, file_name, creator, modifier, `path`, enable, description, create_time, update_time, resource_id, resource_type)
SELECT UUID() AS id, j.name, j.file_name, j.creator, j.modifier, j.`path`, j.enable, j.description, j.create_time, j.update_time, w.id AS resource_id, 'WORKSPACE' AS resource_type
FROM jar_config j JOIN workspace w;
-- 删除无用旧数据
DELETE FROM jar_config WHERE resource_id = '';
-- end

View File

@ -2,16 +2,13 @@
<el-dialog width="50%" :close-on-click-modal="false" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close">
<div v-loading="result.loading">
<ms-jar-config-from :config="currentConfig" :callback="saveConfig" ref="jarConfigFrom" :read-only="isReadOnly"/>
<!-- <ms-jar-search-bar v-if="(!isSearchBarQuery && configs.length > 0) || isSearchBarQuery" :condition="condition"-->
<!-- @search="getJarConfigs" :table-data="configs" ref="jarSearchBar"/>-->
<!-- <ms-jar-config-list @refresh="getJarConfigs" v-if="configs.length > 0" @rowSelect="rowSelect" :table-data="configs" ref="jarConfigList"/>-->
</div>
</el-dialog>
</template>
<script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils";
import MsJarConfigFrom from "./JarConfigFrom";
import MsJarSearchBar from "./JarSearchBar";
@ -23,7 +20,6 @@ export default {
visible: false,
result: {},
currentConfig: {},
configs: [],
condition: {},
isSearchBarQuery: false
}
@ -38,36 +34,16 @@ export default {
open() {
this.visible = true;
this.condition = {};
this.getJarConfigs();
listenGoBack(this.close);
},
saveConfig(config, file) {
for (let item of this.configs) {
if (item.name === config.name && item.id !== config.id) {
this.$warning(this.$t('commons.already_exists'));
return;
}
if (item.fileName === file.name && item.id !== config.id) {
this.$warning(this.$t('api_test.jar_config.file_exist'));
return;
}
}
config.resourceType = 'PROJECT';
config.resourceId = getCurrentProjectID();
let url = config.id ? "/jar/update" : "/jar/add";
this.result = this.$fileUpload(url, file, null, config, () => {
this.$success(this.$t('commons.save_success'));
this.$emit("refresh")
this.visible = false;
// this.getJarConfigs();
});
},
getJarConfigs(isSearchBarQuery) {
if (isSearchBarQuery) {
this.isSearchBarQuery = isSearchBarQuery;
}
this.result = this.$post("/jar/list", this.condition, response => {
this.configs = response.data;
this.currentConfig = {};
});
},
rowSelect(config) {

View File

@ -30,10 +30,17 @@
<el-table-column prop="creator" :label="$t('report.user_name')" show-overflow-tooltip/>
<el-table-column prop="modifier" :label="$t('commons.modifier')" show-overflow-tooltip/>
<el-table-column prop="scope" :label="$t('作用范围')" show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{ scope.row.resourceType === 'WORKSPACE' ? '工作空间' : '项目' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="100">
<template v-slot:default="scope">
<div>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" type="danger"
:disabled="scope.row.resourceType === 'WORKSPACE'"
@exec="handleDelete(scope.row.id)" v-permission="['PROJECT_FILE:READ+DELETE+JAR']"/>
</div>
</template>
@ -57,6 +64,7 @@ import MsContainer from "@/business/components/common/components/MsContainer";
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsJarConfig from "@/business/components/api/test/components/jar/JarConfig";
import {getCurrentProjectID} from "@/common/js/utils";
export default {
name: "MsJarConfigList",
@ -99,6 +107,8 @@ export default {
if (isSearchBarQuery) {
this.isSearchBarQuery = isSearchBarQuery;
}
this.condition.resourceType = 'PROJECT';
this.condition.resourceId = getCurrentProjectID();
this.result = this.$post("/jar/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
let data = response.data;
let {itemCount, listObject} = data;

View File

@ -2,16 +2,14 @@
<el-dialog width="50%" :close-on-click-modal="false" top="5vh" :title="$t('api_test.jar_config.title')" :visible.sync="visible" class="jar-import" @close="close">
<div v-loading="result.loading">
<ms-jar-config-from :config="currentConfig" :callback="saveConfig" ref="jarConfigFrom" :read-only="isReadOnly"/>
<!-- <ms-jar-search-bar v-if="(!isSearchBarQuery && configs.length > 0) || isSearchBarQuery" :condition="condition"-->
<!-- @search="getJarConfigs" :table-data="configs" ref="jarSearchBar"/>-->
<ms-jar-config-list :show-upload-btn="false" :table-data="configs" ref="jarConfigList"/>
<ms-jar-config-list :show-upload-btn="false" ref="jarConfigList"/>
</div>
</el-dialog>
</template>
<script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentWorkspaceId, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import MsJarConfigFrom from "@/business/components/api/test/components/jar/JarConfigFrom";
import MsJarSearchBar from "@/business/components/api/test/components/jar/JarSearchBar";
import MsJarConfigList from "@/business/components/settings/workspace/JarConfigList";
@ -24,7 +22,6 @@ export default {
visible: false,
result: {},
currentConfig: {},
configs: [],
condition: {},
isSearchBarQuery: false
}
@ -42,16 +39,8 @@ export default {
listenGoBack(this.close);
},
saveConfig(config, file) {
for (let item of this.configs) {
if (item.name === config.name && item.id !== config.id) {
this.$warning(this.$t('commons.already_exists'));
return;
}
if (item.fileName === file.name && item.id !== config.id) {
this.$warning(this.$t('api_test.jar_config.file_exist'));
return;
}
}
config.resourceType = 'WORKSPACE';
config.resourceId = getCurrentWorkspaceId();
let url = config.id ? "/jar/update" : "/jar/add";
this.result = this.$fileUpload(url, file, null, config, () => {
this.$success(this.$t('commons.save_success'));

View File

@ -24,6 +24,12 @@
<el-table-column prop="creator" :label="$t('report.user_name')" show-overflow-tooltip/>
<el-table-column prop="modifier" :label="$t('commons.modifier')" show-overflow-tooltip/>
<el-table-column prop="scope" :label="$t('作用范围')" show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{'工作空间'}}</span>
</template>
</el-table-column>
<el-table-column :label="$t('commons.operating')" min-width="100">
<template v-slot:default="scope">
<div>
@ -51,6 +57,7 @@ import MsContainer from "@/business/components/common/components/MsContainer";
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsJarConfig from "@/business/components/api/test/components/jar/JarConfig";
import {getCurrentWorkspaceId} from "@/common/js/utils";
export default {
name: "MsJarConfigList",
@ -93,6 +100,9 @@ export default {
if (isSearchBarQuery) {
this.isSearchBarQuery = isSearchBarQuery;
}
this.condition.resourceType = 'WORKSPACE';
this.condition.resourceId = getCurrentWorkspaceId();
this.result = this.$post("/jar/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
let data = response.data;
let {itemCount, listObject} = data;