Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
9697da5
* 테스트용 코드 임시 pr
horobito Apr 10, 2021
6031e51
* 1) Feed 에 속해있던 timeline 검색을 새로운 도메인 timeLine 으로 할당
horobito Apr 10, 2021
7b04d98
* 표현층에 Feed 정보 전달하기 위한 DTO 생성
horobito Apr 10, 2021
b2641dd
* 시간표현 LocalDataTime 에서 Instant 로 타입 변경
horobito Apr 10, 2021
f5d5cf2
* 도메인 영역 보여내주는 대신, DTO 로 보내주도록 수정
horobito Apr 10, 2021
7415642
* 로그인된 User 정보 가져오기 위한 서비스 형성
horobito Apr 10, 2021
0f81f49
* TimeLineService 에서 SpringSecurity 활용하여 User 가져오도록 수정
horobito Apr 10, 2021
d31a394
* FriendShipService 에서 SpringSecurity 활용하여 User 가져오도록 수정
horobito Apr 10, 2021
8748532
* 아직 테스트 안하는 부분 임시 주석 처리
horobito Apr 10, 2021
5a9873d
* 필요없는 코드 제거
horobito Apr 10, 2021
874e97e
* 좋아요 누른사람 처리를 새로운 도메인 영역을 만들어 할당하게 함
horobito Apr 10, 2021
0ac0315
* 새로운 도메인 영역의 레이어 생성 시작
horobito Apr 10, 2021
0ecd114
* 필요없는 코드 제거
horobito Apr 10, 2021
b4afd7b
* 필요없는 코드 제거 및 User 정보 찾는 코드 변경
horobito Apr 10, 2021
fd7f45f
* 필요없는 코드 제거
horobito Apr 10, 2021
7100fcd
* repository 생성
horobito Apr 10, 2021
d87225e
* 기존 feed 에서 담당하고 있는 부분 가져옴
horobito Apr 10, 2021
ec2146d
* like 기능 구현중 (1) - 분기 작성
horobito Apr 10, 2021
e117169
* 패키지 이름 변경
horobito Apr 11, 2021
ff28e80
* 열거 상수 추가 -> 싫어요 기능 추가 대비
horobito Apr 11, 2021
b0db06a
* PreferredPerson 생성 기능 추가
horobito Apr 11, 2021
d02c820
* 구현에 필요한 기능 추가
horobito Apr 11, 2021
0bce320
* service 층에서 응답위해 필요한 열거타입 생성
horobito Apr 11, 2021
12d1431
* feed 와 댓글 중 어디의 preference 인지 설정하는 코드
horobito Apr 11, 2021
353596d
* 오타 수정
horobito Apr 11, 2021
d340702
* 필요한 열거상수 추가
horobito Apr 11, 2021
3a715af
* Feed 좋아요 기능 전체적인 구현 완료
horobito Apr 11, 2021
aad10a9
* 선호 상태 반환기능 추가
horobito Apr 11, 2021
0e64ce9
* 선호 상태 변경기능 추가
horobito Apr 11, 2021
2c962e1
* 좋아요 수 변경기능 추가 -> 새 객체 반환하도록 설정
horobito Apr 11, 2021
34da7f5
* PreferredPersonController Feed 부분 구현
horobito Apr 11, 2021
6a60e68
* PreferredPersonController Feed 부분 구현
horobito Apr 11, 2021
90a1973
* PreferredPersonService 댓글 부분 구현 시작 & 중첩 코드 제거
horobito Apr 11, 2021
4454958
* 단어 오류 변경 [Logined -> logged]
horobito Apr 11, 2021
b2f4adf
* 해당 feed 에서 comment 찾는 책임을
horobito Apr 11, 2021
bd98896
* UserSessionService 이용해서 유저 찾도록 변경
horobito Apr 11, 2021
70fb228
* 필요한 열거상수 추가[COMMENT_NOT_FOUND]
horobito Apr 11, 2021
61e69e6
* 댓글 좋아요 기능 구현 중
horobito Apr 11, 2021
57c48b1
* 댓글 좋아요 기능 구현 중 [댓글 없을 경우] 구현
horobito Apr 11, 2021
e5656c0
* comment 내 독립성 해치는 코드 제거 및
horobito Apr 12, 2021
fb068a2
* 도메인 이름 의미 명확하게 변경
horobito Apr 12, 2021
9ff223d
* 도메인 이름 의미 명확하게 변경
horobito Apr 12, 2021
238fbf8
* [좋아요 숫자]의 의미가 명확하게 전달되도록 변경
horobito Apr 12, 2021
dc6aa7f
* Feed 와 Comment 의 선호 정보 혼동될 수 있으므로, repository 메소드에 매개변수 추가
horobito Apr 12, 2021
392fd84
* 댓글 관련 좋아요 정보 구현
horobito Apr 12, 2021
25104dc
* 관계를 좀 더 명확히 나타내는 이름으로 변경
horobito Apr 12, 2021
4ccd61a
* 수정된 이름 반영
horobito Apr 12, 2021
c8b893e
* 수정된 이름 반영
horobito Apr 12, 2021
6670867
* 수정된 이름 반영
horobito Apr 12, 2021
f6fef78
* 수정된 이름 반영
horobito Apr 12, 2021
598ee46
* 오타 수정
horobito Apr 12, 2021
4e2e3fe
* 좀 더 간단하게 다대다 관계처럼 동작하도록 변경
horobito Apr 12, 2021
5cfa3fb
* 단순 띄어쓰기
horobito Apr 12, 2021
6cf26d9
* 잠시 테스트 코드 짜보는 중
horobito Apr 12, 2021
c509e77
* FriendShipService 코드 User 에 좀 더 덜 의존하도록 변경중
horobito Apr 12, 2021
4bd37b8
* FriendShipService 코드 User 에 좀 더 덜 의존하도록 변경시도중
horobito Apr 12, 2021
d8672f8
* User 에 덜 의존하도록
horobito Apr 13, 2021
8c10d44
* UserService 에 유저 찾는 메소드 구현 후 FriendShipService 에 적용
horobito Apr 13, 2021
a2b1c14
* UserService 에 유저 찾는 메소드 구현 후 FriendShipService 에 적용 2
horobito Apr 13, 2021
a8f1e8f
* 필요없는 코드 제거
horobito Apr 13, 2021
87265f9
* 필요없는 코드 제거
horobito Apr 13, 2021
bd5148d
* 아무 관계도 아닌 유저끼리의 친구 생성 테스트 성공
horobito Apr 13, 2021
de1fb9f
* 테스트 일부 코드 위치 변경
horobito Apr 13, 2021
a78a3dc
* CRUD 각각 테스트 코드 작성해보기
horobito Apr 13, 2021
10b4881
* Create 중 이미 요청 또는 수락된 경우 테스트
horobito Apr 13, 2021
f668332
* Create 중 수락하는 경우에 대한 테스트 코드
horobito Apr 13, 2021
d951232
* 오타 변경
horobito Apr 13, 2021
5581d21
*userService 로 유저 찾도록 역할 위임
horobito Apr 14, 2021
22d62dd
*친구관계 삭제 테스트
horobito Apr 14, 2021
5f6843a
*잘못된 부분 수정
horobito Apr 14, 2021
47a28b2
*삭제 부분 테스트 구현
horobito Apr 14, 2021
ef9faca
*삭제 부분 테스트 구현 2.
horobito Apr 14, 2021
2b4b7ea
*친구 관계 잘못 구현된 부분 수정 위한
horobito Apr 14, 2021
5244f24
* 친구관계 표현을 위한 열거형 생성 후,
horobito Apr 14, 2021
6f18cc1
* 친구관계 표현을 위한 열거형 생성 후,
horobito Apr 14, 2021
67ea0bd
* 테스트 코드 일단 패스 .. 나중에 다시 시도할 것
horobito Apr 14, 2021
217fb6b
* 삭제부분 반환 값 설정 완료
horobito Apr 14, 2021
d635104
* Controller 층에서 삭제요청에 대한 결과 값에 따른 응답 코드 설정 완료
horobito Apr 14, 2021
432c4fc
* Feed 부분 반환 값 설정 완료 - 좀 불안함
horobito Apr 14, 2021
d960b7f
* FriendShip 친구 리스트 가져오는 것
horobito Apr 14, 2021
66c6ead
* 미사용 테스트 코드 내 오류 발생부분 제거
horobito Apr 14, 2021
b07c92f
* 친구 삭제기능 응답 코드 작성
horobito Apr 14, 2021
26f8b4d
* [내게 온 친구요청 찾는 기능] 의
horobito Apr 14, 2021
b1a66d3
* 필요없는 코드 제거
horobito Apr 14, 2021
151aefa
* [내 타임라인 찾기] 응답 코드 작성
horobito Apr 14, 2021
41e6949
* user 정보 userservice에서 찾도록 변경
horobito Apr 14, 2021
20db8c5
* [Comment 만들기] 응답 코드 작성
horobito Apr 15, 2021
3a10eef
* 필요없는 코드 제거
horobito Apr 15, 2021
d2762e0
* 클래스 위치 변경 및 새로운 레이어 생성
horobito Apr 15, 2021
c181c05
* 스프링 시큐리티에서 필요한 userDetails 를 받아오기 위한 service 기능 구현
horobito Apr 15, 2021
6cc8916
* UserDetailsService 구현 및 그에 필요한 코드들 작성중
horobito Apr 15, 2021
e1ce8d3
* UserDetailsService 구현 및 그에 필요한 코드들 작성중
horobito Apr 15, 2021
ad66c50
* WebSecurityConfig 구현중
horobito Apr 15, 2021
5c8a2df
* 사용할 filter 틀 만듬
horobito Apr 15, 2021
89ac100
* InputStream 의 한버 읽히면 닫히는 문제 해결 위한
horobito Apr 15, 2021
8db1580
* InputStream 의 한버 읽히면 닫히는 문제 해결 위한
horobito Apr 15, 2021
da2aa84
* ObjectMapper 넣어줌
horobito Apr 15, 2021
f92e558
* UserAuthenticationFilter 에 Object Mapper 넣어줌
horobito Apr 15, 2021
3f107e6
* 내부에 필드 하나 추가
horobito Apr 15, 2021
f276ba3
* Filter 에 토큰 가지고 인증하는 과정 추가
horobito Apr 15, 2021
a4deb5c
* 일단 짠다
horobito Apr 15, 2021
c7ad150
* 필요없는 도메인 제거
horobito Apr 15, 2021
d360a52
* 필요없는 코드 제거
horobito Apr 15, 2021
9a15b1c
* 필터링 하지 않는다는 코드 추가
horobito Apr 15, 2021
e7520e2
* 응답코드 수정 - 그러나 아직 잘 모르겠음
horobito Apr 15, 2021
54f3237
* 1. 필요없는 코드 제거 - BasicInfo.java, Feed Repository 내 메소드
horobito Apr 18, 2021
26ef168
* 필요없는 코드 제거
horobito Apr 18, 2021
f54abf7
* [피드 좋아요] 부분 반환 코드 변경
horobito Apr 18, 2021
630e2db
* [피드 좋아요] 부분 반환 코드 다시 변경
horobito Apr 18, 2021
3ee2da8
* [댓글 좋아요] 부분 반환 코드 변경
horobito Apr 18, 2021
f5169f9
* [친구목록 가져오기] 부분 반환 코드 변경
horobito Apr 18, 2021
ba9fcd1
* 로그인 기능 구현 시도
horobito Apr 19, 2021
0fd2f0e
* 필요없는 코드 제거 및 로그인 기능 구현중 - 갑작스럽게 forwardFriendShip 에서 오류가 난다???
horobito Apr 19, 2021
e1bfeb4
* 로그인 기능 구현시도 3
horobito Apr 19, 2021
17bf879
* 테스트 코드 중 필요없는 부분들 제거
horobito Apr 19, 2021
47d6aff
* [친구 삭제 ] 중 1. 친구 관계가 없는 경우 테스트
horobito Apr 19, 2021
c9549c1
* [친구 삭제 ] 중 2. 친구 관계가 있는 경우 테스트 // 주의 = service 부분 반환 값 아직 변경 안함 - 테…
horobito Apr 19, 2021
3da4419
* [친구 찾기] 테스트 1. 필수 요구사항 작성
horobito Apr 19, 2021
5c2e18e
* 친구관계 찾기 테스트 생성 시도
horobito Apr 20, 2021
40c7d30
* 반환값 변경
horobito Apr 20, 2021
427b6d9
* [친구요청 확인 테스트] 1. 알맞은 요청 확인 테스트
horobito Apr 20, 2021
126f480
* [친구요청 확인 테스트] 1.1 페이지 번호 또는 사이즈 잘못된 경우 오류 발생하는지 확인하는 코드 추가
horobito Apr 20, 2021
50cd400
* [친구요청 확인 테스트] 2. 조건에 따른 반환 값 여부 확인
horobito Apr 20, 2021
a4e8cc3
* 친구 삭제 시 필요한 기능 추가
horobito Apr 20, 2021
2fdadfd
* [친구 목록 확인 테스트] - 조건에 맞게 불러오는지 확인 -> 성공
horobito Apr 20, 2021
0e0e28b
* 교훈 : 테스트 실시할 메소드 안에는
horobito Apr 20, 2021
80a05f4
* [요청 수락] 테스트 성공
horobito Apr 20, 2021
291484b
* 내부 코드 약간 수정
horobito Apr 20, 2021
5d5c4dd
* 내부 코드 약간 수정
horobito Apr 20, 2021
1accb81
* [게시글 좋아요 테스트 1]
horobito Apr 20, 2021
3dd3326
* [게시글 좋아요 테스트 2] - 작성자와 친구 관계가 아닐 경우 테스트
horobito Apr 20, 2021
ce32217
* [게시글 좋아요 테스트 3] - 내 게시글인 경우
horobito Apr 20, 2021
803156b
* 테스트에 필요한 몇몇 코드 수정
horobito Apr 20, 2021
ba802d7
* 중첩 코드 제거 위한 변수 추출
horobito Apr 20, 2021
37fe532
* Feed 위한 Helper 적용
horobito Apr 20, 2021
148e679
* Feed 좋아요 테스트
horobito Apr 20, 2021
ce8700d
* [Comment 좋아요 테스트 1]
horobito Apr 20, 2021
8196e8b
* [Comment 좋아요 테스트 ] - 완료
horobito Apr 20, 2021
8b0e8cf
* [FeedService 테스트 시작]
horobito Apr 20, 2021
b090c0d
* [Feed] 에 못 넣은 필드 추가
horobito Apr 20, 2021
824213d
* 코드 수정
horobito Apr 20, 2021
8572c47
* [Feed 만들기] 테스트를 위한 코드들 작성 및 수정
horobito Apr 21, 2021
fdd7b4d
* [Feed 만들기] 2. 올바른 요청 테스트 성공
horobito Apr 21, 2021
8fa2eea
* [Feed 삭제하기] 1. <존재하지 않는 피드에 삭제 요청했을 경우> 테스트
horobito Apr 21, 2021
11aae72
* [Feed 삭제하기] 2. <타인의 글에 삭제를 요청했을 경우> 테스트
horobito Apr 21, 2021
a1a4980
* [Feed 세부정보 확인하기] 1. 게시글 없을 때 2. 친구 관계 아닐 때 테스트
horobito Apr 21, 2021
099e7b1
* [Feed 세부정보 확인하기] 3. 게시글 상세 조회 테스트
horobito Apr 21, 2021
b56e2f9
* [Feed 세부정보 확인하기] 3. <게시글 상세 조회 테스트 > 의 테스트 게시글에 comment 도 넣고 테스트 해봄
horobito Apr 21, 2021
54e1be4
* [comment 만들기]
horobito Apr 21, 2021
a20c1f4
* [comment 만들기]
horobito Apr 21, 2021
1625a27
* [comment 만들기]
horobito Apr 21, 2021
330e7c0
* [comment 만들기]
horobito Apr 21, 2021
64b5dad
* [Timeline 테스트] 1. 페이지 정보 또는 크기 잘못 입력
horobito Apr 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ dependencies {

testImplementation 'org.springframework.security:spring-security-test'

implementation group: 'com.google.guava', name: 'guava', version: '11.0.2'

//2차

implementation 'io.jsonwebtoken:jjwt:0.9.1'
Expand Down
Binary file not shown.
Binary file added com.example.demo.DemoApplication.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.feed.domain.Comment.class
Binary file not shown.
Binary file added com.example.demo.feed.domain.Content.class
Binary file not shown.
Binary file added com.example.demo.feed.domain.Feed.class
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.feed.domain.Writer.class
Binary file not shown.
Binary file added com.example.demo.feed.domain.WriterId.class
Binary file not shown.
Binary file added com.example.demo.feed.domain.WriterName.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.feed.service.FeedService.class
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.friend.domain.BasicInfo.class
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.friend.domain.Friendee.class
Binary file not shown.
Binary file added com.example.demo.friend.domain.Friender.class
Binary file not shown.
Binary file added com.example.demo.friend.domain.Friendship.class
Binary file not shown.
Binary file added com.example.demo.friend.domain.PersonId.class
Binary file not shown.
Binary file added com.example.demo.friend.domain.PersonName.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.user.domain.Password.class
Binary file not shown.
Binary file added com.example.demo.user.domain.User.class
Binary file not shown.
Binary file added com.example.demo.user.domain.UserBasicInfo.class
Binary file not shown.
Binary file added com.example.demo.user.domain.Username.class
Binary file not shown.
Binary file not shown.
Binary file added com.example.demo.user.service.UserService.class
Binary file not shown.
Binary file not shown.
Binary file added java.lang.reflect.Method.class
Binary file not shown.
Binary file not shown.
Binary file added org.apache.commons.logging.LogFactory.class
Binary file not shown.
Binary file added org.springframework.cglib.reflect.FastClass.class
Binary file not shown.
Binary file not shown.
Binary file added org.springframework.util.Assert.class
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.example.demo.feed.controller;


import com.example.demo.feed.service.CommentDto;
import com.example.demo.feed.service.CommentService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.nio.file.AccessDeniedException;

@RestController
@RequiredArgsConstructor
public class CommentController {
Expand All @@ -14,14 +20,21 @@ public class CommentController {

@PostMapping("/feed/{feedId}/comments")
public void makeComment(@PathVariable Long feedId,
@RequestBody String contents){
commentService.makeCommentByFeedIdAndContents(feedId, contents);
@RequestBody String contents) throws AccessDeniedException, IllegalAccessException {

try {
CommentDto result = commentService.makeCommentByFeedIdAndContents(feedId, contents);
ResponseEntity.ok().body(result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 반환 안하는거같네요 🤔

}catch (IllegalArgumentException e){
ResponseEntity.status(HttpStatus.BAD_REQUEST);

}catch (IllegalAccessException e){
ResponseEntity.status(HttpStatus.UNAUTHORIZED);

}


}

// @PostMapping("/feed/{feedId}/comments/{commentId}/like")
// public void likeOrDislikeCommentById(@PathVariable Long feedId,
// @PathVariable int commentId){
// commentService.likeOrDislikeCommentByFeedIdAndCommentId(feedId, commentId);
// }

}
62 changes: 43 additions & 19 deletions src/main/java/com/example/demo/feed/controller/FeedController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@


import com.example.demo.feed.domain.Feed;
import com.example.demo.feed.domain.RequestResult;
import com.example.demo.feed.service.FeedDto;
import com.example.demo.feed.service.FeedService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.web.bind.annotation.*;

import java.nio.file.AccessDeniedException;
import java.util.List;


Expand All @@ -19,37 +24,56 @@ public class FeedController {

private final FeedService feedService;

@PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/feeds")
public Feed[] findTimeline(@RequestParam int page,
@RequestParam int pageSize){
return feedService.findMyTimeLine(page, pageSize);

}

@PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/feeds/{feedId}")
public Feed findFeedDetailByFeedId(@PathVariable Long feedId){
return feedService.findFeedDetailByFeedId(feedId);
public ResponseEntity<FeedDto> findFeedDetailByFeedId(@PathVariable Long feedId) throws AccessDeniedException {


try {
FeedDto result= feedService.findFeedDetailByFeedId(feedId);
return ResponseEntity.ok().body(result);
}catch (IllegalArgumentException e) {
return ResponseEntity.badRequest().build();
}catch( IllegalAccessException e){
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
}

}

@PreAuthorize("hasRole('ROLE_ADMIN')")

@PostMapping("/feeds")
public void makeFeed(@RequestBody String contents){
feedService.makeFeedByContents(contents);
public Object makeFeed(@RequestParam String title,
@RequestParam String contents) throws AccessDeniedException {
Object result = feedService.makeFeedByContents(title, contents);

if (result instanceof FeedDto){
ResponseEntity.ok();
return result;
}else {
switch ((RequestResult)result){
case BAD_REQUEST:
ResponseEntity.status(HttpStatus.BAD_REQUEST);
break;
}
return result;
}

}

@DeleteMapping("/feeds/{feedId}")
public void deleteFeedByFeedId(@PathVariable Long feedId){
feedService.deleteFeedByFeedId(feedId);
public void deleteFeedByFeedId(@PathVariable Long feedId) throws AccessDeniedException {
try {
feedService.deleteFeedByFeedId(feedId);
}catch (IllegalArgumentException e) {

}catch( IllegalAccessException e){

}

}

@PostMapping("/feeds/{feedId}/likes")
public void likeFeedByFeedId(@PathVariable Long feedId){
feedService.likeFeedByFeedID(feedId);
}




}
23 changes: 16 additions & 7 deletions src/main/java/com/example/demo/feed/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.example.demo.feed.domain;


import com.example.demo.user.domain.User;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.Instant;

@Entity
@Table(name = "comment")
Expand All @@ -27,36 +26,46 @@ public class Comment {
@JsonIgnoreProperties("feed")
private Feed feed;


@Embedded
private Writer writer;

private LocalDateTime wrtTime;
private Instant wrtTime;

@Embedded
private Content content;

@Embedded
private Preference preferenceInfo;
private PreferenceCount preferenceCountInfo;

private boolean deleted;

public Comment(Writer writer, Content content){
this.writer = writer;
this.content = content;
this.preferenceInfo = Preference.create();
this.wrtTime = LocalDateTime.now();
this.preferenceCountInfo = PreferenceCount.create();
this.wrtTime = Instant.now();
this.deleted = false;
}

public String getContent(){
return this.content.getContent();
}


public static Comment create(Writer writer, Content content) {
return new Comment(writer, content);
}

public void likeOrDislike() {
public void disLike() {
this.preferenceCountInfo = PreferenceCount.create(this.preferenceCountInfo.getPreference()-1L);
}

public void like() {
this.preferenceCountInfo = PreferenceCount.create(this.preferenceCountInfo.getPreference()+1L);
}


// public boolean checkPossibleOfLike(User user) {
// String writerId = this.getWriter().getWrtName();
// String username = user.getUserBasicInfo().getUsername();
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/com/example/demo/feed/domain/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import lombok.Setter;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

@Entity
Expand All @@ -25,26 +26,31 @@ public class Feed {
@Embedded
private Writer writer;

@Embedded
private Title title;

@Embedded
private Content content;

@Column(name = "preference")
private Preference preferenceInfo;
private PreferenceCount preferenceCountInfo;

@Column(name = "wrt_time")
private LocalDateTime wrtTime;
private Instant wrtTime;

private Boolean deleted;


@OneToMany(mappedBy = "feed", cascade = {CascadeType.PERSIST})
@JsonIgnoreProperties("feed")
private List<Comment> comments;
private List<Comment> comments = new ArrayList<>();

private Feed(Writer writer, Content content){
private Feed(Writer writer, Title title, Content content){
this.writer = writer;
this.content = content;
this.wrtTime = LocalDateTime.now();
this.preferenceInfo = Preference.create();
this.wrtTime = Instant.now();
this.preferenceCountInfo = PreferenceCount.create();
this.title = title;
this.deleted = false;
}

Expand All @@ -53,12 +59,12 @@ public void delete(){
this.deleted =true;
}

public static Feed create(Writer writer, Content content) {
return new Feed(writer, content);
public static Feed create(Writer writer, Title title, Content content) {
return new Feed(writer, title, content);
}

public void like(){
this.preferenceInfo = this.preferenceInfo.like();
this.preferenceCountInfo = this.preferenceCountInfo.like();
}

public void enrollComment(Comment comment) {
Expand All @@ -70,4 +76,8 @@ public void enrollComment(Comment comment) {
public Comment getComment(int commentId) {
return comments.get(commentId);
}

public void disLike() {
this.preferenceCountInfo = PreferenceCount.create(this.preferenceCountInfo.getPreference()-1L);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand All @@ -18,9 +20,8 @@ public interface FeedRepository extends JpaRepository<Feed, Long> {

Feed findFeedByIdAndDeleted(Long id, Boolean deleted);

List<Feed> findFeedsByWriter_Id(WriterId id);

Page<Feed> findAllByWriter(Writer writer);
Page<Feed> findAllByWriter_IdIn(List<WriterId> writerIds, Pageable pageable);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,29 @@
@Setter(AccessLevel.PACKAGE)
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Preference {
public class PreferenceCount {

@Column(name = "preference")
private long preference = 0L;

private Preference(long like){
private PreferenceCount(long like){
this.preference = like;
}


public Preference like(){
return new Preference(this.preference +1L);
public PreferenceCount like(){
return new PreferenceCount(this.preference +1L);
}


public static Preference create(){
return new Preference();


public static PreferenceCount create(){
return new PreferenceCount();
}

public static PreferenceCount create(long preference){
return new PreferenceCount(preference);
}


Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/example/demo/feed/domain/RequestResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.demo.feed.domain;

public enum RequestResult {
BAD_REQUEST,
UNAUTHORIZED,
FORBIDDEN,
OK

}
23 changes: 23 additions & 0 deletions src/main/java/com/example/demo/feed/domain/Title.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.demo.feed.domain;


import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.Embeddable;

@Embeddable
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Title {

private String title;

private Title(String title){
this.title = title;
}
public static Title create(String title){
return new Title(title);
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/example/demo/feed/domain/Writer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public Writer(WriterId id, WriterName wrtName) {
this.wrtName = wrtName;
}

public Long getId(){
return this.id.getWriterId();
}

public String getName(){
return this.wrtName.getWriterName();
}

Comment on lines +29 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 없는 편이 좋을것 같네요

public static Writer create(WriterId wrtId, WriterName wrtName) {
return new Writer(wrtId, wrtName);
}
Expand Down
Loading