Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4018cbe
feat: /introduce 요청 시 자기소개 HTML 반환 구현
Kim-Dohun148 Nov 8, 2025
fe3b927
feat: 자기소개 HTML 생성
Kim-Dohun148 Nov 8, 2025
07a3f38
refactor: /introduce 요청 시 자기소개 HTML 반환 수정
Kim-Dohun148 Nov 8, 2025
595adc9
feat: /introduce?name=이름 요청 시 텍스트(이름) 반환 구현
Kim-Dohun148 Nov 8, 2025
9b01d8a
feat: User 클래스 생성
Kim-Dohun148 Nov 8, 2025
2aaa911
feat: json 요청 시 응답 반환 구현
Kim-Dohun148 Nov 8, 2025
1b90068
feat: CRUD_API 클래스 생성
Kim-Dohun148 Nov 8, 2025
b76f663
feat: User 클래스 id변수, 메소드 기능 추가
Kim-Dohun148 Nov 8, 2025
91b93b6
feat: CRUD_API 클래스 데이터 초기화 메소드 init 구현
Kim-Dohun148 Nov 8, 2025
6d179ea
feat: CRUD_API 클래스 GET API 구현
Kim-Dohun148 Nov 8, 2025
772f1bb
feat: CRUD_API 클래스 PUT API 구현
Kim-Dohun148 Nov 8, 2025
3d63f29
feat: CRUD_API 클래스 DELETE API 구현
Kim-Dohun148 Nov 8, 2025
be61f88
refactor: CRUD_API 클래스 PUT 수정
Kim-Dohun148 Nov 8, 2025
82941e1
feat: CRUD_API 클래스 POST 구현
Kim-Dohun148 Nov 8, 2025
4a8da8d
refactor: CRUD_API 클래스 POST 수정
Kim-Dohun148 Nov 8, 2025
bc8662d
refactor: CRUD_API 클래스 PUT 수정
Kim-Dohun148 Nov 8, 2025
a8737e0
feat: CRUD_API 클래스 GET 예외처리 기능 추가
Kim-Dohun148 Nov 9, 2025
272f2fb
refactor: CRUD_API 클래스 불필요 라이브러리 삭제
Kim-Dohun148 Nov 9, 2025
31474f1
refactor: json 요청 시 응답 반환 User 객체 인수 수정
Kim-Dohun148 Nov 9, 2025
0d8f445
feat: introduce.html 자기소개 내용 추가
Kim-Dohun148 Nov 9, 2025
efc28c0
feat: Model_Article 클래스 구현
Kim-Dohun148 Nov 15, 2025
9336b1f
feat: Model_Board 클래스 구현
Kim-Dohun148 Nov 15, 2025
d7ec5ab
feat: Model_Member 클래스 구현
Kim-Dohun148 Nov 15, 2025
79a8154
feat: Controller 클래스 생성
Kim-Dohun148 Nov 15, 2025
68768dc
feat: Service 클래스 생성
Kim-Dohun148 Nov 15, 2025
75825cb
feat: Repository 클래스 생성
Kim-Dohun148 Nov 15, 2025
a7d7e8d
feat: Repository 클래스 생성자 구현
Kim-Dohun148 Nov 15, 2025
488f784
feat: Repository 클래스 getArticles(특정 article 조회) 메서드 구현
Kim-Dohun148 Nov 15, 2025
fbce50b
feat: Service 클래스 getArticles(특정 article 조회) 메서드 구현
Kim-Dohun148 Nov 15, 2025
e57fc89
feat: Service 클래스 @Service 어노테이션 추가
Kim-Dohun148 Nov 15, 2025
00efea6
feat: Repository 클래스 @Repository 어노테이션 추가
Kim-Dohun148 Nov 15, 2025
fcd49ff
feat: Repository 클래스 setArticles 메서드 구현(새로운 article 생성)
Kim-Dohun148 Nov 16, 2025
89f1932
feat: Service 클래스 setArticles 메서드 구현(새로운 article 생성)
Kim-Dohun148 Nov 16, 2025
5e02c1a
feat: Controller 클래스 setArticles 메서드 구현(새로운 article 생성)
Kim-Dohun148 Nov 16, 2025
910eae7
feat: Repository 클래스 putArticles 메서드 구현(article 수정)
Kim-Dohun148 Nov 16, 2025
45406c1
feat: Service 클래스 putArticles 메서드 구현(article 수정)
Kim-Dohun148 Nov 16, 2025
fa86c98
feat: Controller 클래스 putArticles 메서드 구현(article 수정)
Kim-Dohun148 Nov 16, 2025
49f35e8
feat: Repository 클래스 deleteArticles 메서드 구현(article 삭제)
Kim-Dohun148 Nov 16, 2025
40b4cc7
feat: Service 클래스 deleteArticles 메서드 구현(article 삭제)
Kim-Dohun148 Nov 16, 2025
13278dd
feat: Controller 클래스 deleteArticles 메서드 구현(article 삭제)
Kim-Dohun148 Nov 16, 2025
78cdae3
feat: Repository 클래스 getAllArticles 메서드 구현(모든 article 조회)
Kim-Dohun148 Nov 16, 2025
9eeab85
feat: Service 클래스 getAllArticles 메서드 구현(모든 article 조회)
Kim-Dohun148 Nov 16, 2025
7889654
feat: Controller 클래스 getAllArticles 메서드 구현(모든 article 조회)
Kim-Dohun148 Nov 16, 2025
eb0c165
feat: posts.html 파일 생성
Kim-Dohun148 Nov 16, 2025
73daa87
refactor: Controller -> ArticleController 이름 변경
Kim-Dohun148 Nov 16, 2025
5660650
feat: Repository 클래스 getAllBoards 메서드 구현
Kim-Dohun148 Nov 17, 2025
0c5fde3
feat: Repository 클래스 getAllMembers 메서드 구현
Kim-Dohun148 Nov 17, 2025
93edec5
feat: Service 클래스 getAllBoards 메서드 구현
Kim-Dohun148 Nov 17, 2025
21445b5
feat: Service 클래스 getAllMembers 메서드 구현
Kim-Dohun148 Nov 17, 2025
f042491
feat: ArticleController 클래스 getAllPosts 메서드 구현
Kim-Dohun148 Nov 17, 2025
3a651d1
feat: posts.html 코드 구현
Kim-Dohun148 Nov 17, 2025
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
51 changes: 51 additions & 0 deletions src/main/java/com/example/bcsd/CRUD_API.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.example.bcsd;

