From 29a7b625a68ac3aa031109c5e35912a3cdd600a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:10:40 +0900 Subject: [PATCH 01/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/timetable/domain/Timetable.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/domain/Timetable.java diff --git a/backend/src/main/java/org/example/backend/timetable/domain/Timetable.java b/backend/src/main/java/org/example/backend/timetable/domain/Timetable.java new file mode 100644 index 00000000..eefb8b49 --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/domain/Timetable.java @@ -0,0 +1,78 @@ +package org.example.backend.timetable.domain; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.HashSet; +import java.util.Set; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.example.backend.seminarRoom.domain.SeminarRoom; +import org.example.backend.timetable.domain.dto.TimetableReqDto; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "timetable") +public class Timetable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long timetableId; + + private LocalDate startDate; + private LocalDate endDate; + private LocalTime startTime; + private LocalTime endTime; + + @ElementCollection + @Enumerated(EnumType.STRING) + private Set weekDays = new HashSet<>(); + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "seminar_room_id") + private SeminarRoom seminarRoom; + + @Builder + private Timetable(LocalDate startDate, LocalDate endDate, LocalTime startTime, LocalTime endTime, + Set weekDays, SeminarRoom seminarRoom) { + this.startDate = startDate; + this.endDate = endDate; + this.startTime = startTime; + this.endTime = endTime; + this.weekDays = weekDays; + this.seminarRoom = seminarRoom; + } + + public static Timetable of(TimetableReqDto dto, SeminarRoom seminarRoom) { + return Timetable.builder() + .startDate(dto.getStartDate()) + .endDate(dto.getEndDate()) + .startTime(dto.getStartTime()) + .endTime(dto.getEndTime()) + .weekDays(dto.getWeekDays()) + .seminarRoom(seminarRoom) + .build(); + } + + public void update(TimetableReqDto dto, SeminarRoom seminarRoom) { + this.startDate = dto.getStartDate(); + this.endDate = dto.getEndDate(); + this.startTime = dto.getStartTime(); + this.endTime = dto.getEndTime(); + this.weekDays = dto.getWeekDays(); + this.seminarRoom = seminarRoom; + } +} \ No newline at end of file From e12ba5211f08523bf745a578bf1b569949333d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:10:51 +0900 Subject: [PATCH 02/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20dto?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetable/domain/dto/TimetableReqDto.java | 45 +++++++++++++++++ .../timetable/domain/dto/TimetableResDto.java | 48 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableReqDto.java create mode 100644 backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableResDto.java diff --git a/backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableReqDto.java b/backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableReqDto.java new file mode 100644 index 00000000..1e7a45c0 --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableReqDto.java @@ -0,0 +1,45 @@ +package org.example.backend.timetable.domain.dto; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.Set; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.example.backend.timetable.domain.WeekDay; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class TimetableReqDto { + private LocalDate startDate; + private LocalDate endDate; + private LocalTime startTime; + private LocalTime endTime; + private Set weekDays; + private Long seminarRoomId; + + @Builder + private TimetableReqDto(LocalDate startDate, LocalDate endDate, LocalTime startTime, + LocalTime endTime, Set weekDays, Long seminarRoomId) { + this.startDate = startDate; + this.endDate = endDate; + this.startTime = startTime; + this.endTime = endTime; + this.weekDays = weekDays; + this.seminarRoomId = seminarRoomId; + } + + public static TimetableReqDto of(LocalDate startDate, LocalDate endDate, LocalTime startTime, + LocalTime endTime, Set weekDays, Long seminarRoomId) { + return TimetableReqDto.builder() + .startDate(startDate) + .endDate(endDate) + .startTime(startTime) + .endTime(endTime) + .weekDays(weekDays) + .seminarRoomId(seminarRoomId) + .build(); + } +} \ No newline at end of file diff --git a/backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableResDto.java b/backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableResDto.java new file mode 100644 index 00000000..bc6dd4ea --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/domain/dto/TimetableResDto.java @@ -0,0 +1,48 @@ +package org.example.backend.timetable.domain.dto; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.Set; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.example.backend.timetable.domain.Timetable; +import org.example.backend.timetable.domain.WeekDay; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class TimetableResDto { + private Long timetableId; + private LocalDate startDate; + private LocalDate endDate; + private LocalTime startTime; + private LocalTime endTime; + private Set weekDays; + private String seminarRoomName; + + @Builder + private TimetableResDto(Long timetableId, LocalDate startDate, LocalDate endDate, + LocalTime startTime, LocalTime endTime, Set weekDays, + String seminarRoomName) { + this.timetableId = timetableId; + this.startDate = startDate; + this.endDate = endDate; + this.startTime = startTime; + this.endTime = endTime; + this.weekDays = weekDays; + this.seminarRoomName = seminarRoomName; + } + + public static TimetableResDto of(Timetable timetable) { + return TimetableResDto.builder() + .timetableId(timetable.getTimetableId()) + .startDate(timetable.getStartDate()) + .endDate(timetable.getEndDate()) + .startTime(timetable.getStartTime()) + .endTime(timetable.getEndTime()) + .weekDays(timetable.getWeekDays()) + .seminarRoomName(timetable.getSeminarRoom().getName()) + .build(); + } +} \ No newline at end of file From 7d17ab0e15e53dccf2ffca32254a6522bbaf1db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:11:17 +0900 Subject: [PATCH 03/16] =?UTF-8?q?feat:=20=EC=9A=94=EC=9D=BC=20enum=20?= =?UTF-8?q?=ED=83=80=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/timetable/domain/WeekDay.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/domain/WeekDay.java diff --git a/backend/src/main/java/org/example/backend/timetable/domain/WeekDay.java b/backend/src/main/java/org/example/backend/timetable/domain/WeekDay.java new file mode 100644 index 00000000..3e33e3dc --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/domain/WeekDay.java @@ -0,0 +1,20 @@ +package org.example.backend.timetable.domain; + +import lombok.Getter; + +@Getter +public enum WeekDay { + MONDAY("월"), + TUESDAY("화"), + WEDNESDAY("수"), + THURSDAY("목"), + FRIDAY("금"), + SATURDAY("토"), + SUNDAY("일"); + + private final String korName; + + WeekDay(String korName) { + this.korName = korName; + } +} \ No newline at end of file From 8ea4f45b3310fc44d5fd48f18a83edb225b3f5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:11:41 +0900 Subject: [PATCH 04/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20ser?= =?UTF-8?q?vice=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetable/service/TimetableService.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/service/TimetableService.java diff --git a/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java b/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java new file mode 100644 index 00000000..f58142a4 --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java @@ -0,0 +1,71 @@ +package org.example.backend.timetable.service; + +import jakarta.persistence.EntityNotFoundException; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import org.example.backend.seminarRoom.domain.SeminarRoom; +import org.example.backend.seminarRoom.repository.SeminarRoomRepository; +import org.example.backend.timetable.domain.Timetable; +import org.example.backend.timetable.domain.dto.TimetableReqDto; +import org.example.backend.timetable.domain.dto.TimetableResDto; +import org.example.backend.timetable.repository.TimetableRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class TimetableService { + private final TimetableRepository timetableRepository; + private final SeminarRoomRepository seminarRoomRepository; + + @Transactional + public TimetableResDto createTimetable(TimetableReqDto reqDto) { + SeminarRoom seminarRoom = seminarRoomRepository.findById(reqDto.getSeminarRoomId()) + .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + + validateTimeRange(reqDto); + + Timetable timetable = Timetable.of(reqDto, seminarRoom); + timetableRepository.save(timetable); + + return TimetableResDto.of(timetable); + } + + public List getAllTimetables() { + return timetableRepository.findAll().stream() + .map(TimetableResDto::of) + .collect(Collectors.toList()); + } + + @Transactional + public TimetableResDto updateTimetable(Long timetableId, TimetableReqDto reqDto) { + Timetable timetable = timetableRepository.findById(timetableId) + .orElseThrow(() -> new IllegalArgumentException("시간표가 존재하지 않습니다.")); + + SeminarRoom seminarRoom = seminarRoomRepository.findById(reqDto.getSeminarRoomId()) + .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + + validateTimeRange(reqDto); + + timetable.update(reqDto, seminarRoom); + return TimetableResDto.of(timetable); + } + + @Transactional + public void deleteTimetable(Long timetableId) { + Timetable timetable = timetableRepository.findById(timetableId) + .orElseThrow(() -> new IllegalArgumentException("시간표가 존재하지 않습니다.")); + timetableRepository.delete(timetable); + } + + private void validateTimeRange(TimetableReqDto reqDto) { + if (reqDto.getStartDate().isAfter(reqDto.getEndDate())) { + throw new IllegalArgumentException("시작 날짜는 종료 날짜보다 이후일 수 없습니다."); + } + if (reqDto.getStartTime().isAfter(reqDto.getEndTime())) { + throw new IllegalArgumentException("시작 시간은 종료 시간보다 이후일 수 없습니다."); + } + } +} \ No newline at end of file From 6ae3178fb558c11e8ca8851348e9a47a44f620a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:11:56 +0900 Subject: [PATCH 05/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20rep?= =?UTF-8?q?ository=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/timetable/repository/TimetableRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/repository/TimetableRepository.java diff --git a/backend/src/main/java/org/example/backend/timetable/repository/TimetableRepository.java b/backend/src/main/java/org/example/backend/timetable/repository/TimetableRepository.java new file mode 100644 index 00000000..1db7c7bf --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/repository/TimetableRepository.java @@ -0,0 +1,7 @@ +package org.example.backend.timetable.repository; + +import org.example.backend.timetable.domain.Timetable; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TimetableRepository extends JpaRepository { +} From 3b49f90e5a4e71ff5ba8d392d5a7af52affc692f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:12:01 +0900 Subject: [PATCH 06/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20con?= =?UTF-8?q?troller=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TimetableController.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/controller/TimetableController.java diff --git a/backend/src/main/java/org/example/backend/timetable/controller/TimetableController.java b/backend/src/main/java/org/example/backend/timetable/controller/TimetableController.java new file mode 100644 index 00000000..95289649 --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/controller/TimetableController.java @@ -0,0 +1,48 @@ +package org.example.backend.timetable.controller; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.example.backend.timetable.domain.dto.TimetableReqDto; +import org.example.backend.timetable.domain.dto.TimetableResDto; +import org.example.backend.timetable.service.TimetableService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/timetables") +public class TimetableController { + private final TimetableService timetableService; + + @PostMapping + public ResponseEntity createTimetable(@RequestBody TimetableReqDto reqDto) { + TimetableResDto resDto = timetableService.createTimetable(reqDto); + return ResponseEntity.ok(resDto); + } + @GetMapping + public ResponseEntity> getAllTimetables() { + List timetables = timetableService.getAllTimetables(); + return ResponseEntity.ok(timetables); + } + + @PutMapping("/{timetableId}") + public ResponseEntity updateTimetable( + @PathVariable Long timetableId, + @RequestBody TimetableReqDto reqDto) { + TimetableResDto resDto = timetableService.updateTimetable(timetableId, reqDto); + return ResponseEntity.ok(resDto); + } + + @DeleteMapping("/{timetableId}") + public ResponseEntity deleteTimetable(@PathVariable Long timetableId) { + timetableService.deleteTimetable(timetableId); + return ResponseEntity.ok().build(); + } +} From eb6d891eec898c642655f3ed2aa1e3ee0353a8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:12:37 +0900 Subject: [PATCH 07/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20dto=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminarRoom/domain/SeminarRoom.java | 29 +++++++++++++-- .../domain/dto/SeminarRoomReqDto.java | 33 +++++++++++++++++ .../domain/dto/SeminarRoomResDto.java | 36 +++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomReqDto.java create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomResDto.java diff --git a/backend/src/main/java/org/example/backend/seminarRoom/domain/SeminarRoom.java b/backend/src/main/java/org/example/backend/seminarRoom/domain/SeminarRoom.java index 49297905..d4cea9ab 100644 --- a/backend/src/main/java/org/example/backend/seminarRoom/domain/SeminarRoom.java +++ b/backend/src/main/java/org/example/backend/seminarRoom/domain/SeminarRoom.java @@ -11,16 +11,17 @@ import java.util.ArrayList; import java.util.List; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import org.example.backend.reservation.domain.Reservation; +import org.example.backend.seminarRoom.domain.dto.SeminarRoomReqDto; @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "seminar_room") public class SeminarRoom { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "seminar_room_id") @@ -40,4 +41,28 @@ public class SeminarRoom { @OneToMany(mappedBy = "seminarRoom", cascade = CascadeType.ALL, orphanRemoval = true) private List reservations = new ArrayList<>(); -} + + @Builder + public SeminarRoom(String name, Integer personCapacity, String place, String image) { + this.name = name; + this.personCapacity = personCapacity; + this.place = place; + this.image = image; + } + + public static SeminarRoom of(SeminarRoomReqDto dto) { + return SeminarRoom.builder() + .name(dto.getName()) + .personCapacity(dto.getPersonCapacity()) + .place(dto.getPlace()) + .image(dto.getImage()) + .build(); + } + + public void update(SeminarRoomReqDto dto) { + this.name = dto.getName(); + this.personCapacity = dto.getPersonCapacity(); + this.place = dto.getPlace(); + this.image = dto.getImage(); + } +} \ No newline at end of file diff --git a/backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomReqDto.java b/backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomReqDto.java new file mode 100644 index 00000000..b9ae2b0c --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomReqDto.java @@ -0,0 +1,33 @@ +package org.example.backend.seminarRoom.domain.dto; + +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class SeminarRoomReqDto { + private String name; + private Integer personCapacity; + private String place; + private String image; + + @Builder + private SeminarRoomReqDto(String name, Integer personCapacity, String place, String image) { + this.name = name; + this.personCapacity = personCapacity; + this.place = place; + this.image = image; + } + + public static SeminarRoomReqDto of(String name, Integer personCapacity, String place, String image) { + return SeminarRoomReqDto.builder() + .name(name) + .personCapacity(personCapacity) + .place(place) + .image(image) + .build(); + } +} \ No newline at end of file diff --git a/backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomResDto.java b/backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomResDto.java new file mode 100644 index 00000000..f1d54345 --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/domain/dto/SeminarRoomResDto.java @@ -0,0 +1,36 @@ +package org.example.backend.seminarRoom.domain.dto; + +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.example.backend.seminarRoom.domain.SeminarRoom; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class SeminarRoomResDto { + private Long id; + private String name; + private Integer personCapacity; + private String place; + private String image; + + @Builder + private SeminarRoomResDto(Long id, String name, Integer personCapacity, String place, String image) { + this.id = id; + this.name = name; + this.personCapacity = personCapacity; + this.place = place; + this.image = image; + } + + public static SeminarRoomResDto of(SeminarRoom seminarRoom) { + return SeminarRoomResDto.builder() + .id(seminarRoom.getId()) + .name(seminarRoom.getName()) + .personCapacity(seminarRoom.getPersonCapacity()) + .place(seminarRoom.getPlace()) + .image(seminarRoom.getImage()) + .build(); + } +} \ No newline at end of file From e4e47ed664e3d4b7799f4031051398adc3f11456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:12:52 +0900 Subject: [PATCH 08/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20service=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SeminarRoomService.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java diff --git a/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java b/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java new file mode 100644 index 00000000..289698ab --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java @@ -0,0 +1,59 @@ +package org.example.backend.seminarRoom.service; + +import lombok.RequiredArgsConstructor; +import org.example.backend.seminarRoom.domain.SeminarRoom; +import org.example.backend.seminarRoom.domain.dto.SeminarRoomReqDto; +import org.example.backend.seminarRoom.domain.dto.SeminarRoomResDto; +import org.example.backend.seminarRoom.repository.SeminarRoomRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class SeminarRoomService { + private final SeminarRoomRepository seminarRoomRepository; + + @Transactional + public SeminarRoomResDto createSeminarRoom(SeminarRoomReqDto reqDto) { + validateSeminarRoom(reqDto); + + SeminarRoom seminarRoom = SeminarRoom.of(reqDto); + seminarRoomRepository.save(seminarRoom); + + return SeminarRoomResDto.of(seminarRoom); + } + + public SeminarRoomResDto getSeminarRoom(Long id) { + SeminarRoom seminarRoom = seminarRoomRepository.findById(id) + .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + return SeminarRoomResDto.of(seminarRoom); + } + + @Transactional + public SeminarRoomResDto updateSeminarRoom(Long id, SeminarRoomReqDto reqDto) { + validateSeminarRoom(reqDto); + + SeminarRoom seminarRoom = seminarRoomRepository.findById(id) + .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + + seminarRoom.update(reqDto); + return SeminarRoomResDto.of(seminarRoom); + } + + @Transactional + public void deleteSeminarRoom(Long id) { + SeminarRoom seminarRoom = seminarRoomRepository.findById(id) + .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + seminarRoomRepository.delete(seminarRoom); + } + + private void validateSeminarRoom(SeminarRoomReqDto reqDto) { + if (reqDto.getName() == null || reqDto.getName().trim().isEmpty()) { + throw new IllegalArgumentException("세미나실 이름은 필수입니다."); + } + if (reqDto.getPersonCapacity() == null || reqDto.getPersonCapacity() <= 0) { + throw new IllegalArgumentException("수용 인원은 1명 이상이어야 합니다."); + } + } +} From f5fe359d28509a665f316d76f27cf222b12b9fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:13:03 +0900 Subject: [PATCH 09/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20repository=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminarRoom/repository/SeminarRoomRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/repository/SeminarRoomRepository.java diff --git a/backend/src/main/java/org/example/backend/seminarRoom/repository/SeminarRoomRepository.java b/backend/src/main/java/org/example/backend/seminarRoom/repository/SeminarRoomRepository.java new file mode 100644 index 00000000..8eac9a3b --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/repository/SeminarRoomRepository.java @@ -0,0 +1,7 @@ +package org.example.backend.seminarRoom.repository; + +import org.example.backend.seminarRoom.domain.SeminarRoom; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SeminarRoomRepository extends JpaRepository { +} From 80fe25d0b44c8946eaf9d053dfc4b6b1a773411a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:13:08 +0900 Subject: [PATCH 10/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20controller=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SeminarRoomController.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/domain/controller/SeminarRoomController.java diff --git a/backend/src/main/java/org/example/backend/seminarRoom/domain/controller/SeminarRoomController.java b/backend/src/main/java/org/example/backend/seminarRoom/domain/controller/SeminarRoomController.java new file mode 100644 index 00000000..e5ba8f3c --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/domain/controller/SeminarRoomController.java @@ -0,0 +1,41 @@ +package org.example.backend.seminarRoom.domain.controller; + +import lombok.RequiredArgsConstructor; +import org.example.backend.seminarRoom.domain.dto.SeminarRoomReqDto; +import org.example.backend.seminarRoom.domain.dto.SeminarRoomResDto; +import org.example.backend.seminarRoom.service.SeminarRoomService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/seminar-rooms") +public class SeminarRoomController { + private final SeminarRoomService seminarRoomService; + + @PostMapping + public ResponseEntity createSeminarRoom(@RequestBody SeminarRoomReqDto reqDto) { + SeminarRoomResDto resDto = seminarRoomService.createSeminarRoom(reqDto); + return ResponseEntity.ok(resDto); + } + + @GetMapping("/{id}") + public ResponseEntity getSeminarRoom(@PathVariable Long id) { + SeminarRoomResDto resDto = seminarRoomService.getSeminarRoom(id); + return ResponseEntity.ok(resDto); + } + + @PutMapping("/{id}") + public ResponseEntity updateSeminarRoom( + @PathVariable Long id, + @RequestBody SeminarRoomReqDto reqDto) { + SeminarRoomResDto resDto = seminarRoomService.updateSeminarRoom(id, reqDto); + return ResponseEntity.ok(resDto); + } + + @DeleteMapping("/{id}") + public ResponseEntity deleteSeminarRoom(@PathVariable Long id) { + seminarRoomService.deleteSeminarRoom(id); + return ResponseEntity.ok().build(); + } +} \ No newline at end of file From b3e61da74b0d05f3bc0b860e11150373daaa2e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 03:13:41 +0900 Subject: [PATCH 11/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4,=20=EC=8B=9C=EA=B0=84=ED=91=9C=20=EB=8D=94=EB=AF=B8?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/data.sql | 210 +++++++++++++++++++++------- 1 file changed, 159 insertions(+), 51 deletions(-) diff --git a/backend/src/main/resources/data.sql b/backend/src/main/resources/data.sql index ce428e62..948c8889 100644 --- a/backend/src/main/resources/data.sql +++ b/backend/src/main/resources/data.sql @@ -1,14 +1,21 @@ -DELETE FROM board; -DELETE FROM thesis; -DELETE FROM seminar; -DELETE FROM professor; -DELETE FROM department; -DELETE FROM admin; +DELETE +FROM board; +DELETE +FROM thesis; +DELETE +FROM seminar; +DELETE +FROM professor; +DELETE +FROM department; +DELETE +FROM admin; -- Department 더미 데이터 (1개) INSERT INTO department (korean_name, english_name, intro, phone, location, educational_objective, work_hour, map) -VALUES ('컴퓨터공학과', 'Computer Engineering', '컴퓨터공학과 소개', '010-1234-5678', '본관 101호', '컴퓨터 공학 인재 양성', '9:00 - 18:00', 'https://example.com/map'); +VALUES ('컴퓨터공학과', 'Computer Engineering', '컴퓨터공학과 소개', '010-1234-5678', '본관 101호', '컴퓨터 공학 인재 양성', '9:00 - 18:00', + 'https://example.com/map'); -- Admin 더미 데이터 (1개) INSERT INTO admin (login_id, password, username, email, role) @@ -16,57 +23,158 @@ VALUES ('admin', '$2a$10$FKHTTHcEkAZZGW9XqGtPfOx.apKljbCLvYESM05YbLWzDynnacLPO', -- Professor 더미 데이터 (10개) INSERT INTO professor (name, major, phone, email, position, homepage, lab, profile_image) -VALUES - ('교수1', 'AI', '010-1111-1111', 'prof1@example.com', '교수', 'https://prof1-homepage.com', 'AI 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+008.png'), - ('교수2', 'Machine Learning', '010-2222-2222', 'prof2@example.com', '교수', 'https://prof2-homepage.com', 'ML 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+007.png'), - ('교수3', 'Computer Vision', '010-3333-3333', 'prof3@example.com', '교수', 'https://prof3-homepage.com', 'CV 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+006.png'), - ('교수4', 'NLP', '010-4444-4444', 'prof4@example.com', '교수', 'https://prof4-homepage.com', 'NLP 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+005.png'), - ('교수5', 'Data Science', '010-5555-5555', 'prof5@example.com', '교수', 'https://prof5-homepage.com', 'DS 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+004.png'), - ('교수6', 'Software Engineering', '010-6666-6666', 'prof6@example.com', '교수', 'https://prof6-homepage.com', 'SE 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+003.png'), - ('교수7', 'Cyber Security', '010-7777-7777', 'prof7@example.com', '교수', 'https://prof7-homepage.com', 'CS 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-17+002.png'), - ('교수8', 'Blockchain', '010-8888-8888', 'prof8@example.com', '교수', 'https://prof8-homepage.com', 'Blockchain 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-17+001.png'), - ('교수9', 'Cloud Computing', '010-9999-9999', 'prof9@example.com', '교수', 'https://prof9-homepage.com', 'Cloud 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/dibb.png'), - ('교수10', 'Computer Graphics', '010-1010-1010', 'prof10@example.com', '교수', 'https://prof10-homepage.com', 'CG 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/profile/(1116)%E1%84%83%E1%85%A1%E1%84%8B%E1%85%B5%E1%84%82%E1%85%A1%E1%84%86%E1%85%B5%E1%86%A8%E1%84%83%E1%85%B2%E1%84%8B%E1%85%A9+%E1%84%83%E1%85%A1%E1%86%AB%E1%84%8E%E1%85%A6%E1%84%8F%E1%85%A5%E1%86%BA(1).jpg'); +VALUES ('교수1', 'AI', '010-1111-1111', 'prof1@example.com', '교수', 'https://prof1-homepage.com', 'AI 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+008.png'), + ('교수2', 'Machine Learning', '010-2222-2222', 'prof2@example.com', '교수', 'https://prof2-homepage.com', 'ML 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+007.png'), + ('교수3', 'Computer Vision', '010-3333-3333', 'prof3@example.com', '교수', 'https://prof3-homepage.com', 'CV 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+006.png'), + ('교수4', 'NLP', '010-4444-4444', 'prof4@example.com', '교수', 'https://prof4-homepage.com', 'NLP 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+005.png'), + ('교수5', 'Data Science', '010-5555-5555', 'prof5@example.com', '교수', 'https://prof5-homepage.com', 'DS 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+004.png'), + ('교수6', 'Software Engineering', '010-6666-6666', 'prof6@example.com', '교수', 'https://prof6-homepage.com', + 'SE 연구실', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-18+003.png'), + ('교수7', 'Cyber Security', '010-7777-7777', 'prof7@example.com', '교수', 'https://prof7-homepage.com', 'CS 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-17+002.png'), + ('교수8', 'Blockchain', '010-8888-8888', 'prof8@example.com', '교수', 'https://prof8-homepage.com', 'Blockchain 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/KakaoTalk_Photo_2024-11-21-17-36-17+001.png'), + ('교수9', 'Cloud Computing', '010-9999-9999', 'prof9@example.com', '교수', 'https://prof9-homepage.com', 'Cloud 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/dibb.png'), + ('교수10', 'Computer Graphics', '010-1010-1010', 'prof10@example.com', '교수', 'https://prof10-homepage.com', + 'CG 연구실', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/profile/(1116)%E1%84%83%E1%85%A1%E1%84%8B%E1%85%B5%E1%84%82%E1%85%A1%E1%84%86%E1%85%B5%E1%86%A8%E1%84%83%E1%85%B2%E1%84%8B%E1%85%A9+%E1%84%83%E1%85%A1%E1%86%AB%E1%84%8E%E1%85%A6%E1%84%8F%E1%85%A5%E1%86%BA(1).jpg'); -- Seminar 더미 데이터 (10개) INSERT INTO seminar (name, writer, place, start_date, end_date, speaker, company) -VALUES - ('세미나1', '작성자1', '세미나룸 A', '2024-01-01', '2024-01-02', '연사1', '기업1'), - ('세미나2', '작성자2', '세미나룸 B', '2024-01-10', '2024-01-11', '연사2', '기업2'), - ('세미나3', '작성자3', '세미나룸 C', '2024-02-01', '2024-02-02', '연사3', '기업3'), - ('세미나4', '작성자4', '세미나룸 D', '2024-03-01', '2024-03-02', '연사4', '기업4'), - ('세미나5', '작성자5', '세미나룸 E', '2024-04-01', '2024-04-02', '연사5', '기업5'), - ('세미나6', '작성자6', '세미나룸 F', '2024-05-01', '2024-05-02', '연사6', '기업6'), - ('세미나7', '작성자7', '세미나룸 G', '2024-06-01', '2024-06-02', '연사7', '기업7'), - ('세미나8', '작성자8', '세미나룸 H', '2024-07-01', '2024-07-02', '연사8', '기업8'), - ('세미나9', '작성자9', '세미나룸 I', '2024-08-01', '2024-08-02', '연사9', '기업9'), - ('세미나10', '작성자10', '세미나룸 J', '2024-09-01', '2024-09-02', '연사10', '기업10'); +VALUES ('세미나1', '작성자1', '세미나룸 A', '2024-01-01', '2024-01-02', '연사1', '기업1'), + ('세미나2', '작성자2', '세미나룸 B', '2024-01-10', '2024-01-11', '연사2', '기업2'), + ('세미나3', '작성자3', '세미나룸 C', '2024-02-01', '2024-02-02', '연사3', '기업3'), + ('세미나4', '작성자4', '세미나룸 D', '2024-03-01', '2024-03-02', '연사4', '기업4'), + ('세미나5', '작성자5', '세미나룸 E', '2024-04-01', '2024-04-02', '연사5', '기업5'), + ('세미나6', '작성자6', '세미나룸 F', '2024-05-01', '2024-05-02', '연사6', '기업6'), + ('세미나7', '작성자7', '세미나룸 G', '2024-06-01', '2024-06-02', '연사7', '기업7'), + ('세미나8', '작성자8', '세미나룸 H', '2024-07-01', '2024-07-02', '연사8', '기업8'), + ('세미나9', '작성자9', '세미나룸 I', '2024-08-01', '2024-08-02', '연사9', '기업9'), + ('세미나10', '작성자10', '세미나룸 J', '2024-09-01', '2024-09-02', '연사10', '기업10'); -- Thesis 더미 데이터 (10개) -INSERT INTO thesis (author, journal, content, link, publication_date, thesis_image, publication_collection, publication_issue, publication_page, issn, professor_id) -VALUES - ('저자1', 'Journal A', '논문 내용 1', 'https://example.com/thesis1', '2024-01-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_540224b.jpg', 'Volume 1', 'Issue 1', 'Page 1', '1234-5678', 1), - ('저자2', 'Journal B', '논문 내용 2', 'https://example.com/thesis2', '2024-02-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_587943b.jpg', 'Volume 2', 'Issue 2', 'Page 2', '2345-6789', 2), - ('저자3', 'Journal C', '논문 내용 3', 'https://example.com/thesis3', '2024-03-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_590742b.jpg', 'Volume 3', 'Issue 3', 'Page 3', '3456-7890', 3), - ('저자4', 'Journal D', '논문 내용 4', 'https://example.com/thesis4', '2024-04-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_590742b.jpg', 'Volume 4', 'Issue 4', 'Page 4', '4567-8901', 4), - ('저자5', 'Journal E', '논문 내용 5', 'https://example.com/thesis5', '2024-05-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_590852b.jpg', 'Volume 5', 'Issue 5', 'Page 5', '5678-9012', 5), - ('저자6', 'Journal F', '논문 내용 6', 'https://example.com/thesis6', '2024-06-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_593743b.jpg', 'Volume 6', 'Issue 6', 'Page 6', '6789-0123', 6), - ('저자7', 'Journal G', '논문 내용 7', 'https://example.com/thesis7', '2024-07-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_593743b.jpg', 'Volume 7', 'Issue 7', 'Page 7', '7890-1234', 7), - ('저자8', 'Journal H', '논문 내용 8', 'https://example.com/thesis8', '2024-08-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_596862b.jpg', 'Volume 8', 'Issue 8', 'Page 8', '8901-2345', 8), - ('저자9', 'Journal I', '논문 내용 9', 'https://example.com/thesis9', '2024-09-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_598360b.jpg', 'Volume 9', 'Issue 9', 'Page 9', '9012-3456', 9), - ('저자10', 'Journal J', '논문 내용 10', 'https://example.com/thesis10', '2024-10-01', 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_598598b.jpg', 'Volume 10', 'Issue 10', 'Page 10', '0123-4567', 10); +INSERT INTO thesis (author, journal, content, link, publication_date, thesis_image, publication_collection, + publication_issue, publication_page, issn, professor_id) +VALUES ('저자1', 'Journal A', '논문 내용 1', 'https://example.com/thesis1', '2024-01-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_540224b.jpg', 'Volume 1', 'Issue 1', 'Page 1', + '1234-5678', 1), + ('저자2', 'Journal B', '논문 내용 2', 'https://example.com/thesis2', '2024-02-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_587943b.jpg', 'Volume 2', 'Issue 2', 'Page 2', + '2345-6789', 2), + ('저자3', 'Journal C', '논문 내용 3', 'https://example.com/thesis3', '2024-03-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_590742b.jpg', 'Volume 3', 'Issue 3', 'Page 3', + '3456-7890', 3), + ('저자4', 'Journal D', '논문 내용 4', 'https://example.com/thesis4', '2024-04-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_590742b.jpg', 'Volume 4', 'Issue 4', 'Page 4', + '4567-8901', 4), + ('저자5', 'Journal E', '논문 내용 5', 'https://example.com/thesis5', '2024-05-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_590852b.jpg', 'Volume 5', 'Issue 5', 'Page 5', + '5678-9012', 5), + ('저자6', 'Journal F', '논문 내용 6', 'https://example.com/thesis6', '2024-06-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_593743b.jpg', 'Volume 6', 'Issue 6', 'Page 6', + '6789-0123', 6), + ('저자7', 'Journal G', '논문 내용 7', 'https://example.com/thesis7', '2024-07-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_593743b.jpg', 'Volume 7', 'Issue 7', 'Page 7', + '7890-1234', 7), + ('저자8', 'Journal H', '논문 내용 8', 'https://example.com/thesis8', '2024-08-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_596862b.jpg', 'Volume 8', 'Issue 8', 'Page 8', + '8901-2345', 8), + ('저자9', 'Journal I', '논문 내용 9', 'https://example.com/thesis9', '2024-09-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_598360b.jpg', 'Volume 9', 'Issue 9', 'Page 9', + '9012-3456', 9), + ('저자10', 'Journal J', '논문 내용 10', 'https://example.com/thesis10', '2024-10-01', + 'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/is_598598b.jpg', 'Volume 10', 'Issue 10', 'Page 10', + '0123-4567', 10); -- Board 더미 데이터 (10개) INSERT INTO board (title, content, view_count, writer, file, category) +VALUES ('첫 번째 게시글', '게시글 내용 1', 10, '작성자1', 'file1.txt', 'undergraduate'), + ('두 번째 게시글', '게시글 내용 2', 20, '작성자2', 'file2.txt', 'graduate'), + ('세 번째 게시글', '게시글 내용 3', 30, '작성자3', 'file3.txt', 'employment'), + ('네 번째 게시글', '게시글 내용 4', 40, '작성자4', 'file4.txt', 'scholarship'), + ('다섯 번째 게시글', '게시글 내용 5', 50, '작성자5', 'file5.txt', 'undergraduate'), + ('여섯 번째 게시글', '게시글 내용 6', 60, '작성자6', 'file6.txt', 'graduate'), + ('일곱 번째 게시글', '게시글 내용 7', 70, '작성자7', 'file7.txt', 'employment'), + ('여덟 번째 게시글', '게시글 내용 8', 80, '작성자8', 'file8.txt', 'scholarship'), + ('아홉 번째 게시글', '게시글 내용 9', 90, '작성자9', 'file9.txt', 'undergraduate'), + ('열 번째 게시글', '게시글 내용 10', 100, '작성자10', 'file10.txt', 'graduate'); + + +-- 세미나실 더미데이터 +INSERT INTO seminar_room (name, person_capacity, place, image) +VALUES ('제1세미나실', 20, '본관 3층', 'seminar1.jpg'); +-- 세미나실 더미데이터 +INSERT INTO seminar_room (name, person_capacity, place, image) +VALUES ('제1세미나실', 20, '본관 3층', 'seminar1.jpg'), + ('제2세미나실', 15, '본관 3층', 'seminar2.jpg'), + ('제3세미나실', 30, '본관 4층', 'seminar3.jpg'), + ('스터디룸A', 8, '별관 2층', 'studyA.jpg'), + ('스터디룸B', 8, '별관 2층', 'studyB.jpg'), + ('대회의실', 50, '본관 5층', 'conference.jpg'), + ('소회의실', 12, '본관 5층', 'meeting.jpg'), + ('프로젝트룸1', 10, '별관 3층', 'project1.jpg'), + ('프로젝트룸2', 10, '별관 3층', 'project2.jpg'), + ('강의실A', 40, '본관 2층', 'lectureA.jpg'); + +-- Timetable 더미데이터 +INSERT INTO timetable (start_date, end_date, start_time, end_time, seminar_room_id) +VALUES ('2024-03-04', '2024-06-21', '09:00:00', '10:30:00', 1), + ('2024-03-04', '2024-06-21', '11:00:00', '12:30:00', 1), + ('2024-03-04', '2024-06-21', '13:00:00', '14:30:00', 1), + ('2024-03-11', '2024-06-14', '15:00:00', '17:00:00', 1), + ('2024-03-11', '2024-06-14', '18:00:00', '20:00:00', 1), + ('2024-03-04', '2024-06-21', '10:00:00', '11:30:00', 1), + ('2024-03-04', '2024-06-21', '14:00:00', '15:30:00', 1), + ('2024-03-11', '2024-06-14', '16:00:00', '18:00:00', 1), + ('2024-03-11', '2024-06-14', '13:00:00', '15:00:00', 1), + ('2024-03-04', '2024-06-21', '09:30:00', '11:00:00', 1); + +-- Timetable WeekDays 더미데이터 +INSERT INTO timetable_week_days (timetable_timetable_id, week_days) VALUES - ('첫 번째 게시글', '게시글 내용 1', 10, '작성자1', 'file1.txt', 'undergraduate'), - ('두 번째 게시글', '게시글 내용 2', 20, '작성자2', 'file2.txt', 'graduate'), - ('세 번째 게시글', '게시글 내용 3', 30, '작성자3', 'file3.txt', 'employment'), - ('네 번째 게시글', '게시글 내용 4', 40, '작성자4', 'file4.txt', 'scholarship'), - ('다섯 번째 게시글', '게시글 내용 5', 50, '작성자5', 'file5.txt', 'undergraduate'), - ('여섯 번째 게시글', '게시글 내용 6', 60, '작성자6', 'file6.txt', 'graduate'), - ('일곱 번째 게시글', '게시글 내용 7', 70, '작성자7', 'file7.txt', 'employment'), - ('여덟 번째 게시글', '게시글 내용 8', 80, '작성자8', 'file8.txt', 'scholarship'), - ('아홉 번째 게시글', '게시글 내용 9', 90, '작성자9', 'file9.txt', 'undergraduate'), - ('열 번째 게시글', '게시글 내용 10', 100, '작성자10', 'file10.txt','graduate'); +-- 1번 시간표 (월수금) +(1, 'MONDAY'), +(1, 'WEDNESDAY'), +(1, 'FRIDAY'), + +-- 2번 시간표 (화목) +(2, 'TUESDAY'), +(2, 'THURSDAY'), + +-- 3번 시간표 (월수) +(3, 'MONDAY'), +(3, 'WEDNESDAY'), + +-- 4번 시간표 (목금) +(4, 'THURSDAY'), +(4, 'FRIDAY'), + +-- 5번 시간표 (월수) +(5, 'MONDAY'), +(5, 'WEDNESDAY'), + +-- 6번 시간표 (화) +(6, 'TUESDAY'), + +-- 7번 시간표 (수) +(7, 'WEDNESDAY'), + +-- 8번 시간표 (월목) +(8, 'MONDAY'), +(8, 'THURSDAY'), + +-- 9번 시간표 (화금) +(9, 'TUESDAY'), +(9, 'FRIDAY'), + +-- 10번 시간표 (월수금) +(10, 'MONDAY'), +(10, 'WEDNESDAY'), +(10, 'FRIDAY'); \ No newline at end of file From 17a281723cbdcad1a698abbc47b966add4450f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 13:45:50 +0900 Subject: [PATCH 12/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/SeminarRoomException.java | 15 +++++++++++ .../exception/SeminarRoomExceptionType.java | 26 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomException.java create mode 100644 backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java diff --git a/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomException.java b/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomException.java new file mode 100644 index 00000000..af85cc60 --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomException.java @@ -0,0 +1,15 @@ +package org.example.backend.seminarRoom.exception; + +import lombok.RequiredArgsConstructor; +import org.example.backend.common.exception.BaseException; +import org.example.backend.common.exception.BaseExceptionType; +import org.example.backend.seminar.exception.SeminarExceptionType; + +@RequiredArgsConstructor +public class SeminarRoomException extends BaseException { + private final SeminarRoomExceptionType exceptionType; + @Override + public BaseExceptionType exceptionType() { + return exceptionType; + } +} diff --git a/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java b/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java new file mode 100644 index 00000000..ebb198aa --- /dev/null +++ b/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java @@ -0,0 +1,26 @@ +package org.example.backend.seminarRoom.exception; + +import static org.springframework.http.HttpStatus.NOT_FOUND; + +import lombok.RequiredArgsConstructor; +import org.example.backend.common.exception.BaseExceptionType; +import org.springframework.http.HttpStatus; + +@RequiredArgsConstructor +public enum SeminarRoomExceptionType implements BaseExceptionType { + NOT_FOUND_SEMINAR_ROOM(NOT_FOUND, "세미나룸를 찾을 수 없습니다") + ; + + private final HttpStatus httpStatus; + private final String errorMessage; + + @Override + public HttpStatus httpStatus() { + return null; + } + + @Override + public String errorMessage() { + return null; + } +} From 58f077241dab3b1e24adc3a05606e23482098968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 13:45:55 +0900 Subject: [PATCH 13/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/TimetableException.java | 15 +++++++++++ .../exception/TimetableExceptionType.java | 25 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 backend/src/main/java/org/example/backend/timetable/exception/TimetableException.java create mode 100644 backend/src/main/java/org/example/backend/timetable/exception/TimetableExceptionType.java diff --git a/backend/src/main/java/org/example/backend/timetable/exception/TimetableException.java b/backend/src/main/java/org/example/backend/timetable/exception/TimetableException.java new file mode 100644 index 00000000..412b1631 --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/exception/TimetableException.java @@ -0,0 +1,15 @@ +package org.example.backend.timetable.exception; + +import lombok.RequiredArgsConstructor; +import org.example.backend.common.exception.BaseException; +import org.example.backend.common.exception.BaseExceptionType; +import org.example.backend.seminar.exception.SeminarExceptionType; + +@RequiredArgsConstructor +public class TimetableException extends BaseException { + private final TimetableExceptionType exceptionType; + @Override + public BaseExceptionType exceptionType() { + return exceptionType; + } +} diff --git a/backend/src/main/java/org/example/backend/timetable/exception/TimetableExceptionType.java b/backend/src/main/java/org/example/backend/timetable/exception/TimetableExceptionType.java new file mode 100644 index 00000000..f8e25a44 --- /dev/null +++ b/backend/src/main/java/org/example/backend/timetable/exception/TimetableExceptionType.java @@ -0,0 +1,25 @@ +package org.example.backend.timetable.exception; + +import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.NOT_FOUND; + +import lombok.RequiredArgsConstructor; +import org.example.backend.common.exception.BaseExceptionType; +import org.springframework.http.HttpStatus; + +@RequiredArgsConstructor +public enum TimetableExceptionType implements BaseExceptionType { + NOT_FOUND_TIMETABLE(NOT_FOUND, "시간표를 찾을 수 없습니다"), + INVALID_INPUT_TIME(BAD_REQUEST, "시작 날짜는 종료 날짜보다 이후일 수 없습니다."); + private final HttpStatus httpStatus; + private final String errorMessage; + @Override + public HttpStatus httpStatus() { + return null; + } + + @Override + public String errorMessage() { + return null; + } +} From 8e2934877b7a00b20f2b6698249b9d8a834089c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 13:48:48 +0900 Subject: [PATCH 14/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminarRoom/exception/SeminarRoomExceptionType.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java b/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java index ebb198aa..5a45a111 100644 --- a/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java +++ b/backend/src/main/java/org/example/backend/seminarRoom/exception/SeminarRoomExceptionType.java @@ -1,5 +1,6 @@ package org.example.backend.seminarRoom.exception; +import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.NOT_FOUND; import lombok.RequiredArgsConstructor; @@ -8,7 +9,9 @@ @RequiredArgsConstructor public enum SeminarRoomExceptionType implements BaseExceptionType { - NOT_FOUND_SEMINAR_ROOM(NOT_FOUND, "세미나룸를 찾을 수 없습니다") + NOT_FOUND_SEMINAR_ROOM(NOT_FOUND, "세미나룸를 찾을 수 없습니다"), + INVALID_NAME_VALUE(BAD_REQUEST, "세미나실 이름은 필수입니다."), + INVALID_CAPACITY(BAD_REQUEST, "수용 인원은 1명 이상이어야 합니다."); ; private final HttpStatus httpStatus; From 3ab3c8b896510afa114d5d6710c283c512016955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 13:49:02 +0900 Subject: [PATCH 15/16] =?UTF-8?q?feat:=20=EC=84=B8=EB=AF=B8=EB=82=98?= =?UTF-8?q?=EC=8B=A4=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminarRoom/service/SeminarRoomService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java b/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java index 289698ab..010c06e0 100644 --- a/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java +++ b/backend/src/main/java/org/example/backend/seminarRoom/service/SeminarRoomService.java @@ -1,9 +1,14 @@ package org.example.backend.seminarRoom.service; +import static org.example.backend.seminarRoom.exception.SeminarRoomExceptionType.INVALID_CAPACITY; +import static org.example.backend.seminarRoom.exception.SeminarRoomExceptionType.INVALID_NAME_VALUE; +import static org.example.backend.seminarRoom.exception.SeminarRoomExceptionType.NOT_FOUND_SEMINAR_ROOM; + import lombok.RequiredArgsConstructor; import org.example.backend.seminarRoom.domain.SeminarRoom; import org.example.backend.seminarRoom.domain.dto.SeminarRoomReqDto; import org.example.backend.seminarRoom.domain.dto.SeminarRoomResDto; +import org.example.backend.seminarRoom.exception.SeminarRoomException; import org.example.backend.seminarRoom.repository.SeminarRoomRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,7 +31,7 @@ public SeminarRoomResDto createSeminarRoom(SeminarRoomReqDto reqDto) { public SeminarRoomResDto getSeminarRoom(Long id) { SeminarRoom seminarRoom = seminarRoomRepository.findById(id) - .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + .orElseThrow(() -> new SeminarRoomException(NOT_FOUND_SEMINAR_ROOM)); return SeminarRoomResDto.of(seminarRoom); } @@ -35,7 +40,7 @@ public SeminarRoomResDto updateSeminarRoom(Long id, SeminarRoomReqDto reqDto) { validateSeminarRoom(reqDto); SeminarRoom seminarRoom = seminarRoomRepository.findById(id) - .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + .orElseThrow(() -> new SeminarRoomException(NOT_FOUND_SEMINAR_ROOM)); seminarRoom.update(reqDto); return SeminarRoomResDto.of(seminarRoom); @@ -44,16 +49,16 @@ public SeminarRoomResDto updateSeminarRoom(Long id, SeminarRoomReqDto reqDto) { @Transactional public void deleteSeminarRoom(Long id) { SeminarRoom seminarRoom = seminarRoomRepository.findById(id) - .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + .orElseThrow(() -> new SeminarRoomException(NOT_FOUND_SEMINAR_ROOM)); seminarRoomRepository.delete(seminarRoom); } private void validateSeminarRoom(SeminarRoomReqDto reqDto) { if (reqDto.getName() == null || reqDto.getName().trim().isEmpty()) { - throw new IllegalArgumentException("세미나실 이름은 필수입니다."); + throw new SeminarRoomException(INVALID_NAME_VALUE); } if (reqDto.getPersonCapacity() == null || reqDto.getPersonCapacity() <= 0) { - throw new IllegalArgumentException("수용 인원은 1명 이상이어야 합니다."); + throw new SeminarRoomException(INVALID_CAPACITY); } } } From 7e66aa4ec45b4320317e3f8f322895af1e995fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=98=81=EC=9E=AC?= Date: Sun, 24 Nov 2024 13:49:21 +0900 Subject: [PATCH 16/16] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetable/service/TimetableService.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java b/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java index f58142a4..fac21f2b 100644 --- a/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java +++ b/backend/src/main/java/org/example/backend/timetable/service/TimetableService.java @@ -1,14 +1,19 @@ package org.example.backend.timetable.service; -import jakarta.persistence.EntityNotFoundException; +import static org.example.backend.seminarRoom.exception.SeminarRoomExceptionType.NOT_FOUND_SEMINAR_ROOM; +import static org.example.backend.timetable.exception.TimetableExceptionType.NOT_FOUND_TIMETABLE; + import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.example.backend.seminarRoom.domain.SeminarRoom; +import org.example.backend.seminarRoom.exception.SeminarRoomException; import org.example.backend.seminarRoom.repository.SeminarRoomRepository; import org.example.backend.timetable.domain.Timetable; import org.example.backend.timetable.domain.dto.TimetableReqDto; import org.example.backend.timetable.domain.dto.TimetableResDto; +import org.example.backend.timetable.exception.TimetableException; +import org.example.backend.timetable.exception.TimetableExceptionType; import org.example.backend.timetable.repository.TimetableRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,7 +28,7 @@ public class TimetableService { @Transactional public TimetableResDto createTimetable(TimetableReqDto reqDto) { SeminarRoom seminarRoom = seminarRoomRepository.findById(reqDto.getSeminarRoomId()) - .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + .orElseThrow(() -> new TimetableException(NOT_FOUND_TIMETABLE)); validateTimeRange(reqDto); @@ -42,10 +47,10 @@ public List getAllTimetables() { @Transactional public TimetableResDto updateTimetable(Long timetableId, TimetableReqDto reqDto) { Timetable timetable = timetableRepository.findById(timetableId) - .orElseThrow(() -> new IllegalArgumentException("시간표가 존재하지 않습니다.")); + .orElseThrow(() -> new TimetableException(NOT_FOUND_TIMETABLE)); SeminarRoom seminarRoom = seminarRoomRepository.findById(reqDto.getSeminarRoomId()) - .orElseThrow(() -> new IllegalArgumentException("세미나실이 존재하지 않습니다.")); + .orElseThrow(() -> new SeminarRoomException(NOT_FOUND_SEMINAR_ROOM)); validateTimeRange(reqDto); @@ -56,16 +61,16 @@ public TimetableResDto updateTimetable(Long timetableId, TimetableReqDto reqDto) @Transactional public void deleteTimetable(Long timetableId) { Timetable timetable = timetableRepository.findById(timetableId) - .orElseThrow(() -> new IllegalArgumentException("시간표가 존재하지 않습니다.")); + .orElseThrow(() -> new TimetableException(NOT_FOUND_TIMETABLE)); timetableRepository.delete(timetable); } private void validateTimeRange(TimetableReqDto reqDto) { if (reqDto.getStartDate().isAfter(reqDto.getEndDate())) { - throw new IllegalArgumentException("시작 날짜는 종료 날짜보다 이후일 수 없습니다."); + throw new TimetableException(TimetableExceptionType.INVALID_INPUT_TIME); } if (reqDto.getStartTime().isAfter(reqDto.getEndTime())) { - throw new IllegalArgumentException("시작 시간은 종료 시간보다 이후일 수 없습니다."); + throw new TimetableException(TimetableExceptionType.INVALID_INPUT_TIME); } } } \ No newline at end of file