Skip to content

Commit

Permalink
Merge pull request #254 from urinaner/fix/253
Browse files Browse the repository at this point in the history
[BE] [FIX] 세미나 시간 추가 및 삭제기능 수정
  • Loading branch information
urinaner authored Jan 12, 2025
2 parents 36fa151 + cca4c5c commit cb1aeb6
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.example.backend.seminar.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -9,35 +13,51 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class SeminarReqDto {

@NotBlank(message = "세미나 이름은 필수 입력값입니다.")
@Size(max = 200, message = "세미나 이름은 최대 200자까지 입력 가능합니다")
private String name;

@Size(max = 100, message = "작성자는 최대 100자까지 입력 가능합니다")
private String writer;

@Size(max = 100, message = "장소는 최대 100자까지 입력 가능합니다")
private String place;
private String startDate;
private String endDate;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@NotNull(message = "시작 시간은 필수 입력값입니다.")
private String startTime;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@NotNull(message = "종료 시간은 필수 입력값입니다.")
private String endTime;

@Size(max = 100, message = "연사는 최대 100자까지 입력 가능합니다")
private String speaker;

@Size(max = 100, message = "소속은 최대 100자까지 입력 가능합니다")
private String company;

@Builder
private SeminarReqDto(String name, String writer, String place,
String startDate, String endDate, String speaker, String company) {
String startTime, String endTime, String speaker, String company) {
this.name = name;
this.writer = writer;
this.place = place;
this.startDate = startDate;
this.endDate = endDate;
this.startTime = startTime;
this.endTime = endTime;
this.speaker = speaker;
this.company = company;
}

public static SeminarReqDto of(String name, String writer, String place,
String startDate, String endDate, String speaker, String company) {
String startTime, String endTime, String speaker, String company) {
return SeminarReqDto.builder()
.name(name)
.writer(writer)
.place(place)
.startDate(startDate)
.endDate(endDate)
.startTime(startTime)
.endTime(endTime)
.speaker(speaker)
.company(company)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.example.backend.seminar.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.example.backend.common.utils.TimeParsingUtils;
import org.example.backend.seminar.domain.entity.Seminar;

@Getter
Expand All @@ -13,20 +15,22 @@ public class SeminarResDto {
private String name;
private String writer;
private String place;
private String startDate;
private String endDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private String startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private String endTime;
private String speaker;
private String company;

@Builder
private SeminarResDto(Long id, String name, String writer, String place,
String startDate, String endDate, String speaker, String company) {
String startTime, String endTime, String speaker, String company) {
this.id = id;
this.name = name;
this.writer = writer;
this.place = place;
this.startDate = startDate;
this.endDate = endDate;
this.startTime = startTime;
this.endTime = endTime;
this.speaker = speaker;
this.company = company;
}
Expand All @@ -37,8 +41,8 @@ public static SeminarResDto of(Seminar seminar) {
.name(seminar.getName())
.writer(seminar.getWriter())
.place(seminar.getPlace())
.startDate(seminar.getStartDate())
.endDate(seminar.getEndDate())
.startTime(TimeParsingUtils.formatterString(seminar.getStartTime()))
.endTime(TimeParsingUtils.formatterString(seminar.getEndTime()))
.speaker(seminar.getSpeaker())
.company(seminar.getCompany())
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.example.backend.seminar.domain.entity;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.example.backend.common.utils.TimeParsingUtils;
import org.example.backend.seminar.domain.dto.SeminarReqDto;

@Entity
Expand All @@ -26,11 +28,11 @@ public class Seminar {
@Column(name = "place")
private String place;

@Column(name = "start_date")
private String startDate;
@Column(name = "start_time")
private LocalDateTime startTime;

@Column(name = "end_date")
private String endDate;
@Column(name = "end_time")
private LocalDateTime endTime;

@Column(name = "speaker")
private String speaker;
Expand All @@ -39,13 +41,12 @@ public class Seminar {
private String company;

@Builder
private Seminar(String name, String writer, String place, String startDate,
String endDate, String speaker, String company) {
private Seminar(String name, String writer, String place, LocalDateTime startTime, LocalDateTime endTime, String speaker, String company) {
this.name = name;
this.writer = writer;
this.place = place;
this.startDate = startDate;
this.endDate = endDate;
this.startTime = startTime;
this.endTime = endTime;
this.speaker = speaker;
this.company = company;
}
Expand All @@ -55,8 +56,8 @@ public static Seminar of(SeminarReqDto dto) {
.name(dto.getName())
.writer(dto.getWriter())
.place(dto.getPlace())
.startDate(dto.getStartDate())
.endDate(dto.getEndDate())
.startTime(TimeParsingUtils.formatterLocalDateTime(String.valueOf(dto.getStartTime())))
.endTime(TimeParsingUtils.formatterLocalDateTime(String.valueOf(dto.getEndTime())))
.speaker(dto.getSpeaker())
.company(dto.getCompany())
.build();
Expand All @@ -66,8 +67,8 @@ public void update(SeminarReqDto dto) {
this.name = dto.getName();
this.writer = dto.getWriter();
this.place = dto.getPlace();
this.startDate = dto.getStartDate();
this.endDate = dto.getEndDate();
this.startTime = TimeParsingUtils.formatterLocalDateTime(String.valueOf(dto.getStartTime()));
this.endTime = TimeParsingUtils.formatterLocalDateTime(String.valueOf(dto.getEndTime()));
this.speaker = dto.getSpeaker();
this.company = dto.getCompany();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public SeminarResDto updateSeminar(Long seminarId, SeminarReqDto seminarReqDto)
return SeminarResDto.of(seminar);
}

@Transactional
public void deleteSeminar(Long seminarId) {
Seminar seminar = findSeminarById(seminarId);
seminarRepository.delete(seminar);
Expand Down
22 changes: 11 additions & 11 deletions backend/src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ VALUES ('권병호', '신경생물학', '010-3178-5629', '[email protected]', '
'https://dibb-bucket.s3.ap-northeast-2.amazonaws.com/dummy/KakaoTalk_Photo_2024-12-05-14-44-57+010.png');

-- Seminar 더미 데이터 (10개)
INSERT INTO seminar (name, writer, place, start_date, end_date, speaker, company)
INSERT INTO seminar (name, writer, place, start_time, end_time, speaker, company)
VALUES ('Genome-wide association study to identify QTL for fruit-related traits in a core collection of 287 tomato accessions',
'이건', '충무관101A', '2024-11-29', '2024-11-29', '심성철', '세종대학교 바이오산업자원공학'),
('HOW AL PREDICTS SEISMIC SHAKING', '이건', '충무관702', '2024-12-04', '2024-12-04', '이재홍', 'NIHON UNIVERSITY'),
('CRISPR/Cas9-mediated genome editing for crop improvement', '이건', '충무관101A', '2024-11-30', '2024-11-30', '정다은',
'이건', '충무관101A', '2024-11-29 09:00:00', '2024-11-29 10:00:00', '심성철', '세종대학교 바이오산업자원공학'),
('HOW AL PREDICTS SEISMIC SHAKING', '이건', '충무관702', '2024-12-04 09:00:00', '2024-12-04 10:00:00', '이재홍', 'NIHON UNIVERSITY'),
('CRISPR/Cas9-mediated genome editing for crop improvement', '이건', '충무관101A', '2024-11-30 09:00:00', '2024-11-30 10:00:00', '정다은',
'서울대학교 농생명과학대학'),
('Metabolomics in precision medicine: Current trends and applications', '이건', '충무관702', '2024-12-01',
'2024-12-01', '김현지', '한국생명공학연구원'),
('Advanced tissue engineering for regenerative medicine', '이건', '충무관101A', '2024-12-02', '2024-12-02', '박진우',
('Metabolomics in precision medicine: Current trends and applications', '이건', '충무관702', '2024-12-01 09:00:00',
'2024-12-01 10:00:00', '김현지', '한국생명공학연구원'),
('Advanced tissue engineering for regenerative medicine', '이건', '충무관101A', '2024-12-02 09:00:00', '2024-12-02 10:00:00', '박진우',
'KAIST 바이오융합센터'),
('Bioplastics: Sustainable solutions for the future', '이건', '충무관702', '2024-12-03', '2024-12-03', '이민아',
('Bioplastics: Sustainable solutions for the future', '이건', '충무관702', '2024-12-03 09:00:00', '2024-12-03 10:00:00', '이민아',
'SK 바이오텍'),
('Bioinformatics approaches to microbiome analysis', '이건', '충무관101A', '2024-12-04', '2024-12-04', '최영훈',
('Bioinformatics approaches to microbiome analysis', '이건', '충무관101A', '2024-12-04 09:00:00', '2024-12-04 10:00:00', '최영훈',
'연세대학교 시스템생물학과'),
('Nanotechnology for drug delivery in cancer treatment', '이건', '충무관702', '2024-12-05', '2024-12-05', '한지수',
('Nanotechnology for drug delivery in cancer treatment', '이건', '충무관702', '2024-12-05 09:00:00', '2024-12-05 10:00:00', '한지수',
'삼성바이오로직스'),
('Synthetic biology for biofuel production', '이건', '충무관101A', '2024-12-06', '2024-12-06', '김성민',
('Synthetic biology for biofuel production', '이건', '충무관101A', '2024-12-06 09:00:00', '2024-12-06 10:00:00', '김성민',
'POSTECH 생명공학부'),
('Next-generation sequencing in personalized medicine', '이건', '충무관702', '2024-12-07', '2024-12-07', '류정한',
'이화여자대학교 바이오융합학과');
Expand Down

0 comments on commit cb1aeb6

Please sign in to comment.