-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
✨ [FEAT] 히트맵 그래프 컨트롤러 수정 #351
- Loading branch information
Showing
5 changed files
with
88 additions
and
20 deletions.
There are no files selected for viewing
18 changes: 0 additions & 18 deletions
18
src/main/java/swm_nm/morandi/domain/member/dto/MemberRecordDto.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/swm_nm/morandi/domain/testRecord/dto/GrassHeatMapResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package swm_nm.morandi.domain.testRecord.dto; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; | ||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; | ||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.time.LocalDate; | ||
|
||
|
||
@Builder | ||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
public class GrassHeatMapResponse { | ||
|
||
@JsonSerialize(using = LocalDateSerializer.class) | ||
@JsonDeserialize(using = LocalDateDeserializer.class) | ||
public LocalDate testDate; | ||
|
||
public Long solvedCount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/swm_nm/morandi/domain/testRecord/service/GrassHeatMapService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package swm_nm.morandi.domain.testRecord.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import swm_nm.morandi.domain.testRecord.dto.GrassHeatMapResponse; | ||
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository; | ||
import swm_nm.morandi.global.utils.SecurityUtils; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class GrassHeatMapService { | ||
|
||
private final AttemptProblemRepository attemptProblemRepository; | ||
|
||
public List<GrassHeatMapResponse> getGrassHeatMap() { | ||
Long memberId = SecurityUtils.getCurrentMemberId(); | ||
LocalDateTime oneYearAgo = LocalDateTime.now().minusYears(1); | ||
List<Object[]> grassHeatMap = attemptProblemRepository.getHeatMapDataSinceOneYear(memberId, oneYearAgo); | ||
|
||
return grassHeatMap.stream().map(objects -> | ||
GrassHeatMapResponse.builder() | ||
.testDate((LocalDate) objects[0]) | ||
.solvedCount((Long) objects[1]) | ||
.build()).collect(Collectors.toList()); | ||
|
||
} | ||
} |