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

✨ [feature] #25 - 회원 쪽지 보내기 API 구현 #32

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d199fcf
:wrench Chore: User 도메인 폴더 추가
karryred Jul 25, 2024
6f0acc6
:sparkles: Feat: MessageRestController 생성 및 Message 도메인 필요 폴더 추가
karryred Jul 25, 2024
3dabd2a
:sparkles: MessageDTO 생성
karryred Jul 25, 2024
6b13333
:recycle: MessageRestController 하드코딩용 userId 변수 추가
karryred Jul 25, 2024
be899fe
:recycle: Message 엔티티 필드 수정 및 Message 타입 enum 생성
karryred Jul 25, 2024
965fb99
:sparkles: Feat: UserRepository 생성
karryred Jul 26, 2024
b91fb90
:sparkles: Feat: MessageRepository 생성
karryred Jul 27, 2024
806ab22
:sparkles: Feat: MessageBodyRepository 생성
karryred Jul 27, 2024
33038f0
:recycle: Refactor: Message myId, otherId 필드 이름 변경
karryred Jul 27, 2024
b2ef1d3
:recycle: Refactor: 반환 타입 List<Message>로 변경
karryred Jul 27, 2024
06d1b96
:recycle: Refactor: Message 테이블 변수 변경에 의해 User 테이블 mappedBy 변경
karryred Jul 27, 2024
f9d006e
:sparkles: Feat: MessageBodyConverter 생성
karryred Jul 27, 2024
cb41449
:recycle: Refactor: MessageBody 엔티티 빌더 생성자 추가
karryred Jul 27, 2024
743ff12
:sparkles: Feat: UserErrorStatus 생성
karryred Jul 28, 2024
4621411
:sparkles: Feat: UserConverter 생성
karryred Jul 28, 2024
22c2ab0
:recycle: Refactor: MessageDTO 수정
karryred Jul 28, 2024
6175dcc
:recycle: Refactor: MessageRestController @Valid 추가
karryred Jul 28, 2024
2d46fd1
:sparkles: Feat: MessageConverter 생성
karryred Jul 28, 2024
86e5c88
:sparkles: Feat: MessageCommandService 생성
karryred Jul 28, 2024
b554ec0
:sparkles: Feat: MessageCommandService 생성
karryred Jul 28, 2024
ecbb2ef
:refactor: Recycle: User sentMessages 와 receeivedMessage mappedBy 필드 수정
karryred Jul 28, 2024
1d7332a
:refactor: Recycle: DTO 이름 변경
karryred Jul 28, 2024
4b3c419
:recycle: Refactor: Merge 충돌 해결
karryred Jul 28, 2024
f44b98c
:recycle: Refactor: Merge 충돌 해결2
karryred Jul 28, 2024
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
11 changes: 4 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
## PR 타입(하나 이상의 PR 타입을 선택해주세요)
### PR 타입(하나 이상의 PR 타입을 선택해주세요)
- [ ] 기능 추가
- [ ] 기능 삭제
- [ ] 버그 수정
- [ ] 의존성, 환경 변수, 빌드 관련 코드 업데이트

## 반영 브랜치
### 반영 브랜치
ex) feat/login -> develop

## 변경 사항
### 변경 사항
ex) 로그인 시, 구글 소셜 로그인 기능을 추가했습니다.

## 이슈
-

## 테스트 결과
### 테스트 결과
ex) 베이스 브랜치에 포함되기 위한 코드는 모두 정상적으로 동작해야 합니다. 결과물에 대한 스크린샷, GIF, 혹은 라이브 데모가 가능하도록 샘플API를 첨부할 수도 있습니다.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' //Swagger 의존성 추가
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' // AWS 서비스 의존성 추가
implementation 'org.springframework.boot:spring-boot-starter-validation' // validation

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gaji/service/ServiceApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.TimeZone;

