minor refactoring

This commit is contained in:
dashevchenko 2024-06-05 12:35:50 +03:00
parent 78e4fd3013
commit 70e801f896

View File

@ -19,11 +19,10 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.exception.ThingsboardException;
import org.thingsboard.server.common.data.id.QueueStatsId; import org.thingsboard.server.common.data.id.QueueStatsId;
@ -59,8 +58,7 @@ public class QueueStatsController extends BaseController {
notes = "Returns a page of queue stats objects that are designed to collect queue statistics for every service. " + notes = "Returns a page of queue stats objects that are designed to collect queue statistics for every service. " +
PAGE_DATA_PARAMETERS + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) PAGE_DATA_PARAMETERS + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH)
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/queueStats", params = {"pageSize", "page"}, method = RequestMethod.GET) @GetMapping(value = "/queueStats", params = {"pageSize", "page"})
@ResponseBody
public PageData<QueueStats> getTenantQueueStats(@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true) public PageData<QueueStats> getTenantQueueStats(@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true)
@RequestParam int pageSize, @RequestParam int pageSize,
@Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true) @Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true)
@ -78,8 +76,7 @@ public class QueueStatsController extends BaseController {
@ApiOperation(value = "Get Queue stats entity by id (getQueueStatsById)", @ApiOperation(value = "Get Queue stats entity by id (getQueueStatsById)",
notes = "Fetch the Queue stats object based on the provided Queue stats id. " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) notes = "Fetch the Queue stats object based on the provided Queue stats id. " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH)
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/queueStats/{queueStatsId}", method = RequestMethod.GET) @GetMapping(value = "/queueStats/{queueStatsId}")
@ResponseBody
public QueueStats getQueueStatsById(@Parameter(description = QUEUE_STATS_ID_PARAM_DESCRIPTION) public QueueStats getQueueStatsById(@Parameter(description = QUEUE_STATS_ID_PARAM_DESCRIPTION)
@PathVariable("queueStatsId") String queueStatsIdStr) throws ThingsboardException { @PathVariable("queueStatsId") String queueStatsIdStr) throws ThingsboardException {
checkParameter("queueStatsId", queueStatsIdStr); checkParameter("queueStatsId", queueStatsIdStr);
@ -90,8 +87,7 @@ public class QueueStatsController extends BaseController {
@ApiOperation(value = "Get QueueStats By Ids (getQueueStatsByIds)", @ApiOperation(value = "Get QueueStats By Ids (getQueueStatsByIds)",
notes = "Fetch the Queue stats objects based on the provided ids. ") notes = "Fetch the Queue stats objects based on the provided ids. ")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')") @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/queueStats", params = {"strQueueStatsIds"}, method = RequestMethod.GET) @GetMapping(value = "/queueStats", params = {"strQueueStatsIds"})
@ResponseBody
public List<QueueStats> getQueueStatsByIds( public List<QueueStats> getQueueStatsByIds(
@Parameter(description = "A list of queue stats ids, separated by comma ','", required = true) @Parameter(description = "A list of queue stats ids, separated by comma ','", required = true)
@RequestParam("strQueueStatsIds") String[] strQueueStatsIds) throws ThingsboardException { @RequestParam("strQueueStatsIds") String[] strQueueStatsIds) throws ThingsboardException {