Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull main #25

Merged
merged 82 commits into from
Oct 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
9b96ef9
feat : comment-modeling-fin
HwangJerry Jul 24, 2023
72a9712
feature/likecomment-modeling-fin
HwangJerry Jul 25, 2023
97790ec
feature/likecomment-basetimeentity-applied
HwangJerry Jul 25, 2023
b14c3d2
feat : 그래ë들 세팅 완료 및 스웨ì„거 설정
HwangJerry Jul 27, 2023
e411ed5
fix : om removed
HwangJerry Jul 27, 2023
0e5c09d
post modeling
chs98412 Jul 28, 2023
451e2c2
likepost modeling
chs98412 Jul 28, 2023
d39cb4f
enums setting
chs98412 Jul 28, 2023
9826032
feat: Post dto 생성
chs98412 Jul 28, 2023
a66b6bb
feat: Post Repository 생성
chs98412 Jul 28, 2023
fd545ab
feat: Post 서비스 구현
chs98412 Jul 28, 2023
7a84cb6
feat : add staging.yml
HwangJerry Jul 29, 2023
47cf248
Merge branch 'feature/community' of https://github.com/LikelionUniv/S…
HwangJerry Jul 29, 2023
19972b3
feat : add commentService -> create & update
HwangJerry Jul 29, 2023
43f5f07
feat : comment CUD api:v1 fin
HwangJerry Jul 30, 2023
9933716
fix : set entity fields nullable=false
HwangJerry Jul 30, 2023
2ecc07b
fix : java version reset to 17
HwangJerry Aug 2, 2023
deed7e4
feature : ìexception handling - return format sync
HwangJerry Aug 2, 2023
e42ec7c
fix : yml에 ë reset
HwangJerry Aug 2, 2023
5025c0f
fix: postservice 인터페이스 수정
chs98412 Aug 3, 2023
1340ac0
fix: postservice 구현체 수정
chs98412 Aug 3, 2023
8935d7f
feat: postController 작성
chs98412 Aug 3, 2023
21a5e17
fix : remove value attr
HwangJerry Aug 3, 2023
ebb9979
Merge branch 'feature/community' of https://github.com/LikelionUniv/S…
HwangJerry Aug 3, 2023
6815adc
fix : modified gitignore
HwangJerry Aug 3, 2023
3c8d49b
merge commit
HwangJerry Aug 12, 2023
f889f07
fix: merge confilct fix
HwangJerry Aug 23, 2023
2108ac8
fix: common application.yml ëëadded encoding
HwangJerry Aug 23, 2023
055340a
feature : comment CUD fin
HwangJerry Aug 24, 2023
18793bf
feature : comment ~ readAll api fin
HwangJerry Aug 27, 2023
1ea67d6
feat: 패키지 구조 변경, create 기능 작성
chs98412 Aug 31, 2023
d1a75bc
feat: edit, delete 기능
chs98412 Aug 31, 2023
8b53048
feat: 페이징 조회
chs98412 Aug 31, 2023
43f8d8d
fix : comment builder fixed
HwangJerry Aug 31, 2023
d389c68
fix : comment builder fixed
HwangJerry Aug 31, 2023
b2c497e
fix: 주석 해제
chs98412 Sep 12, 2023
4490409
feat: LikePost
chs98412 Sep 12, 2023
95fd140
fix: post 예외처리
chs98412 Sep 12, 2023
4b4ff27
user 코드 주석 해제
chs98412 Sep 19, 2023
057b58b
fix : fit to HEAD to solve conflict
HwangJerry Sep 29, 2023
671679b
fix : repackaging community
HwangJerry Sep 29, 2023
2562544
fix : field injection into constructor injection
HwangJerry Sep 30, 2023
6ca6fa1
fix : dedupe
HwangJerry Sep 30, 2023
05301f3
fix : refactored likepost
HwangJerry Sep 30, 2023
ca76978
fix: remove common.yml encoding configuration
HwangJerry Sep 30, 2023
8f5b242
fix : follow convention
HwangJerry Sep 30, 2023
01ae3ad
fix : refactored post
HwangJerry Sep 30, 2023
e8089f6
fix : refactored Comment
HwangJerry Sep 30, 2023
d807184
fix : refactored commentLike
HwangJerry Sep 30, 2023
e9eec2a
fix : hide user entity from dto
HwangJerry Oct 1, 2023
e2d430c
fix : refactored postlike
HwangJerry Oct 1, 2023
fcf7695
fix : repackage like
HwangJerry Oct 1, 2023
0698563
fix : bug fixed
HwangJerry Oct 3, 2023
34d3301
fix : swagger authorization에러 fix
seulgi99 Oct 4, 2023
952557f
feature : post api - findByAuthor
HwangJerry Oct 6, 2023
742b8c8
feature : add getPostsByCommentAuthor
HwangJerry Oct 6, 2023
3bdedbd
feature : add findLikedPosts
HwangJerry Oct 6, 2023
86bfec5
fix : solve merge conflict
HwangJerry Oct 6, 2023
79d2098
fix : error fixed
HwangJerry Oct 6, 2023
bd7cfcd
fix : commentcontroller uri
HwangJerry Oct 8, 2023
5666395
fix : commentlikecontoller uri
HwangJerry Oct 8, 2023
bd8bce8
fix : ddl-update
HwangJerry Oct 8, 2023
18458d1
fix : comment/get api param correction
HwangJerry Oct 8, 2023
d0aa7c0
fix : bug fixed
HwangJerry Oct 8, 2023
cdbff87
fix : mypage/get specific posts apis
HwangJerry Oct 8, 2023
5f3a13d
feature : add swagger annotations on community apis
HwangJerry Oct 8, 2023
d7960d0
fix : get comments
HwangJerry Oct 8, 2023
e4c170f
fix : comment body into TEXT
HwangJerry Oct 8, 2023
cf50dae
[force-merge] Merge pull request #21 from LikelionUniv/feature/community
HwangJerry Oct 8, 2023
cd11407
Create stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
652e2d5
Merge pull request #22 from LikelionUniv/seulgi99-patch-1
seulgi99 Oct 9, 2023
9813597
Update stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
2d679f6
Merge pull request #23 from LikelionUniv/seulgi99-patch-1
seulgi99 Oct 9, 2023
52ea968
Update stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
e1fa50d
Update stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
fbaba88
Update stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
de88e04
chore : client Docker파일 수정
seulgi99 Oct 9, 2023
f6336c5
chore : admin Docker파일 수정
seulgi99 Oct 9, 2023
94d0878
chore : client Dockerfile 수정
seulgi99 Oct 9, 2023
a893d35
Update stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
55d5053
Update stag-client-api-deploy.yml
seulgi99 Oct 9, 2023
ff6a821
fix : QueryDslConfig 하나삭제
seulgi99 Oct 9, 2023
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
Prev Previous commit
Next Next commit
fix: postservice 인터페이스 수정
각 메소드 반환형 CommonResponseDto로 변경
  • Loading branch information
