Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

체크리스트 방 정보 작성 API를 구현한다. #75

Merged
merged 50 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4b566b7
feat: Room 엔티티 생성
shin-jisong Jul 22, 2024
099b2e8
feat: User 엔티티 생성
shin-jisong Jul 22, 2024
6f8eb4e
feat: Checklist 엔티티 생성
shin-jisong Jul 22, 2024
256889a
feat: BaseEntity 추가
shin-jisong Jul 22, 2024
a1bd2da
feat: 체크리스트 옵션 추가
shin-jisong Jul 22, 2024
6c4e9ce
feat: 옵션 정보 생성
shin-jisong Jul 22, 2024
c450d90
feat: 도메인 생성자 추가
shin-jisong Jul 22, 2024
45241b7
feat: ChecklistQuestion 엔티티 생성
shin-jisong Jul 22, 2024
be220e7
feat: option id 포함 여부 확인 함수 구현
shin-jisong Jul 22, 2024
13841a1
feat: 체크리스트 생성을 위한 DTO들 생성
shin-jisong Jul 22, 2024
f9f4394
feat: 체크리스트 생성을 위한 Repository 생성
shin-jisong Jul 22, 2024
5d350ba
feat: 체크리스트 질문 목록 생성
shin-jisong Jul 23, 2024
90970c3
style: 옵션 중요한 순으로 정렬
shin-jisong Jul 23, 2024
468ad5f
feat: 룸 정보에 주소 추가
shin-jisong Jul 23, 2024
96965b0
feat: 초기 schema, data sql 설정
shin-jisong Jul 23, 2024
41bf353
feat: 테이블명 추가
shin-jisong Jul 23, 2024
cf81782
feat: Grade 생성
shin-jisong Jul 23, 2024
d54aea2
feat(QuestionList): 질문 포함 여부 확인 기능 구현
shin-jisong Jul 23, 2024
06e3e82
feat: API 형식에 따른 DTO 구조 변경
shin-jisong Jul 23, 2024
1dbcc81
feat: ChecklistQuestion 레포지토리 생성
shin-jisong Jul 23, 2024
1979f7c
feat: 체크리스트 저장 시 예외 처리 구현
shin-jisong Jul 23, 2024
80f44f0
feat(Room): 테이블 이름 지정
shin-jisong Jul 23, 2024
8ca7bac
feat: 체크리스트 저장 기능 구현
shin-jisong Jul 23, 2024
d9ca7a7
test: 테스트 환경 세팅
shin-jisong Jul 23, 2024
f2a7912
chore: 테스트 의존성 추가
shin-jisong Jul 23, 2024
9e33ee4
test: 테스트 기본 코드 작성
shin-jisong Jul 23, 2024
e385279
feat: 중첩 DTO 검증 구현
shin-jisong Jul 23, 2024
b626249
test: 체크리스트 방 정보 작성 E2E 테스트
shin-jisong Jul 23, 2024
ec990a7
test: 옵션 포함 테스트
shin-jisong Jul 23, 2024
af8962d
test: 질문 리스트 포함 테스트
shin-jisong Jul 23, 2024
bee4f57
test: 체크리스트 방 정보 작성 서비스 테스트
shin-jisong Jul 23, 2024
8ce6fb9
style: 코드 재정렬
shin-jisong Jul 23, 2024
acd7d06
Merge branch 'dev-be' into feat/47-write-checklist-api
shin-jisong Jul 23, 2024
24df144
fix: merge 충돌 해결
shin-jisong Jul 23, 2024
0aa98c0
refactor(Option): 접근제어자 수정 및 Integer을 int로 변경
shin-jisong Jul 24, 2024
71e4c53
refactor(ChecklistService): 변수명 변경
shin-jisong Jul 24, 2024
b48cd1a
test(ChecklistE2ETest): 오타 수정
shin-jisong Jul 24, 2024
a65d810
test: 테스트 컨벤션 반영
shin-jisong Jul 24, 2024
44694ef
test: 테스트 값 견고하게 변경
shin-jisong Jul 24, 2024
6d9c9fc
test: 중복 어노테이션 제거
shin-jisong Jul 24, 2024
fd384eb
test: static import 적용
shin-jisong Jul 24, 2024
f2d17cb
refactor: JoinColumn으로 nullable 설정 제거
shin-jisong Jul 24, 2024
d15d588
refactor(Checklist): 기본 생성자 활용해서 생성자 수정
shin-jisong Jul 24, 2024
1b3b8fa
refactor: URI 명확히 수정
shin-jisong Jul 24, 2024
4dc0c8c
style: 가독성 있게 코드 개행
shin-jisong Jul 24, 2024
3e48abe
feat: 체크리스트 방 정보 작성 검증 코드 추가
shin-jisong Jul 24, 2024
0f66137
feat: 엔티티에 불필요 Table 어노테이션 제거
shin-jisong Jul 24, 2024
2b22c57
test: hasMessage ExceptionCode 사용
shin-jisong Jul 24, 2024
8fecebf
refactor: QuestionList -> Questionlist
shin-jisong Jul 24, 2024
58380b0
refactor(Question): categoryId 필드 제거
shin-jisong Jul 24, 2024
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
30 changes: 16 additions & 14 deletions backend/bang-ggood/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
id 'java'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.bang-ggood'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured:5.3.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import java.time.LocalDateTime;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.bang_ggood.checklist.controller;

