Skip to content

Commit

Permalink
feat: 충돌 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoon-Jemin committed Jan 22, 2024
2 parents 9488a0e + 626930c commit 58b6012
Show file tree
Hide file tree
Showing 18 changed files with 560 additions and 180 deletions.
21 changes: 0 additions & 21 deletions src/main/java/aromanticcat/umcproject/config/AppConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package aromanticcat.umcproject.converter;

import aromanticcat.umcproject.entity.NangmanLetter;
import aromanticcat.umcproject.entity.NangmanReply;
import aromanticcat.umcproject.web.dto.NangmanPostBoxRequestDTO;
import aromanticcat.umcproject.web.dto.NangmanPostBoxResponseDTO;

public class NangmanPostBoxConverter {

//낭만 레터 엔티티 -> DTO 생성
public static NangmanPostBoxResponseDTO.SendLetterResultDTO toSendLetterResultDTO(NangmanLetter nangmanLetter){

return NangmanPostBoxResponseDTO.SendLetterResultDTO.builder()
.nangmanLetterId(nangmanLetter.getId())
.senderNickname(nangmanLetter.getSenderNickname())
.createdAt(nangmanLetter.getCreatedAt())
.build();
}

//낭만 레터 DTO -> 엔티티 생성
public static NangmanLetter toNangmanLetterResult(NangmanPostBoxRequestDTO.SendLetterDTO request){
return NangmanLetter.builder()
.isPublic(request.getIsPublic())
.content(request.getContent())
.senderNickname(request.getSenderRandomNickname())
// .member(request.getMember())
.build();
}

//낭만 레터 엔티티 -> 프리뷰 낭만 레터 DTO 생성
public static NangmanPostBoxResponseDTO.LetterSummaryResultDTO toLetterSummaryResultDTO(NangmanLetter nangmanLetter){
// 편지 내용을 40자 까지만 보이도록
String content = nangmanLetter.getContent();
String preview = content.length() <= 40 ? content: content.substring(0, 40) + "...";

return NangmanPostBoxResponseDTO.LetterSummaryResultDTO.builder()
.nangmanLetterId(nangmanLetter.getId())
.preview(preview)
.createdAt(nangmanLetter.getCreatedAt())
.build();
}

//낭만 레터 엔티티 + 랜덤 닉네임 -> 낭만 리플라이 DTO 생성
public static NangmanPostBoxResponseDTO.SelectedLetterResultDTO toReplyLetterResultDTO(NangmanLetter nangmanLetter, String randomNickname){
return NangmanPostBoxResponseDTO.SelectedLetterResultDTO.builder()
.nangmanLetterId(nangmanLetter.getId())
.nangmanLetterContent(nangmanLetter.getContent())
.senderNickname(nangmanLetter.getSenderNickname())
.replySenderNickname(randomNickname)
.build();
}

// 낭만 리플라이 DTO -> 낭만 리플라이 엔티티
public static NangmanReply toNangmanReplyResult(NangmanPostBoxRequestDTO.ReplyLetterDTO request, NangmanLetter nangmanLetter){
return NangmanReply.builder()
.content(request.getReplyContent())
.replySenderNickname(request.getReplySenderNickname())
.nangmanLetter(nangmanLetter)
// .member(request.getMember())
.build();

}

public static NangmanPostBoxResponseDTO.SendReplyResultDTO toSendReplyResultDTO(NangmanReply nangmanReply){
return NangmanPostBoxResponseDTO.SendReplyResultDTO.builder()
.nangmanReplyId(nangmanReply.getId())
.nangmanLetterId(nangmanReply.getNangmanLetter().getId())
.replySenderNickname(nangmanReply.getReplySenderNickname())
.createdAt(nangmanReply.getCreatedAt())
.build();
}



}
42 changes: 42 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Letter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package aromanticcat.umcproject.entity;

import lombok.Getter;

import javax.persistence.*;
import java.time.LocalDateTime;

@Entity
@Getter
@Table(name = "letter")
public class Letter extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long letter_id;

@Column(name = "nickname", length = 60)
private String nickname;

@Column(length = 255)
private String content;

private Boolean open;

@Column(name = "login_status")
private Boolean loginStatus;

@Column(name = "sender_ID")
private Long senderId;

@ManyToOne
@JoinColumn(name = "letter_paper_id",insertable = false, updatable = false)
private LetterPaper letterPaper;

