Skip to content

Commit

Permalink
sse service
Browse files Browse the repository at this point in the history
  • Loading branch information
문준호 authored and 문준호 committed Oct 30, 2023
2 parents 5e99546 + 54b2289 commit 2cf8e9a
Show file tree
Hide file tree
Showing 27 changed files with 189 additions and 138 deletions.
Binary file modified .gradle/7.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
40 changes: 3 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
# JUST - 익명 고민 상담

# Just Mobile App

<p align="center">
주변 사람에게는 말 못할 고민을 털어 놓을 수 있는 공간, Just <br>
<a href="https://spring.io/projects/spring-boot"><img src="https://img.shields.io/badge/Spring_Boot-green.svg"></a>
<a href="https://jakarta.ee/specifications/persistence/2.2/"><img src="https://img.shields.io/badge/JPA-orange.svg"></a>
<a href="https://www.mysql.com/"><img src="https://img.shields.io/badge/MySQL-blue.svg"></a>
<a href="https://spring.io/projects/spring-security"><img src="https://img.shields.io/badge/Spring_Security-green.svg"></a>
<a href="https://aws.amazon.com/webservices/"><img src="https://img.shields.io/badge/AWS_Web_Service-orange.svg"></a>
<a href = "https://github.com/features/actions/"><img src = "https://img.shields.io/badge/GitHub_Actions-gray.svg?logo=github-actions"></a>
<a href = "https://oauth.net/2/"><img src = "https://img.shields.io/badge/OAuth-2.0-yellow.svg"></a>
<a href = "https://www.h2database.com/"><img src ="https://img.shields.io/badge/H2-Database-blue.svg"></a
</p>




## [](https://github.com/inje-megabrain/JUST-FE#%EA%B0%9C%EB%B0%9C-%EC%A7%84%ED%96%89%EC%A4%91%EC%9D%B8-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8%EC%9E%85%EB%8B%88%EB%8B%A4)





### 아키텍쳐 설계
<img width="760" alt="스크린샷 2023-04-09 오후 4 00 25" src="https://user-images.githubusercontent.com/96710732/230759149-f4082ea1-7d8b-46ab-a4f6-a5cd45411677.png">



## 주요 기능

- 기본적인 글쓰기, 좋아요, 무한스크롤 기능 구현
- 피드백을 위한 신고기능



