featurez sign and signup
This commit is contained in:
parent
d46130d303
commit
06e79d7d50
@ -1,72 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.controller;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class UploadController {
|
|
||||||
|
|
||||||
@Value("${file.upload-dir}")
|
|
||||||
String uploadDir;
|
|
||||||
|
|
||||||
private final EventService eventService;
|
|
||||||
|
|
||||||
private final GalleryService galleryService;
|
|
||||||
|
|
||||||
public UploadController(EventService eventService, GalleryService galleryService) {
|
|
||||||
this.eventService = eventService;
|
|
||||||
this.galleryService = galleryService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/uploadimage")
|
|
||||||
public String displayUploadForm() {
|
|
||||||
return "addImages";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/upload/{eventId}", consumes = MULTIPART_FORM_DATA_VALUE)
|
|
||||||
public String uploadImage(Model model,
|
|
||||||
@PathVariable long eventId,
|
|
||||||
@RequestParam("images") List<MultipartFile> images) {
|
|
||||||
|
|
||||||
eventService.addImages(eventId, images);
|
|
||||||
StringBuilder fileNames = new StringBuilder();
|
|
||||||
images.forEach(image -> fileNames.append(image.getOriginalFilename()).append(" "));
|
|
||||||
model.addAttribute("msg", "Uploaded images: " + fileNames);
|
|
||||||
return "addImages";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/upload/gallery/{galleryId}", consumes = MULTIPART_FORM_DATA_VALUE)
|
|
||||||
public String uploadImageToGallery(Model model,
|
|
||||||
@PathVariable long galleryId,
|
|
||||||
@RequestParam("images") List<MultipartFile> images) {
|
|
||||||
|
|
||||||
galleryService.addImages(galleryId, images);
|
|
||||||
StringBuilder fileNames = new StringBuilder();
|
|
||||||
images.forEach(image -> fileNames.append(image.getOriginalFilename()).append(" "));
|
|
||||||
model.addAttribute("msg", "Uploaded images: " + fileNames);
|
|
||||||
return "addImages";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/addevent")
|
|
||||||
public String displayUploadFormToAddEvent() {
|
|
||||||
return "addEvent";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/upload", consumes = MULTIPART_FORM_DATA_VALUE)
|
|
||||||
public String addEvent(Model model,
|
|
||||||
@RequestPart("newEvent") Event newEvent,
|
|
||||||
@RequestPart("images") List<MultipartFile> images) {
|
|
||||||
eventService.addEvent(newEvent, images);
|
|
||||||
StringBuilder fileNames = new StringBuilder();
|
|
||||||
images.forEach(image -> fileNames.append(image.getOriginalFilename()).append(" "));
|
|
||||||
model.addAttribute("msg", "Uploaded images: " + fileNames);
|
|
||||||
return "addEvent";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis;
|
|
||||||
|
|
||||||
public interface EmailService {
|
|
||||||
|
|
||||||
void sendCustomerReservationEmail(Reservation reservation);
|
|
||||||
|
|
||||||
void sendAdminReservationEmail(Reservation reservation);
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis;
|
|
||||||
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
public interface StorageService {
|
|
||||||
|
|
||||||
void init();
|
|
||||||
|
|
||||||
String upload(MultipartFile file, String newFileName);
|
|
||||||
|
|
||||||
Resource download(String fileName);
|
|
||||||
|
|
||||||
void delete(String fileName);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dto;
|
||||||
|
|
||||||
|
public class Company {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dto;
|
||||||
|
|
||||||
|
public class ExportFolder {
|
||||||
|
}
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dto;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
|
||||||
public class Gallery {
|
|
||||||
|
|
||||||
Long id;
|
|
||||||
|
|
||||||
@NotBlank(message = "name cannot be empty")
|
|
||||||
String name;
|
|
||||||
|
|
||||||
String description;
|
|
||||||
|
|
||||||
List<Image> images;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Gallery(" + String.format("name=%s, description=%s)", name, description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dto;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class Image {
|
|
||||||
|
|
||||||
Long id;
|
|
||||||
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
String path;
|
|
||||||
|
|
||||||
String uri;
|
|
||||||
|
|
||||||
public Image(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dto;
|
||||||
|
|
||||||
|
public class License {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dto;
|
||||||
|
|
||||||
|
public class Quote {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dto;
|
||||||
|
|
||||||
|
public class RegisterRequest {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserAccount {
|
||||||
|
private String username;
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
private String role; // or "ADMIN"
|
||||||
|
private Company company;
|
||||||
|
private License license;
|
||||||
|
private List<Quote> quotes;
|
||||||
|
}
|
||||||
@ -1,59 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class EmailServiceImpl implements EmailService {
|
|
||||||
|
|
||||||
@Value("${application.email.from}")
|
|
||||||
String adminEmail;
|
|
||||||
|
|
||||||
private final EmailSenderRepository emailSenderRepository;
|
|
||||||
|
|
||||||
private final DateTimeFormatter outputFormatter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public EmailServiceImpl(EmailSenderRepository emailSenderRepository) {
|
|
||||||
this.emailSenderRepository = emailSenderRepository;
|
|
||||||
this.outputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy 'à' HH:mm");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String buildCustomerReservationEmail(String name, String date, int nbPerson) {
|
|
||||||
return "<div dir=\"ltr\" style=\"font-family: Arial, sans-serif; background-color: #f6f6f6; padding: 20px;\">\n" +
|
|
||||||
" <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"max-width: 600px; margin: auto; background-color: #ffffff; border-radius: 8px; overflow: hidden;\">\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td style=\"padding: 20px; text-align: center;\">\n" +
|
|
||||||
" <h1 style=\"color: #333;\">Bienvenue au Restaurant le BLR!</h1>\n" +
|
|
||||||
" <img src=\"https://demo.stripocdn.email/content/guids/04fb15d2-fa4d-45a6-9edf-63e2a4d6d00a/images/group_3.png\" alt=\"Restaurant le BLR\" width=\"100%\" style=\"max-width: 600px; border-radius: 8px;\">\n" +
|
|
||||||
" <hr style=\"border: none; border-bottom: 4px solid #ccad53; margin: 20px 0;\">\n" +
|
|
||||||
" <h2 style=\"color: #333;\">Bonjour " + name + ",</h2>\n" +
|
|
||||||
" <p style=\"color: #555; line-height: 1.6;\">\n" +
|
|
||||||
" Merci beaucoup pour votre réservation chez <strong>Le BLR</strong>.<br>\n" +
|
|
||||||
" Nous sommes ravis de vous avoir parmi nous !<br>\n" +
|
|
||||||
" Vous avez effectué une réservation pour <strong>" + nbPerson + " " + (nbPerson > 1 ? "personnes" : "personne") + "</strong>.<br>\n" +
|
|
||||||
" Nous avons hâte de vous accueillir dans notre restaurant le <strong>" + date + "</strong> et de vous offrir une expérience inoubliable !<br>\n" +
|
|
||||||
" À très bientôt,<br>\n" +
|
|
||||||
" L'équipe du <strong>Le BLR</strong>\n" +
|
|
||||||
" </p>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" </table>\n" +
|
|
||||||
"</div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendCustomerReservationEmail(Reservation reservation) {
|
|
||||||
emailSenderRepository.send(reservation.getEmail(),
|
|
||||||
buildCustomerReservationEmail(reservation.getName(), reservation.getDate().format(outputFormatter), reservation.getNbPerson()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendAdminReservationEmail(Reservation reservation) {
|
|
||||||
emailSenderRepository.send(adminEmail,
|
|
||||||
buildCustomerReservationEmail(reservation.getName(), reservation.getDate().format(outputFormatter), reservation.getNbPerson()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,86 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.exception.StorageException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.core.io.UrlResource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
public class FileSystemStorageService implements StorageService {
|
|
||||||
|
|
||||||
@Value("${file.upload-dir}")
|
|
||||||
String uploadDir;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
Path directory = Paths.get(uploadDir);
|
|
||||||
if (!Files.exists(directory)) {
|
|
||||||
try {
|
|
||||||
log.info("Create directory {} to store images", directory);
|
|
||||||
Files.createDirectories(directory);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new StorageException("Failed to create directory " + uploadDir, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String upload(MultipartFile file, String newFileName) {
|
|
||||||
|
|
||||||
if (!file.isEmpty()) {
|
|
||||||
|
|
||||||
Path filePath = Paths.get(uploadDir, newFileName);
|
|
||||||
log.info("File path: {}", filePath);
|
|
||||||
try {
|
|
||||||
Files.write(filePath, file.getBytes());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new StorageException("Failed to store file", e);
|
|
||||||
}
|
|
||||||
log.info("save {} to {}", file.getOriginalFilename(), newFileName);
|
|
||||||
return filePath.toString();
|
|
||||||
} else {
|
|
||||||
throw new StorageException("Failed to store file");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Resource download(String fileName) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Path filePath = Paths.get(uploadDir).resolve(fileName).normalize();
|
|
||||||
log.info("Download file path: {}", fileName);
|
|
||||||
Resource resource = new UrlResource(filePath.toUri());
|
|
||||||
if (!resource.exists() || !resource.isReadable()) {
|
|
||||||
throw new StorageException("Could not read file: " + fileName);
|
|
||||||
}
|
|
||||||
return resource;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new StorageException("Failed to download file " + fileName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String fileName) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Path filePath = Paths.get(uploadDir).resolve(fileName).normalize();
|
|
||||||
log.info("Delete file path: {}", fileName);
|
|
||||||
if (Files.exists(filePath)) {
|
|
||||||
Files.delete(filePath);
|
|
||||||
} else {
|
|
||||||
throw new StorageException("File does not exist: " + fileName);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new StorageException("Failed to delete file " + fileName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis;
|
|
||||||
|
|
||||||
public interface EmailSenderRepository {
|
|
||||||
|
|
||||||
void send(String emailAddressTo, String emailContent);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dao;
|
||||||
|
|
||||||
|
public interface CompanyDao {
|
||||||
|
}
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.EventEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface EventDao extends JpaRepository<EventEntity, Long> {
|
|
||||||
|
|
||||||
Optional<EventEntity> findByName(String name);
|
|
||||||
|
|
||||||
List<EventEntity> findAllByDate(Instant date);
|
|
||||||
|
|
||||||
List<EventEntity> findAllByOrderByDateDescNameAsc();
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dao;
|
||||||
|
|
||||||
|
public interface ExportFolderDao {
|
||||||
|
}
|
||||||
@ -1,7 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.GalleryEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface GalleryDao extends JpaRepository<GalleryEntity, Long> {
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.ImageEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface ImageDao extends JpaRepository<ImageEntity, Long> {
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dao;
|
||||||
|
|
||||||
|
public interface LicenseDao {
|
||||||
|
}
|
||||||
@ -1,8 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.MenuCategoryEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface MenuDao extends JpaRepository<MenuCategoryEntity, Long> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.ProductEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface ProductDao extends JpaRepository<ProductEntity, Long> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.dao;
|
||||||
|
|
||||||
|
public class QuoteDao {
|
||||||
|
}
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.ReservationEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ReservationDao extends JpaRepository<ReservationEntity, Long> {
|
|
||||||
|
|
||||||
List<ReservationEntity> findByName(String name);
|
|
||||||
|
|
||||||
@Query("SELECT r FROM ReservationEntity r WHERE r.date >= :startOfDay AND r.date < :endOfDay")
|
|
||||||
List<ReservationEntity> findReservationsByDates(@Param("startOfDay") LocalDateTime startOfDay,
|
|
||||||
@Param("endOfDay") LocalDateTime endOfDay);
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.dao;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.SelectedDayEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface SelectedDayDao extends JpaRepository<SelectedDayEntity, Long> {
|
|
||||||
|
|
||||||
@Query("SELECT day FROM SelectedDayEntity day WHERE day.date >= :date")
|
|
||||||
List<SelectedDayEntity> findAllFromDate(LocalDate date);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.dh7789dev.xpeditis.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Company extends BaseEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String country;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "company", cascade = CascadeType.ALL)
|
||||||
|
private List<UserAccount> users;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "company", cascade = CascadeType.ALL)
|
||||||
|
private List<Quote> quotes;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "company", cascade = CascadeType.ALL)
|
||||||
|
private List<ExportFile> exports;
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "event", uniqueConstraints = {
|
|
||||||
@UniqueConstraint(columnNames = {"name"})
|
|
||||||
})
|
|
||||||
public class EventEntity extends BaseEntity {
|
|
||||||
|
|
||||||
@Column(nullable = false, unique = true)
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
String description;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
LocalDate date;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private List<ImageEntity> images;
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.entity;
|
||||||
|
|
||||||
|
public class ExportFolder {
|
||||||
|
}
|
||||||
@ -1,30 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "gallery", uniqueConstraints = {
|
|
||||||
@UniqueConstraint(columnNames = {"name"})
|
|
||||||
})
|
|
||||||
public class GalleryEntity extends BaseEntity {
|
|
||||||
|
|
||||||
@Column(unique = true)
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
String description;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "gallery", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private List<ImageEntity> images;
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "image", uniqueConstraints = {
|
|
||||||
@UniqueConstraint(columnNames = {"name", "path"})
|
|
||||||
})
|
|
||||||
public class ImageEntity extends BaseEntity {
|
|
||||||
|
|
||||||
@Column(unique = true)
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@Column(unique = true)
|
|
||||||
String path;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "event_id")
|
|
||||||
EventEntity event;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "gallery_id")
|
|
||||||
GalleryEntity gallery;
|
|
||||||
}
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.dh7789dev.xpeditis.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class License extends BaseEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String licenseKey;
|
||||||
|
private LocalDate expirationDate;
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "user_id", unique = true)
|
||||||
|
private UserAccount user;
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "menu_category", uniqueConstraints = {
|
|
||||||
@UniqueConstraint(columnNames = {"name"})
|
|
||||||
})
|
|
||||||
public class MenuCategoryEntity extends BaseEntity {
|
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
@Column(name = "name", nullable = false, unique = true)
|
|
||||||
private MenuCategory.Name name;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "category")
|
|
||||||
private List<ProductEntity> products;
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "product", uniqueConstraints = {
|
|
||||||
@UniqueConstraint(columnNames = {"name"})
|
|
||||||
})
|
|
||||||
public class ProductEntity extends BaseEntity {
|
|
||||||
|
|
||||||
@Column(nullable = false, unique = true)
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
String description;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
BigDecimal price;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "category_id")
|
|
||||||
private MenuCategoryEntity category;
|
|
||||||
}
|
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.dh7789dev.xpeditis.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Quote extends BaseEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String reference;
|
||||||
|
private String status;
|
||||||
|
private BigDecimal estimatedAmount;
|
||||||
|
private LocalDateTime createdAt = LocalDateTime.now();
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private UserAccount user;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Company company;
|
||||||
|
|
||||||
|
@OneToOne(mappedBy = "quote", cascade = CascadeType.ALL)
|
||||||
|
private ExportFile exportFile;
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Table(name = "reservation")
|
|
||||||
public class ReservationEntity extends BaseEntity {
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
String email;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
String phone;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
int nbPerson;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
LocalDateTime date;
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import lombok.experimental.FieldDefaults;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "selected_day")
|
|
||||||
public class SelectedDayEntity extends BaseEntity {
|
|
||||||
|
|
||||||
LocalDate date;
|
|
||||||
}
|
|
||||||
17
infrastructure/src/main/java/com/dh7789dev/xpeditis/entity/UserEntity.java
Executable file → Normal file
17
infrastructure/src/main/java/com/dh7789dev/xpeditis/entity/UserEntity.java
Executable file → Normal file
@ -13,10 +13,7 @@ import java.util.List;
|
|||||||
@Entity
|
@Entity
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Table(name = "users", uniqueConstraints = {
|
public class UserAccountEntity extends BaseEntity implements UserDetails {
|
||||||
@UniqueConstraint(columnNames = {"username", "email"})
|
|
||||||
})
|
|
||||||
public class UserEntity extends BaseEntity implements UserDetails {
|
|
||||||
|
|
||||||
@NaturalId
|
@NaturalId
|
||||||
@Column(nullable = false, unique = true, length = 50)
|
@Column(nullable = false, unique = true, length = 50)
|
||||||
@ -28,7 +25,7 @@ public class UserEntity extends BaseEntity implements UserDetails {
|
|||||||
@Column(name = "last_name", length = 50)
|
@Column(name = "last_name", length = 50)
|
||||||
private String lastName;
|
private String lastName;
|
||||||
|
|
||||||
@Column(nullable = false, unique = true, length = 50)
|
@Column(unique = true, nullable = false)
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@ -41,6 +38,15 @@ public class UserEntity extends BaseEntity implements UserDetails {
|
|||||||
@Column(name = "enabled", nullable = false, columnDefinition = "BOOLEAN DEFAULT TRUE NOT NULL")
|
@Column(name = "enabled", nullable = false, columnDefinition = "BOOLEAN DEFAULT TRUE NOT NULL")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private CompanyEntity company;
|
||||||
|
|
||||||
|
@OneToOne(mappedBy = "user", cascade = CascadeType.ALL)
|
||||||
|
private LicenseEntity license;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
|
||||||
|
private List<QuoteEntity> quotes;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "user")
|
@OneToMany(mappedBy = "user")
|
||||||
private List<TokenEntity> tokens;
|
private List<TokenEntity> tokens;
|
||||||
|
|
||||||
@ -85,3 +91,4 @@ public class UserEntity extends BaseEntity implements UserDetails {
|
|||||||
username, firstName, lastName, email, role.name());
|
username, firstName, lastName, email, role.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.mapper;
|
||||||
|
|
||||||
|
public class CompanyMapper {
|
||||||
|
}
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.EventEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper(/*componentModel = MappingConstants.ComponentModel.SPRING,*/
|
|
||||||
uses = {ImageMapper.class})
|
|
||||||
public interface EventMapper {
|
|
||||||
|
|
||||||
EventMapper INSTANCE = Mappers.getMapper(EventMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
EventEntity eventToEventEntity(Event event);
|
|
||||||
|
|
||||||
Event eventEntityToEvent(EventEntity eventEntity);
|
|
||||||
|
|
||||||
List<Event> eventEntitiesToEvents(List<EventEntity> eventEntities);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.mapper;
|
||||||
|
|
||||||
|
public interface ExportFolderMapper {
|
||||||
|
}
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.dto.Gallery;
|
|
||||||
import com.dh7789dev.xpeditis.entity.GalleryEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
@Mapper(/*componentModel = MappingConstants.ComponentModel.SPRING,*/
|
|
||||||
uses = {ImageMapper.class})
|
|
||||||
public interface GalleryMapper {
|
|
||||||
|
|
||||||
GalleryMapper INSTANCE = Mappers.getMapper(GalleryMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
GalleryEntity galleryToGalleryEntity(Gallery gallery);
|
|
||||||
|
|
||||||
Gallery galleryEntityToGallery(GalleryEntity galleryEntity);
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.dto.Image;
|
|
||||||
import com.dh7789dev.xpeditis.entity.ImageEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.MappingConstants;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
|
|
||||||
public interface ImageMapper {
|
|
||||||
|
|
||||||
ImageMapper INSTANCE = Mappers.getMapper(ImageMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
@Mapping(target = "event", ignore = true)
|
|
||||||
ImageEntity imageToImageEntity(Image image);
|
|
||||||
|
|
||||||
@Mapping(target = "path", ignore = true)
|
|
||||||
@Mapping(target = "uri", expression = "java(\"/api/v1/images/\" + imageEntity.getId())")
|
|
||||||
Image imageEntityToImage(ImageEntity imageEntity);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.mapper;
|
||||||
|
|
||||||
|
public interface LicenseMapper {
|
||||||
|
}
|
||||||
@ -1,27 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.MenuCategoryEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper(/*componentModel = MappingConstants.ComponentModel.SPRING,*/
|
|
||||||
uses = {ProductMapper.class})
|
|
||||||
public interface MenuCategoryMapper {
|
|
||||||
|
|
||||||
MenuCategoryMapper INSTANCE = Mappers.getMapper(MenuCategoryMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
@Mapping(source = "menuItems", target = "products")
|
|
||||||
MenuCategoryEntity menuCategoryToMenuCategoryEntity(MenuCategory menuCategory);
|
|
||||||
|
|
||||||
@Mapping(source = "products", target = "menuItems")
|
|
||||||
MenuCategory menuCategoryEntityToMenuCategory(MenuCategoryEntity menuCategoryEntity);
|
|
||||||
|
|
||||||
List<MenuCategory> menuCategoryEntitiesToMenuCategories(List<MenuCategoryEntity> menuCategoryEntities);
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.ProductEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.MappingConstants;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
|
|
||||||
public interface ProductMapper {
|
|
||||||
|
|
||||||
ProductMapper INSTANCE = Mappers.getMapper(ProductMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
@Mapping(target = "category", ignore = true)
|
|
||||||
ProductEntity menuItemToProductEntity(MenuItem menuItem);
|
|
||||||
|
|
||||||
MenuItem productEntityToMenuItem(ProductEntity productEntity);
|
|
||||||
|
|
||||||
List<MenuItem> productEntitiesToMenuItems(List<ProductEntity> productEntities);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.mapper;
|
||||||
|
|
||||||
|
public interface QuoteMapper {
|
||||||
|
}
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.ReservationEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.MappingConstants;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
|
|
||||||
public interface ReservationMapper {
|
|
||||||
|
|
||||||
ReservationMapper INSTANCE = Mappers.getMapper(ReservationMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
ReservationEntity reservationToReservationEntity(Reservation reservation);
|
|
||||||
|
|
||||||
Reservation reservationEntityToReservation(ReservationEntity reservationEntity);
|
|
||||||
|
|
||||||
List<Reservation> reservationEntitiesToReservation(List<ReservationEntity> reservationEntities);
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.mapper;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.entity.SelectedDayEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.MappingConstants;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
|
|
||||||
public interface SelectedDayMapper {
|
|
||||||
|
|
||||||
SelectedDayMapper INSTANCE = Mappers.getMapper(SelectedDayMapper.class);
|
|
||||||
|
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
|
||||||
@Mapping(target = "modifiedDate", ignore = true)
|
|
||||||
@Mapping(target = "createdBy", ignore = true)
|
|
||||||
@Mapping(target = "modifiedBy", ignore = true)
|
|
||||||
SelectedDayEntity selectedDayToSelectedDayEntity(SelectedDay selectedDay);
|
|
||||||
|
|
||||||
SelectedDay selectedDayEntityToSelectedDay(SelectedDayEntity selectedDayEntity);
|
|
||||||
|
|
||||||
List<SelectedDay> selectedDayEntitiesToSelectedDays(List<SelectedDayEntity> selectedDayEntities);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package com.dh7789dev.xpeditis.mapper;
|
||||||
|
|
||||||
|
public class UserMapper {
|
||||||
|
}
|
||||||
@ -1,44 +0,0 @@
|
|||||||
package com.dh7789dev.xpeditis.repository;
|
|
||||||
|
|
||||||
import com.dh7789dev.xpeditis.EmailSenderRepository;
|
|
||||||
import jakarta.mail.MessagingException;
|
|
||||||
import jakarta.mail.internet.MimeMessage;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Repository
|
|
||||||
public class JavaMailSenderRepository implements EmailSenderRepository {
|
|
||||||
|
|
||||||
@Value("${application.email.from}")
|
|
||||||
String emailAddressFrom;
|
|
||||||
|
|
||||||
private final JavaMailSender emailSender;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public JavaMailSenderRepository(JavaMailSender emailSender) {
|
|
||||||
this.emailSender = emailSender;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public void send(String emailAddressTo, String emailContent) {
|
|
||||||
try {
|
|
||||||
MimeMessage mimeMessage = emailSender.createMimeMessage();
|
|
||||||
MimeMessageHelper helperMessage = new MimeMessageHelper(mimeMessage, "utf-8");
|
|
||||||
helperMessage.setText(emailContent, true);
|
|
||||||
helperMessage.setTo(emailAddressTo);
|
|
||||||
helperMessage.setSubject("Reservation Confirmation");
|
|
||||||
helperMessage.setFrom(emailAddressFrom);
|
|
||||||
emailSender.send(mimeMessage);
|
|
||||||
} catch (MessagingException e) {
|
|
||||||
log.error("failed to send email", e);
|
|
||||||
throw new IllegalStateException("failed to send email");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user