diff --git a/front/src/pages/components/SessionItem.jsx b/front/src/pages/components/SessionItem.jsx index 24dae49..6a745c6 100644 --- a/front/src/pages/components/SessionItem.jsx +++ b/front/src/pages/components/SessionItem.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react" import MyButton from './MyButton' export default function SessionItem(props) { - const date = new Date(props.item.timestamp).toLocaleString('RU-ru') + const date = new Date(props.item.timestamp).toLocaleDateString('ru-RU') return ( diff --git a/src/main/java/com/labwork1/app/student/repository/OrderRepository.java b/src/main/java/com/labwork1/app/student/repository/OrderRepository.java index 7e3c2db..62aa775 100644 --- a/src/main/java/com/labwork1/app/student/repository/OrderRepository.java +++ b/src/main/java/com/labwork1/app/student/repository/OrderRepository.java @@ -3,14 +3,10 @@ package com.labwork1.app.student.repository; import com.labwork1.app.student.model.Order; import com.labwork1.app.student.model.OrderSession; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface OrderRepository extends JpaRepository { @Query("Select os from OrderSession os where os.order.id = :orderId and os.session.id = :sessionId") OrderSession getOrderSession(@Param("orderId") Long orderId, @Param("sessionId") Long sessionId); - @Modifying - @Query("delete from OrderSession os where os.order.id = :orderId and os.session.id = :sessionId") - void deleteSessionInOrder(@Param("orderId") Long orderId, @Param("sessionId") Long sessionId); } \ No newline at end of file diff --git a/src/main/java/com/labwork1/app/student/repository/SessionRepository.java b/src/main/java/com/labwork1/app/student/repository/SessionRepository.java index 5e27ee1..b4907fd 100644 --- a/src/main/java/com/labwork1/app/student/repository/SessionRepository.java +++ b/src/main/java/com/labwork1/app/student/repository/SessionRepository.java @@ -3,10 +3,13 @@ package com.labwork1.app.student.repository; import com.labwork1.app.student.model.Session; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; public interface SessionRepository extends JpaRepository { @Query("Select s from Session s where s.capacity > 0") List findAllSessionsWithCapacity(); + @Query("Select sum(os.count) from OrderSession os where os.session.id = :sessionId") + Integer getCapacity(@Param("sessionId") Long sessionId); } diff --git a/src/main/java/com/labwork1/app/student/service/OrderService.java b/src/main/java/com/labwork1/app/student/service/OrderService.java index ceabb5b..9919051 100644 --- a/src/main/java/com/labwork1/app/student/service/OrderService.java +++ b/src/main/java/com/labwork1/app/student/service/OrderService.java @@ -46,8 +46,6 @@ public class OrderService { currentSession.getCapacity(), count)); } currentSession.setCapacity(currentSession.getCapacity() - count); - /*final Session updatedSession = sessionService.updateSession(currentSession.getId(), - currentSession.getPrice(), currentSession.getCapacity() - count);*/ if (currentOrderSession == null) { currentOrder.addSession(new OrderSession(currentOrder, currentSession, count)); }