部分查询

This commit is contained in:
Captain.B 2020-04-10 11:17:04 +08:00
parent 2a2690e00b
commit c3738739ba
3 changed files with 10 additions and 4 deletions

View File

@ -1,10 +1,12 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.controller.request.WorkspaceRequest;
import io.metersphere.dto.WorkspaceDTO; import io.metersphere.dto.WorkspaceDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
public interface ExtWorkspaceMapper { public interface ExtWorkspaceMapper {
List<WorkspaceDTO> getWorkspaceWithOrg(); List<WorkspaceDTO> getWorkspaceWithOrg(@Param("request") WorkspaceRequest request);
} }

View File

@ -5,6 +5,11 @@
<select id="getWorkspaceWithOrg" resultType="io.metersphere.dto.WorkspaceDTO"> <select id="getWorkspaceWithOrg" resultType="io.metersphere.dto.WorkspaceDTO">
select w.id, w.name, w.organization_id as organizationId, w.description, o.name as organizationName select w.id, w.name, w.organization_id as organizationId, w.description, o.name as organizationName
from workspace w join organization o on w.organization_id = o.id from workspace w join organization o on w.organization_id = o.id
<where>
<if test="request.name != ''">
AND w.name LIKE #{request.name,jdbcType=VARCHAR}
</if>
</where>
</select> </select>
</mapper> </mapper>

View File

@ -7,7 +7,6 @@ import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.WorkspaceRequest; import io.metersphere.controller.request.WorkspaceRequest;
import io.metersphere.dto.OrganizationMemberDTO;
import io.metersphere.dto.WorkspaceDTO; import io.metersphere.dto.WorkspaceDTO;
import io.metersphere.dto.WorkspaceMemberDTO; import io.metersphere.dto.WorkspaceMemberDTO;
import io.metersphere.service.WorkspaceService; import io.metersphere.service.WorkspaceService;
@ -73,9 +72,9 @@ public class WorkspaceController {
@PostMapping("list/all/{goPage}/{pageSize}") @PostMapping("list/all/{goPage}/{pageSize}")
@RequiresRoles(RoleConstants.ADMIN) @RequiresRoles(RoleConstants.ADMIN)
public Pager<List<WorkspaceDTO>> getAllWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize) { public Pager<List<WorkspaceDTO>> getAllWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody WorkspaceRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, workspaceService.getAllWorkspaceList()); return PageUtils.setPageInfo(page, workspaceService.getAllWorkspaceList(request));
} }
@GetMapping("/list/userworkspace/{userId}") @GetMapping("/list/userworkspace/{userId}")