Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Feature/lecture 로컬 브런치 충돌 확인 #38

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/main/java/ducami/org/ducademi/DucademiApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing

@SpringBootApplication
@ConfigurationPropertiesScan
@EnableJpaAuditing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Entity
@Getter @NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "lecture")
Expand All @@ -27,10 +29,10 @@ public class Lecture {
@Column(nullable = false)
private String title;
private String introduction;
private String applyStartDate;
private String applyEndDate;
private String startDate;
private String endDate;
private LocalDateTime applyStartDate;
private LocalDateTime applyEndDate;
private LocalDateTime startDate;
private LocalDateTime endDate;
private String target;

@Enumerated(EnumType.STRING)
Expand All @@ -43,8 +45,9 @@ public class Lecture {
private Long teacherIdx;

@Builder
public Lecture(String title,String introduction,String applyStartDate,String applyEndDate,String startDate,String endDate,String target,LectureType category,Long teacherIdx){
public Lecture(String title,String introduction,LocalDateTime applyStartDate,LocalDateTime applyEndDate,LocalDateTime startDate,LocalDateTime endDate,String target,LectureType category,Long teacherIdx, Integer maxApplier){
this.title = title;
this.maxApplier = maxApplier;
this.introduction = introduction;
this.applyStartDate = applyStartDate;
this.applyEndDate = applyEndDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ducami.org.ducademi.domain.lecture.presentation;


import ducami.org.ducademi.domain.lecture.presentation.dto.request.CreateLecturesRequest;
import ducami.org.ducademi.domain.lecture.service.DucamiLectureService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -30,7 +32,7 @@ public void createLecture(
@PathVariable Long idx,
@RequestBody CreateLecturesRequest request
) {
ducamiLectureService.createLecture(token,request);
ducamiLectureService.createLecture(idx,request);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ducami.org.ducademi.domain.lecture.presentation.dto.request;


import ducami.org.ducademi.domain.lecture.domain.Lecture;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
public class CreateLecturesRequest {

// private String thumbNail;
private String title;
private String introduction;
private String maxApplier;
private LocalDateTime startDate;
private LocalDateTime endDate;
private LocalDateTime applyStartDate;
private LocalDateTime applyEndDate;
private String target;

public Lecture toEntity(){
return Lecture.builder()
.title(this.title)
.introduction(this.introduction)
.maxApplier(Integer.parseInt(this.maxApplier))
.startDate(this.startDate)
.endDate(this.endDate)
.applyStartDate(this.applyStartDate)
.applyEndDate(this.applyEndDate)
.target(this.target).build();
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ducami.org.ducademi.domain.lecture.service;


import ducami.org.ducademi.domain.lecture.domain.repository.LectureRepository;
import ducami.org.ducademi.domain.lecture.presentation.dto.request.CreateLecturesRequest;
import ducami.org.ducademi.domain.member.repository.MemberRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class DucamiLectureService {

private final MemberRepository memberRepository;
private final LectureRepository lectureRepository;

public void createLecture(Long idx, CreateLecturesRequest request){
memberRepository.findById(idx)
.orElseThrow(() -> new IllegalArgumentException("User not found"));

lectureRepository.save(request.toEntity());
}


}