chs98412 committed Aug 3, 2023
commit 5025c0f5330834594f64693b21538c3d96edc572
Binary file removed .DS_Store
Binary file not shown.
Binary file removed likelion-admin/.DS_Store
Binary file not shown.
Binary file removed likelion-admin/src/.DS_Store
Binary file not shown.
Binary file removed likelion-admin/src/main/.DS_Store
Binary file not shown.
Binary file removed likelion-admin/src/main/resources/.DS_Store
Binary file not shown.
Binary file removed likelion-client/.DS_Store
Binary file not shown.
Binary file removed likelion-client/src/.DS_Store
Binary file not shown.
Binary file removed likelion-client/src/main/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,54 +1,109 @@
package likelion.univ.service;

import likelion.univ.domain.dto.PostDto;
import likelion.univ.domain.dto.common.CommonResponseDto;
import likelion.univ.domain.entity.Post;
import likelion.univ.domain.entity.User;
import likelion.univ.domain.entity.enums.MainCategory;
import likelion.univ.domain.entity.enums.SubCategory;
import likelion.univ.domain.repository.PostRepository;
import likelion.univ.domain.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.NoSuchElementException;

@Service
@Transactional
@RequiredArgsConstructor
public class PostServiceImpl implements PostService {

@Autowired
private PostRepository postRepository;

@Autowired
private UserRepository userRepository;
@Override
public PostDto.Save createPost(PostDto.Save createRequest, Long userId) {
public CommonResponseDto<Object> createPost(PostDto.Save createRequest, Long userId) {

//User 찾아오는 로직 추가 필요
try {
User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("유저가 존재하지 않습니다."));

Post savePost = postRepository.save(createEntity(createRequest, user));

Post post = Post.builder()
.title(createRequest.getTitle())
.body(createRequest.getBody())
.thumbnail(createRequest.getThumbnail())
.mainCategory(MainCategory.valueOf(createRequest.getMainCategory()))
.subCategory(SubCategory.valueOf(createRequest.getSubCategory()))
.build();
postRepository.save(post);
return ResposeGenerate(savePost.getId(),"게시물 생성 성공");
} catch (NoSuchElementException e) {
return ErrorGenerate( e.getMessage());
}
}

@Override
public CommonResponseDto<Object> updatePost(PostDto.Update updateRequest, Long userId) {

return new PostDto.Save(post.getTitle(), post.getBody(), post.getThumbnail(), post.getMainCategory().toString(), post.getSubCategory().toString());
try {
User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("유저가 존재하지 않습니다."));
Post findPost = postRepository.findById(updateRequest.getPostId()).orElseThrow(()-> new NoSuchElementException("게시글이 존재하지 않습니다."));
if (user.getId().equals(findPost.getId())){
findPost.update(updateRequest);
postRepository.save(findPost);
return ResposeGenerate(findPost.getId(),"게시물 수정 성공");
}
} catch (NoSuchElementException e) {
return ErrorGenerate( e.getMessage());
}

return ErrorGenerate("본인 소유 게시물이 아닙니다.");
}

