Skip to content

Commit

Permalink
Merge pull request #449 from mash-up-kr/feature/mashong-read-attendance
Browse files Browse the repository at this point in the history
매숑이 출석 현황 확인 API 구현
  • Loading branch information
eunjungL authored Jul 9, 2024
2 parents d430d55 + b77c185 commit 8ff18e0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import kr.mashup.branding.service.mashong.MashongMissionTeamLogService;
import kr.mashup.branding.service.mashong.dto.MissionStatus;
import kr.mashup.branding.service.member.MemberService;
import kr.mashup.branding.ui.mashong.response.MashongAttendanceResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -109,4 +110,15 @@ private MissionStatus missionStatus(Platform platform, Long generationId, Mashon
MashongMissionTeamLog mashongMissionLog = mashongMissionTeamLogService.getMissionLog(latestMissionLevel, platform, generationId);
return MissionStatus.of(mashongMission, latestMissionLevel, mashongMissionLog);
}

public MashongAttendanceResponse readMashongAttendanceStatus(Long memberGenerationId) {
MashongMission mission = mashongMissionService.findMissionByStrategyType(
MissionStrategyType.MASHONG_ATTENDANCE_INDIVIDUAL
);

return mashongMissionLogService.getLastAchievedMissionLog(mission, memberGenerationId)
.map(mashongMissionLog -> new MashongAttendanceResponse(mashongMissionLog.getCurrentStatus()))
.orElseGet(() -> new MashongAttendanceResponse(0));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import kr.mashup.branding.security.MemberAuth;
import kr.mashup.branding.service.mashong.dto.MissionStatus;
import kr.mashup.branding.ui.ApiResponse;
import kr.mashup.branding.ui.mashong.response.MashongAttendanceResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
Expand All @@ -20,22 +20,31 @@
@RequestMapping("api/v1/mashong-mission")
@RequiredArgsConstructor
public class MashongMissionController {

private final MashongMissionFacadeService mashongMissionFacadeService;

@ApiOperation(
value = "매숑이 미션들 상태",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_NOT_FOUND</br>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"</p>"
value = "매숑이 미션들 상태",
notes =
"<h2>Error Code</h2>" +
"<p>" +
"MEMBER_NOT_FOUND</br>" +
"MEMBER_GENERATION_NOT_FOUND</br>" +
"</p>"

)
@GetMapping("/status")
public ApiResponse<List<MissionStatus>> missionStatusList(
@ApiIgnore MemberAuth memberAuth
@ApiIgnore MemberAuth memberAuth
) {
return ApiResponse.success(mashongMissionFacadeService.missionStatusList(memberAuth.getMemberGenerationId()));
}

@ApiOperation(value = "매숑이 출석 현황")
@GetMapping("/attendances")
public ApiResponse<MashongAttendanceResponse> readMashongAttendance(
@ApiIgnore MemberAuth memberAuth
) {
return ApiResponse.success(mashongMissionFacadeService.readMashongAttendanceStatus(memberAuth.getMemberGenerationId()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package kr.mashup.branding.ui.mashong.response;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class MashongAttendanceResponse {

private final int attendanceCount;

public MashongAttendanceResponse(Double missionStatus) {
this.attendanceCount = missionStatus.intValue();
}
}

0 comments on commit 8ff18e0

Please sign in to comment.