|
| 1 | +package com.mtvs.devlinkbackend.channel.controller; |
| 2 | + |
| 3 | +import com.mtvs.devlinkbackend.channel.dto.request.TileInfoRegistDTO; |
| 4 | +import com.mtvs.devlinkbackend.channel.dto.response.TileInfoListResponseDTO; |
| 5 | +import com.mtvs.devlinkbackend.channel.service.TileInfoService; |
| 6 | +import com.mtvs.devlinkbackend.channel.service.TileInfoViewService; |
| 7 | +import io.swagger.v3.oas.annotations.Operation; |
| 8 | +import io.swagger.v3.oas.annotations.media.Content; |
| 9 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 10 | +import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| 11 | +import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| 12 | +import org.springframework.http.HttpStatus; |
| 13 | +import org.springframework.http.ResponseEntity; |
| 14 | +import org.springframework.web.bind.annotation.*; |
| 15 | + |
| 16 | +@RestController |
| 17 | +@RequestMapping("/api/tile/zone") |
| 18 | +public class TileInfoController { |
| 19 | + |
| 20 | + private final TileInfoService tileInfoService; |
| 21 | + private final TileInfoViewService tileInfoViewService; |
| 22 | + |
| 23 | + public TileInfoController(TileInfoService tileInfoService, TileInfoViewService tileInfoViewService) { |
| 24 | + this.tileInfoService = tileInfoService; |
| 25 | + this.tileInfoViewService = tileInfoViewService; |
| 26 | + } |
| 27 | + |
| 28 | + @Operation(summary = "채널 ID로 TileInfo 리스트 조회", description = "특정 채널 ID와 연관된 모든 TileInfo 엔티티를 조회합니다.") |
| 29 | + @ApiResponses(value = { |
| 30 | + @ApiResponse(responseCode = "200", description = "TileInfo 리스트를 성공적으로 조회했습니다.", |
| 31 | + content = @Content(schema = @Schema(implementation = TileInfoListResponseDTO.class))), |
| 32 | + @ApiResponse(responseCode = "404", description = "채널 ID를 찾을 수 없습니다.", content = @Content) |
| 33 | + }) |
| 34 | + @GetMapping("/{channelId}") |
| 35 | + public ResponseEntity<TileInfoListResponseDTO> getTileInfoListByChannelId(@PathVariable String channelId) { |
| 36 | + TileInfoListResponseDTO responseDTO = tileInfoViewService.findTileInfoListByChannelId(channelId); |
| 37 | + return ResponseEntity.ok(responseDTO); |
| 38 | + } |
| 39 | + |
| 40 | + @Operation(summary = "TileInfo 생성", description = "특정 채널에 TileInfo를 생성합니다.") |
| 41 | + @ApiResponses(value = { |
| 42 | + @ApiResponse(responseCode = "201", description = "TileInfo가 성공적으로 생성되었습니다.", |
| 43 | + content = @Content(schema = @Schema(implementation = TileInfoRegistDTO.class))), |
| 44 | + @ApiResponse(responseCode = "400", description = "입력 데이터가 유효하지 않습니다.", content = @Content) |
| 45 | + }) |
| 46 | + @PostMapping("/{channelId}") |
| 47 | + public ResponseEntity<TileInfoRegistDTO> insertTileInfo( |
| 48 | + @PathVariable String channelId, |
| 49 | + @RequestBody TileInfoRegistDTO tileInfoRegistDTO) { |
| 50 | + TileInfoRegistDTO responseDTO = tileInfoService.insertTileInfoByChannelId(tileInfoRegistDTO, channelId); |
| 51 | + return ResponseEntity.status(HttpStatus.CREATED).body(responseDTO); |
| 52 | + } |
| 53 | + |
| 54 | + @Operation(summary = "TileInfo 업데이트", description = "특정 채널에 존재하는 TileInfo를 업데이트합니다.") |
| 55 | + @ApiResponses(value = { |
| 56 | + @ApiResponse(responseCode = "200", description = "TileInfo가 성공적으로 업데이트되었습니다.", |
| 57 | + content = @Content(schema = @Schema(implementation = TileInfoRegistDTO.class))), |
| 58 | + @ApiResponse(responseCode = "404", description = "TileInfo 또는 채널 ID를 찾을 수 없습니다.", content = @Content) |
| 59 | + }) |
| 60 | + @PutMapping("/{channelId}/{tileId}") |
| 61 | + public ResponseEntity<TileInfoRegistDTO> updateTileInfo( |
| 62 | + @PathVariable String channelId, |
| 63 | + @PathVariable String tileId, |
| 64 | + @RequestBody TileInfoRegistDTO tileInfoRegistDTO) { |
| 65 | + TileInfoRegistDTO responseDTO = tileInfoService.updateTileInfoByChannelId(tileInfoRegistDTO, channelId, tileId); |
| 66 | + return ResponseEntity.ok(responseDTO); |
| 67 | + } |
| 68 | + |
| 69 | + @Operation(summary = "TileInfo 삭제", description = "특정 채널에 연관된 모든 TileInfo를 삭제합니다.") |
| 70 | + @ApiResponses(value = { |
| 71 | + @ApiResponse(responseCode = "204", description = "TileInfo가 성공적으로 삭제되었습니다."), |
| 72 | + @ApiResponse(responseCode = "404", description = "채널 ID를 찾을 수 없습니다.", content = @Content) |
| 73 | + }) |
| 74 | + @DeleteMapping("/{channelId}/{tileId}") |
| 75 | + public ResponseEntity<Void> deleteTileInfoByChannelId(@PathVariable String channelId, @PathVariable String tileId) { |
| 76 | + tileInfoService.deleteTileInfoByChannelId(channelId, tileId); |
| 77 | + return ResponseEntity.noContent().build(); |
| 78 | + } |
| 79 | +} |
0 commit comments