From aae17db0e03e0140d1a6cd957261b10be36ae880 Mon Sep 17 00:00:00 2001 From: nuyh Date: Fri, 22 Dec 2023 21:28:03 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9D=98=EC=8B=A4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=98=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=EC=97=90=20seq?= =?UTF-8?q?uence=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/busan/room/RoomService.java | 2 +- .../com/example/busan/room/domain/Room.java | 3 +- .../busan/room/dto/UpdateRoomRequest.java | 2 +- src/main/resources/static/api/openapi3.yaml | 30 ++++++------------- .../busan/room/RoomAdminControllerTest.java | 3 +- .../example/busan/room/RoomServiceTest.java | 3 +- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/example/busan/room/RoomService.java b/src/main/java/com/example/busan/room/RoomService.java index af3c2db..32d9890 100644 --- a/src/main/java/com/example/busan/room/RoomService.java +++ b/src/main/java/com/example/busan/room/RoomService.java @@ -45,7 +45,7 @@ public void save(final CreateRoomRequest request) { public void update(final Long roomId, final UpdateRoomRequest request) { final Room room = roomRepository.findById(roomId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회의실입니다.")); - room.update(request.name(), request.image(), request.maxPeopleCount()); + room.update(request.name(), request.image(), request.maxPeopleCount(), request.sequence()); } @Transactional diff --git a/src/main/java/com/example/busan/room/domain/Room.java b/src/main/java/com/example/busan/room/domain/Room.java index 5a7e3fc..494cece 100644 --- a/src/main/java/com/example/busan/room/domain/Room.java +++ b/src/main/java/com/example/busan/room/domain/Room.java @@ -43,11 +43,12 @@ public Room(final String name, final String image, final Integer maxPeopleCount, this(null, name, image, maxPeopleCount, sequence); } - public void update(final String name, final String image, final Integer maxPeopleCount) { + public void update(final String name, final String image, final Integer maxPeopleCount, final Integer sequence) { validate(name, image, maxPeopleCount); this.name = name; this.image = image; this.maxPeopleCount = maxPeopleCount; + this.sequence = sequence; } public Long getId() { diff --git a/src/main/java/com/example/busan/room/dto/UpdateRoomRequest.java b/src/main/java/com/example/busan/room/dto/UpdateRoomRequest.java index 7f1247f..ab72e78 100644 --- a/src/main/java/com/example/busan/room/dto/UpdateRoomRequest.java +++ b/src/main/java/com/example/busan/room/dto/UpdateRoomRequest.java @@ -1,4 +1,4 @@ package com.example.busan.room.dto; -public record UpdateRoomRequest(String name, String image, Integer maxPeopleCount) { +public record UpdateRoomRequest(String name, String image, Integer maxPeopleCount, Integer sequence) { } diff --git a/src/main/resources/static/api/openapi3.yaml b/src/main/resources/static/api/openapi3.yaml index 8c07104..1d4b919 100644 --- a/src/main/resources/static/api/openapi3.yaml +++ b/src/main/resources/static/api/openapi3.yaml @@ -40,11 +40,11 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/admin-rooms-roomId-1790608654' + $ref: '#/components/schemas/admin-rooms-543864538' examples: 회의실 수정 - 어드민: value: "{\"name\":\"updated\",\"image\":\"updated\",\"maxPeopleCount\"\ - :10}" + :10,\"sequence\":2}" responses: "204": description: "204" @@ -154,7 +154,7 @@ paths: 현재 유저 정보 조회하기: value: "{\"name\":\"연어\",\"phone\":\"01012341234\",\"email\":\"\ test@naver.com\",\"role\":\"USER\",\"company\":\"우형\",\"region\"\ - :\"BUSAN\",\"createdAt\":\"2023-12-21T18:20:09.891402\"}" + :\"BUSAN\",\"createdAt\":\"2023-12-22T21:27:18.831673\"}" post: tags: - members @@ -281,14 +281,14 @@ paths: examples: 자신의 회의실 예약 목록 최신 순으로 보기: value: "[{\"id\":1,\"status\":\"RESERVED\",\"cancelReason\":null,\"\ - startTime\":\"2023-12-21T18:20:11.524852\",\"endTime\":\"2023-12-21T20:20:11.524858\"\ + startTime\":\"2023-12-22T21:27:20.516436\",\"endTime\":\"2023-12-22T23:27:20.51644\"\ ,\"name\":\"황재현\",\"phone\":\"01012341234\",\"reservedAt\":\"\ - 2023-12-21T18:20:11.524868\",\"roomId\":1,\"roomName\":\"대회의실\"\ + 2023-12-22T21:27:20.51645\",\"roomId\":1,\"roomName\":\"대회의실\"\ },{\"id\":2,\"status\":\"CANCELED\",\"cancelReason\":\"쓰기 싫어졌어\ - 요..\",\"startTime\":\"2023-12-21T18:20:11.524875\",\"endTime\"\ - :\"2023-12-21T20:20:11.524877\",\"name\":\"황재현\",\"phone\":\"\ - 01012341234\",\"reservedAt\":\"2023-12-21T18:20:11.524879\",\"\ - roomId\":1,\"roomName\":\"대회의실\"}]" + 요..\",\"startTime\":\"2023-12-22T21:27:20.516458\",\"endTime\"\ + :\"2023-12-22T23:27:20.51646\",\"name\":\"황재현\",\"phone\":\"01012341234\"\ + ,\"reservedAt\":\"2023-12-22T21:27:20.516462\",\"roomId\":1,\"\ + roomName\":\"대회의실\"}]" post: tags: - reservations @@ -548,18 +548,6 @@ components: email: type: string description: 이메일 - admin-rooms-roomId-1790608654: - type: object - properties: - image: - type: string - description: 회의실 이미지 url - maxPeopleCount: - type: number - description: 회의실 최대 수용 인원 - name: - type: string - description: 회의실 이름 members1182193868: type: object properties: diff --git a/src/test/java/com/example/busan/room/RoomAdminControllerTest.java b/src/test/java/com/example/busan/room/RoomAdminControllerTest.java index b6a6499..c51255d 100644 --- a/src/test/java/com/example/busan/room/RoomAdminControllerTest.java +++ b/src/test/java/com/example/busan/room/RoomAdminControllerTest.java @@ -90,7 +90,7 @@ void deleteById() throws Exception { void update() throws Exception { //given httpSession.setAttribute(AUTHORIZATION, new Authentication("test@gmail.com", Role.ADMIN)); - final String request = objectMapper.writeValueAsString(new UpdateRoomRequest("updated", "updated", 10)); + final String request = objectMapper.writeValueAsString(new UpdateRoomRequest("updated", "updated", 10, 2)); //when final MockHttpServletResponse response = mockMvc.perform( @@ -103,6 +103,7 @@ void update() throws Exception { requestFields( fieldWithPath("name").description("회의실 이름"), fieldWithPath("image").description("회의실 이미지 url"), + fieldWithPath("sequence").description("회의실 순서"), fieldWithPath("maxPeopleCount").description("회의실 최대 수용 인원")))) .andReturn() .getResponse(); diff --git a/src/test/java/com/example/busan/room/RoomServiceTest.java b/src/test/java/com/example/busan/room/RoomServiceTest.java index 901b4bc..b9493aa 100644 --- a/src/test/java/com/example/busan/room/RoomServiceTest.java +++ b/src/test/java/com/example/busan/room/RoomServiceTest.java @@ -80,7 +80,7 @@ void deleteById() { void update() { //given final Room room = createRoom(); - final UpdateRoomRequest request = new UpdateRoomRequest("updated", "newImage", 100); + final UpdateRoomRequest request = new UpdateRoomRequest("updated", "newImage", 100, 1); //when roomService.update(room.getId(), request); @@ -91,6 +91,7 @@ void update() { softAssertions.assertThat(updated.getName()).isEqualTo("updated"); softAssertions.assertThat(updated.getImage()).isEqualTo("newImage"); softAssertions.assertThat(updated.getMaxPeopleCount()).isEqualTo(100); + softAssertions.assertThat(updated.getSequence()).isOne(); }); }