-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from PLADI-ALM/feat/PDS-106-getBookingResources
[PDS-106/feat] 관리자 자원 예약 목록 조회
- Loading branch information
Showing
5 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/example/pladialmserver/resource/controller/ResourceAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.example.pladialmserver.resource.controller; | ||
|
||
import com.example.pladialmserver.global.response.ResponseCustom; | ||
import com.example.pladialmserver.resource.dto.response.AdminResourceRes; | ||
import com.example.pladialmserver.resource.service.ResourceService; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Api(tags = "관리자 자원 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/admin/resources") | ||
public class ResourceAdminController { | ||
private final ResourceService resourceService; | ||
|
||
/** | ||
* 관리자 자원 예약 목록을 조회 | ||
*/ | ||
@Operation(summary = "관리자 자원 예약 목록 조회", description = "관리자 페이지에서 자원 예약 내역을 전체 조회한다.") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "(S0001)요청에 성공했습니다."), | ||
}) | ||
@GetMapping("/resources") | ||
public ResponseCustom<Page<AdminResourceRes>> getBookingResources( | ||
@PageableDefault(size = 8) Pageable pageable){ | ||
return ResponseCustom.OK(resourceService.getBookingResources(pageable)); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/example/pladialmserver/resource/dto/response/AdminResourceRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.example.pladialmserver.resource.dto.response; | ||
|
||
import com.example.pladialmserver.booking.entity.ResourceBooking; | ||
import com.example.pladialmserver.global.utils.DateTimeUtil; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class AdminResourceRes { | ||
@Schema(type = "Long", description = "자원 Id", example = "1") | ||
private Long id; | ||
@Schema(type = "String", description = "자원 이름", example = "'벤츠'") | ||
private String name; | ||
@Schema(type = "String", description = "카테고리", example = "'차량'") | ||
private String category; | ||
@Schema(type = "String", description = "예약일자(시작일)", example = "'2023-10-01 12:00' / '2023-10-01'") | ||
private String startDateTime; | ||
@Schema(type = "String", description = "예약일자(종료일)", example = "'2023-10-01 13:00' / '2023-10-03'") | ||
private String endDateTime; | ||
@Schema(type = "String", description = "요청자", example = "이승학(부장)") | ||
private String requester; | ||
@Schema(type = "String", description = "상태", example = "'예약중' / '사용중'") | ||
private String status; | ||
|
||
public static AdminResourceRes toDto(ResourceBooking resourceBooking){ | ||
return AdminResourceRes.builder() | ||
.id(resourceBooking.getResourceBookingId()) | ||
.name(resourceBooking.getResource().getName()) | ||
.category(resourceBooking.getResource().getCategory().getValue()) | ||
.startDateTime(DateTimeUtil.dateToString(resourceBooking.getStartDate())) | ||
.endDateTime(DateTimeUtil.dateToString(resourceBooking.getEndDate())) | ||
.requester(resourceBooking.getUser().getPosition().getName()) | ||
.status(resourceBooking.getStatus().getValue()) | ||
.build(); | ||
|
||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters