add repository

This commit is contained in:
DozorovaA.A 2023-05-09 16:05:51 +04:00
parent 7021f82f56
commit a48605b616
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,7 @@
package com.example.demo.speaker.repository;
import com.example.demo.speaker.model.Appointment;
import org.springframework.data.jpa.repository.JpaRepository;
public interface IAppointmentRepository extends JpaRepository<Appointment, Long> {
}

View File

@ -0,0 +1,14 @@
package com.example.demo.speaker.repository;
import com.example.demo.speaker.model.Company;
import com.example.demo.speaker.model.RequestForCooperation;
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 ICompanyRepository extends JpaRepository<Company, Long> {
@Query("SELECT DISTINCT p.requests FROM Company p where :request MEMBER OF p.requests")
List<RequestForCooperation> getTypesRequest(@Param("request") RequestForCooperation request);
}

View File

@ -0,0 +1,15 @@
package com.example.demo.speaker.repository;
import com.example.demo.speaker.model.Appointment;
import com.example.demo.speaker.model.Employee;
import com.example.demo.speaker.model.RequestForCooperation;
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 IEmployeeRepository extends JpaRepository<Employee, Long> {
@Query("SELECT DISTINCT p.fio FROM Employee p where :appointment = p.appointment")
List<Employee> getEmployeeByAppointment(@Param("appointment") Appointment appointment);
}

View File

@ -0,0 +1,18 @@
package com.example.demo.speaker.repository;
import com.example.demo.speaker.model.Company;
import com.example.demo.speaker.model.Employee;
import com.example.demo.speaker.model.RequestForCooperation;
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 IRequestForCooperationRepository extends JpaRepository<RequestForCooperation, Long> {
@Query("SELECT p.sotr FROM RequestForCooperation p where :id = p.id")
Employee findWorkerByRequest(@Param("id") RequestForCooperation request);
@Query("SELECT p.nameCompany FROM RequestForCooperation p where :company = p.nameCompany")
List<RequestForCooperation> findRequestByCompany(@Param("company") Company company);
}