arseniy.sorokin | bdf2def | 2023-10-05 00:05:32 +0200 | [diff] [blame] | 1 | package pl.hackerspace; |
| 2 | |
| 3 | import lombok.RequiredArgsConstructor; |
| 4 | import lombok.extern.slf4j.Slf4j; |
| 5 | import org.springframework.boot.CommandLineRunner; |
| 6 | import org.springframework.stereotype.Component; |
| 7 | import pl.hackerspace.domain.Client; |
| 8 | import pl.hackerspace.domain.Invoice; |
| 9 | import pl.hackerspace.repository.ClientRepository; |
| 10 | import pl.hackerspace.repository.InvoiceRepository; |
| 11 | |
| 12 | import java.math.BigDecimal; |
| 13 | import java.time.LocalDateTime; |
| 14 | |
| 15 | @Component |
| 16 | @Slf4j |
| 17 | @RequiredArgsConstructor |
| 18 | public class BoostrapInitialData implements CommandLineRunner { |
| 19 | |
| 20 | private final ClientRepository clientRepository; |
| 21 | private final InvoiceRepository invoiceRepository; |
| 22 | |
| 23 | @Override |
| 24 | public void run(String... args) { |
| 25 | log.info("Saving new clients"); |
| 26 | Client client = Client.builder() |
| 27 | .price(BigDecimal.valueOf(200)) |
| 28 | .nip("PL5252497215") |
| 29 | .name("Arseniy Sorokin") |
| 30 | .addressLine1("ul. Bródnowska 3/23") |
| 31 | .addressLine2("03-439 Warszawa, Polska") |
| 32 | .serviceName("Dostęp do Internetu - Umowa HSWAW/666 - Opłata abonamentowa %invoice_month_string%") |
| 33 | .email("arssorokin@gmail.com") |
| 34 | .build(); |
| 35 | clientRepository.save(client); |
| 36 | clientRepository.save(Client.builder() |
| 37 | .price(BigDecimal.valueOf(100)) |
| 38 | .nip("PL111") |
| 39 | .name("Pope Francis") |
| 40 | .addressLine1("St.Peter's square") |
| 41 | .addressLine2("Rome") |
| 42 | .serviceName("Dostęp do Internetu - Umowa HSWAW/2137 - Opłata abonamentowa %invoice_month_string%") |
| 43 | .email("pope@vatican.va") |
| 44 | .build()); |
| 45 | log.info("Saving last invoice"); |
| 46 | invoiceRepository.save(Invoice.builder().id(21196).invoiceTitle("FV21196").creationDate(LocalDateTime.now()) |
| 47 | .client(client).pdfContent(new byte[]{}).build()); |
| 48 | } |
| 49 | } |