diff --git a/build.gradle b/build.gradle index 7e8766c..58f9b3c 100644 --- a/build.gradle +++ b/build.gradle @@ -12,22 +12,24 @@ repositories { mavenCentral() } -jar { - enabled = false -} - dependencies { - implementation(project(':front')) - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'com.h2database:h2:2.1.210' - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-devtools' + implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect' + + implementation 'org.webjars:bootstrap:5.1.3' + implementation 'org.webjars:jquery:3.6.0' + implementation 'org.webjars:font-awesome:6.1.0' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'com.h2database:h2:2.1.210' + + implementation 'org.hibernate.validator:hibernate-validator' + + implementation 'org.springdoc:springdoc-openapi-ui:1.6.5' testImplementation 'org.springframework.boot:spring-boot-starter-test' - implementation 'org.hibernate.validator:hibernate-validator' - implementation 'org.springdoc:springdoc-openapi-ui:1.6.5' } tasks.named('test') { diff --git a/src/main/java/com/labwork1/app/WebConfiguration.java b/src/main/java/com/labwork1/app/WebConfiguration.java index 8b69823..2b87533 100644 --- a/src/main/java/com/labwork1/app/WebConfiguration.java +++ b/src/main/java/com/labwork1/app/WebConfiguration.java @@ -1,35 +1,19 @@ package com.labwork1.app; -import org.springframework.boot.web.server.ErrorPage; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; -import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpStatus; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistration; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.config.annotation.*; + @Configuration public class WebConfiguration implements WebMvcConfigurer { + public static final String REST_API = "/api"; + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + WebMvcConfigurer.super.addViewControllers(registry); + } + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("*"); } - @Override - public void addViewControllers(ViewControllerRegistry registry) { - ViewControllerRegistration registration = registry.addViewController("/notFound"); - registration.setViewName("forward:/index.html"); - registration.setStatusCode(HttpStatus.OK); - - // Alternative way (404 error hits the console): - // > registry.addViewController("/notFound").setViewName("forward:/index.html"); - } - - @Bean - public WebServerFactoryCustomizer containerCustomizer() { - return container -> { - container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notFound")); - }; - } } \ No newline at end of file diff --git a/src/main/java/com/labwork1/app/student/controller/CinemaController.java b/src/main/java/com/labwork1/app/student/controller/CinemaController.java index 767bf26..9b3720e 100644 --- a/src/main/java/com/labwork1/app/student/controller/CinemaController.java +++ b/src/main/java/com/labwork1/app/student/controller/CinemaController.java @@ -1,5 +1,6 @@ package com.labwork1.app.student.controller; +import com.labwork1.app.WebConfiguration; import com.labwork1.app.student.service.CinemaService; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.*; @@ -7,7 +8,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @RestController -@RequestMapping("/cinema") +@RequestMapping(WebConfiguration.REST_API + "/cinema") public class CinemaController { private final CinemaService cinemaService; diff --git a/src/main/java/com/labwork1/app/student/controller/CinemaDto.java b/src/main/java/com/labwork1/app/student/controller/CinemaDto.java index 115bdf7..e6baeac 100644 --- a/src/main/java/com/labwork1/app/student/controller/CinemaDto.java +++ b/src/main/java/com/labwork1/app/student/controller/CinemaDto.java @@ -18,6 +18,18 @@ public class CinemaDto { this.image = new String(cinema.getImage(), StandardCharsets.UTF_8); } + public void setId(long id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setImage(String image) { + this.image = image; + } + public String getImage() { return image; } diff --git a/src/main/java/com/labwork1/app/student/controller/CinemaMvcController.java b/src/main/java/com/labwork1/app/student/controller/CinemaMvcController.java new file mode 100644 index 0000000..4412914 --- /dev/null +++ b/src/main/java/com/labwork1/app/student/controller/CinemaMvcController.java @@ -0,0 +1,81 @@ +package com.labwork1.app.student.controller; + +import com.labwork1.app.student.service.CinemaService; +import jakarta.validation.Valid; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.Base64; +import java.util.List; + +@Controller +@RequestMapping("/cinema") +public class CinemaMvcController { + private final CinemaService cinemaService; + + public CinemaMvcController(CinemaService cinemaService) { + this.cinemaService = cinemaService; + } + + @GetMapping + public String getCinemas(Model model) { + model.addAttribute("cinemas", + cinemaService.findAllCinemas().stream() + .map(CinemaDto::new) + .toList()); + return "cinema"; + } + + @GetMapping(value = {"/edit", "/edit/{id}"}) + public String editCinema(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("cinemaDto", new CinemaDto()); + } else { + model.addAttribute("cinemaId", id); + model.addAttribute("cinemaDto", new CinemaDto(cinemaService.findCinema(id))); + } + return "cinema-edit"; + } + + @GetMapping (value = "/search/") + public String searchCinema(@RequestParam String request, + Model model) { + List cinemas = cinemaService.findAllCinemas(request) + .stream().map(CinemaDto::new).toList(); + model.addAttribute("cinemas", cinemas); + return "cinema"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveCinema(@PathVariable(required = false) Long id, + @RequestParam("multipartFile") MultipartFile multipartFile, + @ModelAttribute @Valid CinemaDto cinemaDto, + BindingResult bindingResult, + Model model) throws IOException { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "cinema-edit"; + } + if (id == null || id <= 0) { + cinemaDto.setImage("data:image/jpeg;base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); + cinemaService.addCinema(cinemaDto); + } else { + cinemaDto.setId(id); + cinemaDto.setImage("data:image/jpeg;base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes())); + cinemaService.updateCinema(cinemaDto); + } + return "redirect:/cinema"; + } + + @PostMapping("/delete/{id}") + public String deleteCinema(@PathVariable Long id) { + cinemaService.deleteCinema(id); + return "redirect:/cinema"; + } + +} diff --git a/src/main/java/com/labwork1/app/student/controller/CustomerController.java b/src/main/java/com/labwork1/app/student/controller/CustomerController.java index ead463d..c2760a6 100644 --- a/src/main/java/com/labwork1/app/student/controller/CustomerController.java +++ b/src/main/java/com/labwork1/app/student/controller/CustomerController.java @@ -1,12 +1,13 @@ package com.labwork1.app.student.controller; +import com.labwork1.app.WebConfiguration; import com.labwork1.app.student.service.CustomerService; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController -@RequestMapping("/customer") +@RequestMapping(WebConfiguration.REST_API + "/customer") public class CustomerController { private final CustomerService customerService; diff --git a/src/main/java/com/labwork1/app/student/controller/CustomerDto.java b/src/main/java/com/labwork1/app/student/controller/CustomerDto.java index 388d81b..812c3ce 100644 --- a/src/main/java/com/labwork1/app/student/controller/CustomerDto.java +++ b/src/main/java/com/labwork1/app/student/controller/CustomerDto.java @@ -27,6 +27,22 @@ public class CustomerDto { } } + public void setId(long id) { + this.id = id; + } + + public void setLogin(String login) { + this.login = login; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setOrders(List orders) { + this.orders = orders; + } + public long getId() { return id; } diff --git a/src/main/java/com/labwork1/app/student/controller/CustomerMvcController.java b/src/main/java/com/labwork1/app/student/controller/CustomerMvcController.java new file mode 100644 index 0000000..104b787 --- /dev/null +++ b/src/main/java/com/labwork1/app/student/controller/CustomerMvcController.java @@ -0,0 +1,64 @@ +package com.labwork1.app.student.controller; + +import com.labwork1.app.student.service.CustomerService; +import jakarta.validation.Valid; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +@Controller +@RequestMapping("/customer") +public class CustomerMvcController { + private final CustomerService customerService; + + public CustomerMvcController(CustomerService customerService) { + this.customerService = customerService; + } + + @GetMapping + public String getCustomers(Model model) { + model.addAttribute("customers", + customerService.findAllCustomers().stream() + .map(CustomerDto::new) + .toList()); + return "customer"; + } + + @GetMapping(value = {"/edit", "/edit/{id}"}) + public String editCustomer(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("customerDto", new CustomerDto()); + } else { + model.addAttribute("customerId", id); + model.addAttribute("customerDto", new CustomerDto(customerService.findCustomer(id))); + } + return "customer-edit"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveCustomer(@PathVariable(required = false) Long id, + @ModelAttribute @Valid CustomerDto customerDto, + BindingResult bindingResult, + Model model) { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "customer-edit"; + } + if (id == null || id <= 0) { + customerService.addCustomer(customerDto.getLogin(), customerDto.getPassword()); + } else { + customerDto.setId(id); + customerService.updateCustomer(id, customerDto.getLogin(), customerDto.getPassword()); + } + return "redirect:/customer"; + } + + @PostMapping("/delete/{id}") + public String deleteCustomer(@PathVariable Long id) { + customerService.deleteCustomer(id); + return "redirect:/customer"; + } + +} diff --git a/src/main/java/com/labwork1/app/student/controller/OrderController.java b/src/main/java/com/labwork1/app/student/controller/OrderController.java index a0ecc5f..f3ab633 100644 --- a/src/main/java/com/labwork1/app/student/controller/OrderController.java +++ b/src/main/java/com/labwork1/app/student/controller/OrderController.java @@ -1,12 +1,13 @@ package com.labwork1.app.student.controller; +import com.labwork1.app.WebConfiguration; import com.labwork1.app.student.service.OrderService; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController -@RequestMapping("/order") +@RequestMapping(WebConfiguration.REST_API + "/order") public class OrderController { private final OrderService orderService; diff --git a/src/main/java/com/labwork1/app/student/controller/OrderDto.java b/src/main/java/com/labwork1/app/student/controller/OrderDto.java index 775fae0..7ae4e42 100644 --- a/src/main/java/com/labwork1/app/student/controller/OrderDto.java +++ b/src/main/java/com/labwork1/app/student/controller/OrderDto.java @@ -10,6 +10,7 @@ import java.util.List; public class OrderDto { private long id; private Date dateOfPurchase; + private Long customerId; private String customer; private List sessions; @@ -19,6 +20,7 @@ public class OrderDto { public OrderDto(Order order) { this.id = order.getId(); this.dateOfPurchase = order.getDateOfPurchase(); + this.customerId = order.getCustomer().getId(); this.customer = order.getCustomer().getLogin(); if (order.getSessions() != null && order.getSessions().size() > 0) this.sessions = order.getSessions() @@ -27,6 +29,30 @@ public class OrderDto { x.getId().getOrderId(), x.getCount())).toList(); } + public Long getCustomerId() { + return customerId; + } + + public void setCustomerId(Long customerId) { + this.customerId = customerId; + } + + public void setId(long id) { + this.id = id; + } + + public void setDateOfPurchase(Date dateOfPurchase) { + this.dateOfPurchase = dateOfPurchase; + } + + public void setCustomer(String customer) { + this.customer = customer; + } + + public void setSessions(List sessions) { + this.sessions = sessions; + } + public long getId() { return id; } diff --git a/src/main/java/com/labwork1/app/student/controller/OrderMvcController.java b/src/main/java/com/labwork1/app/student/controller/OrderMvcController.java new file mode 100644 index 0000000..e760793 --- /dev/null +++ b/src/main/java/com/labwork1/app/student/controller/OrderMvcController.java @@ -0,0 +1,99 @@ +package com.labwork1.app.student.controller; + +import com.labwork1.app.student.service.CustomerService; +import com.labwork1.app.student.service.OrderService; +import com.labwork1.app.student.service.SessionService; +import jakarta.validation.Valid; +import org.slf4j.event.KeyValuePair; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Controller +@RequestMapping("/order") +public class OrderMvcController { + private final OrderService orderService; + private final SessionService sessionService; + private final CustomerService customerService; + + public OrderMvcController(OrderService orderService, SessionService sessionService, CustomerService customerService) { + this.orderService = orderService; + this.sessionService = sessionService; + this.customerService = customerService; + } + + @GetMapping + public String getOrders(Model model) { + model.addAttribute("orders", + orderService.findAllOrders().stream() + .map(OrderDto::new) + .toList()); + return "order"; + } + + @GetMapping(value = {"/edit", "/edit/{id}"}) + public String editOrder(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + List customers = customerService.findAllCustomers().stream() + .map(CustomerDto::new) + .toList(); + model.addAttribute("orderDto", new OrderDto()); + model.addAttribute("customers", customers); + + return "order-edit"; + } else { + List temp = orderService.findOrder(id).getSessions() + .stream().map(x -> new OrderSessionDto(new SessionDto(x.getSession()), + x.getOrder().getId(), x.getCount())).toList(); + List sessions = sessionService.findAllSessions().stream() + .map(SessionDto::new) + .toList(); + HashMap orderSessions = new HashMap<>(); + for (var os : temp) { + orderSessions.put(os.getSession(), os.getCount()); + } + model.addAttribute("orderSessions", orderSessions); + model.addAttribute("sessions", sessions); + model.addAttribute("orderSessionDto", new OrderSessionDto()); + + return "ordersession"; + } + } + + @PostMapping(value = "/") + public String saveOrder(@ModelAttribute @Valid OrderDto orderDto, + BindingResult bindingResult, + Model model) { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "order-edit"; + } + orderService.addOrder(orderDto.getCustomerId()); + return "redirect:/order"; + } + + @PostMapping(value = {"/{id}"}) + public String editOrder(@PathVariable Long id, + @RequestParam("session") Long session, + @RequestParam(value = "count", required = false) Integer count, + Model model) { + if (count == null) + orderService.deleteSessionInOrder(id, session, Integer.MAX_VALUE); + else if (count > 0) + orderService.addSession(id, session, count); + return "redirect:/order/edit/" + id; + } + + @PostMapping("/delete/{id}") + public String deleteOrder(@PathVariable Long id) { + orderService.deleteOrder(id); + return "redirect:/order"; + } + +} diff --git a/src/main/java/com/labwork1/app/student/controller/OrderSessionDto.java b/src/main/java/com/labwork1/app/student/controller/OrderSessionDto.java index 8aa8234..b663c5e 100644 --- a/src/main/java/com/labwork1/app/student/controller/OrderSessionDto.java +++ b/src/main/java/com/labwork1/app/student/controller/OrderSessionDto.java @@ -14,6 +14,18 @@ public class OrderSessionDto { this.count = count; } + public void setSession(SessionDto session) { + this.session = session; + } + + public void setOrderId(Long orderId) { + this.orderId = orderId; + } + + public void setCount(Integer count) { + this.count = count; + } + public SessionDto getSession() { return session; } diff --git a/src/main/java/com/labwork1/app/student/controller/SessionController.java b/src/main/java/com/labwork1/app/student/controller/SessionController.java index 9d04b6e..e06dac0 100644 --- a/src/main/java/com/labwork1/app/student/controller/SessionController.java +++ b/src/main/java/com/labwork1/app/student/controller/SessionController.java @@ -1,16 +1,19 @@ package com.labwork1.app.student.controller; +import com.labwork1.app.WebConfiguration; import com.labwork1.app.student.service.SessionService; import org.springframework.web.bind.annotation.*; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Date; import java.util.List; @RestController -@RequestMapping("/session") +@RequestMapping(WebConfiguration.REST_API + "/session") public class SessionController { private final SessionService sessionService; @@ -36,11 +39,11 @@ public class SessionController { @RequestParam("cinemaid") Long cinemaId, @RequestParam("capacity") Integer capacity) throws ParseException { SimpleDateFormat format = new SimpleDateFormat(); - format.applyPattern("yyyy-MM-dd-HH:ss"); + format.applyPattern("yyyy-MM-dd-HH:mm"); Date docDate = format.parse(timestamp.replace('T', '-')); return new SessionDto(sessionService.findSession( sessionService.addSession(Double.parseDouble(price), - new Timestamp(docDate.getTime()), cinemaId, capacity).getId())); + LocalDateTime.now(), cinemaId, capacity).getId())); } @PutMapping("/{id}") diff --git a/src/main/java/com/labwork1/app/student/controller/SessionDto.java b/src/main/java/com/labwork1/app/student/controller/SessionDto.java index aa91f6a..f994538 100644 --- a/src/main/java/com/labwork1/app/student/controller/SessionDto.java +++ b/src/main/java/com/labwork1/app/student/controller/SessionDto.java @@ -1,16 +1,17 @@ package com.labwork1.app.student.controller; import com.labwork1.app.student.model.Session; +import org.springframework.format.annotation.DateTimeFormat; -import java.sql.Timestamp; +import java.time.LocalDateTime; public class SessionDto { private long id; private Double price; - private Timestamp timestamp; + @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") + private LocalDateTime timestamp; private CinemaDto cinema; private Long capacity; - private int maxCount; public SessionDto() { @@ -22,31 +23,56 @@ public class SessionDto { this.timestamp = session.getTimestamp(); this.capacity = session.getCapacity(); this.maxCount = session.getMaxCount(); - if (session.getCinema() != null) this.cinema = new CinemaDto(session.getCinema()); - else this.cinema = null; + if (session.getCinema() != null) { + this.cinema = new CinemaDto(session.getCinema()); + } else this.cinema = null; } - public int getMaxCount() { - return maxCount; + public CinemaDto getCinema() { + return cinema; + } + + public void setCinema(CinemaDto cinema) { + this.cinema = cinema; } public long getId() { return id; } + public void setId(long id) { + this.id = id; + } + public Double getPrice() { return price; } - public Timestamp getTimestamp() { + public void setPrice(Double price) { + this.price = price; + } + + public LocalDateTime getTimestamp() { return timestamp; } + public void setTimestamp(LocalDateTime timestamp) { + this.timestamp = timestamp; + } + public Long getCapacity() { return capacity; } - public CinemaDto getCinema() { - return cinema; + public void setCapacity(Long capacity) { + this.capacity = capacity; + } + + public int getMaxCount() { + return maxCount; + } + + public void setMaxCount(int maxCount) { + this.maxCount = maxCount; } } diff --git a/src/main/java/com/labwork1/app/student/controller/SessionMvcController.java b/src/main/java/com/labwork1/app/student/controller/SessionMvcController.java new file mode 100644 index 0000000..e8ccba1 --- /dev/null +++ b/src/main/java/com/labwork1/app/student/controller/SessionMvcController.java @@ -0,0 +1,81 @@ +package com.labwork1.app.student.controller; + +import com.labwork1.app.student.service.CinemaService; +import com.labwork1.app.student.service.SessionService; +import jakarta.validation.Valid; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.List; + +@Controller +@RequestMapping("/session") +public class SessionMvcController { + private final SessionService sessionService; + private final CinemaService cinemaService; + + public SessionMvcController(SessionService sessionService, CinemaService cinemaService) { + this.sessionService = sessionService; + this.cinemaService = cinemaService; + } + + @GetMapping + public String getSessions(Model model) { + model.addAttribute("sessions", + sessionService.findAllSessions().stream() + .map(SessionDto::new) + .toList()); + return "session"; + } + + @GetMapping(value = {"/edit", "/edit/{id}"}) + public String editSession(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + List cinemas = cinemaService.findAllCinemas().stream() + .map(CinemaDto::new) + .toList(); + model.addAttribute("sessionDto", new SessionDto()); + model.addAttribute("cinemas", cinemas); + } else { + model.addAttribute("sessionId", id); + model.addAttribute("sessionDto", new SessionDto(sessionService.findSession(id))); + } + return "session-edit"; + } + + @PostMapping(value = "/{id}") + public String editSession(@PathVariable Long id, + @ModelAttribute @Valid SessionDto sessionDto, + BindingResult bindingResult, + Model model) { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "session-edit"; + } + sessionService.updateSession(id, sessionDto.getPrice()); + + return "redirect:/session"; + } + + @PostMapping(value = "/") + public String saveSession(@RequestParam("price") String price, + @RequestParam("timestamp") LocalDateTime timestamp, + @RequestParam("cinemaid") Long cinemaId, + @RequestParam("maxCount") Integer capacity, + Model model) { + sessionService.addSession(Double.parseDouble(price), timestamp, + cinemaId, capacity); + return "redirect:/session"; + } + + @PostMapping("/delete/{id}") + public String deleteSession(@PathVariable Long id) { + sessionService.deleteSession(id); + return "redirect:/session"; + } + +} diff --git a/src/main/java/com/labwork1/app/student/model/Session.java b/src/main/java/com/labwork1/app/student/model/Session.java index b7986ed..1ff14c0 100644 --- a/src/main/java/com/labwork1/app/student/model/Session.java +++ b/src/main/java/com/labwork1/app/student/model/Session.java @@ -2,8 +2,10 @@ package com.labwork1.app.student.model; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; +import org.springframework.format.annotation.DateTimeFormat; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -18,7 +20,8 @@ public class Session { @NotNull(message = "timestamp can't be null or empty") @Column @Temporal(TemporalType.TIMESTAMP) - private Timestamp timestamp; + @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") + private LocalDateTime timestamp; @OneToMany(mappedBy = "session", fetch = FetchType.EAGER) private List orders; @ManyToOne(fetch = FetchType.EAGER) @@ -37,7 +40,7 @@ public class Session { return maxCount; } - public Session(Double price, Timestamp timestamp, Integer maxCount) { + public Session(Double price, LocalDateTime timestamp, Integer maxCount) { this.price = price; this.timestamp = timestamp; this.maxCount = maxCount; @@ -125,11 +128,11 @@ public class Session { this.price = price; } - public Timestamp getTimestamp() { + public LocalDateTime getTimestamp() { return timestamp; } - public void setTimestamp(Timestamp timestamp) { + public void setTimestamp(LocalDateTime timestamp) { this.timestamp = timestamp; } diff --git a/src/main/java/com/labwork1/app/student/service/SessionService.java b/src/main/java/com/labwork1/app/student/service/SessionService.java index 30bffbe..43967b0 100644 --- a/src/main/java/com/labwork1/app/student/service/SessionService.java +++ b/src/main/java/com/labwork1/app/student/service/SessionService.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.List; @Service @@ -23,7 +24,7 @@ public class SessionService { } @Transactional - public Session addSession(Double price, Timestamp date, Long cinemaId, Integer capacity) { + public Session addSession(Double price, LocalDateTime date, Long cinemaId, Integer capacity) { final Session session = new Session(price, date, capacity); final Cinema cinema = cinemaService.findCinema(cinemaId); session.setCinema(cinema); diff --git a/src/main/resources/public/css/style.css b/src/main/resources/public/css/style.css new file mode 100644 index 0000000..b0b24a3 --- /dev/null +++ b/src/main/resources/public/css/style.css @@ -0,0 +1,112 @@ +html, +body { + background: #2b2d33; +} +.green-mark { + background-color: #38a65d; +} +.willSee { + background-color: #38a65d; +} +.delete { + background-color: #e94049; +} +.icon { + width: 50px; + height: 50px; +} +hr { + height: 2px !important; +} +.description { + color: #8f9398; +} +.editIcon { + height: 2.5vh; +} +.posterChoiceToTaste { + width: 290px; + height: 437px; +} +.posterFilmPage{ + width: 290px; + height: 437px; +} +a { + text-decoration: none; +} +a:hover { + color: white; +} + +.current a { + color: white; +} + +/* for film-page */ +.table { + color: #8f9398; +} +/* main */ +@media screen and (max-width: 290px) { + .posterItem { + display: none !important; + } + .fs-1 { + margin-left: 1em !important; + } +} + +body { + background: #2b2d33; +} + +.content { + min-height: calc(100vh - 25.1vh); + background: #40444d; +} + +.content_header { + margin: -1.5em -1.5em 0em -1.5em; + background-color: #8f9297; +} + +.posterItem { + width: 90px; + height: 90px; + margin-top: -10px; +} + +form input { + max-width: 300px; +} + +table tbody tr td { + border: 0px !important; +} + +footer { + flex: 0 0 auto !important; + background: #1a1c20; + color: #c2c2c2; +} + +footer nav { + color: #c2c2c2; +} + +header { + background: #1a1c20; +} + +header a { + color: #c2c2c2; +} + +header a:hover { + color: #ffffff; +} + +.mainInput { + max-width: 200px; +} \ No newline at end of file diff --git a/src/main/resources/public/favicon.svg b/src/main/resources/public/favicon.svg new file mode 100644 index 0000000..c2e8ab2 --- /dev/null +++ b/src/main/resources/public/favicon.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/main/resources/public/search.jpg b/src/main/resources/public/search.jpg new file mode 100644 index 0000000..c0d82e3 Binary files /dev/null and b/src/main/resources/public/search.jpg differ diff --git a/src/main/resources/public/vk.jpg b/src/main/resources/public/vk.jpg new file mode 100644 index 0000000..d2e40c9 Binary files /dev/null and b/src/main/resources/public/vk.jpg differ diff --git a/src/main/resources/templates/cinema-edit.html b/src/main/resources/templates/cinema-edit.html new file mode 100644 index 0000000..5f79ff4 --- /dev/null +++ b/src/main/resources/templates/cinema-edit.html @@ -0,0 +1,32 @@ + + + + + +
+

Фильм

+
+
+
+ + +
+
+ + +
+
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/cinema.html b/src/main/resources/templates/cinema.html new file mode 100644 index 0000000..327bb7c --- /dev/null +++ b/src/main/resources/templates/cinema.html @@ -0,0 +1,57 @@ + + + + + +
+

Фильмы

+
+ + + +
+
+ + +
+
+ + + + + + +
+ ${cinema.name} +
+
+

+ +

+
+
+
9.2
+ +
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/customer-edit.html b/src/main/resources/templates/customer-edit.html new file mode 100644 index 0000000..297ce31 --- /dev/null +++ b/src/main/resources/templates/customer-edit.html @@ -0,0 +1,32 @@ + + + + + +
+

Пользователь

+
+
+
+ + +
+
+ + +
+
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/customer.html b/src/main/resources/templates/customer.html new file mode 100644 index 0000000..8e99be3 --- /dev/null +++ b/src/main/resources/templates/customer.html @@ -0,0 +1,51 @@ + + + + + +
+

Пользователи

+
+ + + +
+ + + + + + + + + + + + + + +
IDЛогинПароль
+ + + + +
+ +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html new file mode 100644 index 0000000..9af2ebb --- /dev/null +++ b/src/main/resources/templates/default.html @@ -0,0 +1,68 @@ + + + + + Киносайт + + + + + + + + + +
+ +
+
+
+

Киносайт

+
+
+
+
+ + + + +
2022 г. + +
+ \ No newline at end of file diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html new file mode 100644 index 0000000..0a81607 --- /dev/null +++ b/src/main/resources/templates/error.html @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..a7a11f2 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,13 @@ + + + + + +
+
It's works!
+ ERROR +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/order-edit.html b/src/main/resources/templates/order-edit.html new file mode 100644 index 0000000..eba3a8d --- /dev/null +++ b/src/main/resources/templates/order-edit.html @@ -0,0 +1,57 @@ + + + + + +
+

Создание заказа

+

Добавление сеансов в заказ

+
+
+
+ + +
+
+ + + Назад + +
+
+
+
+ + +
+
+ + +
+
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/order.html b/src/main/resources/templates/order.html new file mode 100644 index 0000000..098b315 --- /dev/null +++ b/src/main/resources/templates/order.html @@ -0,0 +1,51 @@ + + + + + +
+

Заказы

+
+ + + +
+ + + + + + + + + + + + + + +
IDCustomerDateOfPurchase
+ + + + +
+ +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/ordersession.html b/src/main/resources/templates/ordersession.html new file mode 100644 index 0000000..d54f059 --- /dev/null +++ b/src/main/resources/templates/ordersession.html @@ -0,0 +1,69 @@ + + + + + +
+

+
+
+ + +
+
+ + +
+
+ + + Назад + +
+
+ + + + + + + + + + + + + + + + +
IDPriceCinemaTimestampCount
+ + + + + +
+ + + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/session-edit.html b/src/main/resources/templates/session-edit.html new file mode 100644 index 0000000..60be082 --- /dev/null +++ b/src/main/resources/templates/session-edit.html @@ -0,0 +1,45 @@ + + + + + +
+

Сеанс

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + Назад + +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/session.html b/src/main/resources/templates/session.html new file mode 100644 index 0000000..7aaa9e4 --- /dev/null +++ b/src/main/resources/templates/session.html @@ -0,0 +1,57 @@ + + + + + +
+

Сеансы

+
+ + + +
+ + + + + + + + + + + + + + + + + +
IDPriceCinemaTimestampCapacityMaxCount
+ + + + + + + +
+ +
+
+
+ + \ No newline at end of file