-
Notifications
You must be signed in to change notification settings - Fork 2
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 #5 from giwoong01/develop
main-raking-list 기능 추가
- Loading branch information
Showing
7 changed files
with
135 additions
and
53 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/com/itcontest/skhuming/member/api/MemberController.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,29 @@ | ||
package com.itcontest.skhuming.member.api; | ||
|
||
import com.itcontest.skhuming.member.application.MemberService; | ||
import com.itcontest.skhuming.member.domain.Member; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import java.util.List; | ||
|
||
@Controller | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
public MemberController(MemberService memberService) { | ||
this.memberService = memberService; | ||
} | ||
|
||
/** | ||
* mainPage 1~3등 랭킹 리스트 | ||
*/ | ||
@GetMapping("/api/main") | ||
public ResponseEntity<List<Member>> mainRankingList() { | ||
return new ResponseEntity<>(memberService.mainPageRanking(), HttpStatus.OK); | ||
} | ||
|
||
} |
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
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
49 changes: 49 additions & 0 deletions
49
src/test/java/com/itcontest/skhuming/member/application/MemberServiceTest.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,49 @@ | ||
package com.itcontest.skhuming.member.application; | ||
|
||
import com.itcontest.skhuming.member.domain.Member; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
class MemberServiceTest { | ||
|
||
@Autowired | ||
MemberService memberService; | ||
|
||
@DisplayName("메인페이지 1~3등 랭킹 리스트") | ||
@Test | ||
void mainPageRanking() { | ||
// 데이터 저장 | ||
Member memberA = new Member("member1", "chlrldnd","너의 집앞 골목", "최기웅", "it융합자율학부", " 202014098"); | ||
Member memberB = new Member("member2", "chlrldnd","너의 집앞 골목", "최기웅", "it융합자율학부", " 202014098"); | ||
Member memberC = new Member("member3", "chlrldnd","너의 집앞 골목", "최기웅", "it융합자율학부", " 202014098"); | ||
Member memberD = new Member("member4", "chlrldnd","너의 집앞 골목", "최기웅", "it융합자율학부", " 202014098"); | ||
Member memberE = new Member("member5", "chlrldnd","너의 집앞 골목", "최기웅", "it융합자율학부", " 202014098"); | ||
memberA.plusMyScore(10); | ||
memberB.plusMyScore(80); | ||
memberC.plusMyScore(40); | ||
memberD.plusMyScore(100); | ||
|
||
memberService.memberSave(memberA); | ||
memberService.memberSave(memberB); | ||
memberService.memberSave(memberC); | ||
memberService.memberSave(memberD); | ||
memberService.memberSave(memberE); | ||
|
||
List<Member> memberList = memberService.mainPageRanking(); | ||
|
||
for (Member member : memberList) { | ||
System.out.println("member.getMemberId() = " + member.getMemberId()); | ||
System.out.println("member.getTear() = " + member.getTear()); | ||
System.out.println("member.getNickname() = " + member.getNickname()); | ||
System.out.println("member.getScore() = " + member.getScore()); | ||
} | ||
|
||
} | ||
} |
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