Skip to content

Commit

Permalink
Merge pull request #105 from Hoang-Nguyen-Huy/feat/socket
Browse files Browse the repository at this point in the history
[NguyenHCP] feat: update send invite calendar
  • Loading branch information
nguyenhcp2004 authored Oct 24, 2024
2 parents 6fdf866 + f907b4d commit 10416c4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.swp.PodBookingSystem.controller;

import com.swp.PodBookingSystem.dto.request.Account.AccountCreationRequest;
import com.swp.PodBookingSystem.dto.request.Account.AccountPaginationDTO;
import com.swp.PodBookingSystem.dto.request.Account.AccountResponseClient;
import com.swp.PodBookingSystem.dto.request.Account.AccountUpdateAdminRequest;
import com.swp.PodBookingSystem.dto.request.Account.*;
import com.swp.PodBookingSystem.dto.request.CalendarRequest;
import com.swp.PodBookingSystem.dto.respone.Account.AccountOrderResponse;
import com.swp.PodBookingSystem.dto.respone.ApiResponse;
Expand Down Expand Up @@ -108,17 +105,17 @@ ApiResponse<AccountResponseClient> getMe(@RequestHeader("Authorization") String
.build();
}

// @GetMapping("/send-email")
// public String sendEmail() throws MessagingException, IOException {
// sendEmailService.sendCalenderInvite(
// CalendarRequest.builder()
// .subject("Đăt lịch ở POD Booking")
// .description("Hãy đặt lịch ở calendar để không bỏ lỡ lịch")
// .summary("Đăt lịch ở POD Booking")
// .to("[email protected]")
// .eventDateTime(LocalDateTime.now()).build());
// return "Send email successfully";
// }
@PostMapping("/send-email")
public String sendEmail(@RequestBody SendMailRequest request) throws MessagingException, IOException {
sendEmailService.sendCalenderInvite(
CalendarRequest.builder()
.subject("Đăt lịch ở POD Booking")
.description("Hãy đặt lịch ở calendar để không bị bỏ lỡ")
.summary("Đăt lịch ở POD Booking")
.to(request.getEmail())
.eventDateTime(LocalDateTime.parse("2024-10-27T17:00:00")).build());
return "Send email successfully";
}

@GetMapping("/staff")
public ResponseEntity<List<AccountOrderResponse>> getAllStaffAccounts() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.swp.PodBookingSystem.controller;

import com.swp.PodBookingSystem.dto.request.ChatMessage;
import com.swp.PodBookingSystem.dto.socketPayload.UpdateOrder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Slf4j
@RestController
public class SocketController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package com.swp.PodBookingSystem.dto.request;
package com.swp.PodBookingSystem.dto.request.Account;

import lombok.*;
import lombok.experimental.FieldDefaults;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ChatMessage {
String nickname;
String content;
Date timestamp;
public class SendMailRequest {
String email;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import jakarta.mail.BodyPart;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMessage;
import jakarta.mail.internet.MimeMultipart;
import jakarta.mail.internet.*;
import jakarta.mail.util.ByteArrayDataSource;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -87,14 +84,15 @@ private BodyPart createCalenderMimeBody(CalendarRequest calenderDto) throws IOEx
return calenderBody;
}

private String createCal(CalendarRequest calenderDto) {
private String createCal(CalendarRequest calenderDto) throws AddressException {
ICalendar ical = new ICalendar();
ical.addProperty(new Method(Method.REQUEST));

VEvent event = new VEvent();
event.setSummary(calenderDto.getSummary());
event.setDescription(calenderDto.getDescription());
event.setDateStart(getStartDate(calenderDto.getEventDateTime()));
event.setOrganizer(String.valueOf(new InternetAddress(fromEmailId)));
event.setDuration(new Duration.Builder()
.hours(2)
.build());
Expand All @@ -112,7 +110,7 @@ public void sendMailReminder() throws MessagingException {
LocalDate toDay = LocalDate.now();
List<OrderDetail> orders = orderDetailService.getNextDayBookings(toDay);

for (OrderDetail orderDetail : orders){
for (OrderDetail orderDetail : orders) {
String email = orderDetail.getCustomer().getEmail();
String subject = "Room Booking Reminder";
String text = "Dear " + orderDetail.getCustomer().getName() + ",\n\n"
Expand Down

0 comments on commit 10416c4

Please sign in to comment.