'接口测试筛选修改'

This commit is contained in:
wenyann 2020-06-02 16:47:41 +08:00
parent 6e57757d61
commit dd8ab09875
3 changed files with 25 additions and 4 deletions

View File

@ -1,8 +1,12 @@
package io.metersphere.api.dto;
import io.metersphere.controller.request.OrderRequest;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class QueryAPIReportRequest {
@ -12,5 +16,6 @@ public class QueryAPIReportRequest {
private String name;
private String workspaceId;
private boolean recent = false;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
}

View File

@ -11,12 +11,14 @@ import io.metersphere.base.mapper.ApiTestReportMapper;
import io.metersphere.base.mapper.ext.ExtApiTestReportMapper;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.DashboardTestDTO;
import io.metersphere.i18n.Translator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
@ -24,8 +26,6 @@ import java.util.List;
import java.util.Objects;
import java.util.UUID;
import javax.annotation.Resource;
@Service
@Transactional(rollbackFor = Exception.class)
public class APIReportService {
@ -38,6 +38,7 @@ public class APIReportService {
private ExtApiTestReportMapper extApiTestReportMapper;
public List<APIReportResult> list(QueryAPIReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
return extApiTestReportMapper.list(request);
}

View File

@ -26,8 +26,23 @@
<if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId,jdbcType=VARCHAR}
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
and r.${key} in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</if>
</foreach>
</if>
</where>
ORDER BY r.update_time DESC
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
r.${order.name} ${order.type}
</foreach>
</if>
</select>
<select id="listByTestId" resultMap="BaseResultMap">