部分查询

This commit is contained in:
Captain.B 2020-04-10 11:36:18 +08:00
parent ed9d972bee
commit 2d17d227eb
4 changed files with 26 additions and 5 deletions

View File

@ -7,9 +7,14 @@
p.create_time, w.id as workspaceId, w.name as workspaceName
from project p
join workspace w on p.workspace_id = w.id
<if test="proRequest.workspaceId != null">
where w.id = #{proRequest.workspaceId}
</if>
<where>
<if test="proRequest.name != ''">
and p.name like #{proRequest.name, jdbcType=VARCHAR}
</if>
<if test="proRequest.workspaceId != null">
and w.id = #{proRequest.workspaceId}
</if>
</where>
</select>
</mapper>

View File

@ -2,6 +2,15 @@ package io.metersphere.controller.request;
public class ProjectRequest {
private String workspaceId;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getWorkspaceId() {
return workspaceId;

View File

@ -47,6 +47,9 @@ public class ProjectService {
}
public List<ProjectDTO> getProjectList(ProjectRequest request) {
if (StringUtils.isNotBlank(request.getName())) {
request.setName(StringUtils.wrapIfMissing(request.getName(), "%"));
}
return extProjectMapper.getProjectWithWorkspace(request);
}

View File

@ -11,6 +11,7 @@
<span class="search">
<el-input type="text" size="small" :placeholder="$t('project.search_by_name')"
prefix-icon="el-icon-search"
@change="search"
maxlength="60" v-model="condition" clearable/>
</span>
</el-row>
@ -101,7 +102,7 @@
if (this.$route.path.split('/')[2] === 'project' &&
this.$route.path.split('/')[3] === 'create') {
this.create();
this.$router.push( '/' + this.beaseUrl + '/project/all');
this.$router.push('/' + this.beaseUrl + '/project/all');
}
this.list();
},
@ -172,9 +173,12 @@
}).catch(() => {
});
},
search() {
this.list();
},
list() {
let url = "/project/list/" + this.currentPage + '/' + this.pageSize;
this.result = this.$post(url, {}, (response) => {
this.result = this.$post(url, {name: this.condition}, (response) => {
let data = response.data;
this.items = data.listObject;
this.total = data.itemCount;