Skip to content
Snippets Groups Projects
Commit 690a2d21 authored by Gwan Ju's avatar Gwan Ju
Browse files

Merge branch 'master' into 'kkj'

# Conflicts:
#   src/main/java/umc/spring/post/service/PostServiceImpl.java
parents f5563a7e 89154021
Branches
No related tags found
1 merge request!3refactor: enhance JWT token-based authentication for user login, post...
......@@ -17,6 +17,7 @@ public class SecurityUtil {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || authentication.getName() == null) {
System.out.println("2번");
throw new RuntimeException("No authentication information.");
}
MyUser myUser = (MyUser) authentication.getPrincipal();
......
package umc.spring.post.data.entity;
import jakarta.persistence.*;
public class Like {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "user_id")
private Long userId;
@ManyToOne
@JoinColumn(name = "post_id")
private Long postId;
}
package umc.spring.post.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import umc.spring.post.data.entity.Like;
public interface LikeRepository extends JpaRepository<Like,Long> {
}
......@@ -11,6 +11,7 @@ import umc.spring.post.data.dto.PostResDto;
import umc.spring.post.data.dto.UserInfoDto;
import umc.spring.post.data.entity.Comment;
import umc.spring.post.data.entity.Post;
import umc.spring.post.data.entity.User;
import umc.spring.post.repository.CommentRepository;
import umc.spring.post.repository.PostRepository;
import umc.spring.post.repository.UserRepository;
......@@ -118,6 +119,8 @@ public class PostServiceImpl implements PostService{
}
@Override
public void likeCrew(Long id) {
UserInfoDto userInfoDto = getCurrentMemberId();
Post post = postRepository.findById(id).orElseThrow(() -> new RuntimeException("id가 존재하지 않습니다."));
int likeCount = post.getLikeCount();
post.setLikeCount(++likeCount);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment