-
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.
- Loading branch information
Showing
6 changed files
with
74 additions
and
11 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
26 changes: 26 additions & 0 deletions
26
src/main/java/KNU/Navibook/server/controller/RecordController.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,14 +1,40 @@ | ||
package KNU.Navibook.server.controller; | ||
|
||
import KNU.Navibook.server.domain.Record; | ||
import KNU.Navibook.server.domain.User; | ||
import KNU.Navibook.server.service.RecordService; | ||
import KNU.Navibook.server.service.UserService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.*; | ||
|
||
@Controller | ||
public class RecordController { | ||
@Autowired | ||
RecordService recordService; | ||
@Autowired | ||
UserService userService; | ||
|
||
@GetMapping("/api/record/user/{userId}") | ||
@ResponseBody | ||
public List<Record> userRecord(@PathVariable("userId") String userId, | ||
@RequestParam("page") Integer page)//, @RequestParam("orederBy") String orderBy) | ||
{ | ||
User user = userService.findOne(userId); | ||
List<Record> records = recordService.findRecordByUser(user); | ||
List<Record> pageRecords = new ArrayList<>(); | ||
|
||
// Comparator<Record> cp = Comparator.comparing(Record::getGiveDate); | ||
// Collections.sort(records, cp); | ||
|
||
for(int i = (page*10)-10; records != null && records.size() >= i && i <= page*10; i++){ | ||
pageRecords.add(records.get(i)); | ||
} | ||
|
||
return pageRecords; | ||
} | ||
|
||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
spring.datasource.driverClassName=org.mariadb.jdbc.Driver | ||
spring.datasource.url=jdbc:mariadb://navi.cibnganlxeh6.ap-northeast-2.rds.amazonaws.com:3306/navi | ||
#spring.datasource.url=jdbc:mariadb://navi.cibnganlxeh6.ap-northeast-2.rds.amazonaws.com:3306/navi | ||
spring.datasource.username=root | ||
spring.datasource.password=navi1234 | ||
#spring.datasource.password=navi1234 | ||
spring.mvc.hiddenmethod.filter.enabled=true | ||
|
||
spring.jpa.hibernate.ddl-auto = update | ||
spring.jpa.hibernate.ddl-auto = create | ||
|
||
#spring.datasource.url=jdbc:mariadb://localhost:3306/navi | ||
#spring.datasource.password=root | ||
spring.datasource.url=jdbc:mariadb://localhost:3306/navi | ||
spring.datasource.password=root |
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