-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from potenday-project/develop
면접 관련 주요 기능
- Loading branch information
Showing
32 changed files
with
765 additions
and
13 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/main/generated/com/chwipoClova/feedback/entity/QFeedback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.chwipoClova.feedback.entity; | ||
|
||
import static com.querydsl.core.types.PathMetadataFactory.*; | ||
|
||
import com.querydsl.core.types.dsl.*; | ||
|
||
import com.querydsl.core.types.PathMetadata; | ||
import javax.annotation.processing.Generated; | ||
import com.querydsl.core.types.Path; | ||
import com.querydsl.core.types.dsl.PathInits; | ||
|
||
|
||
/** | ||
* QFeedback is a Querydsl query type for Feedback | ||
*/ | ||
@Generated("com.querydsl.codegen.DefaultEntitySerializer") | ||
public class QFeedback extends EntityPathBase<Feedback> { | ||
|
||
private static final long serialVersionUID = -267482617L; | ||
|
||
private static final PathInits INITS = PathInits.DIRECT2; | ||
|
||
public static final QFeedback feedback = new QFeedback("feedback"); | ||
|
||
public final StringPath content = createString("content"); | ||
|
||
public final NumberPath<Long> feedbackId = createNumber("feedbackId", Long.class); | ||
|
||
public final DateTimePath<java.util.Date> modifyDate = createDateTime("modifyDate", java.util.Date.class); | ||
|
||
public final com.chwipoClova.qa.entity.QQa qa; | ||
|
||
public final DateTimePath<java.util.Date> regDate = createDateTime("regDate", java.util.Date.class); | ||
|
||
public final NumberPath<Integer> type = createNumber("type", Integer.class); | ||
|
||
public QFeedback(String variable) { | ||
this(Feedback.class, forVariable(variable), INITS); | ||
} | ||
|
||
public QFeedback(Path<? extends Feedback> path) { | ||
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS)); | ||
} | ||
|
||
public QFeedback(PathMetadata metadata) { | ||
this(metadata, PathInits.getFor(metadata, INITS)); | ||
} | ||
|
||
public QFeedback(PathMetadata metadata, PathInits inits) { | ||
this(Feedback.class, metadata, inits); | ||
} | ||
|
||
public QFeedback(Class<? extends Feedback> type, PathMetadata metadata, PathInits inits) { | ||
super(type, metadata, inits); | ||
this.qa = inits.isInitialized("qa") ? new com.chwipoClova.qa.entity.QQa(forProperty("qa"), inits.get("qa")) : null; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/java/com/chwipoClova/feedback/controller/FeedbackController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.chwipoClova.feedback.controller; | ||
|
||
public class FeedbackController { | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/com/chwipoClova/feedback/entity/Feedback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.chwipoClova.feedback.entity; | ||
|
||
|
||
import com.chwipoClova.qa.entity.Qa; | ||
import com.chwipoClova.user.entity.User; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import org.hibernate.annotations.DynamicInsert; | ||
|
||
import java.util.Date; | ||
|
||
@Entity(name = "Feedback") | ||
@Table(name = "Feedback") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties() | ||
@DynamicInsert | ||
@Builder | ||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Feedback { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "feedbackId") | ||
@Schema(description = "피드백 ID") | ||
private Long feedbackId; | ||
|
||
@Column(name = "type") | ||
@Schema(description = "피드백타입(1, 2, 3)") | ||
private Integer type; | ||
|
||
@Column(name = "content") | ||
@Schema(description = "피드백내용") | ||
private String content; | ||
|
||
@Column(name = "regDate") | ||
@Schema(description = "등록일") | ||
private Date regDate; | ||
|
||
@Column(name = "modifyDate") | ||
@Schema(description = "수정일") | ||
private Date modifyDate; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "qaId") | ||
private Qa qa; | ||
|
||
// @PrePersist 메서드 정의 (최초 등록시 호출) | ||
@PrePersist | ||
public void prePersist() { | ||
this.regDate = new Date(); // 현재 날짜와 시간으로 등록일 설정 | ||
} | ||
|
||
@PreUpdate | ||
public void preUpdate() { | ||
this.modifyDate = new Date(); // 현재 날짜와 시간으로 수정일 업데이트 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/chwipoClova/feedback/repository/FeedbackRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.chwipoClova.feedback.repository; | ||
|
||
import com.chwipoClova.feedback.entity.Feedback; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface FeedbackRepository extends JpaRepository<Feedback, Long> { | ||
|
||
List<Feedback> findByQaQaIdOrderByFeedbackId(Long qaId); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/chwipoClova/feedback/request/FeedbackDataInsertReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.chwipoClova.feedback.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class FeedbackDataInsertReq { | ||
|
||
@Schema(description = "피드백타입", example = "1", name = "type") | ||
private Integer type; | ||
|
||
@Schema(description = "피드백내용", example = "피드백1입니다.", name = "content") | ||
private String content; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/chwipoClova/feedback/request/FeedbackInsertReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.chwipoClova.feedback.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class FeedbackInsertReq { | ||
|
||
@Schema(description = "질문답변 ID", example = "1", name = "qaId") | ||
private Long qaId; | ||
|
||
@Schema(description = "질문", example = "질문1", name = "question") | ||
private String question; | ||
|
||
@Schema(description = "답변", example = "답변1", name = "answer") | ||
private String answer; | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/chwipoClova/feedback/request/FeedbackListReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.chwipoClova.feedback.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class FeedbackListReq { | ||
|
||
@Schema(description = "질문답변 ID", example = "1", name = "qaId") | ||
private Long qaId; | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/chwipoClova/feedback/response/FeedBackApiRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.chwipoClova.feedback.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class FeedBackApiRes { | ||
|
||
@Schema(description = "질문 ID", example = "1", name = "qaId") | ||
private Long qaId; | ||
|
||
@Schema(description = "피드백 타입", example = "1", name = "type") | ||
private Integer type; | ||
|
||
@Schema(description = "피드백 내용", example = "피드백1입니다.", name = "content") | ||
private String content; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/chwipoClova/feedback/response/FeedbackInsertRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.chwipoClova.feedback.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
import java.util.Date; | ||
|
||
@Data | ||
public class FeedbackInsertRes { | ||
@Schema(description = "질문답변 ID", example = "1", name = "qaId") | ||
private Long qaId; | ||
|
||
@Schema(description = "피드백 ID", example = "1", name = "feedbackId") | ||
private Long feedbackId; | ||
|
||
@Schema(description = "피드백 타입", example = "1", name = "type") | ||
private Integer type; | ||
|
||
@Schema(description = "피드백 내용", example = "피드백입니다.", name = "content") | ||
private String content; | ||
|
||
@Schema(description = "등록일", example = "2023-12-09T10:13:17.838+00:00", name = "regDate") | ||
private Date regDate; | ||
|
||
@Schema(description = "수정일", example = "2023-12-09T10:13:17.838+00:00", name = "modifyDate") | ||
private Date modifyDate; | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/chwipoClova/feedback/response/FeedbackListRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.chwipoClova.feedback.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.Date; | ||
|
||
@Data | ||
@Builder | ||
public class FeedbackListRes { | ||
@Schema(description = "질문답변 ID", example = "1", name = "qaId") | ||
private Long qaId; | ||
|
||
@Schema(description = "피드백 ID", example = "1", name = "feedbackId") | ||
private Long feedbackId; | ||
|
||
@Schema(description = "피드백 타입", example = "1", name = "type") | ||
private Integer type; | ||
|
||
@Schema(description = "피드백 내용", example = "피드백입니다.", name = "content") | ||
private String content; | ||
|
||
@Schema(description = "등록일", example = "2023-12-09T10:13:17.838+00:00", name = "regDate") | ||
private Date regDate; | ||
|
||
@Schema(description = "수정일", example = "2023-12-09T10:13:17.838+00:00", name = "modifyDate") | ||
private Date modifyDate; | ||
|
||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/com/chwipoClova/feedback/service/FeedbackService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.chwipoClova.feedback.service; | ||
|
||
import com.chwipoClova.common.exception.CommonException; | ||
import com.chwipoClova.common.exception.ExceptionCode; | ||
import com.chwipoClova.common.response.CommonResponse; | ||
import com.chwipoClova.common.response.MessageCode; | ||
import com.chwipoClova.feedback.entity.Feedback; | ||
import com.chwipoClova.feedback.repository.FeedbackRepository; | ||
import com.chwipoClova.feedback.request.FeedbackInsertReq; | ||
import com.chwipoClova.feedback.response.FeedBackApiRes; | ||
import com.chwipoClova.feedback.response.FeedbackListRes; | ||
import com.chwipoClova.qa.entity.Qa; | ||
import com.chwipoClova.qa.repository.QaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
@Slf4j | ||
public class FeedbackService { | ||
|
||
private final FeedbackRepository feedbackRepository; | ||
|
||
private final QaRepository qaRepository; | ||
|
||
@Transactional | ||
public CommonResponse insertFeedback(List<FeedbackInsertReq> feedbackInsertListReq) throws IOException { | ||
|
||
// TODO 피드백 연동 필요함 | ||
// 테스트 데이터 | ||
List<FeedBackApiRes> feedBackApiListRes = new ArrayList<>(); | ||
feedbackInsertListReq.stream().forEach(feedbackInsertReq -> { | ||
Long qaId = feedbackInsertReq.getQaId(); | ||
FeedBackApiRes feedBackApiRes = new FeedBackApiRes(); | ||
feedBackApiRes.setQaId(qaId); | ||
feedBackApiRes.setType(1); | ||
feedBackApiRes.setContent("피드백1입니다."); | ||
feedBackApiListRes.add(feedBackApiRes); | ||
FeedBackApiRes feedBackApiRes2 = new FeedBackApiRes(); | ||
feedBackApiRes2.setQaId(qaId); | ||
feedBackApiRes2.setType(2); | ||
feedBackApiRes2.setContent("피드백2입니다."); | ||
feedBackApiListRes.add(feedBackApiRes2); | ||
}); | ||
|
||
feedBackApiListRes.stream().forEach(feedBackApiRes -> { | ||
Long qaId = feedBackApiRes.getQaId(); | ||
Qa qa = qaRepository.findById(qaId).orElseThrow(() -> new CommonException(ExceptionCode.QA_NULL.getMessage(), ExceptionCode.QA_NULL.getCode())); | ||
|
||
Feedback feedback = Feedback.builder() | ||
.type(feedBackApiRes.getType()) | ||
.content(feedBackApiRes.getContent()) | ||
.qa(qa) | ||
.build(); | ||
feedbackRepository.save(feedback); | ||
}); | ||
|
||
return new CommonResponse<>(MessageCode.OK.getCode(), null, MessageCode.OK.getMessage()); | ||
} | ||
|
||
public List<FeedbackListRes> selectFeedbackList(Long qaId) { | ||
List<FeedbackListRes> feedbackListResList = new ArrayList<>(); | ||
|
||
List<Feedback> feedbackList = feedbackRepository.findByQaQaIdOrderByFeedbackId(qaId); | ||
feedbackList.stream().forEach(feedback -> { | ||
FeedbackListRes feedbackListRes = FeedbackListRes.builder() | ||
.qaId(feedback.getQa().getQaId()) | ||
.feedbackId(feedback.getFeedbackId()) | ||
.type(feedback.getType()) | ||
.content(feedback.getContent()) | ||
.regDate(feedback.getRegDate()) | ||
.modifyDate(feedback.getModifyDate()) | ||
.build(); | ||
feedbackListResList.add(feedbackListRes); | ||
}); | ||
return feedbackListResList; | ||
} | ||
|
||
} |
Oops, something went wrong.