Skip to content

Commit

Permalink
#62 [MERGE] : 그룹게시판 api 수정 (#63)
Browse files Browse the repository at this point in the history
## 작업
 - isAlarmActive(알람이 울리는 날 여부)를 클라이언트에서 받지 않고 서버에서 가져와서 response 반환하게 수정
  • Loading branch information
05AM authored Oct 19, 2023
2 parents 40c0be7 + 3e7ca87 commit af51427
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import com.wakeUpTogetUp.togetUp.api.users.model.User;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import java.time.DayOfWeek;

import javax.persistence.*;
import java.sql.Time;



@ToString
@Entity
@Table(name = "alarm")
Expand Down Expand Up @@ -140,4 +143,24 @@ public void modifyProperties(String name, String icon,
setMission(mission);
setMissionObject(missionObject);
}
public boolean getDayOfWeekValue(DayOfWeek dayOfWeek) {
switch (dayOfWeek) {
case MONDAY:
return getMonday();
case TUESDAY:
return getTuesday();
case WEDNESDAY:
return getWednesday();
case THURSDAY:
return getThursday();
case FRIDAY:
return getFriday();
case SATURDAY:
return getSaturday();
case SUNDAY:
return getSunday();
default:
throw new IllegalArgumentException("Invalid day of the week");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,9 @@
public enum AvatarTheme {
NOOB_CHICK("신입 병아리"),
TWINKLING_TEDDY_BEAR("눈을 반짝이는 곰돌이"),
CUTE_BUNNY("깜찍한 토끼")
;
CUTE_BUNNY("깜찍한 토끼");

private final String value;

private static final Map<String, AvatarTheme> valueToEnum = new HashMap<>();

// 열거형 상수 생성 시에 value를 영어로 매핑
static {
for (AvatarTheme theme : AvatarTheme.values()) {
valueToEnum.put(theme.value, theme);
}
}

public String getValue() {
return value;
}

// 한글 값을 받아서 해당 열거형 상수의 이름(영어)을 반환
public static AvatarTheme fromValue(String value) {
return valueToEnum.get(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ public BaseResponse<List<RoomRes>> getList(@Parameter(hidden = true) @AuthUser I
@GetMapping("/user/mission-log")
public BaseResponse<RoomUserMissionLogRes> getRoomLogDetailByDate(@Parameter(hidden = true) @AuthUser Integer userId,
@Parameter(description = "룸 아이디",example = "1") Integer roomId,
@Parameter(description = "기록을 가져올 날의 LocalDateTime String 값" , example = "2023-09-20 11:55:38") String localDateTime,
@Parameter(description = "알람이 울리는 날인지 여부",example = "true") Boolean isAlarmActive
@Parameter(description = "기록을 가져올 날의 LocalDateTime String 값" , example = "2023-09-20 11:55:38") String localDateTime
) {


return new BaseResponse(Status.SUCCESS,roomService.getRoomUserLogList(userId,roomId,localDateTime,isAlarmActive));
return new BaseResponse(Status.SUCCESS,roomService.getRoomUserLogList(userId,roomId,localDateTime));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<RoomRes> getRoomList(Integer userId) {
}


public RoomUserMissionLogRes getRoomUserLogList(Integer userId,Integer roomId,String localDateTimeString ,Boolean isAlarmActive){
public RoomUserMissionLogRes getRoomUserLogList(Integer userId,Integer roomId,String localDateTimeString ){

LocalDateTime localDateTime = timeFormatter.stringToLocalDateTime(localDateTimeString);
List<RoomUser> roomUserList = roomUserRepository.findAllByRoom_Id(roomId);
Expand All @@ -105,11 +105,13 @@ public RoomUserMissionLogRes getRoomUserLogList(Integer userId,Integer roomId,St
roomUserMissionLogRes.setUserLogList(EntityDtoMapper.INSTANCE.toUserLogDataList(roomUserList));

//isMyLog, missionPicLink, userCompleteType 는 각케이스에 맞게 설정
return setUserLogData(roomUserMissionLogRes, userId, roomId, isAlarmActive, localDateTime);
return setUserLogData(roomUserMissionLogRes, userId, roomId, localDateTime);

}

public RoomUserMissionLogRes setUserLogData(RoomUserMissionLogRes roomUserMissionLogRes, Integer userId, Integer roomId, boolean isAlarmActive, LocalDateTime localDateTime){
public RoomUserMissionLogRes setUserLogData(RoomUserMissionLogRes roomUserMissionLogRes, Integer userId, Integer roomId, LocalDateTime localDateTime){

boolean isAlarmActive = alarmRepository.findFirstByRoom_Id(roomId).getDayOfWeekValue(localDateTime.getDayOfWeek());
if(!isAlarmActive)
{
for (RoomUserMissionLogRes.UserLogData userLogData : roomUserMissionLogRes.getUserLogList()) {
Expand Down

0 comments on commit af51427

Please sign in to comment.