DTO name change

This commit is contained in:
indx0
2025-11-25 11:02:18 +03:00
parent ada915a4b6
commit 92450eae24
5 changed files with 14 additions and 15 deletions

View File

@@ -1,7 +1,6 @@
package com.example.nto.controller; package com.example.nto.controller;
import com.example.nto.dto.EmployeeDTO;; import com.example.nto.dto.EmployeeInfoDTO;;
import com.example.nto.exception.CodeNotFoundException;
import com.example.nto.service.EmployeeService; import com.example.nto.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -31,7 +30,7 @@ public class EmployeeController {
} }
@GetMapping("/{code}/info") @GetMapping("/{code}/info")
public ResponseEntity<EmployeeDTO> info(@PathVariable String code) { public ResponseEntity<EmployeeInfoDTO> info(@PathVariable String code) {
return ResponseEntity.ok(employeeService.getInfo(code)); return ResponseEntity.ok(employeeService.getInfo(code));
} }
} }

View File

@@ -7,7 +7,7 @@ import java.time.LocalDate;
import java.util.Map; import java.util.Map;
@Data @Data
public class EmployeeDTO { public class EmployeeInfoDTO {
private String name; private String name;
private String photoUrl; private String photoUrl;
private Map<LocalDate, Place> booking; private Map<LocalDate, Place> booking;

View File

@@ -1,6 +1,6 @@
package com.example.nto.service; package com.example.nto.service;
import com.example.nto.dto.EmployeeDTO; import com.example.nto.dto.EmployeeInfoDTO;
/** /**
* TODO: ДОРАБОТАТЬ в рамках задания * TODO: ДОРАБОТАТЬ в рамках задания
@@ -10,5 +10,5 @@ import com.example.nto.dto.EmployeeDTO;
*/ */
public interface EmployeeService { public interface EmployeeService {
boolean codeExists(String code); boolean codeExists(String code);
EmployeeDTO getInfo(String code); EmployeeInfoDTO getInfo(String code);
} }

View File

@@ -1,6 +1,6 @@
package com.example.nto.service.impl; package com.example.nto.service.impl;
import com.example.nto.dto.EmployeeDTO; import com.example.nto.dto.EmployeeInfoDTO;
import com.example.nto.entity.Employee; import com.example.nto.entity.Employee;
import com.example.nto.exception.CodeNotFoundException; import com.example.nto.exception.CodeNotFoundException;
import com.example.nto.repository.EmployeeRepository; import com.example.nto.repository.EmployeeRepository;
@@ -30,7 +30,7 @@ public class EmployeeServiceImpl implements EmployeeService {
} }
@Override @Override
public EmployeeDTO getInfo(String code) { public EmployeeInfoDTO getInfo(String code) {
this.codeExists(code); this.codeExists(code);
Employee employee = employeeRepository.findByCode(code); Employee employee = employeeRepository.findByCode(code);
return EmployeeMapper.convertToDTO(employee); return EmployeeMapper.convertToDTO(employee);

View File

@@ -1,6 +1,6 @@
package com.example.nto.util; package com.example.nto.util;
import com.example.nto.dto.EmployeeDTO; import com.example.nto.dto.EmployeeInfoDTO;
import com.example.nto.entity.Booking; import com.example.nto.entity.Booking;
import com.example.nto.entity.Employee; import com.example.nto.entity.Employee;
import com.example.nto.entity.Place; import com.example.nto.entity.Place;
@@ -12,10 +12,10 @@ import java.util.stream.Collectors;
@UtilityClass @UtilityClass
public class EmployeeMapper { public class EmployeeMapper {
public static EmployeeDTO convertToDTO(Employee employee) { public static EmployeeInfoDTO convertToDTO(Employee employee) {
EmployeeDTO employeeDto = new EmployeeDTO(); EmployeeInfoDTO employeeInfoDto = new EmployeeInfoDTO();
employeeDto.setName(employee.getName()); employeeInfoDto.setName(employee.getName());
employeeDto.setPhotoUrl(employee.getPhotoUrl()); employeeInfoDto.setPhotoUrl(employee.getPhotoUrl());
Map<LocalDate, Place> bookingMap = employee.getBooking() Map<LocalDate, Place> bookingMap = employee.getBooking()
.stream() .stream()
@@ -27,8 +27,8 @@ public class EmployeeMapper {
.build() .build()
)); ));
employeeDto.setBooking(bookingMap); employeeInfoDto.setBooking(bookingMap);
return employeeDto; return employeeInfoDto;
} }
} }