diff --git a/nw/src/main/java/lab/cherry/nw/controller/OrgController.java b/nw/src/main/java/lab/cherry/nw/controller/OrgController.java index 6a04038..719c3f1 100644 --- a/nw/src/main/java/lab/cherry/nw/controller/OrgController.java +++ b/nw/src/main/java/lab/cherry/nw/controller/OrgController.java @@ -199,7 +199,8 @@ public ResponseEntity deleteOrganization(@PathVariable("id") String id) { @GetMapping("/invite") @Operation(summary = "사용자(랑부) 초대", description = "이메일로 조직 초대 메일을 발송합니다.") - public ResponseEntity inviteUser(@RequestParam(required = false) String orgid, @RequestParam(required = false) String email) { + public ResponseEntity inviteUser(@RequestParam(required = false) String orgid, + @RequestParam(required = false) String email) { log.info("[OrgController] inviteUser...!"); orgService.inviteOrgSend(orgid, email); diff --git a/nw/src/main/java/lab/cherry/nw/error/handler/CustomAccessDeniedHandler.java b/nw/src/main/java/lab/cherry/nw/error/handler/CustomAccessDeniedHandler.java index 38978d4..51296dd 100644 --- a/nw/src/main/java/lab/cherry/nw/error/handler/CustomAccessDeniedHandler.java +++ b/nw/src/main/java/lab/cherry/nw/error/handler/CustomAccessDeniedHandler.java @@ -2,6 +2,7 @@ import lab.cherry.nw.error.enums.ErrorCode; import lab.cherry.nw.util.FormatConverter; +import lombok.extern.slf4j.Slf4j; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; diff --git a/nw/src/main/java/lab/cherry/nw/error/handler/GlobalExceptionHandler.java b/nw/src/main/java/lab/cherry/nw/error/handler/GlobalExceptionHandler.java index c08f555..499777d 100644 --- a/nw/src/main/java/lab/cherry/nw/error/handler/GlobalExceptionHandler.java +++ b/nw/src/main/java/lab/cherry/nw/error/handler/GlobalExceptionHandler.java @@ -1,10 +1,6 @@ package lab.cherry.nw.error.handler; -import lab.cherry.nw.error.ErrorResponse; -import lab.cherry.nw.error.enums.ErrorCode; -import lab.cherry.nw.error.exception.CustomException; -import lab.cherry.nw.error.exception.EntityNotFoundException; -import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.AccessDeniedException; import org.springframework.dao.DuplicateKeyException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -13,14 +9,13 @@ import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.WebRequest; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; -import org.springframework.web.servlet.NoHandlerFoundException; -import jakarta.servlet.http.HttpServletResponse; -import java.nio.file.AccessDeniedException; -import java.util.HashMap; +import lab.cherry.nw.error.ErrorResponse; +import lab.cherry.nw.error.enums.ErrorCode; +import lab.cherry.nw.error.exception.CustomException; +import lab.cherry.nw.error.exception.EntityNotFoundException; +import lombok.extern.slf4j.Slf4j; @Slf4j @RestControllerAdvice 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 b843344..09bcc31 100644 --- a/nw/src/main/java/lab/cherry/nw/model/EventEntity.java +++ b/nw/src/main/java/lab/cherry/nw/model/EventEntity.java @@ -28,16 +28,14 @@ @Builder @NoArgsConstructor @AllArgsConstructor @Document(collection = "events") -@JsonPropertyOrder({ "eventSeq", "eventTitle", "eventLocation", "resDate", "weddingDate", "evenDate", "updated_at" }) +@JsonPropertyOrder({ "id", "title", "location", "resDate", "weddingDate", "updated_at" }) public class EventEntity implements Serializable { @Id - @JsonProperty("eventSeq") @Schema(title = "이벤트 고유번호", example = "64ed89aa9e813b5ab16da6de") private String id; @NotNull - @JsonProperty("eventTitle") @Schema(title = "이벤트 이름", example = "{time}시 {title}") @Size(min = 1, max = 20, message = "이벤트 이름은 20자 이내로만 가능합니다.") private String title; @@ -48,18 +46,20 @@ public class EventEntity implements Serializable { // private String description; @NotNull - @JsonProperty("eventLocation") @Schema(title = "이벤트 장소", example = "더모멘트홀") @Size(min = 1, max = 20, message = "이벤트 장소명은 20글자 이내로만 가능합니다.") private String location; @NotBlank - @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul") + @JsonProperty("resDate") + @JsonFormat(locale = "ko_KR", timezone = "Asia/Seoul") + // @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul") @Schema(title = "예약 날짜", example = "2023-08-29T05:11:38.002Z") private String resDate; @NotBlank - @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul") + @JsonFormat(locale = "ko_KR", timezone = "Asia/Seoul") + // @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss", locale = "ko_KR", timezone = "Asia/Seoul") @Schema(title = "예식 날짜", example = "2023-08-29T05:11:38.002Z") private String weddingDate; diff --git a/nw/src/main/java/lab/cherry/nw/service/EventService.java b/nw/src/main/java/lab/cherry/nw/service/EventService.java index 62cec6a..3b2cf1a 100644 --- a/nw/src/main/java/lab/cherry/nw/service/EventService.java +++ b/nw/src/main/java/lab/cherry/nw/service/EventService.java @@ -18,9 +18,7 @@ public interface EventService { Page getEvents(Pageable pageable); EventEntity createEvent(String id); -// void updateById(String id, WeddinghallEntity.UpdateDto weddinghall); EventEntity findById(String id); -// WeddinghallEntity findByName(String name); void deleteById(String id); - // Page findPageByName(String name, Pageable pageable); + boolean checkExistsWithEventId(String id); } diff --git a/nw/src/main/java/lab/cherry/nw/service/Impl/EmailAuthServiceImpl.java b/nw/src/main/java/lab/cherry/nw/service/Impl/EmailAuthServiceImpl.java index d5d2e99..e9c6900 100644 --- a/nw/src/main/java/lab/cherry/nw/service/Impl/EmailAuthServiceImpl.java +++ b/nw/src/main/java/lab/cherry/nw/service/Impl/EmailAuthServiceImpl.java @@ -119,7 +119,7 @@ public void ResetPasswordSend(String email, String password) { public void InviteOrgSend(String orgid, String orgname, String email) { MimeMessage message = javaMmailSender.createMimeMessage(); - String _link = FRONTEND_ADDR + "/auth/register/org/" + orgid; + String _link = FRONTEND_ADDR + "/register/org/" + orgid; try { message.addRecipients(MimeMessage.RecipientType.TO, email); 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 7739515..aea4b37 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 @@ -73,10 +73,10 @@ public EventEntity createEvent(String id) { dateFormat = FormatConverter.convertDateFormat(userCardEntity.getResDate()); // {hour}:{min} {groom}♥{bride} - String eventName = dateFormat.get("hour") + ":" + dateFormat.get("minute") + " " + userCardEntity.getGroom().getName() + "♥" + userCardEntity.getBride().getName(); + String eventName = dateFormat.get("hour") + ":" + ((dateFormat.get("minute") == 0) ? "00" : dateFormat.get("minute")) + " " + userCardEntity.getGroom().getName() + "♥" + userCardEntity.getBride().getName(); EventEntity eventEntity = EventEntity.builder() - .id(userCardEntity.getUserinfo().getId()) + .id(userCardEntity.getId()) .title(eventName) .location(userCardEntity.getWeddinghall().getName()) .resDate(userCardEntity.getResDate()) @@ -161,4 +161,14 @@ public UserCardEntity userCardFindById(String id) { return userCardRepository.findById(id).orElseThrow(() -> new EntityNotFoundException("Usercard with Id " + id + " Not Found.")); } + @Transactional(readOnly = true) + public boolean checkExistsWithEventId(String id) { + if (eventRepository.findById(id).isPresent()) { + return true; + } else { + return false; + } + } + + } \ No newline at end of file diff --git a/nw/src/main/java/lab/cherry/nw/service/Impl/OrgServiceImpl.java b/nw/src/main/java/lab/cherry/nw/service/Impl/OrgServiceImpl.java index 3288188..2a05cad 100644 --- a/nw/src/main/java/lab/cherry/nw/service/Impl/OrgServiceImpl.java +++ b/nw/src/main/java/lab/cherry/nw/service/Impl/OrgServiceImpl.java @@ -221,6 +221,8 @@ public Page findPageByName(String name, Pageable pageable) { public void inviteOrgSend(String orgid, String email) { + log.error("orgid is {}", orgid); + OrgEntity orgEntity = findById(orgid); emailAuthService.InviteOrgSend(orgEntity.getId(), orgEntity.getName(), email); diff --git a/nw/src/main/java/lab/cherry/nw/service/Impl/UserCardServiceImpl.java b/nw/src/main/java/lab/cherry/nw/service/Impl/UserCardServiceImpl.java index b8f567d..b68b6f8 100644 --- a/nw/src/main/java/lab/cherry/nw/service/Impl/UserCardServiceImpl.java +++ b/nw/src/main/java/lab/cherry/nw/service/Impl/UserCardServiceImpl.java @@ -36,7 +36,6 @@ public class UserCardServiceImpl implements UserCardService { private final UserCardRepository userCardRepository; - private final UserRepository userRepository; private final UserService userService; private final WeddinghallService weddinghallService; private final EventService eventService; @@ -200,7 +199,9 @@ public void updateWeddinghallByName(String id, String weddinghall) { */ public void deleteById(String id) { - eventService.deleteById(id); + if(eventService.checkExistsWithEventId(id)) { + eventService.deleteById(id); + } userCardRepository.delete(userCardRepository.findById(id).orElseThrow(() -> new EntityNotFoundException("Usercard with Id " + id + " Not Found."))); }