@ManyToOne
@JoinColumn(name = "stamp_id", insertable = false, updatable = false)
private Stamp stamp;

@ManyToOne
@JoinColumn(name = "id", insertable = false, updatable = false)
private Letterbox letterbox;
}
26 changes: 26 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/LetterPaper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package aromanticcat.umcproject.entity;

import lombok.Getter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;

@Entity
@Getter
@Table(name = "letter_paper")
public class LetterPaper extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long letter_paper_id;

@NotNull
private String image_url;

@NotNull
private String name;

@OneToMany(mappedBy = "letterPaper")
private List<Letter> letters;
}
38 changes: 38 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Letterbox.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package aromanticcat.umcproject.entity;

import lombok.Getter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;

@Entity
@Getter
@Table(name = "letterbox")
public class Letterbox extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long letterbox_id;

@Column(name = "user_id", nullable = false)
private Long userId;

@NotNull
private String name;
@NotNull
private String color;

@NotNull
@Column(name = "end_dt")
private LocalDateTime endDt;

@NotNull
private Boolean activate;

@NotNull
private Boolean sender;

@OneToMany(mappedBy = "letterbox")
private List<Letter> letters;
}
22 changes: 11 additions & 11 deletions src/main/java/aromanticcat/umcproject/entity/NangmanLetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,35 @@ public class NangmanLetter extends BaseEntity {
private Long id;

@NotNull
private String sender_nickname;
private String senderNickname;

@NotNull
private Boolean is_public;
private Boolean isPublic;

@NotNull
private String content;

@NotNull
@Builder.Default
private Boolean has_response = false;
private Boolean hasResponse = false;

private Integer thumbs_up_cnt;
private Integer thumbsUpCnt;

private Integer heart_cnt;
private Integer heartCnt;

private Integer crying_cnt;
private Integer cryingCnt;

private Integer clover_cnt;
private Integer cloverCnt;

private Integer clap_cnt;
private Integer clapCnt;

private Integer star_cnt;
private Integer starCnt;

@JoinColumn(name = "member_id")
@ManyToOne(fetch = FetchType.LAZY)
private Member member;

public void change(Boolean has_response){
this.has_response = has_response;
public void change(Boolean hasResponse){
this.hasResponse = hasResponse;
}
}
21 changes: 11 additions & 10 deletions src/main/java/aromanticcat/umcproject/entity/NangmanReply.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package aromanticcat.umcproject.entity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import lombok.Getter;
import lombok.*;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Entity
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class NangmanReply extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String response_sender_nickname;
@NotNull
private String replySenderNickname;

@NotNull
private String content;

@JoinColumn(name = "letter_id")
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/aromanticcat/umcproject/entity/Stamp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package aromanticcat.umcproject.entity;

import lombok.Getter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;

@Entity
@Getter
@Table(name = "stamp")
public class Stamp extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long stamp_id;

@NotNull
private String image_url;

@NotNull
private String name;

@OneToMany(mappedBy = "stamp")
private List<Letter> letters;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
import aromanticcat.umcproject.entity.NangmanLetter;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface NangmanLetterRepository extends JpaRepository<NangmanLetter, Long> {

List<NangmanLetter> findByHasResponseFalse();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package aromanticcat.umcproject.repository;

import aromanticcat.umcproject.entity.NangmanReply;
import org.springframework.data.jpa.repository.JpaRepository;

public interface NangmanReplyRepository extends JpaRepository<NangmanReply, Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package aromanticcat.umcproject.service;

import aromanticcat.umcproject.entity.NangmanLetter;
import aromanticcat.umcproject.entity.NangmanReply;
import aromanticcat.umcproject.web.dto.NangmanPostBoxRequestDTO;

import java.util.List;

public interface NangmanPostBoxService {

NangmanLetter writeAndSendLetter(NangmanPostBoxRequestDTO.SendLetterDTO requestDTO);

List<NangmanLetter> getLetterList();

NangmanLetter getLetterById(Long id);

NangmanReply writeAndSendReply(NangmanPostBoxRequestDTO.ReplyLetterDTO requestDTO, Long id);

// NangmanLetterDTO readOne(Long id);
//
// void receivedReply(NangmanLetterDTO nangmanLetterDTO);
}
Loading

0 comments on commit 58b6012

Please sign in to comment.