Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ef7d876
updateREAEME
Jiwon-cho Jan 27, 2022
e561bf3
swagger,h2
Feb 3, 2022
b53e4ed
Merge branch 'feature/README' into main
Feb 3, 2022
587503f
swagger,h2
Feb 3, 2022
677ab6d
swagger 수정
Jiwon-cho Feb 3, 2022
9eb7cf8
board CRUD,SEARCH
Jiwon-cho Feb 7, 2022
0539af5
board CRUD,find
Jiwon-cho Feb 8, 2022
0185d14
swagger,CRD
Feb 10, 2022
1affd5c
Merge branch 'main' of https://github.com/Jiwon-cho/Anonymous_Server …
Feb 14, 2022
0888eea
swagger,CRD
Feb 15, 2022
dd17471
Merge branch 'main' into feature/README
choipureum Feb 16, 2022
39e816b
swagger,respons 적용중
Feb 16, 2022
fe343ce
Merge remote-tracking branch 'origin/feature/README' into feature/README
Feb 16, 2022
e45ad7b
Common class 생성
Jiwon-cho Feb 16, 2022
b3498c9
Merge branch 'main' of https://github.com/IloveDev-Crew/anonymous-ser…
Feb 25, 2022
2b5bfdf
BoardResponse,SaveRequestDTO 생성,Controller 수정
Feb 25, 2022
ed6b474
BoardResponse,SaveRequestDTO 생성,Controller 수정
Feb 25, 2022
664fe20
Merge branch 'main' of https://github.com/IloveDev-Crew/anonymous-ser…
Feb 25, 2022
d24d6f0
BoardResponse,SaveRequestDTO 생성,Controller 수정
Feb 25, 2022
7259335
Merge remote-tracking branch 'origin/main' into main
Mar 2, 2022
e6c216c
swagger,h2
Feb 3, 2022
49674f0
swagger 수정
Jiwon-cho Feb 3, 2022
275975a
board CRUD,SEARCH
Jiwon-cho Feb 7, 2022
4adc451
board CRUD,find
Jiwon-cho Feb 8, 2022
80c4238
swagger,CRD
Feb 10, 2022
aba21fc
swagger,CRD
Feb 15, 2022
9fc60c6
swagger,respons 적용중
Feb 16, 2022
a8841c6
Common class 생성
Jiwon-cho Feb 16, 2022
d0fe5a6
BoardResponse,SaveRequestDTO 생성,Controller 수정
Feb 25, 2022
999f72b
BoardResponse,SaveRequestDTO 생성,Controller 수정
Feb 25, 2022
e202620
BoardResponse,SaveRequestDTO 생성,Controller 수정
Feb 25, 2022
6c3d5b4
Board CRUD 브랜치 REBASE
Mar 3, 2022
56048f6
Merge remote-tracking branch 'origin/feature/Board_CRUD' into feature…
Mar 3, 2022
bcefa98
Board CRUD delte
Mar 4, 2022
fc65c58
Merge branch 'main' of https://github.com/IloveDev-Crew/anonymous-ser…
Mar 7, 2022
9da8222
Board CRUD,update,selectAll
Mar 7, 2022
e5c64f9
User,UserController 삭제,Transactional 변경
Mar 8, 2022
1199562
BoardResponse,SaveRequestDTO 삭제
Mar 11, 2022
343630c
controllerTest test
Jiwon-cho Mar 14, 2022
9f09d9f
controllerTest createTest
Jiwon-cho Mar 16, 2022
cf4c836
BoardControllerTest,deleteBoardTest 작성
Mar 17, 2022
5097be2
controllerTest,selectBoardTest,serviceTest
Jiwon-cho Mar 17, 2022
128f516
BoardControllerTest,When 추가
Mar 23, 2022
70df3ab
BoardControllerTest,When 추가
Mar 23, 2022
37bb9f6
BoardControllerTest,select,create test 로직 변경
Mar 24, 2022
5541e51
BoardRepositoryTest 작성,BoardFixture 내 메소드 추가
Jiwon-cho Mar 30, 2022
8725965
BoardServiceTest 추가
Jiwon-cho Mar 31, 2022
c5c1225
Post로 이름 수정,ServiceTest 코드 추가작성, 향후 메소드명 변경 계획
Jiwon-cho Apr 1, 2022
f8dce5a
method명 변경,Controller-updateTest 추가
Apr 4, 2022
e226d67
build Fail 확인용 커밋
Apr 5, 2022
6029a85
build Fail 확인용 커밋
Apr 5, 2022
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
![ERD](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRGT__PbylyF-wZjJh_61kLKx0UH8l8J80uxg&usqp=CAU "ERD")

### Period

2022.01.14 ~ 2022.


### Stacks
| category | stack |
|---|:---:|
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.makefire.anonymous.domain.board.entity;


import com.makefire.anonymous.domain.common.BasicEntity;
import lombok.*;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;


