diff --git a/board_exam_project-master/.gradle/7.1.1/fileHashes/resourceHashesCache.bin b/board_exam_project-master/.gradle/7.1.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..009c912 Binary files /dev/null and b/board_exam_project-master/.gradle/7.1.1/fileHashes/resourceHashesCache.bin differ diff --git a/board_exam_project-master/.gradle/buildOutputCleanup/outputFiles.bin b/board_exam_project-master/.gradle/buildOutputCleanup/outputFiles.bin index 04fc1a2..aa97df9 100644 Binary files a/board_exam_project-master/.gradle/buildOutputCleanup/outputFiles.bin and b/board_exam_project-master/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/controller/LoginController.class b/board_exam_project-master/build/classes/java/main/com/study/board/controller/LoginController.class index d3420e7..fbeba1e 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/controller/LoginController.class and b/board_exam_project-master/build/classes/java/main/com/study/board/controller/LoginController.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/controller/RegistrationController.class b/board_exam_project-master/build/classes/java/main/com/study/board/controller/RegistrationController.class index 91620b4..0a117a8 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/controller/RegistrationController.class and b/board_exam_project-master/build/classes/java/main/com/study/board/controller/RegistrationController.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/entity/Freeboard.class b/board_exam_project-master/build/classes/java/main/com/study/board/entity/Freeboard.class index 5f0fd27..859271f 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/entity/Freeboard.class and b/board_exam_project-master/build/classes/java/main/com/study/board/entity/Freeboard.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/entity/User.class b/board_exam_project-master/build/classes/java/main/com/study/board/entity/User.class index e554290..5b21e7d 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/entity/User.class and b/board_exam_project-master/build/classes/java/main/com/study/board/entity/User.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/ga/Board.class b/board_exam_project-master/build/classes/java/main/com/study/board/ga/Board.class index 519292c..630ac75 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/ga/Board.class and b/board_exam_project-master/build/classes/java/main/com/study/board/ga/Board.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardController.class b/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardController.class index 8ffb011..6e7de49 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardController.class and b/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardController.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardService.class b/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardService.class index 114b86f..33db7d8 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardService.class and b/board_exam_project-master/build/classes/java/main/com/study/board/ga/BoardService.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodo.class b/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodo.class index dc1e182..da6912e 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodo.class and b/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodo.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoController.class b/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoController.class index d74ed7d..035885a 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoController.class and b/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoController.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoService.class b/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoService.class index 3e2ae33..e8b500a 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoService.class and b/board_exam_project-master/build/classes/java/main/com/study/board/ga/dodoService.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/repository/BoardRepository.class b/board_exam_project-master/build/classes/java/main/com/study/board/repository/BoardRepository.class index 041bce0..8b19324 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/repository/BoardRepository.class and b/board_exam_project-master/build/classes/java/main/com/study/board/repository/BoardRepository.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/repository/FreeboardRepository.class b/board_exam_project-master/build/classes/java/main/com/study/board/repository/FreeboardRepository.class index 3fdf62a..400e705 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/repository/FreeboardRepository.class and b/board_exam_project-master/build/classes/java/main/com/study/board/repository/FreeboardRepository.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/repository/UserRepository.class b/board_exam_project-master/build/classes/java/main/com/study/board/repository/UserRepository.class index 439ac43..19a3a49 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/repository/UserRepository.class and b/board_exam_project-master/build/classes/java/main/com/study/board/repository/UserRepository.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/repository/dodoRepository.class b/board_exam_project-master/build/classes/java/main/com/study/board/repository/dodoRepository.class index 5cb7db8..f35e3a8 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/repository/dodoRepository.class and b/board_exam_project-master/build/classes/java/main/com/study/board/repository/dodoRepository.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/service/FreeboardService.class b/board_exam_project-master/build/classes/java/main/com/study/board/service/FreeboardService.class index 1aadb24..5a18f8f 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/service/FreeboardService.class and b/board_exam_project-master/build/classes/java/main/com/study/board/service/FreeboardService.class differ diff --git a/board_exam_project-master/build/classes/java/main/com/study/board/service/UserService.class b/board_exam_project-master/build/classes/java/main/com/study/board/service/UserService.class index 54db119..aa4850f 100644 Binary files a/board_exam_project-master/build/classes/java/main/com/study/board/service/UserService.class and b/board_exam_project-master/build/classes/java/main/com/study/board/service/UserService.class differ diff --git a/board_exam_project-master/build/resources/main/templates/main.html b/board_exam_project-master/build/resources/main/templates/main.html index c296583..c2659f5 100644 --- a/board_exam_project-master/build/resources/main/templates/main.html +++ b/board_exam_project-master/build/resources/main/templates/main.html @@ -83,6 +83,7 @@ pdf리스트 회원가입 login + 마이페이지 logout diff --git a/board_exam_project-master/build/resources/main/templates/users/mypage.html b/board_exam_project-master/build/resources/main/templates/users/mypage.html new file mode 100644 index 0000000..6566a1f --- /dev/null +++ b/board_exam_project-master/build/resources/main/templates/users/mypage.html @@ -0,0 +1,107 @@ + + + + 사용자 페이지 + + + + +

