diff --git a/nw/src/main/java/lab/cherry/nw/model/EventEntity.java b/nw/src/main/java/lab/cherry/nw/model/EventEntity.java index f13b3ec..f677883 100644 --- a/nw/src/main/java/lab/cherry/nw/model/EventEntity.java +++ b/nw/src/main/java/lab/cherry/nw/model/EventEntity.java @@ -33,12 +33,9 @@ public class EventEntity implements Serializable { @Id - @JsonIgnore - private String id; - @JsonProperty("eventSeq") @Schema(title = "이벤트 고유번호", example = "64ed89aa9e813b5ab16da6de") - private String seq; + private String id; @NotNull @JsonProperty("eventTitle") @@ -76,5 +73,9 @@ public class EventEntity implements Serializable { @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul") @Schema(title = "이벤트 마지막 업데이트 시간", example = "2023-07-04 12:00:00") private Instant updated_at; + + public void editTitle(String title) { + this.title = title; + } } diff --git a/nw/src/main/java/lab/cherry/nw/model/UserEntity.java b/nw/src/main/java/lab/cherry/nw/model/UserEntity.java index 5414b9c..54c7e21 100644 --- a/nw/src/main/java/lab/cherry/nw/model/UserEntity.java +++ b/nw/src/main/java/lab/cherry/nw/model/UserEntity.java @@ -66,7 +66,7 @@ public class UserEntity implements Serializable { @JsonProperty("userPhoto") @Schema(title = "사용자 사진") private Object photo; - + @JsonProperty("userEnabled") @Schema(title = "사용자 활성화 여부", example = "true") private Boolean enabled; @@ -90,7 +90,6 @@ public class UserEntity implements Serializable { @Schema(title = "Org 정보", example = "더모멘트") // private Set orgs = new HashSet<>(); private OrgEntity org; - public void emailVerifiedSuccess() { this.isEmailVerified = true; diff --git a/nw/src/main/java/lab/cherry/nw/repository/EventRepository.java b/nw/src/main/java/lab/cherry/nw/repository/EventRepository.java index d9cecd3..1058228 100644 --- a/nw/src/main/java/lab/cherry/nw/repository/EventRepository.java +++ b/nw/src/main/java/lab/cherry/nw/repository/EventRepository.java @@ -15,7 +15,7 @@ //@Repository public interface EventRepository extends MongoRepository { - Optional findBySeq(String seq); + Optional findById(String id); Optional findByTitle(String title); } \ No newline at end of file diff --git a/nw/src/main/java/lab/cherry/nw/repository/UserCardRepository.java b/nw/src/main/java/lab/cherry/nw/repository/UserCardRepository.java index 199dd19..7b40f31 100644 --- a/nw/src/main/java/lab/cherry/nw/repository/UserCardRepository.java +++ b/nw/src/main/java/lab/cherry/nw/repository/UserCardRepository.java @@ -5,6 +5,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.mongodb.repository.MongoRepository; +import org.springframework.data.mongodb.repository.Query; import lab.cherry.nw.model.UserCardEntity; @@ -26,4 +27,7 @@ public interface UserCardRepository extends MongoRepository findById(String id); List findAllById(List orgIds); + + @Query("{'userinfo.$_id' : ?0}") + Optional findByUserSeq(String seq); } diff --git a/nw/src/main/java/lab/cherry/nw/service/Impl/EventServiceImpl.java b/nw/src/main/java/lab/cherry/nw/service/Impl/EventServiceImpl.java index 9e534dc..7739515 100644 --- a/nw/src/main/java/lab/cherry/nw/service/Impl/EventServiceImpl.java +++ b/nw/src/main/java/lab/cherry/nw/service/Impl/EventServiceImpl.java @@ -67,35 +67,26 @@ public Page getEvents(Pageable pageable) { */ public EventEntity createEvent(String id) { - UserCardEntity UserCardEntity = userCardFindById(id); + UserCardEntity userCardEntity = userCardFindById(id); Map dateFormat = new HashMap<>(); - dateFormat = FormatConverter.convertDateFormat(UserCardEntity.getResDate()); - - String eventName = dateFormat.get("hour") + ":" + dateFormat.get("minute") + " " + UserCardEntity.getGroom().getName() + "♥" + UserCardEntity.getBride().getName(); + dateFormat = FormatConverter.convertDateFormat(userCardEntity.getResDate()); // {hour}:{min} {groom}♥{bride} - EventEntity _eventEntity = findByTitle(eventName); // 중복 체크 - - EventEntity eventEntity = EventEntity.builder() - .id(_eventEntity.getId()) - .seq(id) - .title(eventName) - .location(UserCardEntity.getWeddinghall().getName()) - .resDate(UserCardEntity.getResDate()) - .weddingDate(UserCardEntity.getWeddingDate()) - .updated_at(Instant.now()) - .build(); + String eventName = dateFormat.get("hour") + ":" + dateFormat.get("minute") + " " + userCardEntity.getGroom().getName() + "♥" + userCardEntity.getBride().getName(); - return eventRepository.save(eventEntity); + EventEntity eventEntity = EventEntity.builder() + .id(userCardEntity.getUserinfo().getId()) + .title(eventName) + .location(userCardEntity.getWeddinghall().getName()) + .resDate(userCardEntity.getResDate()) + .weddingDate(userCardEntity.getWeddingDate()) + .updated_at(Instant.now()) + .build(); + + return eventRepository.save(eventEntity); } - - // @Transactional(readOnly = true) - // public Page findPageByName(String name, Pageable pageable) { - // return eventRepository.findPageByName(name, pageable); - // } - /** * [EventServiceImpl] 이벤트 이름 중복 체크 함수 * @@ -131,23 +122,6 @@ public EventEntity findById(String id) { return eventRepository.findById(id).orElseThrow(() -> new EntityNotFoundException("Event with Id " + id + " Not Found.")); } - /** - * [EventServiceImpl] Seq로 이벤트 조회 함수 - * - * @param seq 조회할 이벤트의 식별자입니다. - * @return 주어진 식별자에 해당하는 이벤트 정보 - * @throws EntityNotFoundException 해당 ID의 이벤트 정보가 없을 경우 예외 처리 발생 - *
-     * 입력한 id에 해당하는 이벤트 정보를 조회합니다.
-     * 
- * - * Author : taking(taking@duck.com) - */ - @Transactional(readOnly = true) - public EventEntity findBySeq(String seq) { - return eventRepository.findBySeq(seq).orElseThrow(() -> new EntityNotFoundException("Event with Seq " + seq + " Not Found.")); - } - /** * [EventServiceImpl] Title로 이벤트 조회 함수 *