GetEntersByLogin usecase

This commit is contained in:
Niktia 2025-02-19 12:54:21 +03:00
parent 43d9689a68
commit e7f3130b0e
3 changed files with 18 additions and 5 deletions

View File

@ -3,7 +3,9 @@ package com.example.nto.repository;
import com.example.nto.entity.Enter;
import org.springframework.data.jpa.repository.JpaRepository;
public interface EnterRepository extends JpaRepository<Enter, Long> {
import java.util.List;
import java.util.Optional;
Enter getByEmployee();
public interface EnterRepository extends JpaRepository<Enter, Long> {
List<Enter> findByEmployeeLogin(String login);
}

View File

@ -1,8 +1,11 @@
package com.example.nto.service;
import com.example.nto.dto.EnterDto;
import com.example.nto.entity.Enter;
import org.springframework.stereotype.Service;
import java.util.List;
public interface EnterService {
Enter getEnterByLogin(String Login);
List<EnterDto> getByLogin(String Login);
}

View File

@ -1,11 +1,17 @@
package com.example.nto.service.impl;
import com.example.nto.dto.EnterDto;
import com.example.nto.entity.Enter;
import com.example.nto.utils.EnterMapper;
import com.example.nto.repository.EnterRepository;
import com.example.nto.service.EnterService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class EnterServiceImpl implements EnterService {
@ -13,7 +19,9 @@ public class EnterServiceImpl implements EnterService {
private final EnterRepository enterRepository;
@Override
public Enter getEnterByLogin(String Login) {
return null;
public List<EnterDto> getByLogin(String login) {
List<Enter> enters = enterRepository.findByEmployeeLogin(login);
return enters.stream().map(EnterMapper::convertToDto).collect(Collectors.toList());
}
}