@EnableJpaAuditing
@SpringBootApplication
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class ServiceApplication {

public static void main(String[] args) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/gaji/service/config/AmazonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public class AmazonConfig {
@Value("${cloud.aws.region.static}")
private String region;

@Value("${cloud.aws.s3.bucket}")
@Value("${cloud.aws.s3.bucket")
private String bucket;

@Value("${cloud.aws.s3.path.blog}")
@Value("${cloud.aws.s3.path.blog")
private String blogPath;

@Value("${cloud.aws.s3.path.project}")
@Value("${cloud.aws.s3.path.project")
private String projectPath;

@Value("${cloud.aws.s3.path.question}")
@Value("${cloud.aws.s3.path.question")
private String questionPath;

@Value("${cloud.aws.s3.path.study}")
@Value("${cloud.aws.s3.path.study")
private String studyPath;

@PostConstruct
Expand Down
1 change: 1 addition & 0 deletions src/main/java/gaji/service/domain/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gaji.service.domain.enums.ReportPostEnum;
import gaji.service.domain.enums.ReportPostTypeEnum;
import gaji.service.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gaji/service/domain/alram/Alarm.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gaji.service.domain.alram;

import gaji.service.domain.User;
import gaji.service.domain.user.entity.User;
import gaji.service.domain.enums.IsConfirmed;
import jakarta.persistence.*;
import lombok.AccessLevel;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/gaji/service/domain/alram/UserAlarm.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gaji.service.domain.alram;

import gaji.service.domain.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package gaji.service.domain.common.entity;
package gaji.service.domain.common;

import jakarta.persistence.Column;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import java.time.LocalDateTime;

public abstract class BaseEntity {
public class BaseEntity {
@CreatedDate
@Column(updatable = false)
private LocalDateTime createdAt;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

32 changes: 1 addition & 31 deletions src/main/java/gaji/service/domain/enums/PostStatusEnum.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
package gaji.service.domain.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Getter
@Slf4j
public enum PostStatusEnum {
RECRUITING("모집중"),
RECRUITMENT_COMPLETED("모집완료"),
NEED_RESOLUTION("해결필요"),
RESOLVED("해결완료"),
DELETED("삭제됨"),
POSTING("게시중");

@JsonValue
private final String value;

PostStatusEnum(String value) {
this.value = value;
}

@JsonCreator // Json -> Object, 역직렬화 수행하는 메서드
public static PostStatusEnum from(String param) {
for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
if (postStatusEnum.getValue().equals(param)) {
return postStatusEnum;
}
}
log.error("PostStatusEnum.from() exception occur param: {}", param);
return null;
}
RECRUITING, RECRUITMENT_COMPLETED, NEED_RESOLUTION, RESOLVED, DELETED
}
29 changes: 1 addition & 28 deletions src/main/java/gaji/service/domain/enums/PostTypeEnum.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
package gaji.service.domain.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Getter
@Slf4j
public enum PostTypeEnum {
BLOG("블로그"),
PROJECT_RECRUITMENT("프로젝트 모집"),
QUESTION("질문");

@JsonValue
private final String value;

PostTypeEnum(String value) {
this.value = value;
}

@JsonCreator // Json -> Object, 역직렬화 수행하는 메서드
public static PostTypeEnum from(String param) {
for (PostTypeEnum postTypeEnum : PostTypeEnum.values()) {
if (postTypeEnum.getValue().equals(param)) {
return postTypeEnum;
}
}
log.error("PostTypeEnum.from() exception occur param: {}", param);
return null;
}
BLOG, PROJECT_RECRUITMENT, RECRUITMENT

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gaji.service.domain.message.converter;

import gaji.service.domain.message.entity.MessageBody;
import gaji.service.domain.message.web.dto.MessageRequestDTO;

public class MessageBodyConverter {
public static MessageBody toMessageBody(MessageRequestDTO.CreateMessageDTO messageRequestDTO){
return MessageBody.builder()
.body(messageRequestDTO.getBody())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package gaji.service.domain.message.converter;

import gaji.service.domain.message.entity.Message;
import gaji.service.domain.message.enums.MessageTypeEnum;
import gaji.service.domain.message.web.dto.MessageRequestDTO;
import gaji.service.domain.message.web.dto.MessageResponseDTO;
import gaji.service.domain.user.entity.User;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

public class MessageConverter {
public static MessageResponseDTO.CreateResultDTO toCreateResultDTO(List<Message> messageList){
List<Long> messageIds = messageList.stream()
.map(Message::getId)
.collect(Collectors.toList());

return MessageResponseDTO.CreateResultDTO.builder()
.messageIds(messageIds)
.build();
}

public static Message toSendMessage(User mine, User other){
return Message.builder()
.mine(mine)
.other(other)
.type(MessageTypeEnum.Send)
.sendDate(LocalDateTime.now())
.build();
}

public static Message toReceiveMessage(User mine, User other){
return Message.builder()
.mine(other)
.other(mine)
.type(MessageTypeEnum.Receive)
.sendDate(LocalDateTime.now()).
build();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package gaji.service.domain.message;
package gaji.service.domain.message.entity;

import gaji.service.domain.User;
import gaji.service.domain.message.enums.MessageTypeEnum;
import gaji.service.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -21,20 +23,31 @@ public class Message {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "my_id", referencedColumnName = "user_id")
private User sender;
private User self;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "other_id", referencedColumnName = "user_id")
private User receiver;
private User other;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "message_body_id")
private MessageBody messageBody;

private Boolean type;
private MessageTypeEnum type;
private LocalDateTime readDate;
private LocalDateTime sendDate;


@Builder
public Message(User mine, User other, MessageTypeEnum type, LocalDateTime sendDate) {
this.self = mine;
this.other = other;
this.type = type;
this.sendDate = sendDate;
}

public void setMessageBody(MessageBody messageBody) {
this.messageBody = messageBody;
messageBody.getMessageList().add(this);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package gaji.service.domain.message;
package gaji.service.domain.message.entity;

import gaji.service.domain.user.entity.User;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -21,4 +23,8 @@ public class MessageBody {

private String body;

@Builder
public MessageBody(String body) {
this.body = body;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package gaji.service.domain.message.enums;

public enum MessageTypeEnum {
Send, Receive
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gaji.service.domain.message.repository;

import gaji.service.domain.message.entity.MessageBody;
import org.springframework.data.jpa.repository.JpaRepository;

public interface MessageBodyRepository extends JpaRepository<MessageBody, Long> {
}
Loading