style(proyecto): quitados import no usados y añadida indentación

parent 00497e1e
Showing with 26 additions and 21 deletions
...@@ -6,5 +6,6 @@ import java.util.List; ...@@ -6,5 +6,6 @@ import java.util.List;
public interface ReadRecipeUseCase { public interface ReadRecipeUseCase {
RecipeOutputDto readById(Long id); RecipeOutputDto readById(Long id);
List<RecipeOutputDto> readAll(); List<RecipeOutputDto> readAll();
} }
...@@ -8,7 +8,6 @@ import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper; ...@@ -8,7 +8,6 @@ import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
...@@ -23,8 +22,12 @@ public class CreateRecipeUseCaseImpl implements CreateRecipeUseCase { ...@@ -23,8 +22,12 @@ public class CreateRecipeUseCaseImpl implements CreateRecipeUseCase {
public RecipeOutputDto create(RecipeInputDto recipeInputDto) { public RecipeOutputDto create(RecipeInputDto recipeInputDto) {
RecipeJpa recipeJpa = mapper.mapJpa(mapper.map(recipeInputDto)); RecipeJpa recipeJpa = mapper.mapJpa(mapper.map(recipeInputDto));
recipeJpa.getSteps().forEach(step -> {step.setRecipe(recipeJpa);}); recipeJpa.getSteps().forEach(step -> {
recipeJpa.getIngredients().forEach(ingredient -> {ingredient.setRecipe(recipeJpa);}); step.setRecipe(recipeJpa);
});
recipeJpa.getIngredients().forEach(ingredient -> {
ingredient.setRecipe(recipeJpa);
});
RecipeJpa savedRecipe = repository.create(recipeJpa); RecipeJpa savedRecipe = repository.create(recipeJpa);
return mapper.map(mapper.mapJpa(savedRecipe)); return mapper.map(mapper.mapJpa(savedRecipe));
......
...@@ -8,7 +8,6 @@ import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper; ...@@ -8,7 +8,6 @@ import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
......
package com.example.apprecetas.recipe.domain.repository; package com.example.apprecetas.recipe.domain.repository;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa;
public interface CreateRecipeRepository { public interface CreateRecipeRepository {
RecipeJpa create(RecipeJpa recipeJpa); RecipeJpa create(RecipeJpa recipeJpa);
......
...@@ -7,5 +7,6 @@ import java.util.Optional; ...@@ -7,5 +7,6 @@ import java.util.Optional;
public interface ReadRecipeRepository { public interface ReadRecipeRepository {
Optional<RecipeJpa> readById(Long id); Optional<RecipeJpa> readById(Long id);
List<RecipeJpa> readAll(); List<RecipeJpa> readAll();
} }
...@@ -25,7 +25,7 @@ public class CreateRecipeController { ...@@ -25,7 +25,7 @@ public class CreateRecipeController {
@PostMapping @PostMapping
public ResponseEntity<RecipeOutputDto> create(@RequestBody @Valid RecipeInputDto recipeInputDto, BindingResult result) { public ResponseEntity<RecipeOutputDto> create(@RequestBody @Valid RecipeInputDto recipeInputDto, BindingResult result) {
if(result.hasErrors()) { if (result.hasErrors()) {
String errorMsg = result.getFieldErrors().stream() String errorMsg = result.getFieldErrors().stream()
.map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage()) .map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage())
.collect(Collectors.joining(";")); .collect(Collectors.joining(";"));
......
...@@ -2,7 +2,6 @@ package com.example.apprecetas.recipe.infrastructure.controller; ...@@ -2,7 +2,6 @@ package com.example.apprecetas.recipe.infrastructure.controller;
import com.example.apprecetas.recipe.application.DeleteRecipeUseCase; import com.example.apprecetas.recipe.application.DeleteRecipeUseCase;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
......
...@@ -3,7 +3,6 @@ package com.example.apprecetas.recipe.infrastructure.controller; ...@@ -3,7 +3,6 @@ package com.example.apprecetas.recipe.infrastructure.controller;
import com.example.apprecetas.recipe.application.ReadRecipeUseCase; import com.example.apprecetas.recipe.application.ReadRecipeUseCase;
import com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto; import com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -26,7 +25,7 @@ public class ReadRecipeController { ...@@ -26,7 +25,7 @@ public class ReadRecipeController {
@GetMapping @GetMapping
public ResponseEntity<List<RecipeOutputDto>> readAll() { public ResponseEntity<List<RecipeOutputDto>> readAll() {
if(service.readAll().isEmpty()) { if (service.readAll().isEmpty()) {
return ResponseEntity.noContent().build(); return ResponseEntity.noContent().build();
} }
return ResponseEntity.ok().body(service.readAll()); return ResponseEntity.ok().body(service.readAll());
......
...@@ -2,11 +2,11 @@ package com.example.apprecetas.recipe.infrastructure.controller; ...@@ -2,11 +2,11 @@ package com.example.apprecetas.recipe.infrastructure.controller;
import com.example.apprecetas.exception.UnprocessableEntityException; import com.example.apprecetas.exception.UnprocessableEntityException;
import com.example.apprecetas.recipe.application.UpdateRecipeUseCase; import com.example.apprecetas.recipe.application.UpdateRecipeUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import com.example.apprecetas.recipe.infrastructure.controller.dto.input.RecipeInputDto; import com.example.apprecetas.recipe.infrastructure.controller.dto.input.RecipeInputDto;
import com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto; import com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -21,7 +21,7 @@ public class UpdateRecipeController { ...@@ -21,7 +21,7 @@ public class UpdateRecipeController {
@PutMapping("/{id}") @PutMapping("/{id}")
public ResponseEntity<RecipeOutputDto> update(@PathVariable Long id, @RequestBody @Valid RecipeInputDto recipeInputDto, BindingResult result) { public ResponseEntity<RecipeOutputDto> update(@PathVariable Long id, @RequestBody @Valid RecipeInputDto recipeInputDto, BindingResult result) {
if(result.hasErrors()) { if (result.hasErrors()) {
String errorMsg = result.getFieldErrors().stream() String errorMsg = result.getFieldErrors().stream()
.map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage()) .map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage())
.collect(Collectors.joining(";")); .collect(Collectors.joining(";"));
......
...@@ -10,9 +10,11 @@ import org.mapstruct.Mapper; ...@@ -10,9 +10,11 @@ import org.mapstruct.Mapper;
public interface RecipeMapper { public interface RecipeMapper {
RecipeOutputDto map(Recipe recipe); RecipeOutputDto map(Recipe recipe);
Recipe map(RecipeInputDto recipeInputDto); Recipe map(RecipeInputDto recipeInputDto);
RecipeJpa mapJpa(Recipe recipe); RecipeJpa mapJpa(Recipe recipe);
Recipe mapJpa(RecipeJpa recipeJpa); Recipe mapJpa(RecipeJpa recipeJpa);
} }
...@@ -4,7 +4,6 @@ import com.example.apprecetas.recipe.domain.repository.CreateRecipeRepository; ...@@ -4,7 +4,6 @@ import com.example.apprecetas.recipe.domain.repository.CreateRecipeRepository;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
......
...@@ -4,7 +4,6 @@ import com.example.apprecetas.recipe.domain.repository.DeleteRecipeRepository; ...@@ -4,7 +4,6 @@ import com.example.apprecetas.recipe.domain.repository.DeleteRecipeRepository;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
......
...@@ -4,7 +4,6 @@ import com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository; ...@@ -4,7 +4,6 @@ import com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa; import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
......
...@@ -7,6 +7,7 @@ import java.util.List; ...@@ -7,6 +7,7 @@ import java.util.List;
public interface ReadUserUseCase { public interface ReadUserUseCase {
UserOutputDto readById(Long id); UserOutputDto readById(Long id);
List<UserOutputDto> readAll(); List<UserOutputDto> readAll();
} }
package com.example.apprecetas.user.domain.entity; package com.example.apprecetas.user.domain.entity;
import lombok.*; import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
......
...@@ -8,6 +8,7 @@ import java.util.Optional; ...@@ -8,6 +8,7 @@ import java.util.Optional;
public interface ReadUserRepository { public interface ReadUserRepository {
Optional<UserJpa> readById(Long id); Optional<UserJpa> readById(Long id);
List<UserJpa> readAll(); List<UserJpa> readAll();
} }
...@@ -2,7 +2,6 @@ package com.example.apprecetas.user.infrastructure.config; ...@@ -2,7 +2,6 @@ package com.example.apprecetas.user.infrastructure.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
......
...@@ -25,7 +25,7 @@ public class CreateUserController { ...@@ -25,7 +25,7 @@ public class CreateUserController {
@PostMapping @PostMapping
public ResponseEntity<UserOutputDto> create(@Valid @RequestBody UserInputDto userInputDto, BindingResult result) { public ResponseEntity<UserOutputDto> create(@Valid @RequestBody UserInputDto userInputDto, BindingResult result) {
if(result.hasErrors()) { if (result.hasErrors()) {
String errorMsg = result.getFieldErrors().stream() String errorMsg = result.getFieldErrors().stream()
.map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage()) .map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage())
.collect(Collectors.joining("; ")); .collect(Collectors.joining("; "));
......
package com.example.apprecetas.user.infrastructure.controller; package com.example.apprecetas.user.infrastructure.controller;
import com.example.apprecetas.user.application.DeleteUserUseCase; import com.example.apprecetas.user.application.DeleteUserUseCase;
import com.example.apprecetas.user.domain.repository.DeleteUserRepository;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
......
...@@ -25,7 +25,7 @@ public class ReadUserController { ...@@ -25,7 +25,7 @@ public class ReadUserController {
@GetMapping @GetMapping
public ResponseEntity<List<UserOutputDto>> readAll() { public ResponseEntity<List<UserOutputDto>> readAll() {
if(service.readAll().isEmpty()) if (service.readAll().isEmpty())
return ResponseEntity.noContent().build(); return ResponseEntity.noContent().build();
return ResponseEntity.ok().body(service.readAll()); return ResponseEntity.ok().body(service.readAll());
} }
......
package com.example.apprecetas.user.infrastructure.controller.dto; package com.example.apprecetas.user.infrastructure.controller.dto;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
......
...@@ -10,9 +10,11 @@ import org.mapstruct.Mapper; ...@@ -10,9 +10,11 @@ import org.mapstruct.Mapper;
public interface UserMapper { public interface UserMapper {
User map(UserInputDto userInputDto); User map(UserInputDto userInputDto);
UserOutputDto map(User user); UserOutputDto map(User user);
UserJpa mapJpa(User user); UserJpa mapJpa(User user);
User mapJpa(UserJpa userJpa); User mapJpa(UserJpa userJpa);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment