Skip to content
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
4 changes: 4 additions & 0 deletions buildDockerWindow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker buildx build --platform linux/amd64 -t comncheck/spring-backend-oauth:1.0.5 .

11 changes: 0 additions & 11 deletions src/main/java/com/ComNCheck/ComNCheck/ComNCheckApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ComNCheck.ComNCheck;

import io.github.cdimascio.dotenv.Dotenv;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

Expand All @@ -9,16 +8,6 @@ public class ComNCheckApplication {

public static void main(String[] args) {

//Load .env file
Dotenv dotenv = Dotenv.load();
System.setProperty("H2_DB_URL", dotenv.get("H2_DB_URL"));
System.setProperty("DB_USERNAME", dotenv.get("DB_USERNAME"));
System.setProperty("DB_PASSWORD", dotenv.get("DB_PASSWORD"));
System.setProperty("JWT_SECRET", dotenv.get("JWT_SECRET"));
System.setProperty("GOOGLE_CLIENT_ID", dotenv.get("GOOGLE_CLIENT_ID"));
System.setProperty("GOOGLE_CLIENT_SECRET", dotenv.get("GOOGLE_CLIENT_SECRET"));
System.setProperty("JWT_EXPIRATIONMS",dotenv.get("JWT_EXPIRATIONMS"));
System.setProperty("GOOGLE_REDIRECT_URI",dotenv.get("GOOGLE_REDIRECT_URI"));
SpringApplication.run(ComNCheckApplication.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public ResponseEntity<QuestionResponseDTO> getQuestion(@PathVariable Long majorQ
}

@GetMapping
@Operation(summary = "fAQ의 답변이 달린 게시글 목록 조회", description = "댓글이 달린 모든 게시글 목록을 조회한다.")
@Operation(summary = "fAQ의 답변이 달린 게시글 목록 조회 공유가 true 인 경우만"
, description = "댓글이 달린 모든 게시글 목록을 조회한다.")
public ResponseEntity<List<QuestionResponseDTO>> getAllQuestion() {
List<QuestionResponseDTO> questions = questionService.getQuestionsWithAnswer();
return ResponseEntity.ok(questions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
public class QuestionRequestDTO {
private String title;
private String content;

private boolean shared;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public class QuestionResponseDTO {
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
private AnswerResponseDTO answer;
private boolean shared;

public static QuestionResponseDTO of(Question question) {
return QuestionResponseDTO.builder()
.id(question.getId())
.title(question.getTitle())
.content(question.getContent())
.shared(question.isShared())
//.writerId(question.getWriter().getId())
.createdAt(question.getCreatedAt())
.updatedAt(question.getUpdatedAt())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class Question {
@Column(nullable = false)
private String content;

@Column(nullable = false)
private boolean shared;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "writer_id")
private Member writer;
Expand All @@ -48,13 +51,10 @@ public class Question {
@Column
private LocalDateTime updatedAt;

// @Column
// private boolean


/*
연관관계 편의 메서드
*/

public void setAnswer(Answer answer) {
this.answer = answer;
answer.setQuestion(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.ComNCheck.ComNCheck.domain.majorQuestion.model.entity.Question;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface QuestionRepository extends JpaRepository<Question, Long> {
List<Question> findAllByWriterMemberId(Long writerId);
List<Question> findByAnswerIsNotNull();
Optional<Question> findByIdAndSharedTrue(Long id);
List<Question> findByAnswerIsNotNullAndSharedTrue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public QuestionResponseDTO createQuestion(QuestionRequestDTO requestDTO, Long me
Question question = Question.builder()
.title(requestDTO.getTitle())
.content(requestDTO.getContent())
.shared(requestDTO.isShared())
.writer(writer)
.build();

Expand All @@ -44,7 +45,7 @@ public QuestionResponseDTO getQuestion(Long questionId) {

public List<QuestionResponseDTO> getQuestionsWithAnswer() {

return questionRepository.findByAnswerIsNotNull()
return questionRepository.findByAnswerIsNotNullAndSharedTrue()
.stream()
.map(QuestionResponseDTO::of)
.toList();
Expand Down