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

Feat/17 #28

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-ui:1.6.15'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'

// model mapper
implementation 'org.modelmapper:modelmapper:3.1.0'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package aromanticcat.umcproject.converter;

import aromanticcat.umcproject.entity.NangmanLetter;
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();
}



}
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;
}
1 change: 0 additions & 1 deletion src/main/java/aromanticcat/umcproject/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Member extends BaseEntity {

@Id
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/aromanticcat/umcproject/entity/NangmanLetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +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 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,19 @@
package aromanticcat.umcproject.service;

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

import java.util.List;

public interface NangmanPostBoxService {

NangmanLetter writeAndSendLetter(NangmanPostBoxRequestDTO.SendLetterDTO requestDTO, String randomNickname);

List<NangmanLetter> getLetterList();

NangmanLetter getLetterById(Long id);

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