feat: lecture
lecture entity, repository, service, controller 추가
This commit is contained in:
parent
3b88c03d9e
commit
ed966e985e
@ -23,9 +23,13 @@ dependencies {
|
|||||||
implementation 'mysql:mysql-connector-java:8.0.33'
|
implementation 'mysql:mysql-connector-java:8.0.33'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
implementation group: 'io.livekit', name: 'livekit-server', version: '0.6.1'
|
implementation group: 'io.livekit', name: 'livekit-server', version: '0.6.1'
|
||||||
|
implementation 'org.projectlombok:lombok'
|
||||||
|
annotationProcessor 'org.projectlombok:lombok'
|
||||||
|
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.edufocus.edufocus.lecture.controller;
|
||||||
|
|
||||||
|
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||||
|
import com.edufocus.edufocus.lecture.service.LectureService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/lecture")
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LectureController {
|
||||||
|
|
||||||
|
private final LectureService lectureService;
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<?> createLecture (@RequestBody Lecture lecture) {
|
||||||
|
lectureService.createLecture(lecture);
|
||||||
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{lectureId}")
|
||||||
|
public ResponseEntity<?> deleteLecture (@PathVariable long lectureId) {
|
||||||
|
lectureService.deleteLecture(lectureId);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<?> findAllLecture () {
|
||||||
|
List<Lecture> lectures = lectureService.findAllLecture();
|
||||||
|
return new ResponseEntity<>(lectures, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/teacherId/{teacherId}")
|
||||||
|
public ResponseEntity<?> findByTeacherId (@PathVariable String teacherId) {
|
||||||
|
List<Lecture> lectures = lectureService.findLectureByTeacherId(teacherId);
|
||||||
|
return new ResponseEntity<>(lectures, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/title/{title}")
|
||||||
|
public ResponseEntity<?> findByTitle (@PathVariable String title) {
|
||||||
|
Lecture lecture = lectureService.findLectureByTitle(title);
|
||||||
|
|
||||||
|
if (lecture == null) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<>(lecture, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.edufocus.edufocus.lecture.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class Lecture {
|
||||||
|
|
||||||
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "teacher_id")
|
||||||
|
private String teacherId;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column(name = "start_date")
|
||||||
|
@Temporal(TemporalType.DATE)
|
||||||
|
private Date startDate;
|
||||||
|
|
||||||
|
@Column(name = "end_date")
|
||||||
|
@Temporal(TemporalType.DATE)
|
||||||
|
private Date endDate;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
private String plan;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.edufocus.edufocus.lecture.repository;
|
||||||
|
|
||||||
|
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface LectureRepository extends JpaRepository<Lecture, Long> {
|
||||||
|
Lecture findByTitle(@Param("title") String title);
|
||||||
|
|
||||||
|
List<Lecture> findByTeacherId(@Param("teacherId") String teacherId);
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.edufocus.edufocus.lecture.service;
|
||||||
|
|
||||||
|
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public interface LectureService {
|
||||||
|
|
||||||
|
void createLecture(Lecture lecture);
|
||||||
|
|
||||||
|
void deleteLecture(long lectureId);
|
||||||
|
|
||||||
|
Lecture findLectureByTitle(String title);
|
||||||
|
|
||||||
|
List<Lecture> findLectureByTeacherId(String teacherId);
|
||||||
|
|
||||||
|
List<Lecture> findAllLecture();
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.edufocus.edufocus.lecture.service;
|
||||||
|
|
||||||
|
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||||
|
import com.edufocus.edufocus.lecture.repository.LectureRepository;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LectureServiceImpl implements LectureService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final LectureRepository lectureRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createLecture(Lecture lecture) {
|
||||||
|
lectureRepository.save(lecture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteLecture(long lectureId) {
|
||||||
|
lectureRepository.deleteById(lectureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Lecture findLectureByTitle(String title) {
|
||||||
|
return lectureRepository.findByTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Lecture> findLectureByTeacherId(String teacherId) {
|
||||||
|
return lectureRepository.findByTeacherId(teacherId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Lecture> findAllLecture() {
|
||||||
|
return lectureRepository.findAll();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
spring.application.name=edufocus
|
spring.application.name=edufocus
|
||||||
|
server.port=8080
|
||||||
|
|
||||||
server.port=${SERVER_PORT:6080}
|
|
||||||
server.ssl.enabled=false
|
server.ssl.enabled=false
|
||||||
|
|
||||||
# LiveKit configuration
|
# LiveKit configuration
|
||||||
@ -8,10 +8,11 @@ livekit.api.key=${LIVEKIT_API_KEY:devkey}
|
|||||||
livekit.api.secret=${LIVEKIT_API_SECRET:secret}
|
livekit.api.secret=${LIVEKIT_API_SECRET:secret}
|
||||||
|
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.url=jdbc:mysql://localhost:3306/edufocus?serverTimezone=Asia/Seoul
|
spring.datasource.url=jdbc:mysql://localhost:3306/edufocus?useSSL=false
|
||||||
spring.datasource.username=root
|
spring.datasource.username=root
|
||||||
spring.datasource.password=root
|
spring.datasource.password=root
|
||||||
|
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
||||||
|
|
||||||
spring.jpa.database=mysql
|
spring.jpa.database=mysql
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=create
|
||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
Loading…
Reference in New Issue
Block a user