From f6de14712e97b57ea3217195f3c1f7ec28668115 Mon Sep 17 00:00:00 2001 From: SoowanPark Date: Wed, 17 Jan 2024 00:51:26 +0900 Subject: [PATCH 1/3] [Add] private String department --- src/main/java/careerfestival/career/domain/User.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/careerfestival/career/domain/User.java b/src/main/java/careerfestival/career/domain/User.java index 6be21047..b72f9370 100644 --- a/src/main/java/careerfestival/career/domain/User.java +++ b/src/main/java/careerfestival/career/domain/User.java @@ -63,6 +63,9 @@ public class User extends BaseEntity { @Column(length = 20, name = "company") private String company; + @Column(length = 20, name = "department") + private String department; + @Column(length = 20, name = "position") private String position; From 98ad724f7e49d502ff363cb5f5e603db6aa2ba38 Mon Sep 17 00:00:00 2001 From: kwondm7 Date: Wed, 17 Jan 2024 18:26:03 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Feat]=20=EA=B8=B0=EB=A1=9D=EC=9E=A5=20?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20&=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=20=EB=93=B1=EB=A1=9D=ED=95=98=EA=B8=B0=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 --- .../career/domain/Category.java | 3 - .../careerfestival/career/domain/Event.java | 6 +- .../careerfestival/career/domain/Record.java | 14 +++-- .../careerfestival/career/domain/User.java | 55 +++++++++++-------- .../career/domain/enums/KeywordName.java | 1 - .../login/dto/UserSignUpRequestDto.java | 3 - .../career/login/service/UserService.java | 4 ++ .../record/controller/RecordController.java | 18 +++++- .../career/record/dto/RecordEtcDto.java | 4 +- .../record/dto/RecordLectureSeminarDto.java | 12 ++-- .../record/dto/RecordMainResponseDto.java | 21 +++++++ .../career/record/service/RecordService.java | 12 +++- .../controller/RegisterController.java | 6 +- .../career/register/dto/RegisterEventDto.java | 17 ++++++ .../register/service/RegisterService.java | 17 +++--- .../career/repository/RecordRepository.java | 4 +- src/main/resources/application.yml | 3 +- 17 files changed, 138 insertions(+), 62 deletions(-) create mode 100644 src/main/java/careerfestival/career/record/dto/RecordMainResponseDto.java diff --git a/src/main/java/careerfestival/career/domain/Category.java b/src/main/java/careerfestival/career/domain/Category.java index 8b265cf6..f76f5cff 100644 --- a/src/main/java/careerfestival/career/domain/Category.java +++ b/src/main/java/careerfestival/career/domain/Category.java @@ -21,9 +21,6 @@ public class Category extends BaseEntity { @Column(length = 200, name = "category_name") private String categoryName; - @Column(length = 200, name = "category_detail") - private String categoryDetail; - @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) private List record = new ArrayList<>(); diff --git a/src/main/java/careerfestival/career/domain/Event.java b/src/main/java/careerfestival/career/domain/Event.java index 06c57637..6836bbc4 100644 --- a/src/main/java/careerfestival/career/domain/Event.java +++ b/src/main/java/careerfestival/career/domain/Event.java @@ -65,9 +65,11 @@ public class Event extends BaseEntity { private String managerName; @Column(nullable = false, length = 20, name = "manager_email") private String managerEmail; - @Column(columnDefinition = "INT") + @Column(columnDefinition = "INT DEFAULT 0") private int hits; + @Column(length = 300, name = "event_etc_detail") + private String eventEtcDetail; @ManyToOne(fetch = FetchType.LAZY) private Category category; @@ -92,6 +94,4 @@ public class Event extends BaseEntity { @OneToMany(mappedBy = "event", cascade = CascadeType.ALL) private List participate = new ArrayList<>(); - - } \ No newline at end of file diff --git a/src/main/java/careerfestival/career/domain/Record.java b/src/main/java/careerfestival/career/domain/Record.java index 541292ec..8b9cf52e 100644 --- a/src/main/java/careerfestival/career/domain/Record.java +++ b/src/main/java/careerfestival/career/domain/Record.java @@ -4,7 +4,7 @@ import jakarta.persistence.*; import lombok.*; -import java.time.LocalDateTime; +import java.time.LocalDate; import careerfestival.career.domain.mapping.RecordKeyword; import java.util.ArrayList; import java.util.List; @@ -20,21 +20,23 @@ public class Record extends BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(nullable = false, length = 20, name = "event_name") private String eventName; @Column(nullable = false, name = "event_date") - private LocalDateTime eventDate; - + private LocalDate eventDate; + @OneToMany(mappedBy = "record", cascade = CascadeType.ALL) + private List recordKeywords = new ArrayList<>(); @Column(nullable = false, length = 300, name = "event_description") private String eventDescription; @Column(length = 300, name = "networking_name") private String networkingName; @Column(length = 300, name = "networking_contact") private String networkingContact; + @Column(length = 300, name = "record_etc_detail") + private String recordEtcDetail; - @OneToMany(mappedBy = "record", cascade = CascadeType.ALL) - private List recordKeywords = new ArrayList<>(); - + // 행사유형 @ManyToOne(fetch = FetchType.LAZY) private Category category; diff --git a/src/main/java/careerfestival/career/domain/User.java b/src/main/java/careerfestival/career/domain/User.java index b72f9370..a7be0b3b 100644 --- a/src/main/java/careerfestival/career/domain/User.java +++ b/src/main/java/careerfestival/career/domain/User.java @@ -5,7 +5,6 @@ import careerfestival.career.domain.enums.Role; import careerfestival.career.domain.enums.UserStatus; import careerfestival.career.domain.mapping.Participate; -import careerfestival.career.domain.mapping.RecordKeyword; import careerfestival.career.domain.mapping.UserKeyword; import jakarta.persistence.*; import lombok.*; @@ -21,38 +20,27 @@ @Builder public class User extends BaseEntity { - // 회원가입 1 화면 + // 회원가입 1, 2 화면 @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(nullable = false, length = 300, name = "email") - private String email; - - @Column(nullable = false, length = 300, name = "password") - private String password; - @Column(nullable = false, length = 20, name = "name") private String name; - @Column(nullable = false, length = 200, name = "phone_number") - private String phoneNumber; - - // status와 inacticedate는 회원 탈퇴, 게시글 삭제 시 필요 기능 - @Enumerated(EnumType.STRING) - @Column(columnDefinition = "VARCHAR(15) DEFAULT 'ACTIVE'") - private UserStatus status; + @Column(nullable = false, length = 300, name = "password") + private String password; - private Timestamp inactiveDate; - // status와 inactivedate는 회원 탈퇴, 게시글 삭제 시 필요 기능 - @Enumerated(EnumType.STRING) - @Column(columnDefinition = "VARCHAR(15) DEFAULT 'ACTIVE'") - private UserStatus userStatus; + @Column(nullable = false, length = 300, name = "email") + private String email; - // 회원가입 2 화면 @Enumerated(EnumType.STRING) private Role role; + // 전화번호는 회원가입 3 화면에서 저장되는 값이기 때문에 nullable이면 insert 과정에서 오류 발생 -> null 허용으로 수정함 + @Column(length = 200, name = "phone_number") + private String phoneNumber; + // 회원가입 3 화면 (대략 6가지) @Enumerated(EnumType.STRING) private Gender gender; @@ -60,15 +48,38 @@ public class User extends BaseEntity { @Column(columnDefinition = "INT") private int age; + /* + + ------------관심 지역 들어갈 자리---------------- + + */ + + // 소속(회사/기관/학교명) @Column(length = 20, name = "company") private String company; + // 부서 및 학과 @Column(length = 20, name = "department") private String department; + // 직급 @Column(length = 20, name = "position") private String position; + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) + private List userKeyWord = new ArrayList<>(); + + /* + ----------위에는 회원가입에 직접 사용되는 값들---------------- + */ + + + private Timestamp inactiveDate; + + // status와 inactivedate는 회원 탈퇴, 게시글 삭제 시 필요 기능 + @Enumerated(EnumType.STRING) + @Column(columnDefinition = "VARCHAR(15) DEFAULT 'ACTIVE'") + private UserStatus userStatus; @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List comment = new ArrayList<>(); @@ -77,7 +88,7 @@ public class User extends BaseEntity { private List event = new ArrayList<>(); @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) - private List userKeyWord = new ArrayList<>(); + private List record = new ArrayList<>(); @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List wish = new ArrayList<>(); diff --git a/src/main/java/careerfestival/career/domain/enums/KeywordName.java b/src/main/java/careerfestival/career/domain/enums/KeywordName.java index 72c5a6f9..fd81d79b 100644 --- a/src/main/java/careerfestival/career/domain/enums/KeywordName.java +++ b/src/main/java/careerfestival/career/domain/enums/KeywordName.java @@ -5,5 +5,4 @@ public enum KeywordName { 예술, 마켓팅, 과학기술, 디자인, 영상, 의학, 여행, 기타 - } diff --git a/src/main/java/careerfestival/career/login/dto/UserSignUpRequestDto.java b/src/main/java/careerfestival/career/login/dto/UserSignUpRequestDto.java index fbff5ef7..070d683b 100644 --- a/src/main/java/careerfestival/career/login/dto/UserSignUpRequestDto.java +++ b/src/main/java/careerfestival/career/login/dto/UserSignUpRequestDto.java @@ -11,12 +11,9 @@ public class UserSignUpRequestDto { private String email; - private String password; private String checkPassword; - private String name; - private Role role; @Builder diff --git a/src/main/java/careerfestival/career/login/service/UserService.java b/src/main/java/careerfestival/career/login/service/UserService.java index 7ca513eb..0de5ea8f 100644 --- a/src/main/java/careerfestival/career/login/service/UserService.java +++ b/src/main/java/careerfestival/career/login/service/UserService.java @@ -28,12 +28,16 @@ public Long signUp(UserSignUpRequestDto userSignUpRequestDto) { if(exists){ throw new IllegalStateException("이미 존재하는 이메일입니다."); } + System.out.println("userSignUpRequestDto.getPassword() = " + userSignUpRequestDto.getPassword()); + System.out.println("userSignUpRequestDto.getCheckPassword() = " + userSignUpRequestDto.getCheckPassword()); //비밀번호 입력 확인 if(!userSignUpRequestDto.getPassword().equals(userSignUpRequestDto.getCheckPassword())){ throw new IllegalStateException("비밀번호가 일치하지 않습니다."); } + + User user = userSignUpRequestDto.toEntity(); user.updatePassword(bCryptPasswordEncoder.encode(userSignUpRequestDto.getPassword())); diff --git a/src/main/java/careerfestival/career/record/controller/RecordController.java b/src/main/java/careerfestival/career/record/controller/RecordController.java index 01493143..ecd79242 100644 --- a/src/main/java/careerfestival/career/record/controller/RecordController.java +++ b/src/main/java/careerfestival/career/record/controller/RecordController.java @@ -2,20 +2,23 @@ import careerfestival.career.record.dto.RecordEtcDto; import careerfestival.career.record.dto.RecordLectureSeminarDto; +import careerfestival.career.record.dto.RecordMainResponseDto; import careerfestival.career.record.service.RecordService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.List; + @RequiredArgsConstructor @RequestMapping("/record") @RestController public class RecordController { private final RecordService recordService; - @PostMapping("/lecture-seminar") - public ResponseEntity recordLectureSeminar(@RequestParam("userId") Long userId, @RequestBody RecordLectureSeminarDto recordLectureSeminarDto) { + @PostMapping("/lecture-seminar/{userId}") + public ResponseEntity recordLectureSeminar(@PathVariable("userId") Long userId, @RequestBody RecordLectureSeminarDto recordLectureSeminarDto) { try { recordService.recordLectureSeminar(userId, recordLectureSeminarDto); return new ResponseEntity<>(HttpStatus.OK); @@ -35,4 +38,15 @@ public ResponseEntity recordEtc(@RequestParam("userId") Long userId, @Requ } } + // 메인페이지 1차 구현 완료 + @GetMapping("") + public ResponseEntity> getRecordsByUserId(@RequestParam("userId") Long userId) { + try { + List recordMainResponses = recordService.getRecordsByUserId(userId); + return ResponseEntity.ok(recordMainResponses); + } catch (IllegalArgumentException e) { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + + } } diff --git a/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java b/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java index ac0bf667..d3477e73 100644 --- a/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java +++ b/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java @@ -7,7 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; +import java.time.LocalDate; import java.util.List; @Getter @@ -16,7 +16,7 @@ @Builder public class RecordEtcDto { private String eventName; - private LocalDateTime eventDate; + private LocalDate eventDate; private List recordKeyword; private String networkingName; private String networkingContact; diff --git a/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java b/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java index 975e5867..4f81c47c 100644 --- a/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java +++ b/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java @@ -7,7 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; +import java.time.LocalDate; import java.util.List; @@ -17,23 +17,25 @@ @Builder // 강연, 세미나 DTO public class RecordLectureSeminarDto { - - private LocalDateTime eventDate; - private String eventName; + private LocalDate eventDate; + // 행사 커리어 키워드 in RecordKeyword private List recordKeyword; - + private String eventDescription; private String networkingName; private String networkingContact; + @Builder public Record toEntity() { return Record.builder() .eventName(eventName) .eventDate(eventDate) + .eventDescription(eventDescription) .recordKeywords(recordKeyword) .networkingName(networkingName) .networkingContact(networkingContact) .build(); } + } diff --git a/src/main/java/careerfestival/career/record/dto/RecordMainResponseDto.java b/src/main/java/careerfestival/career/record/dto/RecordMainResponseDto.java new file mode 100644 index 00000000..095f5687 --- /dev/null +++ b/src/main/java/careerfestival/career/record/dto/RecordMainResponseDto.java @@ -0,0 +1,21 @@ +package careerfestival.career.record.dto; + +import careerfestival.career.domain.Record; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class RecordMainResponseDto { + private String eventName; + + public static RecordMainResponseDto fromEntity(Record record) { + return RecordMainResponseDto.builder() + .eventName(record.getEventName()) + .build(); + } +} diff --git a/src/main/java/careerfestival/career/record/service/RecordService.java b/src/main/java/careerfestival/career/record/service/RecordService.java index 29b5ab6b..2c4b36d2 100644 --- a/src/main/java/careerfestival/career/record/service/RecordService.java +++ b/src/main/java/careerfestival/career/record/service/RecordService.java @@ -4,12 +4,16 @@ import careerfestival.career.domain.User; import careerfestival.career.record.dto.RecordEtcDto; import careerfestival.career.record.dto.RecordLectureSeminarDto; +import careerfestival.career.record.dto.RecordMainResponseDto; import careerfestival.career.repository.RecordKeywordRepository; import careerfestival.career.repository.RecordRepository; import careerfestival.career.repository.UserRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.stream.Collectors; + @Service @RequiredArgsConstructor public class RecordService { @@ -32,8 +36,6 @@ public void recordLectureSeminar(Long userId, RecordLectureSeminarDto recordLect public void recordEtc(Long userId, RecordEtcDto recordEtcDto) { - System.out.println("recordEtcDto.getEventName() = " + recordEtcDto.getEventName()); - System.out.println("recordEtcDto.getRecordKeyword() = " + recordEtcDto.getRecordKeyword()); User user = userRepository.findById(userId) .orElseThrow(()->new RuntimeException("User not found with id: " + userId)); @@ -45,4 +47,10 @@ public void recordEtc(Long userId, RecordEtcDto recordEtcDto) { // Record 테이블에만 저장된 상태 } + public List getRecordsByUserId(Long userId) { + List records = recordRepository.findByUserId(userId); + return records.stream() + .map(RecordMainResponseDto::fromEntity) + .collect(Collectors.toList()); + } } diff --git a/src/main/java/careerfestival/career/register/controller/RegisterController.java b/src/main/java/careerfestival/career/register/controller/RegisterController.java index 7d11f1bf..ad538a25 100644 --- a/src/main/java/careerfestival/career/register/controller/RegisterController.java +++ b/src/main/java/careerfestival/career/register/controller/RegisterController.java @@ -15,9 +15,9 @@ public class RegisterController { private final RegisterService registerService; // 이벤트 등록 (eventName이랑 description만) - @PostMapping("/event") - public ResponseEntity registerEvent(@RequestBody RegisterEventDto registerEventDto) { - registerService.registerEvent(registerEventDto); + @PostMapping("/event/{userId}") + public ResponseEntity registerEvent(@PathVariable("userId") Long userId, @RequestBody RegisterEventDto registerEventDto) { + registerService.registerEvent(userId, registerEventDto); return new ResponseEntity(HttpStatus.OK); } diff --git a/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java b/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java index 1fa33b46..72e09136 100644 --- a/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java +++ b/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java @@ -1,5 +1,6 @@ package careerfestival.career.register.dto; +import careerfestival.career.domain.Category; import careerfestival.career.domain.Event; import lombok.*; import java.time.LocalDateTime; @@ -15,13 +16,22 @@ public class RegisterEventDto { private String eventName; private String description; + private LocalDateTime eventStart; + private LocalDateTime eventEnd; + // 행사 신청 외부사이트 private String link; private String eventContent; + private String address; + private String specAddress; + private String managerName; private String managerEmail; + private Category category; + private String eventEtcDetail; + @Builder public Event toEntity() { return Event.builder() @@ -29,11 +39,18 @@ public Event toEntity() { .recruitmentEnd(recruitmentEnd) .eventName(eventName) .description(description) + .eventStart(eventStart) + .eventEnd(eventEnd) .link(link) .eventContent(eventContent) + .address(address) + .specAddress(specAddress) .managerName(managerName) .managerEmail(managerEmail) + .eventEtcDetail(eventEtcDetail) .build(); } + + } diff --git a/src/main/java/careerfestival/career/register/service/RegisterService.java b/src/main/java/careerfestival/career/register/service/RegisterService.java index f5f91d01..16866120 100644 --- a/src/main/java/careerfestival/career/register/service/RegisterService.java +++ b/src/main/java/careerfestival/career/register/service/RegisterService.java @@ -2,9 +2,11 @@ import careerfestival.career.domain.Category; import careerfestival.career.domain.Event; +import careerfestival.career.domain.User; import careerfestival.career.register.dto.RegisterEventDto; import careerfestival.career.repository.CategoryRepository; import careerfestival.career.repository.EventRepository; +import careerfestival.career.repository.UserRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -13,17 +15,18 @@ @Service @RequiredArgsConstructor public class RegisterService { + private final UserRepository userRepository; private final EventRepository eventRepository; private final CategoryRepository categoryRepository; - public Long registerEvent(RegisterEventDto registerEventDto) { + public void registerEvent(Long userId, RegisterEventDto registerEventDto) { + User user = userRepository.findById(userId) + .orElseThrow(() -> new RuntimeException("User not found with id" + userId)); Event event = registerEventDto.toEntity(); - eventRepository.save(event); - return event.getId(); - } + event.setUser(user); - // 행사 유형 모두 찾기 - public List findCategories() { - return categoryRepository.findAll(); + Category category = registerEventDto.getCategory(); + eventRepository.save(event); + categoryRepository.save(category); } } diff --git a/src/main/java/careerfestival/career/repository/RecordRepository.java b/src/main/java/careerfestival/career/repository/RecordRepository.java index fca2672a..f5e8850a 100644 --- a/src/main/java/careerfestival/career/repository/RecordRepository.java +++ b/src/main/java/careerfestival/career/repository/RecordRepository.java @@ -4,7 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface RecordRepository extends JpaRepository { - + List findByUserId(Long userId); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7fffe5a3..eee9389b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/careerfestival username: root - password: swtndhks12 + password: "0000" driver-class-name: com.mysql.cj.jdbc.Driver @@ -21,7 +21,6 @@ spring: auto: create-drop default_batch_fetch_size: 1000 - jwt: secret: 86221d73fc259a5107f402c07a85d92379a00f9a5add4bd258179733b07de544b8ab747c931715c toeknValidTime: ${TOKEN_VALID_TIME} From eddf08c78e6b6dfa35b8ecec83e1cb84195b9c77 Mon Sep 17 00:00:00 2001 From: kwondm7 Date: Thu, 18 Jan 2024 03:25:24 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Refactor]=20=EA=B0=95=EC=97=B0/=EC=84=B8?= =?UTF-8?q?=EB=AF=B8=EB=82=98=20=EA=B8=B0=EB=A1=9D=EC=9E=A5=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D=ED=95=98=EA=B8=B0=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comments/Service/CommentService.java | 2 +- .../comments/dto/CommentRequestDto.java | 2 +- .../comments/dto/CommentResponseDto.java | 2 +- .../career/domain/Category.java | 30 ----------- .../careerfestival/career/domain/Comment.java | 30 ----------- .../careerfestival/career/domain/Event.java | 29 +++++----- .../careerfestival/career/domain/Gender.java | 17 ------ .../careerfestival/career/domain/Host.java | 28 ---------- .../careerfestival/career/domain/Record.java | 10 ++-- .../careerfestival/career/domain/User.java | 9 ++-- .../career/domain/enums/Category.java | 6 +++ .../career/domain/enums/Gender.java | 14 ++++- .../career/domain/mapping/Comment.java | 54 +++++++++++++++++++ .../career/domain/mapping/EventKeyword.java | 25 --------- .../career/domain/{ => mapping}/Follow.java | 4 +- .../career/domain/mapping/RecordKeyword.java | 32 ----------- .../career/domain/{ => mapping}/Region.java | 3 +- .../career/domain/mapping/UserKeyword.java | 24 --------- .../career/domain/{ => mapping}/Wish.java | 4 +- .../record/controller/RecordController.java | 11 ++-- .../career/record/dto/RecordEtcDto.java | 3 -- .../record/dto/RecordLectureSeminarDto.java | 13 ++--- .../career/record/service/RecordService.java | 11 ++-- .../career/register/dto/RegisterEventDto.java | 2 - .../register/service/RegisterService.java | 7 --- .../career/repository/CategoryRepository.java | 10 ---- .../career/repository/CommentRepository.java | 2 +- .../repository/RecordKeywordRepository.java | 8 --- 28 files changed, 118 insertions(+), 274 deletions(-) delete mode 100644 src/main/java/careerfestival/career/domain/Category.java delete mode 100644 src/main/java/careerfestival/career/domain/Comment.java delete mode 100644 src/main/java/careerfestival/career/domain/Gender.java delete mode 100644 src/main/java/careerfestival/career/domain/Host.java create mode 100644 src/main/java/careerfestival/career/domain/enums/Category.java create mode 100644 src/main/java/careerfestival/career/domain/mapping/Comment.java delete mode 100644 src/main/java/careerfestival/career/domain/mapping/EventKeyword.java rename src/main/java/careerfestival/career/domain/{ => mapping}/Follow.java (82%) delete mode 100644 src/main/java/careerfestival/career/domain/mapping/RecordKeyword.java rename src/main/java/careerfestival/career/domain/{ => mapping}/Region.java (89%) delete mode 100644 src/main/java/careerfestival/career/domain/mapping/UserKeyword.java rename src/main/java/careerfestival/career/domain/{ => mapping}/Wish.java (81%) delete mode 100644 src/main/java/careerfestival/career/repository/CategoryRepository.java delete mode 100644 src/main/java/careerfestival/career/repository/RecordKeywordRepository.java diff --git a/src/main/java/careerfestival/career/comments/Service/CommentService.java b/src/main/java/careerfestival/career/comments/Service/CommentService.java index b6fd1fb3..bb89a4fd 100644 --- a/src/main/java/careerfestival/career/comments/Service/CommentService.java +++ b/src/main/java/careerfestival/career/comments/Service/CommentService.java @@ -2,7 +2,7 @@ import careerfestival.career.comments.dto.CommentRequestDto; import careerfestival.career.comments.dto.CommentResponseDto; -import careerfestival.career.domain.Comment; +import careerfestival.career.domain.mapping.Comment; import careerfestival.career.domain.Event; import careerfestival.career.domain.User; import careerfestival.career.repository.CommentRepository; diff --git a/src/main/java/careerfestival/career/comments/dto/CommentRequestDto.java b/src/main/java/careerfestival/career/comments/dto/CommentRequestDto.java index a04f507f..02633421 100644 --- a/src/main/java/careerfestival/career/comments/dto/CommentRequestDto.java +++ b/src/main/java/careerfestival/career/comments/dto/CommentRequestDto.java @@ -1,6 +1,6 @@ package careerfestival.career.comments.dto; -import careerfestival.career.domain.Comment; +import careerfestival.career.domain.mapping.Comment; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/careerfestival/career/comments/dto/CommentResponseDto.java b/src/main/java/careerfestival/career/comments/dto/CommentResponseDto.java index 7f444a1c..9deb7f87 100644 --- a/src/main/java/careerfestival/career/comments/dto/CommentResponseDto.java +++ b/src/main/java/careerfestival/career/comments/dto/CommentResponseDto.java @@ -1,6 +1,6 @@ package careerfestival.career.comments.dto; -import careerfestival.career.domain.Comment; +import careerfestival.career.domain.mapping.Comment; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/careerfestival/career/domain/Category.java b/src/main/java/careerfestival/career/domain/Category.java deleted file mode 100644 index f76f5cff..00000000 --- a/src/main/java/careerfestival/career/domain/Category.java +++ /dev/null @@ -1,30 +0,0 @@ -package careerfestival.career.domain; - -import careerfestival.career.domain.common.BaseEntity; -import jakarta.persistence.*; -import lombok.*; - -import java.util.ArrayList; -import java.util.List; - -@Entity -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class Category extends BaseEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(length = 200, name = "category_name") - private String categoryName; - - @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) - private List record = new ArrayList<>(); - - @OneToMany(mappedBy = "category", cascade = CascadeType.ALL) - private List event = new ArrayList<>(); - -} diff --git a/src/main/java/careerfestival/career/domain/Comment.java b/src/main/java/careerfestival/career/domain/Comment.java deleted file mode 100644 index 3da02890..00000000 --- a/src/main/java/careerfestival/career/domain/Comment.java +++ /dev/null @@ -1,30 +0,0 @@ -package careerfestival.career.domain; - -import careerfestival.career.domain.common.BaseEntity; -import jakarta.persistence.*; -import lombok.*; - -@Entity -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class Comment extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(length = 300, name = "comment_content") - private String commentContent; - - @Column(length = 300, name = "parent_content") - private String parentContent; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "event_id") - private Event event; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; -} diff --git a/src/main/java/careerfestival/career/domain/Event.java b/src/main/java/careerfestival/career/domain/Event.java index 6836bbc4..06b14f66 100644 --- a/src/main/java/careerfestival/career/domain/Event.java +++ b/src/main/java/careerfestival/career/domain/Event.java @@ -2,9 +2,8 @@ import careerfestival.career.domain.common.BaseEntity; -import careerfestival.career.domain.mapping.EventImage; -import careerfestival.career.domain.mapping.EventKeyword; -import careerfestival.career.domain.mapping.Participate; +import careerfestival.career.domain.enums.Category; +import careerfestival.career.domain.mapping.*; import jakarta.persistence.*; import lombok.*; @@ -25,8 +24,6 @@ public class Event extends BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - - // 모집 시작일 & 모집 종료일 @Column(nullable = false, name = "recruitment_start") private LocalDateTime recruitmentStart; @@ -46,34 +43,35 @@ public class Event extends BaseEntity { private LocalDateTime eventStart; @Column(nullable = false, name = "event_end") private LocalDateTime eventEnd; - @Column(nullable = false, length = 300, name = "link") + @Column(length = 300, name = "link") private String link; @Column(nullable = false, length = 200, name = "event_content") private String eventContent; + // 행사 정보이미지 들어가야함 + + @Column(nullable = false, length = 40, name = "event_cost") + private String eventCost; + //행사 주소 @Column(nullable = false, length = 40, name ="address") private String address; @Column(nullable = false, length = 40, name ="spec_address") private String specAddress; - - - //checkpoint 주최자랑 연결? - //회원 id 연결 주최자와 @Column(nullable = false, length = 20, name = "manager_name") private String managerName; - @Column(nullable = false, length = 20, name = "manager_email") + @Column(length = 20, name = "manager_email") private String managerEmail; @Column(columnDefinition = "INT DEFAULT 0") private int hits; + @Enumerated(EnumType.STRING) + private Category category; + @Column(length = 300, name = "event_etc_detail") private String eventEtcDetail; - @ManyToOne(fetch = FetchType.LAZY) - private Category category; - @ManyToOne(fetch = FetchType.LAZY) private Region region; @@ -83,9 +81,6 @@ public class Event extends BaseEntity { @OneToMany(mappedBy = "event", cascade = CascadeType.ALL) private List eventImg = new ArrayList<>(); - @OneToMany(mappedBy = "event", cascade = CascadeType.ALL) - private List eventKeyword = new ArrayList<>(); - @OneToMany(mappedBy = "event", cascade = CascadeType.ALL) private List comment = new ArrayList<>(); diff --git a/src/main/java/careerfestival/career/domain/Gender.java b/src/main/java/careerfestival/career/domain/Gender.java deleted file mode 100644 index 4288a427..00000000 --- a/src/main/java/careerfestival/career/domain/Gender.java +++ /dev/null @@ -1,17 +0,0 @@ -package careerfestival.career.domain; - -import com.fasterxml.jackson.annotation.JsonCreator; - -public enum Gender { - 남성, 여성; - - @JsonCreator - public static Gender fromString(String genderStr) { - for (Gender gender : Gender.values()) { - if (gender.name().equalsIgnoreCase(genderStr)) { - return gender; - } - } - throw new IllegalArgumentException("No constant with text " + genderStr + " found"); - } -} diff --git a/src/main/java/careerfestival/career/domain/Host.java b/src/main/java/careerfestival/career/domain/Host.java deleted file mode 100644 index 1645aab5..00000000 --- a/src/main/java/careerfestival/career/domain/Host.java +++ /dev/null @@ -1,28 +0,0 @@ -package careerfestival.career.domain; - -import careerfestival.career.domain.common.BaseEntity; -import jakarta.persistence.*; -import lombok.*; - -@Entity -@Getter -@Setter -@Builder -@NoArgsConstructor(access = AccessLevel.PUBLIC) -@AllArgsConstructor(access = AccessLevel.PROTECTED) - -public class Host extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - - @Column(nullable = false, length = 20, name = "host_name") - private String hostName; - - @Column(nullable = false, length = 300, name = "profile_img") - private String profileImg; - - @ManyToOne(fetch = FetchType.LAZY) - private User user; -} diff --git a/src/main/java/careerfestival/career/domain/Record.java b/src/main/java/careerfestival/career/domain/Record.java index 8b9cf52e..c572dd59 100644 --- a/src/main/java/careerfestival/career/domain/Record.java +++ b/src/main/java/careerfestival/career/domain/Record.java @@ -1,12 +1,12 @@ package careerfestival.career.domain; import careerfestival.career.domain.common.BaseEntity; +import careerfestival.career.domain.enums.Category; +import careerfestival.career.domain.enums.KeywordName; import jakarta.persistence.*; import lombok.*; import java.time.LocalDate; -import careerfestival.career.domain.mapping.RecordKeyword; -import java.util.ArrayList; import java.util.List; @Entity @@ -20,13 +20,10 @@ public class Record extends BaseEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(nullable = false, length = 20, name = "event_name") private String eventName; @Column(nullable = false, name = "event_date") private LocalDate eventDate; - @OneToMany(mappedBy = "record", cascade = CascadeType.ALL) - private List recordKeywords = new ArrayList<>(); @Column(nullable = false, length = 300, name = "event_description") private String eventDescription; @Column(length = 300, name = "networking_name") @@ -36,9 +33,8 @@ public class Record extends BaseEntity { @Column(length = 300, name = "record_etc_detail") private String recordEtcDetail; - // 행사유형 - @ManyToOne(fetch = FetchType.LAZY) private Category category; + private List keywordName; @ManyToOne(fetch = FetchType.LAZY) private User user; diff --git a/src/main/java/careerfestival/career/domain/User.java b/src/main/java/careerfestival/career/domain/User.java index a7be0b3b..3b28861a 100644 --- a/src/main/java/careerfestival/career/domain/User.java +++ b/src/main/java/careerfestival/career/domain/User.java @@ -4,8 +4,10 @@ import careerfestival.career.domain.enums.Gender; import careerfestival.career.domain.enums.Role; import careerfestival.career.domain.enums.UserStatus; +import careerfestival.career.domain.mapping.Comment; +import careerfestival.career.domain.mapping.Follow; import careerfestival.career.domain.mapping.Participate; -import careerfestival.career.domain.mapping.UserKeyword; +import careerfestival.career.domain.mapping.Wish; import jakarta.persistence.*; import lombok.*; @@ -66,9 +68,6 @@ public class User extends BaseEntity { @Column(length = 20, name = "position") private String position; - @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) - private List userKeyWord = new ArrayList<>(); - /* ----------위에는 회원가입에 직접 사용되는 값들---------------- */ @@ -97,7 +96,7 @@ public class User extends BaseEntity { private List participate = new ArrayList<>(); @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) - private List host = new ArrayList<>(); + private List organizer = new ArrayList<>(); @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List follow = new ArrayList<>(); diff --git a/src/main/java/careerfestival/career/domain/enums/Category.java b/src/main/java/careerfestival/career/domain/enums/Category.java new file mode 100644 index 00000000..e4375371 --- /dev/null +++ b/src/main/java/careerfestival/career/domain/enums/Category.java @@ -0,0 +1,6 @@ +package careerfestival.career.domain.enums; + +public enum Category { + 강연세미나, 학술대회, + 전시박람회, 기타 +} diff --git a/src/main/java/careerfestival/career/domain/enums/Gender.java b/src/main/java/careerfestival/career/domain/enums/Gender.java index 112c9e88..29ce2832 100644 --- a/src/main/java/careerfestival/career/domain/enums/Gender.java +++ b/src/main/java/careerfestival/career/domain/enums/Gender.java @@ -1,5 +1,17 @@ package careerfestival.career.domain.enums; +import com.fasterxml.jackson.annotation.JsonCreator; + public enum Gender { - 남성, 여성 + 남성, 여성; + + @JsonCreator + public static Gender fromString(String genderStr) { + for (Gender gender : Gender.values()) { + if (gender.name().equalsIgnoreCase(genderStr)) { + return gender; + } + } + throw new IllegalArgumentException("No constant with text " + genderStr + " found"); + } } diff --git a/src/main/java/careerfestival/career/domain/mapping/Comment.java b/src/main/java/careerfestival/career/domain/mapping/Comment.java new file mode 100644 index 00000000..de301ee3 --- /dev/null +++ b/src/main/java/careerfestival/career/domain/mapping/Comment.java @@ -0,0 +1,54 @@ +package careerfestival.career.domain.mapping; + +import careerfestival.career.domain.Event; +import careerfestival.career.domain.User; +import careerfestival.career.domain.common.BaseEntity; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class Comment extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(length = 300, name = "comment_content") + private String commentContent; + + @Column(length = 300, name = "parent_content") + private String parentContent; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "event_id") + private Event event; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @Entity + @Getter + @Setter + @Builder + @NoArgsConstructor(access = AccessLevel.PUBLIC) + @AllArgsConstructor(access = AccessLevel.PROTECTED) + public static class Organizer extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + + @Column(nullable = false, length = 20, name = "host_name") + private String organizerName; + + @Column(nullable = false, length = 300, name = "profile_img") + private String organizerImg; + + @ManyToOne(fetch = FetchType.LAZY) + private User user; + } +} diff --git a/src/main/java/careerfestival/career/domain/mapping/EventKeyword.java b/src/main/java/careerfestival/career/domain/mapping/EventKeyword.java deleted file mode 100644 index 920b2515..00000000 --- a/src/main/java/careerfestival/career/domain/mapping/EventKeyword.java +++ /dev/null @@ -1,25 +0,0 @@ -package careerfestival.career.domain.mapping; - -import careerfestival.career.domain.Event; -import careerfestival.career.domain.common.BaseEntity; -import careerfestival.career.domain.enums.KeywordName; -import jakarta.persistence.*; -import lombok.*; - -@Entity -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class EventKeyword extends BaseEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Enumerated(EnumType.STRING) - private KeywordName keywordName; - - @ManyToOne(fetch = FetchType.LAZY) - private Event event; -} diff --git a/src/main/java/careerfestival/career/domain/Follow.java b/src/main/java/careerfestival/career/domain/mapping/Follow.java similarity index 82% rename from src/main/java/careerfestival/career/domain/Follow.java rename to src/main/java/careerfestival/career/domain/mapping/Follow.java index 776e4866..2b40f395 100644 --- a/src/main/java/careerfestival/career/domain/Follow.java +++ b/src/main/java/careerfestival/career/domain/mapping/Follow.java @@ -1,5 +1,6 @@ -package careerfestival.career.domain; +package careerfestival.career.domain.mapping; +import careerfestival.career.domain.User; import careerfestival.career.domain.common.BaseEntity; import jakarta.persistence.*; import lombok.*; @@ -18,5 +19,4 @@ public class Follow extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) private User user; - } diff --git a/src/main/java/careerfestival/career/domain/mapping/RecordKeyword.java b/src/main/java/careerfestival/career/domain/mapping/RecordKeyword.java deleted file mode 100644 index 24af2c00..00000000 --- a/src/main/java/careerfestival/career/domain/mapping/RecordKeyword.java +++ /dev/null @@ -1,32 +0,0 @@ -package careerfestival.career.domain.mapping; - -import careerfestival.career.domain.Record; -import careerfestival.career.domain.User; -import careerfestival.career.domain.common.BaseEntity; -import careerfestival.career.domain.enums.KeywordName; -import jakarta.persistence.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class RecordKeyword extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Enumerated(EnumType.STRING) - private KeywordName keywordName; - - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "record_id") - private Record record; - - -} \ No newline at end of file diff --git a/src/main/java/careerfestival/career/domain/Region.java b/src/main/java/careerfestival/career/domain/mapping/Region.java similarity index 89% rename from src/main/java/careerfestival/career/domain/Region.java rename to src/main/java/careerfestival/career/domain/mapping/Region.java index 65f93e48..62040428 100644 --- a/src/main/java/careerfestival/career/domain/Region.java +++ b/src/main/java/careerfestival/career/domain/mapping/Region.java @@ -1,5 +1,6 @@ -package careerfestival.career.domain; +package careerfestival.career.domain.mapping; +import careerfestival.career.domain.Event; import careerfestival.career.domain.common.BaseEntity; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/careerfestival/career/domain/mapping/UserKeyword.java b/src/main/java/careerfestival/career/domain/mapping/UserKeyword.java deleted file mode 100644 index f0839d79..00000000 --- a/src/main/java/careerfestival/career/domain/mapping/UserKeyword.java +++ /dev/null @@ -1,24 +0,0 @@ -package careerfestival.career.domain.mapping; - -import careerfestival.career.domain.User; -import careerfestival.career.domain.common.BaseEntity; -import careerfestival.career.domain.enums.KeywordName; -import jakarta.persistence.*; -import lombok.*; - -@Entity -@Getter -@Setter -@NoArgsConstructor(access = AccessLevel.PUBLIC) -@AllArgsConstructor(access = AccessLevel.PROTECTED) -public class UserKeyword extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Enumerated(EnumType.STRING) - private KeywordName keywordName; - - @ManyToOne(fetch = FetchType.LAZY) - private User user; -} diff --git a/src/main/java/careerfestival/career/domain/Wish.java b/src/main/java/careerfestival/career/domain/mapping/Wish.java similarity index 81% rename from src/main/java/careerfestival/career/domain/Wish.java rename to src/main/java/careerfestival/career/domain/mapping/Wish.java index b4e760ba..7d7c46d4 100644 --- a/src/main/java/careerfestival/career/domain/Wish.java +++ b/src/main/java/careerfestival/career/domain/mapping/Wish.java @@ -1,5 +1,7 @@ -package careerfestival.career.domain; +package careerfestival.career.domain.mapping; +import careerfestival.career.domain.Event; +import careerfestival.career.domain.User; import careerfestival.career.domain.common.BaseEntity; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/careerfestival/career/record/controller/RecordController.java b/src/main/java/careerfestival/career/record/controller/RecordController.java index ecd79242..4a29fa1f 100644 --- a/src/main/java/careerfestival/career/record/controller/RecordController.java +++ b/src/main/java/careerfestival/career/record/controller/RecordController.java @@ -17,6 +17,7 @@ public class RecordController { private final RecordService recordService; + // @PostMapping("/lecture-seminar/{userId}") public ResponseEntity recordLectureSeminar(@PathVariable("userId") Long userId, @RequestBody RecordLectureSeminarDto recordLectureSeminarDto) { try { @@ -27,9 +28,8 @@ public ResponseEntity recordLectureSeminar(@PathVariable("userId") Long us } } - // User가 Keyword 테이블에서 선택한다고 했을 때, Keyword_id를 넘겨주는 방법은 어떤지? (어차피 Keyword는 정해져 있으니까?) - @PostMapping("/etc") - public ResponseEntity recordEtc(@RequestParam("userId") Long userId, @RequestBody RecordEtcDto recordEtcDto) { + @PostMapping("/etc/{userId}") + public ResponseEntity recordEtc(@PathVariable("userId") Long userId, @RequestBody RecordEtcDto recordEtcDto) { try { recordService.recordEtc(userId, recordEtcDto); return new ResponseEntity<>(HttpStatus.OK); @@ -39,14 +39,13 @@ public ResponseEntity recordEtc(@RequestParam("userId") Long userId, @Requ } // 메인페이지 1차 구현 완료 - @GetMapping("") - public ResponseEntity> getRecordsByUserId(@RequestParam("userId") Long userId) { + @GetMapping("/{userId}") + public ResponseEntity> getRecordsByUserId(@PathVariable("userId") Long userId) { try { List recordMainResponses = recordService.getRecordsByUserId(userId); return ResponseEntity.ok(recordMainResponses); } catch (IllegalArgumentException e) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } - } } diff --git a/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java b/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java index d3477e73..7646e34e 100644 --- a/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java +++ b/src/main/java/careerfestival/career/record/dto/RecordEtcDto.java @@ -1,7 +1,6 @@ package careerfestival.career.record.dto; import careerfestival.career.domain.Record; -import careerfestival.career.domain.mapping.RecordKeyword; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -17,7 +16,6 @@ public class RecordEtcDto { private String eventName; private LocalDate eventDate; - private List recordKeyword; private String networkingName; private String networkingContact; @@ -26,7 +24,6 @@ public Record toEntity() { return Record.builder() .eventName(eventName) .eventDate(eventDate) - .recordKeywords(recordKeyword) .networkingName(networkingName) .networkingContact(networkingContact) .build(); diff --git a/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java b/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java index 4f81c47c..a8869e97 100644 --- a/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java +++ b/src/main/java/careerfestival/career/record/dto/RecordLectureSeminarDto.java @@ -1,7 +1,8 @@ package careerfestival.career.record.dto; import careerfestival.career.domain.Record; -import careerfestival.career.domain.mapping.RecordKeyword; +import careerfestival.career.domain.enums.Category; +import careerfestival.career.domain.enums.KeywordName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -10,29 +11,29 @@ import java.time.LocalDate; import java.util.List; - @Getter @NoArgsConstructor @AllArgsConstructor @Builder // 강연, 세미나 DTO public class RecordLectureSeminarDto { + private Category category; private String eventName; private LocalDate eventDate; - // 행사 커리어 키워드 in RecordKeyword - private List recordKeyword; + private List keywordName; private String eventDescription; + /* + ----이미지 첨부 관련 내용---- + */ private String networkingName; private String networkingContact; - @Builder public Record toEntity() { return Record.builder() .eventName(eventName) .eventDate(eventDate) .eventDescription(eventDescription) - .recordKeywords(recordKeyword) .networkingName(networkingName) .networkingContact(networkingContact) .build(); diff --git a/src/main/java/careerfestival/career/record/service/RecordService.java b/src/main/java/careerfestival/career/record/service/RecordService.java index 2c4b36d2..fc7c2189 100644 --- a/src/main/java/careerfestival/career/record/service/RecordService.java +++ b/src/main/java/careerfestival/career/record/service/RecordService.java @@ -5,7 +5,6 @@ import careerfestival.career.record.dto.RecordEtcDto; import careerfestival.career.record.dto.RecordLectureSeminarDto; import careerfestival.career.record.dto.RecordMainResponseDto; -import careerfestival.career.repository.RecordKeywordRepository; import careerfestival.career.repository.RecordRepository; import careerfestival.career.repository.UserRepository; import lombok.RequiredArgsConstructor; @@ -18,23 +17,20 @@ @RequiredArgsConstructor public class RecordService { private final RecordRepository recordRepository; - private final RecordKeywordRepository recordKeywordRepository; private final UserRepository userRepository; public void recordLectureSeminar(Long userId, RecordLectureSeminarDto recordLectureSeminarDto) { - - // 전달받은 userId로 연관관계 매핑된 User 테이블에 맞춰서 DB에 저장하기 + // 이미지 첨부 및 글자 수 제한 적용 필요 User user = userRepository.findById(userId) .orElseThrow(() -> new RuntimeException("User not found with id: " + userId)); Record record = recordLectureSeminarDto.toEntity(); + record.setCategory(recordLectureSeminarDto.getCategory()); + record.setKeywordName(recordLectureSeminarDto.getKeywordName()); record.setUser(user); - recordRepository.save(record); } - - public void recordEtc(Long userId, RecordEtcDto recordEtcDto) { User user = userRepository.findById(userId) @@ -43,7 +39,6 @@ public void recordEtc(Long userId, RecordEtcDto recordEtcDto) { Record record = recordEtcDto.toEntity(); record.setUser(user); recordRepository.save(record); - recordKeywordRepository.saveAll(record.getRecordKeywords()); // Record 테이블에만 저장된 상태 } diff --git a/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java b/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java index 72e09136..31827843 100644 --- a/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java +++ b/src/main/java/careerfestival/career/register/dto/RegisterEventDto.java @@ -1,6 +1,5 @@ package careerfestival.career.register.dto; -import careerfestival.career.domain.Category; import careerfestival.career.domain.Event; import lombok.*; import java.time.LocalDateTime; @@ -29,7 +28,6 @@ public class RegisterEventDto { private String managerName; private String managerEmail; - private Category category; private String eventEtcDetail; @Builder diff --git a/src/main/java/careerfestival/career/register/service/RegisterService.java b/src/main/java/careerfestival/career/register/service/RegisterService.java index 16866120..94f1735e 100644 --- a/src/main/java/careerfestival/career/register/service/RegisterService.java +++ b/src/main/java/careerfestival/career/register/service/RegisterService.java @@ -1,23 +1,18 @@ package careerfestival.career.register.service; -import careerfestival.career.domain.Category; import careerfestival.career.domain.Event; import careerfestival.career.domain.User; import careerfestival.career.register.dto.RegisterEventDto; -import careerfestival.career.repository.CategoryRepository; import careerfestival.career.repository.EventRepository; import careerfestival.career.repository.UserRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.util.List; - @Service @RequiredArgsConstructor public class RegisterService { private final UserRepository userRepository; private final EventRepository eventRepository; - private final CategoryRepository categoryRepository; public void registerEvent(Long userId, RegisterEventDto registerEventDto) { User user = userRepository.findById(userId) @@ -25,8 +20,6 @@ public void registerEvent(Long userId, RegisterEventDto registerEventDto) { Event event = registerEventDto.toEntity(); event.setUser(user); - Category category = registerEventDto.getCategory(); eventRepository.save(event); - categoryRepository.save(category); } } diff --git a/src/main/java/careerfestival/career/repository/CategoryRepository.java b/src/main/java/careerfestival/career/repository/CategoryRepository.java deleted file mode 100644 index 5b2e3f47..00000000 --- a/src/main/java/careerfestival/career/repository/CategoryRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package careerfestival.career.repository; - -import careerfestival.career.domain.Category; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface CategoryRepository extends JpaRepository { - -} \ No newline at end of file diff --git a/src/main/java/careerfestival/career/repository/CommentRepository.java b/src/main/java/careerfestival/career/repository/CommentRepository.java index 37e70b5c..d56b7071 100644 --- a/src/main/java/careerfestival/career/repository/CommentRepository.java +++ b/src/main/java/careerfestival/career/repository/CommentRepository.java @@ -1,6 +1,6 @@ package careerfestival.career.repository; -import careerfestival.career.domain.Comment; +import careerfestival.career.domain.mapping.Comment; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/careerfestival/career/repository/RecordKeywordRepository.java b/src/main/java/careerfestival/career/repository/RecordKeywordRepository.java deleted file mode 100644 index 70f1e627..00000000 --- a/src/main/java/careerfestival/career/repository/RecordKeywordRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package careerfestival.career.repository; - -import careerfestival.career.domain.mapping.RecordKeyword; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface RecordKeywordRepository extends JpaRepository { - -}