部分查询

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

View File

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

View File

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

View File

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