refactor(项目管理): 项目添加创建人列,支持高级搜索

This commit is contained in:
Captain.B 2021-05-18 19:50:59 +08:00 committed by 刘瑞斌
parent 5c3bb0f74e
commit 08c9c1d5b8
17 changed files with 220 additions and 22 deletions

View File

@ -33,7 +33,7 @@ public class Project implements Serializable {
private Boolean scenarioCustomNum;
private static final long serialVersionUID = 1L;
private String createUser;
private String protocal;
private static final long serialVersionUID = 1L;
}

View File

@ -1033,6 +1033,76 @@ public class ProjectExample {
addCriterion("scenario_custom_num not between", value1, value2, "scenarioCustomNum");
return (Criteria) this;
}
public Criteria andCreateUserIsNull() {
addCriterion("create_user is null");
return (Criteria) this;
}
public Criteria andCreateUserIsNotNull() {
addCriterion("create_user is not null");
return (Criteria) this;
}
public Criteria andCreateUserEqualTo(String value) {
addCriterion("create_user =", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotEqualTo(String value) {
addCriterion("create_user <>", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThan(String value) {
addCriterion("create_user >", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserGreaterThanOrEqualTo(String value) {
addCriterion("create_user >=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThan(String value) {
addCriterion("create_user <", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLessThanOrEqualTo(String value) {
addCriterion("create_user <=", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserLike(String value) {
addCriterion("create_user like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotLike(String value) {
addCriterion("create_user not like", value, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserIn(List<String> values) {
addCriterion("create_user in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotIn(List<String> values) {
addCriterion("create_user not in", values, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserBetween(String value1, String value2) {
addCriterion("create_user between", value1, value2, "createUser");
return (Criteria) this;
}
public Criteria andCreateUserNotBetween(String value1, String value2) {
addCriterion("create_user not between", value1, value2, "createUser");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -16,6 +16,7 @@
<result column="issue_template_id" jdbcType="VARCHAR" property="issueTemplateId" />
<result column="custom_num" jdbcType="BIT" property="customNum" />
<result column="scenario_custom_num" jdbcType="BIT" property="scenarioCustomNum" />
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -77,7 +78,8 @@
</sql>
<sql id="Base_Column_List">
id, workspace_id, `name`, description, create_time, update_time, tapd_id, jira_key,
zentao_id, `repeatable`, case_template_id, issue_template_id, custom_num, scenario_custom_num
zentao_id, `repeatable`, case_template_id, issue_template_id, custom_num, scenario_custom_num,
create_user
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ProjectExample" resultMap="BaseResultMap">
select
@ -114,12 +116,14 @@
description, create_time, update_time,
tapd_id, jira_key, zentao_id,
`repeatable`, case_template_id, issue_template_id,
custom_num, scenario_custom_num)
custom_num, scenario_custom_num, create_user
)
values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR}, #{zentaoId,jdbcType=VARCHAR},
#{repeatable,jdbcType=BIT}, #{caseTemplateId,jdbcType=VARCHAR}, #{issueTemplateId,jdbcType=VARCHAR},
#{customNum,jdbcType=BIT}, #{scenarioCustomNum,jdbcType=BIT})
#{customNum,jdbcType=BIT}, #{scenarioCustomNum,jdbcType=BIT}, #{createUser,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Project">
insert into project
@ -166,6 +170,9 @@
<if test="scenarioCustomNum != null">
scenario_custom_num,
</if>
<if test="createUser != null">
create_user,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -210,6 +217,9 @@
<if test="scenarioCustomNum != null">
#{scenarioCustomNum,jdbcType=BIT},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ProjectExample" resultType="java.lang.Long">
@ -263,6 +273,9 @@
<if test="record.scenarioCustomNum != null">
scenario_custom_num = #{record.scenarioCustomNum,jdbcType=BIT},
</if>
<if test="record.createUser != null">
create_user = #{record.createUser,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -283,7 +296,8 @@
case_template_id = #{record.caseTemplateId,jdbcType=VARCHAR},
issue_template_id = #{record.issueTemplateId,jdbcType=VARCHAR},
custom_num = #{record.customNum,jdbcType=BIT},
scenario_custom_num = #{record.scenarioCustomNum,jdbcType=BIT}
scenario_custom_num = #{record.scenarioCustomNum,jdbcType=BIT},
create_user = #{record.createUser,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -330,6 +344,9 @@
<if test="scenarioCustomNum != null">
scenario_custom_num = #{scenarioCustomNum,jdbcType=BIT},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -347,7 +364,8 @@
case_template_id = #{caseTemplateId,jdbcType=VARCHAR},
issue_template_id = #{issueTemplateId,jdbcType=VARCHAR},
custom_num = #{customNum,jdbcType=BIT},
scenario_custom_num = #{scenarioCustomNum,jdbcType=BIT}
scenario_custom_num = #{scenarioCustomNum,jdbcType=BIT},
create_user = #{createUser,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -1,14 +1,65 @@
<?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.ExtProjectMapper">
<sql id="condition">
<include refid="io.metersphere.base.mapper.ext.ExtApiTestMapper.condition"/>
</sql>
<sql id="combine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
AND p.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
AND p.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.createTime != null">
AND p.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.creator != null">
AND p.create_user
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
</sql>
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
select p.id, p.workspace_id, p.name, p.description, p.update_time, p.issue_template_id, p.case_template_id,
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key, p.zentao_id,p.repeatable, p.custom_num,
user.name as createUserName,
p.scenario_custom_num
from project p
join workspace w on p.workspace_id = w.id
left join user on user.id = p.create_user
<where>
<if test="proRequest.combine != null">
<include refid="combine">
<property name="condition" value="proRequest.combine"/>
<property name="name" value="proRequest.name"/>
</include>
</if>
<if test="proRequest.filters != null and proRequest.filters.size() > 0">
<foreach collection="proRequest.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'create_user'">
AND p.create_user IN
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
<if test="proRequest.name != null and proRequest.name != ''">
and p.name like #{proRequest.name, jdbcType=VARCHAR}
</if>

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.AddProjectRequest;
import io.metersphere.controller.request.ProjectRequest;
import io.metersphere.dto.ProjectDTO;
import io.metersphere.service.CheckPermissionService;
@ -66,7 +67,7 @@ public class ProjectController {
@PostMapping("/add")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER,}, logical = Logical.OR)
public Project addProject(@RequestBody Project project, HttpServletRequest request) {
public Project addProject(@RequestBody AddProjectRequest project, HttpServletRequest request) {
Project returnModel = projectService.addProject(project);
//创建项目的时候默认增加Mock环境

View File

@ -0,0 +1,11 @@
package io.metersphere.controller.request;
import io.metersphere.base.domain.Project;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class AddProjectRequest extends Project {
private String protocal;
}

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@Setter
@ -11,4 +12,6 @@ public class ProjectRequest {
private String workspaceId;
private String name;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
}

View File

@ -8,4 +8,5 @@ import lombok.Setter;
@Setter
public class ProjectDTO extends Project {
private String workspaceName;
private String createUserName;
}

View File

@ -83,6 +83,7 @@ public class ProjectService {
project.setUpdateTime(createTime);
// set workspace id
project.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
project.setCreateUser(SessionUtils.getUserId());
projectMapper.insertSelective(project);
return project;
}

@ -1 +1 @@
Subproject commit e435fe1d01a2495481efa58daf3875be07b2ac9b
Subproject commit 9a95a444a4f0a477427f94bd107571430d85e766

View File

@ -69,3 +69,4 @@ ALTER TABLE test_plan_api_case ADD create_user VARCHAR(100) NULL;
ALTER TABLE test_plan_api_scenario ADD create_user VARCHAR(100) NULL;
ALTER TABLE test_plan_load_case ADD create_user VARCHAR(100) NULL;
ALTER TABLE test_case_report ADD create_user VARCHAR(100) NULL;
ALTER TABLE project ADD create_user VARCHAR(100) NULL;

View File

@ -465,6 +465,8 @@ export const CASE_REVIEW_STATUS = {
export const TEST_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, STATUS, CREATOR];
export const PROJECT_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, CREATOR];
export const REPORT_CONFIGS = [NAME, TEST_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE];
export const TEST_CASE_CONFIGS = [NAME, API_TAGS, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR, EXECUTOR, CASE_REVIEW_STATUS];

View File

@ -10,7 +10,9 @@
</template>
</ms-table-header>
</template>
<el-table border class="adjust-table" :data="items" style="width: 100%" @sort-change="sort">
<el-table border class="adjust-table" :data="items" style="width: 100%"
@sort-change="sort"
@filter-change="filter">
<el-table-column prop="name" :label="$t('commons.name')" width="250" show-overflow-tooltip/>
<el-table-column prop="description" :label="$t('commons.description')" show-overflow-tooltip>
<template v-slot:default="scope">
@ -18,6 +20,16 @@
</template>
</el-table-column>
<!--<el-table-column prop="workspaceName" :label="$t('project.owning_workspace')"/>-->
<el-table-column
prop="createUser"
:label="$t('commons.create_user')"
:filters="userFilters"
column-key="create_user"
show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{ scope.row.createUserName }}</span>
</template>
</el-table-column>
<el-table-column
sortable
prop="createTime"
@ -41,9 +53,11 @@
<ms-table-operator :is-tester-permission="true" @editClick="edit(scope.row)"
@deleteClick="handleDelete(scope.row)">
<template v-slot:behind>
<ms-table-operator-button :is-tester-permission="true" :tip="$t('api_test.environment.environment_config')" icon="el-icon-setting"
<ms-table-operator-button :is-tester-permission="true"
:tip="$t('api_test.environment.environment_config')" icon="el-icon-setting"
type="info" @exec="openEnvironmentConfig(scope.row)"/>
<ms-table-operator-button :is-tester-permission="true" :tip="$t('load_test.other_resource')" icon="el-icon-files"
<ms-table-operator-button :is-tester-permission="true" :tip="$t('load_test.other_resource')"
icon="el-icon-files"
type="success" @exec="openFiles(scope.row)"/>
</template>
</ms-table-operator>
@ -54,7 +68,8 @@
:total="total"/>
</el-card>
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="createVisible" destroy-on-close @close="handleClose">
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="createVisible" destroy-on-close
@close="handleClose">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="140px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"></el-input>
@ -117,7 +132,13 @@ import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {getCurrentProjectID, getCurrentUser, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {
getCurrentProjectID,
getCurrentUser,
getCurrentWorkspaceId,
listenGoBack,
removeGoBackListener
} from "@/common/js/utils";
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
@ -127,9 +148,10 @@ import TemplateComponent from "../../track/plan/view/comonents/report/TemplateCo
import {PROJECT_ID} from "@/common/js/constants";
import MsJarConfig from "../../api/test/components/jar/JarConfig";
import MsTableButton from "../../common/components/MsTableButton";
import {_sort} from "@/common/js/tableUtils";
import {_filter, _sort} from "@/common/js/tableUtils";
import MsResourceFiles from "@/business/components/performance/test/components/ResourceFiles";
import TemplateSelect from "@/business/components/settings/workspace/template/TemplateSelect";
import {PROJECT_CONFIGS} from "@/business/components/common/components/search/search-components";
export default {
name: "MsProject",
@ -151,7 +173,7 @@ export default {
result: {},
btnTips: this.$t('project.create'),
title: this.$t('project.create'),
condition: {},
condition: {components: PROJECT_CONFIGS},
items: [],
tapd: false,
jira: false,
@ -160,6 +182,7 @@ export default {
currentPage: 1,
pageSize: 10,
total: 0,
userFilters: [],
rules: {
name: [
{required: true, message: this.$t('project.input_name'), trigger: 'blur'},
@ -171,7 +194,7 @@ export default {
// caseTemplateId: [{required: true}],
// issueTemplateId: [{required: true}],
},
}
};
},
props: {
baseUrl: {
@ -185,6 +208,7 @@ export default {
this.$router.replace('/setting/project/all');
}
this.list();
this.getMaintainerOptions();
},
activated() {
this.list();
@ -198,6 +222,14 @@ export default {
this.createVisible = false;
},
methods: {
getMaintainerOptions() {
let workspaceId = getCurrentWorkspaceId();
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
},
create() {
let workspaceId = this.currentUser.lastWorkspaceId;
this.getOptions();
@ -305,23 +337,27 @@ export default {
let data = response.data;
this.items = data.listObject;
this.total = data.itemCount;
})
});
},
sort(column) {
_sort(column, this.condition);
this.list();
},
filter(filters) {
_filter(filters, this.condition);
this.list();
},
openEnvironmentConfig(project) {
this.$refs.environmentConfig.open(project.id);
},
},
created() {
document.addEventListener('keydown', this.handleEvent)
document.addEventListener('keydown', this.handleEvent);
},
beforeDestroy() {
document.removeEventListener('keydown', this.handleEvent);
}
}
};
</script>
<style scoped>

@ -1 +1 @@
Subproject commit e50f0463826ac4d7837ea3a237333827774a1b19
Subproject commit 097d3a5a00beaa660d34525765d93b35e63f52c0

View File

@ -156,6 +156,7 @@ export default {
more_operator: "More operator",
mock: "Mock settings",
all_module_title: "All module",
create_user: 'Creator',
table: {
select_tip: "Item {0} data is selected"
},

View File

@ -157,6 +157,7 @@ export default {
more_operator: "更多操作",
mock: "Mock 设置",
all_module_title: "全部模块",
create_user: '创建人',
table: {
select_tip: "已选中 {0} 条数据"
},
@ -811,7 +812,7 @@ export default {
wait_controller: "等待控制器",
if_controller: "条件控制器",
loop_controller: "循环控制器",
transcation_controller:"事务控制器",
transcation_controller: "事务控制器",
scenario_import: "场景导入",
customize_script: "自定义脚本",
customize_req: "自定义请求",

View File

@ -157,6 +157,7 @@ export default {
more_operator: "更多操作",
mock: "Mock 設置",
all_module_title: "全部模塊",
create_user: "創建人",
table: {
select_tip: "已選中 {0} 條數據"
},