Skip to content

Commit

Permalink
Merge pull request #207 from IT-Cotato/develop
Browse files Browse the repository at this point in the history
[Release] V2.2024.11.19.01
  • Loading branch information
Youthhing authored Nov 19, 2024
2 parents 0210fa6 + b63ece4 commit 2eedb1d
Show file tree
Hide file tree
Showing 22 changed files with 145 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.cotato.csquiz.api.attendance.dto.MemberAttendanceRecordsResponse;
import org.cotato.csquiz.api.attendance.dto.OfflineAttendanceRequest;
import org.cotato.csquiz.api.attendance.dto.OnlineAttendanceRequest;
import org.cotato.csquiz.api.attendance.dto.AttendanceRecordResponse;
import org.cotato.csquiz.api.attendance.dto.UpdateAttendanceRecordRequest;
import org.cotato.csquiz.api.attendance.dto.UpdateAttendanceRequest;
import org.cotato.csquiz.domain.attendance.service.AttendanceAdminService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,14 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalTime;
import java.util.Objects;
import lombok.Builder;
import org.cotato.csquiz.domain.attendance.enums.DeadLine;
import java.time.LocalDateTime;

public record AttendanceDeadLineDto(
@Schema(example = "19:05:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss")
LocalTime attendanceDeadLine,
@Schema(example = "19:20:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss")
LocalTime lateDeadLine
@Schema(example = "2024-11-11T119:05:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
LocalDateTime attendanceDeadLine,
@Schema(example = "2024-11-11T19:20:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
LocalDateTime lateDeadLine
) {

@Builder
public AttendanceDeadLineDto {
if (Objects.isNull(attendanceDeadLine)) {
attendanceDeadLine = DeadLine.DEFAULT_ATTENDANCE_DEADLINE.getTime();
}
if (Objects.isNull(lateDeadLine)) {
lateDeadLine = DeadLine.DEFAULT_LATE_DEADLINE.getTime();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.cotato.csquiz.api.attendance.dto;

import org.cotato.csquiz.domain.attendance.enums.AttendanceRecordResult;
import org.cotato.csquiz.domain.attendance.enums.AttendanceResult;
import org.cotato.csquiz.domain.auth.entity.Member;

public record AttendanceRecordResponse(
AttendanceMemberInfo memberInfo,
AttendanceRecordResult result
AttendanceResult result
) {
public static AttendanceRecordResponse of(Member member, AttendanceRecordResult result) {
public static AttendanceRecordResponse of(Member member, AttendanceResult result) {
return new AttendanceRecordResponse(
AttendanceMemberInfo.from(member),
result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,28 @@
import java.util.stream.Collectors;
import org.cotato.csquiz.domain.attendance.entity.AttendanceRecord;
import org.cotato.csquiz.domain.attendance.enums.AttendanceResult;
import org.cotato.csquiz.domain.attendance.enums.AttendanceType;

public record AttendanceStatistic(
Integer online,
Integer offline,
Integer late,
Integer absent
long online,
long offline,
long late,
long absent
) {
public static AttendanceStatistic of(List<AttendanceRecord> attendanceRecords, Integer totalAttendance) {
Map<AttendanceResult, List<AttendanceRecord>> countByStatus = attendanceRecords.stream()
.collect(Collectors.groupingBy(AttendanceRecord::getAttendanceResult));
List<AttendanceRecord> presentRecords = countByStatus.getOrDefault(AttendanceResult.PRESENT, List.of());
private static final Long ZERO_VALUE = 0L;

int onlineCount = (int) presentRecords.stream()
.filter(record -> AttendanceType.ONLINE == record.getAttendanceType())
.count();
int offLineCount = (int) presentRecords.stream()
.filter(record -> AttendanceType.OFFLINE == record.getAttendanceType())
.count();
public static AttendanceStatistic of(List<AttendanceRecord> attendanceRecords, Integer totalAttendanceCount) {
Map<AttendanceResult, Long> attendanceRecordsByResult = attendanceRecords.stream()
.collect(Collectors.groupingBy(AttendanceRecord::getAttendanceResult, Collectors.counting()));

return new AttendanceStatistic(
onlineCount,
offLineCount,
countByStatus.getOrDefault(AttendanceResult.LATE, List.of()).size(),
totalAttendance - filterNotAbsentRecord(attendanceRecords).size()
attendanceRecordsByResult.getOrDefault(AttendanceResult.ONLINE, ZERO_VALUE),
attendanceRecordsByResult.getOrDefault(AttendanceResult.OFFLINE, ZERO_VALUE),
attendanceRecordsByResult.getOrDefault(AttendanceResult.LATE, ZERO_VALUE),
totalAttendanceCount - countNotAbsents(attendanceRecords).size()
);
}

private static List<AttendanceRecord> filterNotAbsentRecord(List<AttendanceRecord> attendanceRecords) {
private static List<AttendanceRecord> countNotAbsents(List<AttendanceRecord> attendanceRecords) {
return attendanceRecords.stream()
.filter(AttendanceRecord::isAttendanceResultNotAbsent)
.toList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package org.cotato.csquiz.api.attendance.dto;

import java.time.LocalTime;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import org.cotato.csquiz.domain.attendance.embedded.Location;
import org.cotato.csquiz.domain.attendance.entity.Attendance;

public record AttendanceTimeResponse(
Long sessionId,
LocalTime attendanceDeadLine,
LocalTime lateDeadLine,
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
LocalDateTime attendanceDeadLine,
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
LocalDateTime lateDeadLine,
Location location
) {

public static AttendanceTimeResponse from(Attendance attendance) {
return new AttendanceTimeResponse(
attendance.getSessionId(),
attendance.getAttendanceDeadLine().toLocalTime(),
attendance.getLateDeadLine().toLocalTime(),
attendance.getAttendanceDeadLine(),
attendance.getLateDeadLine(),
attendance.getLocation()
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.cotato.csquiz.api.attendance.dto;

import org.cotato.csquiz.domain.attendance.enums.AttendanceRecordResult;
import org.cotato.csquiz.domain.attendance.enums.AttendanceResult;

public record UpdateAttendanceRecordRequest(
Long memberId,
AttendanceRecordResult attendanceResult
AttendanceResult attendanceResult
) {
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
package org.cotato.csquiz.api.attendance.dto;

import static org.cotato.csquiz.domain.attendance.enums.DeadLine.DEFAULT_ATTENDANCE_DEADLINE;
import static org.cotato.csquiz.domain.attendance.enums.DeadLine.DEFAULT_LATE_DEADLINE;

import jakarta.validation.constraints.NotNull;
import java.util.Objects;
import org.cotato.csquiz.domain.attendance.embedded.Location;

public record UpdateAttendanceRequest(
@NotNull
Long attendanceId,
Location location,
@NotNull
AttendanceDeadLineDto attendTime
) {

public UpdateAttendanceRequest {
if (Objects.isNull(attendTime)) {
attendTime = new AttendanceDeadLineDto(DEFAULT_ATTENDANCE_DEADLINE.getTime(),
DEFAULT_LATE_DEADLINE.getTime());
}
}

public static UpdateAttendanceRequest of(Long attendanceId, Location location, AttendanceDeadLineDto attendTime) {
return new UpdateAttendanceRequest(attendanceId, location, attendTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import org.cotato.csquiz.domain.generation.enums.CSEducation;
import org.cotato.csquiz.domain.generation.enums.DevTalk;
Expand All @@ -27,13 +26,13 @@ public record AddSessionRequest(
@NotNull
LocalDateTime sessionDateTime,

@Schema(example = "19:10:00", description = "출석 마감 시간, 해당 시간 이후 지각 처리")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss")
LocalTime attendanceDeadLine,
@Schema(example = "2024-11-11T19:10:00", description = "출석 마감 시간, 해당 시간 이후 지각 처리")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
LocalDateTime attendanceDeadLine,

@Schema(example = "19:20:00", description = "지각 마감 시간, 해당 시간 이후 결석 처리")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss")
LocalTime lateDeadLine,
@Schema(example = "2024-11-11T19:20:00", description = "지각 마감 시간, 해당 시간 이후 결석 처리")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
LocalDateTime lateDeadLine,

ItIssue itIssue,
Networking networking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public record UpdateSessionRequest(
) {
public UpdateSessionRequest {
if (Objects.isNull(attendTime)) {
attendTime = new AttendanceDeadLineDto(DEFAULT_ATTENDANCE_DEADLINE.getTime(),
DEFAULT_LATE_DEADLINE.getTime());
attendTime = new AttendanceDeadLineDto(
LocalDateTime.of(sessionDateTime.toLocalDate(), DEFAULT_ATTENDANCE_DEADLINE.getTime()),
LocalDateTime.of(sessionDateTime.toLocalDate(), DEFAULT_LATE_DEADLINE.getTime())
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public enum ErrorCode {
INVALID_ATTEND_TIME(HttpStatus.BAD_REQUEST, "AT-102", "시간 입력 범위가 잘못되었습니다."),
ALREADY_ATTEND(HttpStatus.CONFLICT, "AT-301", "이미 해당 타입으로 출석한 기록이 있습니다."),
ATTENDANCE_NOT_OPEN(HttpStatus.BAD_REQUEST, "AT-401", "출석 시간이 아닙니다."),
ATTENDANCE_PERMISSION(HttpStatus.BAD_REQUEST, "AT-402", "해당 기수의 부원이 아닙니다."),

//프로젝트 관련
LOGO_IMAGE_EXIST(HttpStatus.CONFLICT, "PJ-301", "이미 로고 이미지가 존재합니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.cotato.csquiz.common.entity.BaseTimeEntity;
import org.cotato.csquiz.domain.attendance.enums.AttendanceRecordResult;
import org.cotato.csquiz.domain.attendance.enums.AttendanceResult;
import org.cotato.csquiz.domain.attendance.enums.AttendanceType;

Expand Down Expand Up @@ -89,7 +88,7 @@ public static AttendanceRecord offlineRecord(Attendance attendance, Long memberI

public static AttendanceRecord absentRecord(Attendance attendance, Long memberId) {
return new AttendanceRecord(
AttendanceType.ABSENT,
AttendanceType.NO_ATTEND,
AttendanceResult.ABSENT,
null,
memberId,
Expand All @@ -110,26 +109,7 @@ public void updateAttendanceResult(AttendanceResult attendanceResult) {
this.attendanceResult = attendanceResult;
}

public void updateByAttendanceRecordResult(AttendanceRecordResult result) {
switch (result) {
case ONLINE:
updateAttendanceType(AttendanceType.ONLINE);
updateAttendanceResult(AttendanceResult.PRESENT);
break;
case OFFLINE:
updateAttendanceType(AttendanceType.OFFLINE);
updateAttendanceResult(AttendanceResult.PRESENT);
break;
case ABSENT:
updateAttendanceType(AttendanceType.ABSENT);
updateAttendanceResult(AttendanceResult.ABSENT);
break;
case LATE:
updateAttendanceResult(AttendanceResult.LATE);
}
}

public boolean isAttendanceResultNotAbsent() {
return attendanceResult != AttendanceResult.ABSENT;
return !attendanceResult.isPresented();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
@Getter
@AllArgsConstructor
public enum AttendanceResult {
PRESENT("출석", "출석에 성공하셨습니다."),
LATE("지각", "기준 시간을 지나 지각 처리 되었습니다."),
ABSENT("결석", "지각 마감 시간을 지나 결석 처리 되었습니다.")
PRESENT("출석", "출석", true), // Todo https://youthing.atlassian.net/jira/software/projects/COT/boards/2?selectedIssue=COT-64&sprints=3
ONLINE("대면 출석", "대면으로 출석했습니다.", true),
OFFLINE("비대면 출석", "비대면으로 출석했습니다.", true),
LATE("지각", "기준 시간을 지나 지각 처리 되었습니다.", false),
ABSENT("결석", "지각 마감 시간을 지나 결석 처리 되었습니다.", false)
;

private final String description;
private final String message;
private final boolean isPresented;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum AttendanceType {

OFFLINE("대면 출석"),
ONLINE("비대면 출석"),
ABSENT("출결 미 입력")
NO_ATTEND("출결 미 입력")
;

private final String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public interface AttendanceRecordRepository extends JpaRepository<AttendanceReco
List<AttendanceRecord> findAllByAttendanceIdsInQueryAndMemberId(@Param("attendanceIds") List<Long> attendanceIds, @Param("memberId") Long memberId);

List<AttendanceRecord> findAllByAttendanceId(Long attendanceId);

List<AttendanceRecord> findAllByAttendanceIdAndMemberIdIn(Long id, List<Long> memberIds);
}
Loading

0 comments on commit 2eedb1d

Please sign in to comment.