import jakarta.annotation.PostConstruct;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;

@RestController
public class CRUD_API {
private Map<String, User> userMap;

@PostConstruct
public void init() {
userMap = new HashMap<String, User>();
userMap.put("1", new User("1", 23, "김도훈"));
userMap.put("2", new User("2", 24, "도훈"));
userMap.put("3", new User("3", 25, "훈도김"));
}

@GetMapping("/user/{id}")
public ResponseEntity<User> getUser(@PathVariable("id") String id) {
User user = userMap.get(id);

if (user == null) {
return ResponseEntity.notFound().build();
}

return ResponseEntity.ok(user);
}

@PostMapping("/user/{id}")
public void getUser(
@PathVariable("id") String id,
@RequestBody User user) {
userMap.put(id, user);
}

@PutMapping("/user/{id}")
public void setUser(
@PathVariable("id") String id,
@RequestBody User userChange) {
userMap.get(id).setAge(userChange.getAge());
userMap.get(id).setName(userChange.getName());
}

@DeleteMapping("/user/{id}")
public void deleteUser(@PathVariable("id") String id) {
userMap.remove(id);
}
}
59 changes: 59 additions & 0 deletions src/main/java/com/example/bcsd/Controller/ArticleController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.example.bcsd.Controller;

import org.springframework.ui.Model;

import com.example.bcsd.Model.Article;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;

@org.springframework.stereotype.Controller
public class ArticleController {
private Service service;

public ArticleController(Service service) {
this.service = service;
}

@ResponseBody
@GetMapping("/posts")
public String getAllPosts(Model model) {
model.addAttribute("articles", service.getAllArticles());
model.addAttribute("Boards", service.getAllBoards());
model.addAttribute("members", service.getAllMembers());

return "posts";
}

@GetMapping("/articles")
public Collection<Article> getAllArticles() {
return service.getAllArticles();
}

@GetMapping("/articles/{id}")
public ResponseEntity<Article> getArticles(@PathVariable("id") String id) {
return service.getArticles(id);
}

@PostMapping("/articles/{id}")
public void setArticles(
@PathVariable("id") String id,
@RequestBody Article article) {
service.setArticles(id, article);
}

@PutMapping("/articles/{id}")
public void putArticles(
@PathVariable("id") String id,
@RequestBody Article article) {

service.putArticles(id, article);
}

@DeleteMapping("/articles/{id}")
public void deleteArticles(@PathVariable("id") String id) {
service.deleteArticles(id);
}

}
89 changes: 89 additions & 0 deletions src/main/java/com/example/bcsd/Controller/Repository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.example.bcsd.Controller;

