diff --git a/src/main/java/com/example/healthylife/config/jwt/JwtAuthenticationFilter.java b/src/main/java/com/example/healthylife/config/jwt/JwtAuthenticationFilter.java index d789350..8215cc3 100644 --- a/src/main/java/com/example/healthylife/config/jwt/JwtAuthenticationFilter.java +++ b/src/main/java/com/example/healthylife/config/jwt/JwtAuthenticationFilter.java @@ -20,7 +20,7 @@ //역할: HTTP 요청의 JWT 인증 처리 @Slf4j @RequiredArgsConstructor -public class JwtAuthenticationFilter extends GenericFilterBean { +public class JwtAuthenticationFilter extends GenericFilterBean { private final JwtUtil jwtUtil; diff --git a/src/main/java/com/example/healthylife/controller/CommunityController.java b/src/main/java/com/example/healthylife/controller/CommunityController.java index d997e95..e83da38 100644 --- a/src/main/java/com/example/healthylife/controller/CommunityController.java +++ b/src/main/java/com/example/healthylife/controller/CommunityController.java @@ -70,8 +70,8 @@ public Boolean delete(@RequestParam long communitySq) { } @ApiOperation(value = "커뮤니티 단일조회") - @GetMapping("/communitySq") - public ResponseEntity getCommunityBySq(@RequestParam Long communitySq) { + @GetMapping("/communitySq/{community}") + public ResponseEntity getCommunityBySq(@PathVariable Long communitySq) { try { Optional community = communityService.findCommunityBySq(communitySq); if (community.isPresent()) { @@ -87,9 +87,9 @@ public ResponseEntity getCommunityBySq(@RequestParam Long commu // 커뮤니티 글 조회수 @ApiOperation(value = "커뮤니티 글 추천") - @PostMapping("/recommend") - public ResponseEntity recommendCommunity(@RequestParam Long sq) { - communityService.incrementRecommend(sq); + @PostMapping("/view/{sq}") + public ResponseEntity Communityview(@PathVariable Long sq) { + communityService.incrementview(sq); return ResponseEntity.ok().build(); } } diff --git a/src/main/java/com/example/healthylife/entity/CommunityEntity.java b/src/main/java/com/example/healthylife/entity/CommunityEntity.java index 262dd1c..ee35ebd 100644 --- a/src/main/java/com/example/healthylife/entity/CommunityEntity.java +++ b/src/main/java/com/example/healthylife/entity/CommunityEntity.java @@ -36,9 +36,9 @@ public class CommunityEntity implements Serializable { private Date communityCreated; //커뮤니티 글 조회수 - //communityCheck - @Column(name = "community_check", length = 200) - private long communityCheck; + //communityview + @Column(name = "communityview", length = 200 ) + private int communityview; //커뮤니티 글 추천수 //communityRecommend @@ -57,12 +57,12 @@ public class CommunityEntity implements Serializable { //builder @Builder(toBuilder = true) - public CommunityEntity(long communitySq, String communityTitle, String communityContents, Date communityCreated, long communityCheck, long communityRecommend, UserEntity user){ + public CommunityEntity(long communitySq, String communityTitle, String communityContents, Date communityCreated, int communityview, long communityRecommend, UserEntity user){ this.communitySq= communitySq; this.communityTitle = communityTitle; this.communityContents = communityContents; this.communityCreated = communityCreated; - this.communityCheck = communityCheck; + this.communityview = communityview; this.communityRecommend = communityRecommend; this.user = user; } diff --git a/src/main/java/com/example/healthylife/repository/CommunityRepository.java b/src/main/java/com/example/healthylife/repository/CommunityRepository.java index 9b67903..00899df 100644 --- a/src/main/java/com/example/healthylife/repository/CommunityRepository.java +++ b/src/main/java/com/example/healthylife/repository/CommunityRepository.java @@ -2,7 +2,6 @@ import com.example.healthylife.entity.CommunityEntity; -import com.example.healthylife.entity.UserEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; @@ -15,16 +14,16 @@ public interface CommunityRepository extends JpaRepository { public List findByCommunitySqAndCommunityTitle(long communitySq, String communityTitle); -//jpaQUERY + //jpaQUERY @Query("SELECT community FROM CommunityEntity community " + "WHERE community.communityTitle = :param") public CommunityEntity findMyStyleBySQL(String param); -//native query + //native query @Query(value = "SELECT * FROM community " + "WHERE community_title = :param", nativeQuery = true) public CommunityEntity findMyStyleByNativeSQL(String param); -//내가 작성한 글 조회 + //내가 작성한 글 조회 List findByUserUserId(String userId); // 커뮤니티 단일조회 @@ -32,6 +31,6 @@ public interface CommunityRepository extends JpaRepository findCommunityBySq(Long communitySq) { return community; } - // 커뮤니티 추천 + // 커뮤니티 조회수 @Transactional - public void incrementRecommend(Long communitySq) { - communityRepository.incrementCommunityRecommend(communitySq); + public void incrementview(Long communitySq) { + communityRepository.incrementCommunityview(communitySq); }