사용자 정보 보여주기~~

+

user_id =

+ + + + + + + + + + + + + + + +
IDNicknameEmail
+ +

사용자가 그동안 작성한 자유게시판 게시글 목록

+ + + + + + + + + + + + + + + + + + + + + + + +
usercontentIdTitleContentCreated AtUpdated AtActions
+ Edit + Delete +
+ + + diff --git a/board_exam_project-master/build/tmp/compileTestJava/previous-compilation-data.bin b/board_exam_project-master/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 0000000..1b9671f Binary files /dev/null and b/board_exam_project-master/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/board_exam_project-master/src/main/java/com/study/board/controller/MyPageController.java b/board_exam_project-master/src/main/java/com/study/board/controller/MyPageController.java new file mode 100644 index 0000000..a13efaf --- /dev/null +++ b/board_exam_project-master/src/main/java/com/study/board/controller/MyPageController.java @@ -0,0 +1,44 @@ +package com.study.board.controller; + +import com.study.board.entity.Freeboard; +import com.study.board.entity.User; +import com.study.board.service.FreeboardService; +import com.study.board.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpSession; +import java.util.List; + +@RestController +public class MyPageController { + @Autowired + private UserService userService; + @Autowired + private FreeboardService freeboardService; + + @GetMapping("/mypage") + @ResponseBody + public ResponseEntity mypage(HttpSession session) { + Object obj = session.getAttribute("user"); // 사용자 정보 받아서 오브젝트로 만들기 + if (obj == null) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("사용자가 로그인되어 있지 않습니다."); + } else { + // 사용자 id를 Long 타입으로 변환 + Long userId = Long.parseLong(obj.toString()); + // 사용자 정보 불러오기 + User user = userService.getUserInfo(userId); + + // freeboard에서 사용자가 작성한 글 불러오기 + List userFreeboards = freeboardService.getContentByUserId(userId); + + return ResponseEntity.ok().body(userFreeboards); + } + } +} diff --git a/board_exam_project-master/src/main/java/com/study/board/entity/User.java b/board_exam_project-master/src/main/java/com/study/board/entity/User.java index 584c25e..a415314 100644 --- a/board_exam_project-master/src/main/java/com/study/board/entity/User.java +++ b/board_exam_project-master/src/main/java/com/study/board/entity/User.java @@ -88,4 +88,5 @@ public int getIsDeleted() { public void setIsDeleted(int isDeleted) { this.isDeleted = isDeleted; } + } diff --git a/board_exam_project-master/src/main/java/com/study/board/repository/FreeboardRepository.java b/board_exam_project-master/src/main/java/com/study/board/repository/FreeboardRepository.java index ea7370f..d7c2db5 100644 --- a/board_exam_project-master/src/main/java/com/study/board/repository/FreeboardRepository.java +++ b/board_exam_project-master/src/main/java/com/study/board/repository/FreeboardRepository.java @@ -1,8 +1,15 @@ package com.study.board.repository; import com.study.board.entity.Freeboard; +import com.study.board.entity.Pdf; +import com.study.board.entity.User; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import java.util.List; + +@Repository public interface FreeboardRepository extends JpaRepository { + List findAllByUserId(Long userId); //마이페이지에서 유저가 작성한 자유게시판 글들을 찾을 때 사용하는 함수 } diff --git a/board_exam_project-master/src/main/java/com/study/board/repository/UserRepository.java b/board_exam_project-master/src/main/java/com/study/board/repository/UserRepository.java index 805941c..b7c509f 100644 --- a/board_exam_project-master/src/main/java/com/study/board/repository/UserRepository.java +++ b/board_exam_project-master/src/main/java/com/study/board/repository/UserRepository.java @@ -6,6 +6,4 @@ import java.util.Optional; @Repository public interface UserRepository extends JpaRepository { - Optional findByEmail(String email); - Optional findByNickname(String nickname); } diff --git a/board_exam_project-master/src/main/java/com/study/board/service/FreeboardService.java b/board_exam_project-master/src/main/java/com/study/board/service/FreeboardService.java index abed75f..032f67d 100644 --- a/board_exam_project-master/src/main/java/com/study/board/service/FreeboardService.java +++ b/board_exam_project-master/src/main/java/com/study/board/service/FreeboardService.java @@ -55,4 +55,8 @@ public void deleteFreeboard(Integer id) { .orElseThrow(() -> new NoSuchElementException("Freeboard not found with id " + id)); freeboardRepository.delete(freeboard); } + + public List getContentByUserId(Long userId){ //user의 id를 받아서 user Id로 작성된 글들을 찾아 Freeboard 타입 리스트로 반환 + return freeboardRepository.findAllByUserId(userId); + } } diff --git a/board_exam_project-master/src/main/java/com/study/board/service/UserService.java b/board_exam_project-master/src/main/java/com/study/board/service/UserService.java index 9f3979c..65a1c9e 100644 --- a/board_exam_project-master/src/main/java/com/study/board/service/UserService.java +++ b/board_exam_project-master/src/main/java/com/study/board/service/UserService.java @@ -1,5 +1,6 @@ package com.study.board.service; +import com.study.board.entity.Freeboard; import com.study.board.entity.User; import com.study.board.repository.UserRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -28,10 +29,6 @@ public void register(User user) { // Save the user to the database userRepository.save(user); } - - - - public boolean authenticate(Long id, String password) { Optional optionalUser = userRepository.findById(id); if (optionalUser.isPresent()) { @@ -43,6 +40,13 @@ public boolean authenticate(Long id, String password) { return false; } + public User getUserInfo(Long id) { + Optional user = userRepository.findById(id); + return user.orElse(null); + } + + + diff --git a/board_exam_project-master/src/main/resources/templates/main.html b/board_exam_project-master/src/main/resources/templates/main.html index c296583..c2659f5 100644 --- a/board_exam_project-master/src/main/resources/templates/main.html +++ b/board_exam_project-master/src/main/resources/templates/main.html @@ -83,6 +83,7 @@ pdf리스트 회원가입 login + 마이페이지 logout diff --git a/board_exam_project-master/src/main/resources/templates/users/mypage.html b/board_exam_project-master/src/main/resources/templates/users/mypage.html new file mode 100644 index 0000000..6566a1f --- /dev/null +++ b/board_exam_project-master/src/main/resources/templates/users/mypage.html @@ -0,0 +1,107 @@ + + + + 사용자 페이지 + + + + +

사용자 정보 보여주기~~

+

user_id =

+ + + + + + + + + + + + + + + +
IDNicknameEmail
+ +

사용자가 그동안 작성한 자유게시판 게시글 목록

+ + + + + + + + + + + + + + + + + + + + + + + +
usercontentIdTitleContentCreated AtUpdated AtActions
+ Edit + Delete +
+ + + diff --git "a/board_exam_project-master/uploads/pdf/03_\353\254\270\354\240\234\355\225\264\352\262\260\354\227\220\354\235\264\354\240\204\355\212\270.pdf" "b/board_exam_project-master/uploads/pdf/03_\353\254\270\354\240\234\355\225\264\352\262\260\354\227\220\354\235\264\354\240\204\355\212\270.pdf" deleted file mode 100644 index 3aefb6e..0000000 Binary files "a/board_exam_project-master/uploads/pdf/03_\353\254\270\354\240\234\355\225\264\352\262\260\354\227\220\354\235\264\354\240\204\355\212\270.pdf" and /dev/null differ diff --git "a/board_exam_project-master/uploads/pdf/06_\355\203\220\354\203\2113_\352\265\255\354\247\200\354\240\201\355\203\220\354\203\211.pdf" "b/board_exam_project-master/uploads/pdf/06_\355\203\220\354\203\2113_\352\265\255\354\247\200\354\240\201\355\203\220\354\203\211.pdf" deleted file mode 100644 index ef53291..0000000 Binary files "a/board_exam_project-master/uploads/pdf/06_\355\203\220\354\203\2113_\352\265\255\354\247\200\354\240\201\355\203\220\354\203\211.pdf" and /dev/null differ diff --git "a/board_exam_project-master/uploads/pdf/2\354\243\274\354\260\250_\352\270\200\353\241\234\353\262\214 \353\271\204\354\246\210\353\213\210\354\212\244\355\231\230\352\262\275\354\227\220\354\204\234\354\235\230 \354\240\225\353\263\264\354\213\234\354\212\244\355\205\234(Laudon_MIS14_ch01).pdf" "b/board_exam_project-master/uploads/pdf/2\354\243\274\354\260\250_\352\270\200\353\241\234\353\262\214 \353\271\204\354\246\210\353\213\210\354\212\244\355\231\230\352\262\275\354\227\220\354\204\234\354\235\230 \354\240\225\353\263\264\354\213\234\354\212\244\355\205\234(Laudon_MIS14_ch01).pdf" deleted file mode 100644 index 6090de4..0000000 Binary files "a/board_exam_project-master/uploads/pdf/2\354\243\274\354\260\250_\352\270\200\353\241\234\353\262\214 \353\271\204\354\246\210\353\213\210\354\212\244\355\231\230\352\262\275\354\227\220\354\204\234\354\235\230 \354\240\225\353\263\264\354\213\234\354\212\244\355\205\234(Laudon_MIS14_ch01).pdf" and /dev/null differ