From 1544973e7b6193172879d4779fc2cc11f68f366e Mon Sep 17 00:00:00 2001 From: dasha Date: Mon, 17 Apr 2023 14:12:12 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/pages/components/SessionItem.jsx | 2 +- .../com/labwork1/app/student/repository/OrderRepository.java | 4 ---- .../labwork1/app/student/repository/SessionRepository.java | 3 +++ .../java/com/labwork1/app/student/service/OrderService.java | 2 -- 4 files changed, 4 insertions(+), 7 deletions(-) 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)); }