diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomService.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomService.java index 3ef0e2e9..d5347984 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomService.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/RoomService.java @@ -260,12 +260,20 @@ public RoomDetailRes getRoomDetail(Integer roomId){ List roomUsers = roomUserRepository.findAllByRoom_Id(roomId); - //dto 매핑 - RoomDetailRes roomDetailRes = EntityDtoMapper.INSTANCE.toRoomDetailRes(alarm); + //dto 매핑 mapper 사용 + RoomDetailRes roomDetailRes =new RoomDetailRes(); + roomDetailRes.setRoomData(EntityDtoMapper.INSTANCE.toRoomDetailResRoomData(alarm)); + roomDetailRes.setAlarmData(EntityDtoMapper.INSTANCE.toRoomDetailResAlarmData(alarm)); roomDetailRes.setUserList(EntityDtoMapper.INSTANCE.toUserDataList(roomUsers)); - roomDetailRes.setCreatedAtString("개설일 "+timeFormatter.timestampToDotDateFormat(alarm.getRoom().getCreatedAt())); - roomDetailRes.setPersonnelString(roomUsers.size()+"명이 함께해요"); + //dto 매핑 - 커스텀 필드 + roomDetailRes.getRoomData().setCreatedAtString(timeFormatter.timestampToDotDateFormat(alarm.getRoom().getCreatedAt())); + roomDetailRes.getRoomData().setPersonnelString(roomUsers.size()); + + // ex) 13:00 -> pm 1:00 + roomDetailRes.getAlarmData().setAlarmTime(timeFormatter.timeStringToAMPMFormat(alarm.getAlarmTime())); + // ex) 평일, 주말, 매일, 월요일, (월, 화, 수), 빈칸 + roomDetailRes.getAlarmData().setAlarmDay(timeFormatter.formatDaysOfWeek(alarm.getMonday(),alarm.getTuesday(),alarm.getWednesday(),alarm.getThursday(),alarm.getFriday(),alarm.getSaturday(),alarm.getSunday())); return roomDetailRes; } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java index 58bb131a..319a5463 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/api/room/dto/response/RoomDetailRes.java @@ -13,27 +13,52 @@ @Builder public class RoomDetailRes { - @Schema( description = "룸이 가지고 있는 알람의 아이콘",example = "⏰") - private String icon; + @Schema(description = "룸 정보") + private RoomData roomData; - @Schema(description = "room name", example = "설여대 기상방") - private String name; + @Schema(description = "룸 정보") + private AlarmData alarmData; - @Schema(description = "room 소개",example = "소프트웨어융학학과 기상방입니다.") - private String intro; + @Schema(description = "룸의 유저들 정보 리스트") + private List userList; + @Builder + @Data + public static class RoomData { - @Schema(description = "room 개설일",example = "개설일 2020.02.03") - private String createdAtString; + @Schema( description = "룸이 가지고 있는 알람의 아이콘",example = "⏰") + private String icon; -// @Schema(description = "룸이 가지고 있는 알람의 미션" , example = "강아지") -// private String mission; -// -// private String a + @Schema(description = "room name", example = "설여대 기상방") + private String name; + + @Schema(description = "room 소개",example = "소프트웨어융학학과 기상방입니다.") + private String intro; + + @Schema(description = "room 개설일",example = "2020.02.03") + private String createdAtString; + + @Schema(description = "함께하는 인원수",example = "6") + private Integer personnelString; + + + } + + @Builder + @Data + public static class AlarmData { + @Schema(description = "미션의 한국말",example = "자동차") + private String missionKr; + + @Schema(description = "알람 시간", example = "06:00") + private String alarmTime; + + @Schema(description = "그룹알람 울리는 날",example = "주중") + private String alarmDay; + + + } - @Schema(description = "함께하는 인원수",example = "6명이 함께해요") - private String personnelString; - private List userList; @Builder @Data diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java b/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java index 6d110450..bc335d77 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/utils/TimeFormatter.java @@ -8,7 +8,9 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import java.util.Date; +import java.util.Locale; +import java.util.Objects; +import java.util.stream.Stream; @Component public class TimeFormatter { @@ -41,4 +43,49 @@ public LocalDateTime stringToLocalDateTime(String timeString) return localDateTime; } + + public String timeStringToAMPMFormat(String timeString) { + LocalTime localTime = stringToLocalTime(timeString); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("a h:mm").withLocale(Locale.ENGLISH); + return localTime.format(formatter).toLowerCase(); + } + + + + + public String formatDaysOfWeek(boolean monday, boolean tuesday, boolean wednesday, boolean thursday, boolean friday, boolean saturday, boolean sunday) { + + StringBuilder formattedDays = new StringBuilder(); + + Boolean[] weekDays= {true, true, true, true, true, false, false }; + Boolean[] weekend = {false, false, false, false, false, true, true}; + Boolean[] none = {false, false, false, false, false, false, false}; + Boolean[] everyDay= {true, true, true, true, true, true, true }; + + + Boolean[] alarmDays = {monday, tuesday, wednesday, thursday, friday, saturday, sunday }; + + if(Objects.deepEquals(weekDays,alarmDays)) + formattedDays.append("주중"); + else if(Objects.deepEquals(weekend,alarmDays)) + formattedDays.append("주말"); + else if (Objects.deepEquals(none,alarmDays)) + formattedDays.append(""); + else if(Objects.deepEquals(everyDay,alarmDays)) + formattedDays.append("매일"); + else + { + + for (int i = 0; i < alarmDays.length; i++) { + if (alarmDays[i]) { + formattedDays.append(new String[]{"월", "화", "수", "목", "금","토","일"}[i]); + formattedDays.append(","); + } + } + formattedDays.deleteCharAt(formattedDays.length() - 1); + } + + return formattedDays.toString(); + } + } diff --git a/src/main/java/com/wakeUpTogetUp/togetUp/utils/mapper/EntityDtoMapper.java b/src/main/java/com/wakeUpTogetUp/togetUp/utils/mapper/EntityDtoMapper.java index dbf3a3c9..9ea202ad 100644 --- a/src/main/java/com/wakeUpTogetUp/togetUp/utils/mapper/EntityDtoMapper.java +++ b/src/main/java/com/wakeUpTogetUp/togetUp/utils/mapper/EntityDtoMapper.java @@ -84,11 +84,14 @@ public interface EntityDtoMapper { @Mapping(target = "icon",source = "icon") @Mapping(target = "name",source = "room.name") @Mapping(target = "intro",source = "room.intro") - RoomDetailRes toRoomDetailRes(Alarm alarm); + RoomDetailRes.RoomData toRoomDetailResRoomData(Alarm alarm); + + @Mapping(target = "missionKr", source = "missionObject.kr") + RoomDetailRes.AlarmData toRoomDetailResAlarmData(Alarm alarm); @Mapping(target = "userId",source = "user.id") @Mapping(target = "userName",source = "user.name") @Mapping(target = "isHost",source = "isHost") - RoomDetailRes.UserData toUserData(RoomUser roomUser); + RoomDetailRes.UserData toRoomDetailUserData(RoomUser roomUser); @Mapping(target = "userId",source = "user.id") @Mapping(target = "userName",source = "user.name") diff --git a/src/main/resources/static/docs/index.html b/src/main/resources/static/docs/index.html index dea35472..9db230ba 100644 --- a/src/main/resources/static/docs/index.html +++ b/src/main/resources/static/docs/index.html @@ -474,32 +474,337 @@

AlarmController

알람 단일 조회

Path parameters

-
-

Snippet path-parameters not found for operation::alarm-getAlarm

-
+ + ++++++ + + + + + + + + + + + + + + + + +
Table 1. /app/alarms/{alarmId}
ParameterTypeDescriptionOptional

alarmId

int

알람 Id

false

Request parameters

-
-

Snippet request-parameters not found for operation::alarm-getAlarm

-
+ ++++++ + + + + + + + + +
ParameterTypeDescriptionOptional

HTTP request

-
-

Snippet http-request not found for operation::alarm-getAlarm

+
+
+
GET /app/alarms/42 HTTP/1.1
+Accept: application/json
+Host: togetup.shop
+

Response fields

-
-

Snippet response-fields not found for operation::alarm-getAlarm

-
+ ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PathTypeDescriptionOptional

httpStatusCode

Number

http 상태코드

false

httpReasonPhrase

String

http 상태코드 설명문구

false

message

String

설명 메시지

false

result

Object

결과

false

result.id

Number

알람 Id

false

result.userId

Number

사용자 Id

false

result.missionId

Number

미션 Id

false

result.name

String

알람 이름

false

result.icon

String

아이콘

false

result.sound

String

알람 벨소리

false

result.volume

Number

볼륨

false

result.isVibrate

Boolean

진동 여부

false

result.isRoutineOn

Boolean

루틴 활성 여부

false

result.snoozeInterval

Number

다시울림 간격(분)

false

result.snoozeCnt

Number

다시울림 횟수

false

result.startHour

Number

시작 시

false

result.startMinute

Number

시작 분

false

result.monday

Boolean

월요일 알림 여부

false

result.tuesday

Boolean

화요일 알림 여부

false

result.wednesday

Boolean

수요일 알림 여부

false

result.thursday

Boolean

목요일 알림 여부

false

result.friday

Boolean

금요일 알림 여부

false

result.saturday

Boolean

토요일 알림 여부

false

result.sunday

Boolean

일요일 알림 여부

false

result.isActivated

Boolean

알람 활성 여부

false

result.routineResList[]

Array

루틴 리스트

true

result.routineResList[].id

Number

루틴 Id

true

result.routineResList[].userId

Number

사용자 Id

true

result.routineResList[].missionId

Number

미션 Id

true

result.routineResList[].name

String

루틴 이름

true

result.routineResList[].estimatedTime

Number

예상 소요 시간

true

result.routineResList[].icon

String

아이콘

true

result.routineResList[].color

String

색상

true

HTTP response

-
-

Snippet http-response not found for operation::alarm-getAlarm

+
+
+
HTTP/1.1 200 OK
+Vary: Origin
+Vary: Access-Control-Request-Method
+Vary: Access-Control-Request-Headers
+Content-Type: application/json;charset=UTF-8
+Content-Length: 1014
+
+{
+  "httpStatusCode" : 200,
+  "httpReasonPhrase" : "OK",
+  "message" : "요청에 성공하였습니다.",
+  "result" : {
+    "id" : 42,
+    "userId" : 9,
+    "missionId" : 1,
+    "name" : "기상알람",
+    "icon" : "⏰",
+    "sound" : "default",
+    "volume" : 80,
+    "isVibrate" : true,
+    "isRoutineOn" : true,
+    "snoozeInterval" : 5,
+    "snoozeCnt" : 3,
+    "startHour" : 6,
+    "startMinute" : 0,
+    "monday" : true,
+    "tuesday" : true,
+    "wednesday" : true,
+    "thursday" : true,
+    "friday" : true,
+    "saturday" : true,
+    "sunday" : false,
+    "isActivated" : true,
+    "routineResList" : [ {
+      "id" : 5,
+      "userId" : 9,
+      "missionId" : 1,
+      "name" : "기상",
+      "estimatedTime" : 10,
+      "icon" : "⏰",
+      "color" : "#000000"
+    }, {
+      "id" : 7,
+      "userId" : 9,
+      "missionId" : 2,
+      "name" : "샤워",
+      "estimatedTime" : 15,
+      "icon" : "\uD83D\uDEBF",
+      "color" : "#000000"
+    } ]
+  }
+}
+
@@ -509,7 +814,7 @@

HTTP response