### 기능 동작 영상
[![](https://github.com/inje-megabrain/JUST-FE/raw/main/readme_images/ui.gif)](https://github.com/inje-megabrain/JUST-FE/blob/main/readme_images/ui.gif)
## 프로젝트 목적

이 앱은 주변 사람들에게 털어놓기 어려운 걱정을 익명으로 공유하여 해소할 수 있는 플랫폼입니다. 이를 통해 당신은 누구에게도 말하지 못했던 걱정과 고민을 안전하게 나눌 수 있습니다. 앱 내에서 다른 사용자들과 대화를 나누고 충고를 구할 수 있으며, 이를 통해 당신은 더 나은 방향으로 나아갈 수 있게 됩니다. 이 앱은 당신의 고민을 더 이상 혼자 짊어지지 않도록 도와줄 것입니다.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-10-28T17:05:25+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 17.0.7 (Homebrew)"
date = "2023-10-30T14:06:10+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
)
@Component
public class MemberMapperImpl implements MemberMapper {
Expand Down
40 changes: 18 additions & 22 deletions src/main/generated/com/example/just/Mapper/PostMapperImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import com.example.just.Dao.Comment;
import com.example.just.Dao.Member;
import com.example.just.Dao.Post;
import com.example.just.Dto.PostDto;
import com.example.just.Dto.PutPostDto;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-10-28T17:05:25+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 17.0.7 (Homebrew)"
date = "2023-10-30T14:06:10+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
)
@Component
public class PostMapperImpl implements PostMapper {

@Override
public Post toEntity(PostDto dto) {
public Post toEntity(PutPostDto dto) {
if ( dto == null ) {
return null;
}
Expand All @@ -30,7 +30,6 @@ public Post toEntity(PostDto dto) {
post.setPost_tag( dto.getPost_tag() );
post.setPost_picture( dto.getPost_picture() );
post.setPost_create_time( dto.getPost_create_time() );
post.setPost_like( dto.getPost_like() );
post.setSecret( dto.getSecret() );
post.setEmoticon( dto.getEmoticon() );
post.setPost_category( dto.getPost_category() );
Expand All @@ -43,39 +42,36 @@ public Post toEntity(PostDto dto) {
if ( list1 != null ) {
post.setComments( new ArrayList<Comment>( list1 ) );
}
post.setBlamedCount( dto.getBlamedCount() );

return post;
}

@Override
public PostDto toDto(Post entity) {
public PutPostDto toDto(Post entity) {
if ( entity == null ) {
return null;
}

PostDto postDto = new PostDto();
PutPostDto putPostDto = new PutPostDto();

postDto.setPost_id( entity.getPost_id() );
postDto.setPost_content( entity.getPost_content() );
postDto.setPost_tag( entity.getPost_tag() );
postDto.setPost_like( entity.getPost_like() );
postDto.setPost_picture( entity.getPost_picture() );
postDto.setPost_create_time( entity.getPost_create_time() );
postDto.setSecret( entity.getSecret() );
postDto.setEmoticon( entity.getEmoticon() );
postDto.setPost_category( entity.getPost_category() );
putPostDto.setPost_id( entity.getPost_id() );
putPostDto.setPost_content( entity.getPost_content() );
putPostDto.setPost_tag( entity.getPost_tag() );
putPostDto.setPost_picture( entity.getPost_picture() );
putPostDto.setPost_create_time( entity.getPost_create_time() );
putPostDto.setSecret( entity.getSecret() );
putPostDto.setEmoticon( entity.getEmoticon() );
putPostDto.setPost_category( entity.getPost_category() );
List<Member> list = entity.getLikedMembers();
if ( list != null ) {
postDto.setLikedMembers( new ArrayList<Member>( list ) );
putPostDto.setLikedMembers( new ArrayList<Member>( list ) );
}
postDto.setMember( entity.getMember() );
putPostDto.setMember( entity.getMember() );
List<Comment> list1 = entity.getComments();
if ( list1 != null ) {
postDto.setComments( new ArrayList<Comment>( list1 ) );
putPostDto.setComments( new ArrayList<Comment>( list1 ) );
}
postDto.setBlamedCount( entity.getBlamedCount() );

return postDto;
return putPostDto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.example.just.Dao.Comment;
import com.example.just.Dto.CommentDto;
import com.example.just.Service.CommentService;
import com.example.just.jwt.JwtProvider;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -16,11 +18,17 @@ public class CommentController {
@Autowired
private CommentService commentService;

@Autowired
private JwtProvider jwtProvider;

@ApiOperation(value = "댓글 작성 API")
@PostMapping("/post/{postId}/comments")
public ResponseEntity<Comment> createComment(@PathVariable Long postId,
@RequestBody CommentDto commentDto,
@RequestParam Long member_id) {
HttpServletRequest req) {

String token = jwtProvider.getAccessToken(req);
Long member_id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰
Comment comment = commentService.createComment(postId, member_id, commentDto);
return ResponseEntity.ok(comment);
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/example/just/Controller/PostController.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.example.just.Controller;

import com.example.just.Dto.PostDto;

import com.example.just.Dto.PostPostDto;
import com.example.just.Dto.PutPostDto;
import com.example.just.Service.PostService;
import com.example.just.Service.ResponseGetPost;
import com.example.just.Service.ResponsePost;
Expand Down Expand Up @@ -37,6 +38,7 @@ public ResponseGetPost getPosts(@RequestParam Long request_page,
Long member_id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰

String cursor = req.getHeader("viewed");

return postService.searchByCursor(cursor, request_page, member_id);
}

Expand All @@ -55,11 +57,11 @@ public ResponseEntity<Slice<Post>> getMyPosts(
*/

@Operation(summary = "게시글 작성 api", description = "post_content, post_tag는 null값이 발생하면" +
" 안됨\n" + "다른 건 null이와도 예외처리 완료\n 자기가 쓴 글이면 true")
@Operation(summary = "게시글 작성 api", description = "RequestBody에 null값이 있으면 안됨"
+ "\n 공개글이면 true 아니라면 false")
@PostMapping("/post/post")
public ResponsePost write(HttpServletRequest request,
@RequestBody PostDto postDto) {
@RequestBody PostPostDto postDto) {
String token = jwtProvider.getAccessToken(request);
System.out.println(token + "ㅋㅋ");
Long member_id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰
Expand All @@ -75,12 +77,12 @@ public ResponsePost deletePost(@RequestParam Long post_id) {

@Operation(summary = "게시글 수정 api", description = "JSON넘길 때 null이 하나도 있으면 안됨 꼭 다채워서 넘기기")
@PutMapping("/put/post")
public ResponsePost putPost(@RequestParam Long post_id, HttpServletRequest request,
@RequestBody PostDto postDto) {
public ResponsePost putPost(HttpServletRequest request,
@RequestBody PutPostDto postDto) {
String token = jwtProvider.getAccessToken(request);

Long member_id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰
return postService.putPost(post_id, member_id, postDto);
return postService.putPost(member_id, postDto);
}

@Operation(summary = "게시글 좋아요 api", description = "\n 자기가 좋아요 한 글이면 true")
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/example/just/Dao/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.springframework.stereotype.Service;

import javax.persistence.*;
import java.sql.Timestamp;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/example/just/Dao/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.hibernate.annotations.OnDeleteAction;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

Expand All @@ -17,7 +18,7 @@
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class Notification{
public class Notification implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long notId;
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/example/just/Dto/CommentDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,15 @@
@Getter
@Setter
public class CommentDto {
private Long comment_id; //댓글 아이디

private String comment_content; //댓글 내용

private LocalDateTime comment_create_time; //댓글 작성 시간

private Long comment_like; //추천수

private Long comment_dislike; //비추천수

private Long member_id;

private Long parentCommentId;
public CommentDto() {
}

public CommentDto(Comment comment) {
this.comment_id = comment_id;
this.comment_content = comment_content;
this.comment_create_time = comment_create_time;
this.comment_like = comment_like;
this.comment_dislike = comment_dislike;
this.member_id=member_id;
this.parentCommentId = comment.getParent() == null ? null : comment.getParent().getComment_id();
}
}
6 changes: 2 additions & 4 deletions src/main/java/com/example/just/Dto/MemberDto.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package com.example.just.Dto;
import com.example.just.Dao.Post;
import com.example.just.Dao.Role;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import lombok.*;
import org.hibernate.annotations.CreationTimestamp;

import javax.persistence.*;

//로그인 할 때 사용할 Dto
@Builder
Expand All @@ -38,7 +34,9 @@ public class MemberDto {

private int blameCount;

@Builder.Default
private List<Post> likedPosts = new ArrayList<>();

@Builder.Default
private List<Post> posts = new ArrayList<>();
}
7 changes: 4 additions & 3 deletions src/main/java/com/example/just/Dto/NotificationDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
import lombok.Setter;


import java.io.Serializable;
import java.util.Date;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class NotificationDto {
public class NotificationDto implements Serializable {

private String not_type; //알림 타입

private Long not_post_id; //알림 내용

private Date not_datetime; //알림 발생 시일

private Member Receiver; //알림이 발생한 글
private Long receiver; //알림이 발생한 글

private Long senderId; //알림 송신자

Expand All @@ -31,7 +32,7 @@ public static NotificationDto create(Notification notification){
notification.getNotType(),
notification.getNotPostId(),
notification.getNotDatetime(),
notification.getReceiver(),
notification.getReceiver().getId(),
notification.getSenderId()
);
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/com/example/just/Dto/PostDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@

import com.example.just.Dao.Comment;
import com.example.just.Dao.Member;
import com.example.just.Dao.Notification;
import com.example.just.Dao.Post;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Getter
Expand Down
Loading

0 comments on commit 2cf8e9a

Please sign in to comment.