@Entity
@Table(name="BOARD")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Board extends BasicEntity {



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

간격조정 부탁드립니다

@Column(nullable = false)
private String title;

@Lob
@Column(nullable = false)
private String content;


private String author;

private Long authorId;


@Builder
public Board(String title, String content, String author, Long authorId) {
this.title = title;
this.content = content;
this.author = author;
this.authorId = authorId;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.makefire.anonymous.domain.board.repository;

import com.makefire.anonymous.domain.board.entity.Board;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface BoardRepository extends JpaRepository<Board, Long> {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.makefire.anonymous.domain.common;

import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;


import javax.persistence.*;
import java.time.LocalDateTime;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BasicEntity {
@Id
@GeneratedValue
private Long id;


@CreatedDate
@Column(name = "created_date")
private LocalDateTime createdDate;

@LastModifiedDate
@Column(name = "modifiedDate")
private LocalDateTime modifiedDate;




}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.makefire.anonymous.domain.user.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

/**
*packageName : com.makefire.anonymous
Expand All @@ -11,5 +14,14 @@
* 22-01-15 최푸름
* ---------------------------------
*/




public class User {
}





}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.makefire.anonymous.rest.controller.api;


import com.makefire.anonymous.rest.dto.request.board.BoardSaveRequestDTO;
import com.makefire.anonymous.rest.dto.response.board.BoardResponseDTO;
import com.makefire.anonymous.service.board.BoardService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/board")
public class BoardController {

private final BoardService boardService;



@GetMapping("/findAll")
public ResponseEntity<List<BoardResponseDTO>> boardList() {

return ResponseEntity.ok().body( boardService.findAll());
}

@PostMapping("/create")
public ResponseEntity<Long> save(@RequestBody BoardSaveRequestDTO requestDTO) {

return ResponseEntity.ok().body(boardService.save(requestDTO));
}


@GetMapping("/findById/{id}")
public ResponseEntity<BoardResponseDTO> findById(@PathVariable("id") Long id) {

return ResponseEntity.ok().body(boardService.findById(id));
}

}




Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.makefire.anonymous.rest.controller.api;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
*packageName : com.makefire.anonymous
* fileName : UserController
Expand All @@ -14,5 +15,13 @@
* ---------------------------------
*/
@Controller
public class UserController {
}
public class UserController{


@RequestMapping(method=RequestMethod.GET,path="/getMethod")
//localhost:8080/api/getMethod
public String getRequest(){
return "skxokj.rolls";

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.makefire.anonymous.rest.dto.request.board;

import com.makefire.anonymous.domain.board.entity.Board;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class BoardSaveRequestDTO {
private String title;
private String content;
private String author;
private Long authorId;

@Builder
public BoardSaveRequestDTO(String title, String content, String author, Long authorId) {
this.title = title;
this.content = content;
this.author = author;
this.authorId = authorId;
}

public Board toEntity() {
return Board.builder()
.title(title)
.content(content)
.author(author)
.authorId(authorId)
.build();

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.makefire.anonymous.rest.dto.response;

import lombok.Data;

@Data
public class Message {

private StatusEnum status;
private String message;
private Object data;

public Message() {
this.status = StatusEnum.BAD_REQUEST;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BAD_REQUEST로 고정될 경우 다른 경우는 현재 반환이 어려워보입니다. 좀 더 확장성있는 구조 설계를 해야할 것 같습니다

this.data = null;
this.message = null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.makefire.anonymous.rest.dto.response;



/**
* packageName : com.makefire.anonymous.rest.dto.response
* fileName : Response
Expand All @@ -12,5 +14,8 @@
* 2022-01-15 User 최초 생성
*/

public class Response {
public class Response{



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.makefire.anonymous.rest.dto.response;

public enum StatusEnum {

OK(200, "OK"),
BAD_REQUEST(400, "BAD_REQUEST"),
NOT_FOUND(404, "NOT_FOUND"),
INTERNAL_SERER_ERROR(500, "INTERNAL_SERVER_ERROR");

int statusCode;
String code;

StatusEnum(int statusCode, String code) {
this.statusCode = statusCode;
this.code = code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.makefire.anonymous.rest.dto.response.board;

import com.makefire.anonymous.domain.board.entity.Board;
import lombok.Getter;
import lombok.Setter;

@Getter
public class BoardResponseDTO {

private Long id, authorId;
private String title, content, author;

@Setter
private Long viewCount;

public BoardResponseDTO(Board entity) {
this.id = entity.getId();
this.title = entity.getTitle();
this.content = entity.getContent();
this.author = entity.getAuthor();
this.authorId = entity.getAuthorId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.makefire.anonymous.service.board;

import com.makefire.anonymous.domain.board.entity.Board;
import com.makefire.anonymous.domain.board.repository.BoardRepository;
import com.makefire.anonymous.rest.dto.request.board.BoardSaveRequestDTO;
import com.makefire.anonymous.rest.dto.response.board.BoardResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class BoardService {
private final BoardRepository boardRepository;






public List<BoardResponseDTO> findAll() {
return boardRepository.findAll().stream().map(BoardResponseDTO::new).collect(Collectors.toList());
}

public BoardResponseDTO findById(Long id) {
Board entity = boardRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("해당 게시물이 없습니다. id=" + id));

return new BoardResponseDTO(entity);
}

public Long save(BoardSaveRequestDTO requestDTO) {
return boardRepository.save(requestDTO.toEntity())
.getId();
}


}
21 changes: 20 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@ spring:
include: local, config.oauth
mvc:
pathmatch:
matching-strategy: ant_path_matcher
matching-strategy: ant_path_matcher
jpa:
show_sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
datasource:
username: test # 사용자 이름 (로그인 시 사용)
password: 1234
hikari:
jdbc-url: jdbc:h2:mem:testdb;MODE=MYSQL
h2:
console:
enabled: true
settings:
web-allow-others: true
path: /h2-console