package com.its.op.controller; import com.its.op.dto.ThreadMonitoringDto; import com.its.op.dto.WebsocketMonitoringDto; import com.its.op.service.ResourceMonitoringService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; @Slf4j @RequiredArgsConstructor @Validated @RestController @RequestMapping("/api/resource") @Api(tags = "00.공통-99.리소스 모니터링") public class ResourceMonitoringController { private final ResourceMonitoringService resourceMonitoringService; @ApiOperation(value = "스레드 리소스 현재값 저장", response = ThreadMonitoringDto.class, responseContainer = "ArrayList") @PutMapping(path="/threads/save/{tag}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> threadMonitoringSave(@PathVariable final String tag) { List result = this.resourceMonitoringService.threadMonitoringSave(tag); return ResponseEntity.ok(result); } @ApiOperation(value = "스레드 리소스 삭제", response = ThreadMonitoringDto.class, responseContainer = "ArrayList") @DeleteMapping(path="/threads/delete/{tag}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> threadMonitoringDelete(@PathVariable final String tag) { List result = this.resourceMonitoringService.threadMonitoringDelete(tag); return ResponseEntity.ok(result); //return ResponseEntity.ok().build(); } @ApiOperation(value = "스레드 리소스 저장값 조회", response = ThreadMonitoringDto.class, responseContainer = "ArrayList") @GetMapping(path="/threads/query/{tag}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> threadMonitoringQuery(@PathVariable final String tag) { List result = this.resourceMonitoringService.threadMonitoringQuery(tag); return ResponseEntity.ok(result); } @ApiOperation(value = "스레드 리소스 저장값과 현재값 비교", response = ThreadMonitoringDto.class, responseContainer = "ArrayList") @GetMapping(path="/threads/diff/{tag}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> threadMonitoringDiff(@PathVariable final String tag) { List result = this.resourceMonitoringService.threadMonitoringDiff(tag); return ResponseEntity.ok(result); } @ApiOperation(value = "스레드 리소스 현재값 조회", response = ThreadMonitoringDto.class, responseContainer = "ArrayList") @GetMapping(path="/threads", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> threadMonitoringCurrent() { List result = this.resourceMonitoringService.threadMonitoringCurrent(); return ResponseEntity.ok(result); } @ApiOperation(value = "웹소켓 조회", response = WebsocketMonitoringDto.class, responseContainer = "ArrayList") @GetMapping(path="/websocket/list", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getWebsocketList() { List result = this.resourceMonitoringService.getWebsocketList(); return ResponseEntity.ok(result); } @ApiOperation(value = "웹소켓 디버그 조회", response = String.class, responseContainer = "ArrayList") @GetMapping(path="/websocket/debug/{flag}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getWebsocketDebug( @ApiParam(name = "flag", value = "디버그 설정(0 or 1", example = "0", required = true) @PathVariable("flag") String flag ) { String result = this.resourceMonitoringService.getWebsocketDebug(flag); return ResponseEntity.ok(result); } }