import com.bang_ggood.checklist.dto.ChecklistCreateRequest;
import com.bang_ggood.checklist.service.ChecklistService;
import jakarta.validation.Valid;
import java.net.URI;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChecklistController {

private final ChecklistService checklistService;

public ChecklistController(ChecklistService checklistService) {
this.checklistService = checklistService;
}

@PostMapping("/checklists")
public ResponseEntity<Void> createChecklist(@Valid @RequestBody ChecklistCreateRequest checklistCreateRequest) {
long checklistId = checklistService.createChecklist(checklistCreateRequest);
return ResponseEntity.created(URI.create("/checklists/" + checklistId)).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.bang_ggood.checklist.domain;

import com.bang_ggood.BaseEntity;
import com.bang_ggood.room.domain.Room;
import com.bang_ggood.user.domain.User;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import java.util.Objects;


@Entity
public class Checklist extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
private User user;

@OneToOne(fetch = FetchType.LAZY)
private Room room;

private Integer deposit;

private Integer rent;

private Integer contractTerm;

private String realEstate;

public Checklist(User user, Room room, Integer deposit, Integer rent, Integer contractTerm, String realEstate) {
this.user = user;
this.room = room;
this.deposit = deposit;
this.rent = rent;
this.contractTerm = contractTerm;
this.realEstate = realEstate;
}

public Checklist(Integer deposit, Integer rent, Integer contractTerm, String realEstate) {
this(null, null, deposit, rent, contractTerm, realEstate);
}

protected Checklist() {
}
shin-jisong marked this conversation as resolved.
Show resolved Hide resolved

public Long getId() {
return id;
}

public User getUser() {
return user;
}

public Room getRoom() {
return room;
}

public Integer getDeposit() {
return deposit;
}

public Integer getRent() {
return rent;
}

public Integer getContractTerm() {
return contractTerm;
}

public String getRealEstate() {
return realEstate;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Checklist checklist = (Checklist) o;
return Objects.equals(id, checklist.id);
}

@Override
public int hashCode() {
return Objects.hashCode(id);
}

@Override
public String toString() {
return "Checklist{" +
"id=" + id +
", user=" + user +
", room=" + room +
", deposit=" + deposit +
", rent=" + rent +
", contractTerm=" + contractTerm +
", realEstate='" + realEstate + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.bang_ggood.checklist.domain;

import com.bang_ggood.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import java.util.Objects;


@Entity
public class ChecklistOption extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
private Checklist checklist;

@Column(nullable = false)
private Integer optionId;

public ChecklistOption(Checklist checklist, Integer optionId) {
this.checklist = checklist;
this.optionId = optionId;
}

protected ChecklistOption() {
}

public Long getId() {
return id;
}

public Checklist getChecklist() {
return checklist;
}

public Integer getOptionId() {
return optionId;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ChecklistOption that = (ChecklistOption) o;
return Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return Objects.hashCode(id);
}

@Override
public String toString() {
return "ChecklistOption{" +
"id=" + id +
", checklist=" + checklist +
", optionId=" + optionId +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.bang_ggood.checklist.domain;

import com.bang_ggood.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import java.util.Objects;


@Entity
public class ChecklistQuestion extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
private Checklist checklist;

private int questionId;

private String answer;

public ChecklistQuestion(Checklist checklist, int questionId, String answer) {
this.checklist = checklist;
this.questionId = questionId;
this.answer = answer;
}

protected ChecklistQuestion() {
}

public Long getId() {
return id;
}

public Checklist getChecklist() {
return checklist;
}

public int getQuestionId() {
return questionId;
}

public String getAnswer() {
return answer;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ChecklistQuestion that = (ChecklistQuestion) o;
return Objects.equals(id, that.id);
}

@Override
public int hashCode() {
return Objects.hashCode(id);
}

@Override
public String toString() {
return "ChecklistQuestion{" +
"id=" + id +
", checklist=" + checklist +
", questionId=" + questionId +
", answer=" + answer +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bang_ggood.checklist.domain;

public enum Grade {

GOOD(3),
SOSO(2),
BAD(1);

Grade(int score) {
}
}
Loading
Loading