Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#62 [FIX] : 그룹게시판 api 수정 #63

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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