Compare commits

..

No commits in common. "368d5b337d49971c4a1662652139d80f36e0cc92" and "6bb6fb72537acdb1cf8ac8db81bdff6723421da7" have entirely different histories.

1 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -31,12 +32,15 @@ public class ApiController {
@GetMapping("/top") @GetMapping("/top")
@Operation(summary = "查询TOP") @Operation(summary = "查询TOP")
public List<TopModel> top(@RequestParam(value = "type") String type, public List<TopModel> top(@RequestParam(value = "type", required = false) String type,
@RequestParam(value = "vendorId", required = false) Long vendorId, @RequestParam(value = "vendorId", required = false) Long vendorId,
@RequestParam(value = "vendorType", required = false) String vendorType, @RequestParam(value = "vendorType", required = false) String vendorType,
@RequestParam(value = "limit", required = false, defaultValue = "5") Integer limit, @RequestParam(value = "limit", required = false, defaultValue = "5") Integer limit,
@Value(Common.REQ_CONTEXT) RequestContext context, @Value(Common.REQ_CONTEXT) RequestContext context,
HttpServletRequest request) { HttpServletRequest request) {
if (StringUtils.isEmpty(type)) {
throw new IllegalArgumentException("type is null!");
}
LineChartResult chart = switch (type) { LineChartResult chart = switch (type) {
case "hostCpu" -> this.topService.topOfHostCpu(vendorId, limit); case "hostCpu" -> this.topService.topOfHostCpu(vendorId, limit);
case "hostMem" -> this.topService.topOfHostMem(vendorId, limit); case "hostMem" -> this.topService.topOfHostMem(vendorId, limit);