Skip to content

Commit

Permalink
Merge pull request #52 from taking/taking
Browse files Browse the repository at this point in the history
Chore: Event Logic Modified
  • Loading branch information
taking authored Oct 29, 2023
2 parents 17c3c21 + bf6e050 commit 77a3a1e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 46 deletions.
9 changes: 5 additions & 4 deletions nw/src/main/java/lab/cherry/nw/model/EventEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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;
}

}
3 changes: 1 addition & 2 deletions nw/src/main/java/lab/cherry/nw/model/UserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -90,7 +90,6 @@ public class UserEntity implements Serializable {
@Schema(title = "Org 정보", example = "더모멘트")
// private Set<OrgEntity> orgs = new HashSet<>();
private OrgEntity org;


public void emailVerifiedSuccess() {
this.isEmailVerified = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//@Repository
public interface EventRepository extends MongoRepository<EventEntity, String> {

Optional<EventEntity> findBySeq(String seq);
Optional<EventEntity> findById(String id);
Optional<EventEntity> findByTitle(String title);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand All @@ -26,4 +27,7 @@ public interface UserCardRepository extends MongoRepository<UserCardEntity, Stri
Optional<UserCardEntity> findById(String id);

List<UserCardEntity> findAllById(List<String> orgIds);

@Query("{'userinfo.$_id' : ?0}")
Optional<UserCardEntity> findByUserSeq(String seq);
}
52 changes: 13 additions & 39 deletions nw/src/main/java/lab/cherry/nw/service/Impl/EventServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,35 +67,26 @@ public Page<EventEntity> getEvents(Pageable pageable) {
*/
public EventEntity createEvent(String id) {

UserCardEntity UserCardEntity = userCardFindById(id);
UserCardEntity userCardEntity = userCardFindById(id);

Map<String, Integer> 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<EventEntity> findPageByName(String name, Pageable pageable) {
// return eventRepository.findPageByName(name, pageable);
// }

/**
* [EventServiceImpl] 이벤트 이름 중복 체크 함수
*
Expand Down Expand Up @@ -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의 이벤트 정보가 없을 경우 예외 처리 발생
* <pre>
* 입력한 id에 해당하는 이벤트 정보를 조회합니다.
* </pre>
*
* 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로 이벤트 조회 함수
*
Expand Down

0 comments on commit 77a3a1e

Please sign in to comment.