Skip to content

Commit

Permalink
Merge pull request #190 from a-romantic-cat/feat/27
Browse files Browse the repository at this point in the history
feat: 매일 자정 초기화 메서드 삭제
  • Loading branch information
Yoon-Jemin authored Feb 20, 2024
2 parents 95313e3 + 87f792c commit 1b58871
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import aromanticcat.umcproject.entity.Member;
import aromanticcat.umcproject.security.SecurityUserDto;
import aromanticcat.umcproject.web.dto.Member.MemberRequestDTO;
import aromanticcat.umcproject.web.dto.Member.MemberResponseDTO;

import java.util.List;
import java.util.Optional;

public interface MemberService {
Expand All @@ -21,4 +23,6 @@ public interface MemberService {
Member updateNickname(String nickname);

Member findByMemberId(Long memberId);

List<MemberResponseDTO.MemberInfoDTO> findMemberList(String userEmail);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
import aromanticcat.umcproject.security.Role;
import aromanticcat.umcproject.security.SecurityUserDto;
import aromanticcat.umcproject.security.jwt.JwtAuthFilter;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.transaction.Transactional;

import aromanticcat.umcproject.web.dto.Member.MemberResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -84,4 +89,5 @@ public Member findByMemberId(Long memberId) {
Member member = repository.findById(memberId).orElse(null);
return member;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ public void stepCompleted(String userEmail, Long missionId) { // 미션 안
}
}

@Override
@Transactional
@Scheduled(cron = "0 0 0 * * *") // 매일 자정에 실행되도록 설정
public void resetDailyMissions() {

List<MemberMission> memberMissions = memberMissionRepository.findAll();

for (MemberMission memberMission : memberMissions) {
Mission mission = memberMission.getMission();
if (mission.isEveryday()) {
memberMission.resetStep();
memberMission.setMissionStatus(MissionStatus.NOT_STARTED);
// MemberMission 엔티티를 저장하여 변경 사항을 데이터베이스에 반영
memberMissionRepository.save(memberMission);
}
}
}
// @Override
// @Transactional
// @Scheduled(cron = "0 0 0 * * *") // 매일 자정에 실행되도록 설정
// public void resetDailyMissions() {
//
// List<MemberMission> memberMissions = memberMissionRepository.findAll();
//
// for (MemberMission memberMission : memberMissions) {
// Mission mission = memberMission.getMission();
// if (mission.isEveryday()) {
// memberMission.resetStep();
// memberMission.setMissionStatus(MissionStatus.NOT_STARTED);
// // MemberMission 엔티티를 저장하여 변경 사항을 데이터베이스에 반영
// memberMissionRepository.save(memberMission);
// }
// }
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import aromanticcat.umcproject.web.dto.Friend.FriendResponseDTO;
import aromanticcat.umcproject.web.dto.Friend.FriendResponseDTO.WaitingFriendDTO;
import aromanticcat.umcproject.web.dto.Member.MemberRequestDTO;
import aromanticcat.umcproject.web.dto.Member.MemberResponseDTO;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package aromanticcat.umcproject.web.dto.Member;

import aromanticcat.umcproject.entity.FriendStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -25,4 +26,14 @@ public static class MemberJoinResultDTO {
public static class MemberNicknameDTO {
String nickname;
}

@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class MemberInfoDTO{

String Name; // 멤버 닉네임
Long MemberId; // 멤버 우편함 번호 (고유 번호)
}
}

0 comments on commit 1b58871

Please sign in to comment.