Skip to content

Commit

Permalink
[CHORE] 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Jan 23, 2024
1 parent 52013ce commit cb9f465
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 39 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class ValueConfig {
private String ALARM_MESSAGE_TITLE;
@Value("${sopt.alarm.message.content_end}")
private String ALARM_MESSAGE_CONTENT;
@Value("${sopt.current.generation}")
private int GENERATION;

private final int SUB_LECTURE_MAX_ROUND = 2;
private final String ETC_MESSAGE = "출석 점수가 반영되지 않아요.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import org.sopt.makers.operation.entity.SubLecture;
import org.sopt.makers.operation.entity.lecture.Lecture;

import lombok.Builder;

@Builder
public record AttendanceResponseDTO(
Long lectureId,
Long subLectureId
) {

public static AttendanceResponseDTO of(Lecture lecture, SubLecture subLecture) {
return new AttendanceResponseDTO(lecture.getId(), subLecture.getId());
return AttendanceResponseDTO.builder()
.lectureId(lecture.getId())
.subLectureId(subLecture.getId())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@

import lombok.val;

import org.sopt.makers.operation.config.GenerationConfig;
import org.sopt.makers.operation.config.ValueConfig;
import org.sopt.makers.operation.entity.Attendance;
import org.sopt.makers.operation.entity.Member;
import org.sopt.makers.operation.entity.Part;
import org.sopt.makers.operation.entity.QMember;
import org.sopt.makers.operation.entity.SubAttendance;
import org.sopt.makers.operation.entity.lecture.LectureStatus;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
Expand All @@ -35,7 +33,7 @@
public class AttendanceRepositoryImpl implements AttendanceCustomRepository {

private final JPAQueryFactory queryFactory;
private final GenerationConfig generationConfig;
private final ValueConfig valueConfig;

@Override
public List<Attendance> findAttendanceByMemberId(Long memberId) {
Expand All @@ -46,7 +44,7 @@ public List<Attendance> findAttendanceByMemberId(Long memberId) {
.leftJoin(attendance.lecture, lecture)
.where(attendance.member.id.eq(memberId),
lecture.lectureStatus.eq(LectureStatus.END),
lecture.generation.eq(generationConfig.getCurrentGeneration())
lecture.generation.eq(valueConfig.getGENERATION())
)
.orderBy(attendance.lecture.startDate.desc())
.fetch();
Expand Down Expand Up @@ -95,7 +93,7 @@ public List<Attendance> findToday(long memberPlaygroundId) {
.leftJoin(subAttendance.subLecture, subLecture).fetchJoin()
.where(
member.playgroundId.eq(memberPlaygroundId),
member.generation.eq(generationConfig.getCurrentGeneration()),
member.generation.eq(valueConfig.getGENERATION()),
lecture.part.eq(member.part).or(lecture.part.eq(Part.ALL)),
lecture.startDate.between(startOfDay, endOfDay))
.orderBy(lecture.startDate.asc())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.sopt.makers.operation.entity.Part.*;
import static org.sopt.makers.operation.entity.alarm.Status.*;

import org.sopt.makers.operation.config.ValueConfig;
import org.sopt.makers.operation.dto.alarm.AlarmSendRequestDTO;
import org.sopt.makers.operation.dto.alarm.AlarmSenderDTO;
import org.sopt.makers.operation.dto.member.MemberSearchCondition;
Expand All @@ -15,7 +16,6 @@
import org.sopt.makers.operation.external.api.PlayGroundServer;
import org.sopt.makers.operation.repository.alarm.AlarmRepository;
import org.sopt.makers.operation.repository.member.MemberRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -34,13 +34,12 @@
@Service
@RequiredArgsConstructor
public class AlarmServiceImpl implements AlarmService {
@Value("${sopt.current.generation}")
private int currentGeneration;

private final AlarmRepository alarmRepository;
private final MemberRepository memberRepository;
private final AlarmSender alarmSender;
private final PlayGroundServer playGroundServer;
private final ValueConfig valueConfig;

@Override
@Transactional
Expand Down Expand Up @@ -68,15 +67,15 @@ private List<String> getTargetIdList(Alarm alarm) {
return activeTargetList;
}

val inactiveTargetList = getInactiveTargetList(currentGeneration, alarm.getPart());
val inactiveTargetList = getInactiveTargetList(valueConfig.getGENERATION(), alarm.getPart());
return inactiveTargetList.stream()
.filter(target -> !activeTargetList.contains(target))
.toList();
}

private List<String> getActiveTargetList(Part part) {
part = part.equals(ALL) ? null : part;
val members = memberRepository.search(new MemberSearchCondition(part, currentGeneration));
val members = memberRepository.search(new MemberSearchCondition(part, valueConfig.getGENERATION()));
return members.stream()
.filter(member -> nonNull(member.getPlaygroundId()))
.map(member -> String.valueOf(member.getPlaygroundId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import static java.util.Objects.nonNull;
import static org.sopt.makers.operation.common.ExceptionMessage.*;

import java.util.List;

import org.sopt.makers.operation.config.ValueConfig;
import org.sopt.makers.operation.dto.attendance.AttendanceMemberResponseDTO;
import org.sopt.makers.operation.dto.attendance.SubAttendanceUpdateRequestDTO;
import org.sopt.makers.operation.dto.attendance.SubAttendanceUpdateResponseDTO;
import org.sopt.makers.operation.dto.attendance.MemberResponseDTO;
import lombok.val;
import org.sopt.makers.operation.dto.attendance.*;
import org.sopt.makers.operation.entity.AttendanceStatus;
Expand All @@ -22,7 +20,6 @@
import org.sopt.makers.operation.exception.SubLectureException;
import org.sopt.makers.operation.repository.lecture.SubLectureRepository;
import org.sopt.makers.operation.repository.member.MemberRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -42,9 +39,7 @@ public class AttendanceServiceImpl implements AttendanceService {
private final MemberRepository memberRepository;
private final SubLectureRepository subLectureRepository;
private final AttendanceRepository attendanceRepository;

@Value("${sopt.current.generation}")
private int currentGeneration;
private final ValueConfig valueConfig;

@Override
@Transactional
Expand Down Expand Up @@ -81,7 +76,7 @@ public AttendancesResponseDTO findAttendancesByLecture(Long lectureId, Part part
@Transactional
public AttendResponseDTO attend(Long playGroundId, AttendRequestDTO requestDTO) {
log.info("[Attendance: attend start] id: " + playGroundId);
val member = memberRepository.getMemberByPlaygroundIdAndGeneration(playGroundId, currentGeneration)
val member = memberRepository.getMemberByPlaygroundIdAndGeneration(playGroundId, valueConfig.getGENERATION())
.orElseThrow(() -> new MemberException(INVALID_MEMBER.getName()));

val memberId = member.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.RequiredArgsConstructor;
import lombok.val;

import org.sopt.makers.operation.config.ValueConfig;
import org.sopt.makers.operation.dto.attendance.AttendanceTotalCountVO;
import org.sopt.makers.operation.dto.attendance.AttendanceTotalResponseDTO;
import org.sopt.makers.operation.dto.attendance.AttendanceTotalVO;
Expand All @@ -20,7 +21,6 @@
import org.sopt.makers.operation.exception.MemberException;
import org.sopt.makers.operation.repository.attendance.AttendanceRepository;
import org.sopt.makers.operation.repository.member.MemberRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

Expand All @@ -34,9 +34,7 @@
public class MemberServiceImpl implements MemberService {
private final MemberRepository memberRepository;
private final AttendanceRepository attendanceRepository;

@Value("${sopt.current.generation}")
private int currentGeneration;
private final ValueConfig valueConfig;

@Override
public MembersResponseDTO getMemberList(Part part, int generation, Pageable pageable) {
Expand All @@ -58,7 +56,7 @@ public MembersResponseDTO getMemberList(Part part, int generation, Pageable page

@Override
public AttendanceTotalResponseDTO getMemberTotalAttendance(Long playGroundId) {
val member = memberRepository.getMemberByPlaygroundIdAndGeneration(playGroundId, currentGeneration)
val member = memberRepository.getMemberByPlaygroundIdAndGeneration(playGroundId, valueConfig.getGENERATION())
.orElseThrow(() -> new MemberException(INVALID_MEMBER.getName()));

val attendances = findAttendances(member);
Expand All @@ -72,7 +70,7 @@ public AttendanceTotalResponseDTO getMemberTotalAttendance(Long playGroundId) {

@Override
public MemberScoreGetResponse getMemberScore(Long playGroundId) {
val member = memberRepository.getMemberByPlaygroundIdAndGeneration(playGroundId, currentGeneration)
val member = memberRepository.getMemberByPlaygroundIdAndGeneration(playGroundId, valueConfig.getGENERATION())
.orElseThrow(() -> new MemberException(INVALID_MEMBER.getName()));

return MemberScoreGetResponse.of(member.getScore());
Expand Down

0 comments on commit cb9f465

Please sign in to comment.