@Override
public void updatePost(PostDto.Update updateRequest, Long userId) {
public CommonResponseDto<Object> deletePost(PostDto.Delete deleteRequest, Long userId) {

try {
User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("유저가 존재하지 않습니다."));
Post findPost = postRepository.findById(deleteRequest.getPostId()).orElseThrow(()-> new NoSuchElementException("게시글이 존재하지 않습니다."));
if (user.getId().equals(findPost.getId())){
postRepository.delete(findPost);
return NoDataResponseGenerate("게시물 삭제 성공");
}
} catch (NoSuchElementException e) {
return ErrorGenerate( e.getMessage());
}
return ErrorGenerate("본인 소유 게시물이 아닙니다.");

}


Post post = postRepository.findById(updateRequest.getPostId()).get(); //예외처리: 포스트가 없을 때
private static CommonResponseDto<Object> NoDataResponseGenerate(String message) {
return CommonResponseDto.builder()
.message(message)
.build();
}

post.update(updateRequest); //예외처리: 포스트 소유자가 아닐 때
postRepository.save(post);
private static CommonResponseDto<Object> ResposeGenerate(Object data, String message) {
return CommonResponseDto.builder()
.data(data)
.message(message)
.build();
}

private static CommonResponseDto<Object> ErrorGenerate(String message) {
return CommonResponseDto.builder()
.message(message)
.build();
}

@Override
public void deletePost(PostDto.Delete deleteRequest, Long userId) {

Post post = postRepository.findById(deleteRequest.getPostId()).get(); //예외처리: 포스트가 없을 때
postRepository.delete(post);//예외처리: 포스트 소유자가 아닐 때

private static Post createEntity(PostDto.Save createRequest, User user) {
return Post.builder()
.author(user)
.title(createRequest.getTitle())
.body(createRequest.getBody())
.thumbnail(createRequest.getThumbnail())
.mainCategory(MainCategory.valueOf(createRequest.getMainCategory()))
.subCategory(SubCategory.valueOf(createRequest.getSubCategory()))
.build();
}
}