forked from Soomin-Lim/be-java-web-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FEAT : jdbc 구현 및 테스트 * FEAT : 회원가입 기능 db 연동 * FEAT : 로그인 기능 db 연동 * FEAT : list 기능 db 연동 * FEAT : Html controller, htmlservice Autowired 처리 * FEAT : qna 등록 기능 구현 * FEAT : qna 홈페이지 출력 기능 구현 * FEAT : qna에 글쓴 시간 추가 * FEAT : 한줄 게시판이므로 qna title 삭제 * FEAT : 로그인한 사람만 질문 가능 할 수 있게 구현 * FEAT : 로그아웃 구현 * REFORMAT CODE * FEAT : qna 날짜순 정렬 구현 * REFACTOR : 필요없는 것 삭제 * FIX : logback.xml 이름 수정
- Loading branch information
Showing
27 changed files
with
456 additions
and
83 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//package bejavawebserver; | ||
// | ||
//import bejavawebserver.repository.JdbcRepository; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.context.annotation.Configuration; | ||
// | ||
//import javax.sql.DataSource; | ||
// | ||
// | ||
//@Configuration | ||
//public class SpringConfig { | ||
// private DataSource dataSource; | ||
// | ||
// @Autowired | ||
// public SpringConfig(DataSource dataSource){ | ||
// this.dataSource = dataSource; | ||
// } | ||
// | ||
// @Bean | ||
// public JdbcRepository jdbcRepository(){ | ||
// return new JdbcRepository(dataSource); | ||
// } | ||
//} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/bejavawebserver/controller/QnaController.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,25 @@ | ||
package bejavawebserver.controller; | ||
|
||
import bejavawebserver.model.Qna; | ||
import bejavawebserver.model.QnaForm; | ||
import bejavawebserver.service.QnaService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
@Controller | ||
public class QnaController { | ||
@Autowired | ||
QnaService qnaService; | ||
|
||
@PostMapping("/qna/form") | ||
public String writeQna(QnaForm qnaForm) { | ||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); | ||
qnaService.addQna(new Qna(qnaForm, time)); | ||
return "redirect:/index.html"; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package bejavawebserver.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class Qna { | ||
private String writer; | ||
private String contents; | ||
private String time; | ||
|
||
public Qna(QnaForm qnaForm, String time) { | ||
this.writer = qnaForm.getWriter(); | ||
this.contents = qnaForm.getContents(); | ||
this.time = time; | ||
} | ||
|
||
public Qna(String writer, String contents, String time) { | ||
this.writer = writer; | ||
this.contents = contents; | ||
this.time = time; | ||
} | ||
} |
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,17 @@ | ||
package bejavawebserver.model; | ||
|
||
import lombok.Data; | ||
import lombok.NonNull; | ||
|
||
@Data | ||
public class QnaForm { | ||
@NonNull | ||
private String writer; | ||
@NonNull | ||
private String contents; | ||
|
||
public QnaForm(@NonNull String writer, @NonNull String contents) { | ||
this.writer = writer; | ||
this.contents = contents; | ||
} | ||
} |
Oops, something went wrong.