-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from TeamPINGLE/develop
Deploy
- Loading branch information
Showing
31 changed files
with
449 additions
and
176 deletions.
There are no files selected for viewing
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
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
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
32 changes: 32 additions & 0 deletions
32
src/main/java/org/pingle/pingleserver/controller/TestController.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,32 @@ | ||
package org.pingle.pingleserver.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.pingle.pingleserver.domain.enums.URole; | ||
import org.pingle.pingleserver.repository.UserRepository; | ||
import org.pingle.pingleserver.utils.JwtUtil; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@Profile({"local", "dev"}) | ||
@RequestMapping("/test") | ||
@RequiredArgsConstructor | ||
public class TestController { | ||
private final JwtUtil jwtUtil; | ||
private final UserRepository userRepository; | ||
|
||
@Value("${token-test.key}") | ||
private String key; | ||
|
||
@GetMapping("/token/{userId}") | ||
public ResponseEntity<?> getToken(@PathVariable("userId") Long userId, | ||
@RequestHeader(value = "Test-Key", required = false) String testKey){ | ||
if (!key.isBlank() && !key.equals(testKey)) { | ||
return ResponseEntity.badRequest().body("Invalid test key"); | ||
} | ||
userRepository.findByIdOrThrow(userId); | ||
return ResponseEntity.ok(jwtUtil.generateTokens(userId, URole.USER)); | ||
} | ||
} |
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
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/org/pingle/pingleserver/domain/enums/SearchOrder.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,11 @@ | ||
package org.pingle.pingleserver.domain.enums; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum SearchOrder { | ||
NEW("new"), UPCOMING("upcoming"); | ||
private final String value; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/org/pingle/pingleserver/dto/reponse/KeywordResponse.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,15 @@ | ||
package org.pingle.pingleserver.dto.reponse; | ||
|
||
import lombok.Builder; | ||
import org.pingle.pingleserver.domain.enums.TKeyword; | ||
|
||
@Builder | ||
public record KeywordResponse (String name, String value){ | ||
|
||
public static KeywordResponse of(TKeyword keyword){ | ||
return KeywordResponse.builder() | ||
.name(keyword.toString()) | ||
.value(keyword.getValue()) | ||
.build(); | ||
} | ||
} |
41 changes: 1 addition & 40 deletions
41
src/main/java/org/pingle/pingleserver/dto/reponse/PinResponse.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 |
---|---|---|
@@ -1,45 +1,6 @@ | ||
package org.pingle.pingleserver.dto.reponse; | ||
|
||
import org.pingle.pingleserver.domain.Meeting; | ||
import org.pingle.pingleserver.domain.Pin; | ||
import org.pingle.pingleserver.domain.enums.MCategory; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
public record PinResponse(Long id, Double x, Double y, MCategory category, int meetingCount) { | ||
public static PinResponse of(Pin pin, MCategory category, int count) { | ||
return new PinResponse(pin.getId(),pin.getPoint().getX(), pin.getPoint().getY(), | ||
category, count); | ||
} | ||
public static PinResponse ofWithNoFilter(Pin pin) { | ||
return new PinResponse(pin.getId(),pin.getPoint().getX(), pin.getPoint().getY(), | ||
getMostRecentMeetingCategoryOfPin(pin), getMeetingCount(pin)); | ||
} | ||
public static PinResponse ofWithFilter(Pin pin, MCategory mCategory) { | ||
return new PinResponse(pin.getId(),pin.getPoint().getX(), pin.getPoint().getY(), | ||
mCategory, getMeetingCountWithFilter(pin, mCategory)); | ||
|
||
} | ||
private static MCategory getMostRecentMeetingCategoryOfPin (Pin pin) { | ||
Comparator<Meeting> comparator = Comparator.comparing(Meeting::getStartAt); | ||
List<Meeting> meetingList = pin.getMeetingList(); | ||
meetingList.sort(comparator); | ||
return meetingList.get(0).getCategory(); | ||
} | ||
|
||
private static int getMeetingCount(Pin pin) { | ||
return pin.getMeetingList().size(); | ||
} | ||
private static int getMeetingCountWithFilter(Pin pin, MCategory category) { | ||
int count = 0; | ||
List<Meeting> meetings = pin.getMeetingList(); | ||
for(Meeting meeting : meetings) { | ||
if(meeting.getCategory().getValue().equals(category.getValue())) | ||
count++; | ||
} | ||
|
||
return count; | ||
} | ||
|
||
public record PinResponse(Long id, Double x, Double y, MCategory category) { | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/pingle/pingleserver/dto/reponse/TeamCreationResponse.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,16 @@ | ||
package org.pingle.pingleserver.dto.reponse; | ||
|
||
import org.pingle.pingleserver.domain.Team; | ||
import org.pingle.pingleserver.domain.enums.TKeyword; | ||
|
||
public record TeamCreationResponse ( | ||
Long id, | ||
String name, | ||
String email, | ||
String code, | ||
TKeyword keyword | ||
) { | ||
public static TeamCreationResponse of(Team team) { | ||
return new TeamCreationResponse(team.getId(), team.getName(), team.getEmail(), team.getCode(), team.getKeyword()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/org/pingle/pingleserver/dto/reponse/TeamNameDuplicatedResponse.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,4 @@ | ||
package org.pingle.pingleserver.dto.reponse; | ||
|
||
public record TeamNameDuplicatedResponse (boolean result){ | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/org/pingle/pingleserver/dto/request/TeamCreationRequest.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,10 @@ | ||
package org.pingle.pingleserver.dto.request; | ||
|
||
import org.pingle.pingleserver.domain.enums.TKeyword; | ||
|
||
public record TeamCreationRequest ( | ||
String name, | ||
String email, | ||
TKeyword keyword | ||
) { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/pingle/pingleserver/dto/response/MyTeamResponse.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,17 @@ | ||
package org.pingle.pingleserver.dto.response; | ||
|
||
import org.pingle.pingleserver.domain.Team; | ||
|
||
public record MyTeamResponse ( | ||
Long id, String keyword, String name, Long meetingCount, Long participantCount, boolean isOwner, String code) { | ||
public static MyTeamResponse of(Team team, Long meetingCount, Long participantCount, boolean isOwner) { | ||
return new MyTeamResponse( | ||
team.getId(), | ||
team.getKeyword().getValue(), | ||
team.getName(), | ||
meetingCount, | ||
participantCount, | ||
isOwner, | ||
team.getCode()); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/org/pingle/pingleserver/dto/response/RankingIndividualResponse.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,6 @@ | ||
package org.pingle.pingleserver.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record RankingIndividualResponse (String name, LocalDateTime latestVisitedDate, Long locationCount) { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/pingle/pingleserver/dto/response/RankingResponse.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,17 @@ | ||
package org.pingle.pingleserver.dto.response; | ||
|
||
import java.util.List; | ||
|
||
public record RankingResponse (int meetingCount, List<RankingIndividualResponse> locations) { | ||
public static RankingResponse of (List<RankingIndividualResponse> responses) { | ||
return new RankingResponse(getSumOfMeetings(responses), responses); | ||
} | ||
|
||
private static int getSumOfMeetings (List<RankingIndividualResponse> responses) { | ||
int sum = 0; | ||
for (RankingIndividualResponse response : responses) { | ||
sum += response.locationCount(); | ||
} | ||
return sum; | ||
} | ||
} |
Oops, something went wrong.