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

Study Controller, Service 추가 #11

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
22dd9b1
feat: 스터디 생성 기능 추가
ybkang1108 Jan 16, 2025
90ad73f
feat: StudyCreateResponse DTO 추가
ybkang1108 Jan 16, 2025
2ea0826
feat: 스터디 전체 목록 조회 기능 추가
ybkang1108 Jan 16, 2025
3310c20
feat: 스터디 정보 조회 기능 추가
ybkang1108 Jan 16, 2025
b700946
feat: 스터디 삭제 기능 추가
ybkang1108 Jan 16, 2025
e99cab5
refactor: delete, detail response dto수정 및 cascade 설정
ybkang1108 Jan 17, 2025
52858dc
feat: 스터디 수정 기능 추가
ybkang1108 Jan 17, 2025
33b6e77
refactor: response에 메시지 제거
ybkang1108 Jan 17, 2025
baf1a6e
refactor: dto를 record로 변경
ybkang1108 Jan 21, 2025
e45b8ad
feat: exception 추가
ybkang1108 Jan 21, 2025
a412bbf
refactor: curriculum 수정
ybkang1108 Jan 22, 2025
2a4f89f
feat: day에 create 추가
ybkang1108 Jan 22, 2025
d864b11
refactor: record로 변경
ybkang1108 Jan 22, 2025
eb57a8f
feat: custom exception 추가
ybkang1108 Jan 22, 2025
6633caf
refactor: record로 변경
ybkang1108 Jan 22, 2025
047112b
feat: study 도메인에 create, update 추가
ybkang1108 Jan 22, 2025
2ce3d78
refactor: study service 수정
ybkang1108 Jan 22, 2025
889051a
refactor: study controller 수정
ybkang1108 Jan 22, 2025
ee5864b
refactor: springdoc 버전 수정
ybkang1108 Jan 23, 2025
ff5eb99
refactor: 불필요한 생성자 제거
ybkang1108 Jan 24, 2025
31ad47d
refactor: create, update 메소드 도메인으로 이동
ybkang1108 Jan 24, 2025
872757d
fix: 잘못된 로직 수정
ybkang1108 Jan 24, 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
16 changes: 12 additions & 4 deletions src/main/java/com/gdgoc/study_group/study/api/StudyController.java
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import com.gdgoc.study_group.study.application.StudyService;
import com.gdgoc.study_group.study.dto.StudyCreateRequest;
import com.gdgoc.study_group.study.dto.StudyCreateResponse;
import com.gdgoc.study_group.study.dto.StudyListResponse;
import java.util.List;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/studies")
Expand All @@ -25,4 +24,13 @@ public ResponseEntity<StudyCreateResponse> createStudy(@RequestBody StudyCreateR

return ResponseEntity.ok(newStudy);
}

@GetMapping()
public ResponseEntity<List<StudyListResponse>> getStudyList() {
List<StudyListResponse> studyList = studyService.getStudyList();

return ResponseEntity.ok(studyList);
}


}
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.gdgoc.study_group.study.domain.Study;
import com.gdgoc.study_group.study.dto.StudyCreateRequest;
import com.gdgoc.study_group.study.dto.StudyCreateResponse;
import com.gdgoc.study_group.study.dto.StudyListResponse;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -62,35 +64,24 @@ public StudyCreateResponse createStudy(StudyCreateRequest request) {

studyRepository.save(study);

// response DTO 생성
StudyCreateResponse response =
StudyCreateResponse.builder()
.id(study.getId())
.name(study.getName())
.description(study.getDescription())
.requirement(study.getRequirement())
.maxParticipants(study.getMaxParticipants())
.studyStatus(study.getStudyStatus())
.curriculums(new ArrayList<>())
.days(new ArrayList<>())
.build();
return StudyCreateResponse.builder().message("Study Created").id(study.getId()).build();
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
}

// response에 curriculum DTO 추가
for (Curriculum curriculum : study.getCurriculums()) {
CurriculumDTO curriculumDTO =
CurriculumDTO.builder()
.week(curriculum.getWeek())
.subject(curriculum.getSubject())
.build();
response.getCurriculums().add(curriculumDTO);
}
public List<StudyListResponse> getStudyList() {
List<Study> studyList = studyRepository.findAll();
List<StudyListResponse> studyListResponses = new ArrayList<>();

// response에 day DTO 추가
for (Day day : study.getDays()) {
DayDTO dayDTO = DayDTO.builder().day(day.getDay()).startTime(day.getStartTime()).build();
response.getDays().add(dayDTO);
for (Study study : studyList) {
StudyListResponse studyResponse =
StudyListResponse.builder()
.id(study.getId())
.name(study.getName())
.description(study.getDescription())
.status(study.getStudyStatus())
.build();
studyListResponses.add(studyResponse);
}

return response;
return studyListResponses;
}
}
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
package com.gdgoc.study_group.study.dto;

import com.gdgoc.study_group.curriculum.dto.CurriculumDTO;
import com.gdgoc.study_group.day.dto.DayDTO;
import com.gdgoc.study_group.study.domain.StudyStatus;
import java.util.List;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class StudyCreateResponse {
private String message;
private Long id;
private String name;
private String description;
private String requirement;
private Integer maxParticipants;
private StudyStatus studyStatus;
private List<CurriculumDTO> curriculums;
private List<DayDTO> days;
}
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.gdgoc.study_group.study.dto;

import com.gdgoc.study_group.study.domain.StudyStatus;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class StudyListResponse {
private Long id;
private String name;
private String description;
private StudyStatus status;
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
ybkang1108 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spring:

jpa:
hibernate:
ddl-auto: create
ddl-auto: update
properties:
hibernate:
format_sql: true
Expand Down