Skip to content

Commit

Permalink
feat: 회의실 수정하기 기능에 sequence 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Dec 22, 2023
1 parent 3d0713f commit aae17db
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/example/busan/room/RoomService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/example/busan/room/domain/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
}
30 changes: 9 additions & 21 deletions src/main/resources/static/api/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -154,7 +154,7 @@ paths:
현재 유저 정보 조회하기:
value: "{\"name\":\"연어\",\"phone\":\"01012341234\",\"email\":\"\
[email protected]\",\"role\":\"USER\",\"company\":\"우형\",\"region\"\
:\"BUSAN\",\"createdAt\":\"2023-12-21T18:20:09.891402\"}"
:\"BUSAN\",\"createdAt\":\"2023-12-22T21:27:18.831673\"}"
post:
tags:
- members
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void deleteById() throws Exception {
void update() throws Exception {
//given
httpSession.setAttribute(AUTHORIZATION, new Authentication("[email protected]", 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(
Expand All @@ -103,6 +103,7 @@ void update() throws Exception {
requestFields(
fieldWithPath("name").description("회의실 이름"),
fieldWithPath("image").description("회의실 이미지 url"),
fieldWithPath("sequence").description("회의실 순서"),
fieldWithPath("maxPeopleCount").description("회의실 최대 수용 인원"))))
.andReturn()
.getResponse();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/example/busan/room/RoomServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
});
}

Expand Down

0 comments on commit aae17db

Please sign in to comment.