import ch.qos.logback.core.model.Model;
import com.example.bcsd.Model.Article;
import com.example.bcsd.Model.Board;
import com.example.bcsd.Model.Member;
import jakarta.annotation.PostConstruct;
import org.springframework.http.ResponseEntity;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@org.springframework.stereotype.Repository
public class Repository {
private Map<String, Article> articleMap;
private Map<String, Board> boardMap;
private Map<String, Member> memberMap;

@PostConstruct
public void init() {
articleMap = new HashMap<String, Article>();
articleMap.put("1", new Article(
1,
1,
1,
"제목1",
"내용1",
"2025/11/15",
""
));
articleMap.put("2", new Article(
2,
2,
2,
"제목2",
"내용2",
"2025/11/16",
""
));

boardMap = new HashMap<String, Board>();
boardMap.put("1", new Board(1, "자유게시판"));

memberMap = new HashMap<String, Member>();
memberMap.put("1", new Member(1, "회원1", "이메일", "비밀번호"));
}

public Collection<Article> getAllArticles() {
return articleMap.values();
}

public Collection<Board> getAllboards() {
return boardMap.values();
}

public Collection<Member> getAllMembers() {
return memberMap.values();
}

public ResponseEntity<Article> getArticles(String id) {
Article article = articleMap.get(id);

if (article == null) {
return ResponseEntity.notFound().build();
}

return ResponseEntity.ok(article);
}

public void setArticles(String id, Article article) {
articleMap.put(id, article);
}

public void putArticles(String id, Article article) {
articleMap.get(id).setId(article.getId());
articleMap.get(id).setWriterId(article.getWriterId());
articleMap.get(id).setBoardId(article.getBoardId());
articleMap.get(id).setTitle(article.getTitle());
articleMap.get(id).setContent(article.getContent());
articleMap.get(id).setWriterDate(article.getWriterDate());
articleMap.get(id).setReviseDate(article.getReviseDate());
}

public void deleteArticles(String id) {
articleMap.remove(id);
}
}
45 changes: 45 additions & 0 deletions src/main/java/com/example/bcsd/Controller/Service.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.example.bcsd.Controller;

import com.example.bcsd.Model.Article;
import com.example.bcsd.Model.Member;
import org.springframework.http.ResponseEntity;

import java.util.Collection;

@org.springframework.stereotype.Service
public class Service {
private Repository repository;

public Service(Repository repository) {
this.repository = repository;
}

public Collection<Article> getAllArticles() {
return repository.getAllArticles();
}

public Collection<Member> getAllBoards() {
return repository.getAllMembers();
}

public Collection<Member> getAllMembers() {
return repository.getAllMembers();
}


public ResponseEntity<Article> getArticles(String id) {
return repository.getArticles(id);
}

public void setArticles(String id, Article article) {
repository.setArticles(id, article);
}

public void putArticles(String id, Article article) {
repository.putArticles(id, article);
}

public void deleteArticles(String id) {
repository.deleteArticles(id);
}
}
19 changes: 19 additions & 0 deletions src/main/java/com/example/bcsd/HelloController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
Expand All @@ -17,4 +18,22 @@ public String hello() {
public String hello2() {
return "hello";
}

@GetMapping("/introduce")
public String introduce() {
return "introduce";
}

@ResponseBody
@GetMapping(value = "/introduce", params = "name") // 파라미터 구분
public String introduce2(@RequestParam("name") String myName) { // name 입력받기
return "안녕하세요 제 이름은" + myName + "입니다!";
}

@ResponseBody
@GetMapping("/json")
public User json() {
User person = new User("1", 23, "김도훈");
return person;
}
}
78 changes: 78 additions & 0 deletions src/main/java/com/example/bcsd/Model/Article.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.example.bcsd;


public class Article {
private int id;
private int writerId;
private int boardId;
private String title;
private String content;
private String writerDate;
private String reviseDate;

public Article(
int id,
int writerId,
int boardId,
String title,
String content,
String writerDate,
String reviseDate) {
this.id = id;
this.writerId = writerId;
this.boardId = boardId;
this.title = title;
this.content = content;
this.writerDate = writerDate;
this.reviseDate = reviseDate;
}

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}

public int getWriterId() {
return writerId;
}
public void setWriterId(int writerId) {
this.writerId = writerId;
}

public int getBoardId() {
return boardId;
}
public void setBoardId(int boardId) {
this.boardId = boardId;
}

public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}

public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}

public String getWriterDate() {
return writerDate;
}
public void setWriterDate(String writerDate) {
this.writerDate = writerDate;
}

public String getReviseDate() {
return reviseDate;
}
public void setReviseDate(String reviseDate) {
this.reviseDate = reviseDate;
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/example/bcsd/Model/Board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.example.bcsd;

public class Board {
private int id;
private String name;

public Board(int id, String name) {
this.id = id;
this.name = name;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName(){
return name;
}

public void setName(String name) {
this.name = name;
}
}
Loading