Skip to content

Commit 3ef26c3

Browse files
committed
fix brand en session del front + fix eliminar prenda (no traía garmentCode en prendaEntity)
1 parent c2d88e8 commit 3ef26c3

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

src/main/java/com/outfitlab/project/domain/interfaces/repositories/GarmentRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public interface GarmentRepository {
1919

2020
void createGarment(
2121
String name,
22+
String garmentCode,
2223
String type,
2324
String color,
2425
String brandCode,

src/main/java/com/outfitlab/project/domain/model/UserModel.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ public UserModel(String name, String lastName, String email, Role role, boolean
6363
this.brand = brand;
6464
}
6565

66+
public UserModel(String name, String lastName, String email, String satulation, String secondName, Integer years, String password,
67+
LocalDateTime createdAt, LocalDateTime updatedAt, Role role, boolean verified, boolean status,
68+
String verificationToken, String userImageUrl, BrandModel brandModel) {
69+
this.name = name;
70+
this.lastName = lastName;
71+
this.email = email;
72+
this.satulation = satulation;
73+
this.secondName = secondName;
74+
this.years = years;
75+
this.hashedPassword = password;
76+
this.createdAt = createdAt;
77+
this.updatedAt = updatedAt;
78+
this.role = role;
79+
this.verified = verified;
80+
this.status = status;
81+
this.verificationToken = verificationToken;
82+
this.userImg = userImageUrl;
83+
this.brand = brandModel;
84+
}
85+
6686
/*
6787
* public String getPassword() {
6888
* return "";

src/main/java/com/outfitlab/project/domain/useCases/garment/CreateGarment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public CreateGarment(GarmentRepository garmentRepository) {
1515
public void execute(String name, String type, String color, String brandCode, String imageUrl, String climaNombre, List<String> ocasionesNombres) {
1616
this.garmentRepository.createGarment(
1717
name,
18+
formatGarmentCode(name),
1819
type,
1920
color,
2021
brandCode,

src/main/java/com/outfitlab/project/infrastructure/model/UserEntity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ public static UserModel convertEntityToModel(UserEntity entity) {
111111
entity.isVerified(),
112112
entity.isStatus(),
113113
entity.getVerificationToken(),
114-
entity.getUserImageUrl());
114+
entity.getUserImageUrl(),
115+
MarcaEntity.convertToModelWithoutPrendas(entity.getBrand())
116+
);
115117
}
116118

117119
public static UserEntity convertModelToEntity(UserModel model) {

src/main/java/com/outfitlab/project/infrastructure/repositories/GarmentRepositoryImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,35 @@ public PrendaModel findByGarmentCode(String garmentCode) throws GarmentNotFoundE
7272
@Override
7373
public void createGarment(
7474
String name,
75+
String garmentCode,
7576
String type,
7677
String colorNombre,
7778
String brandCode,
7879
String imageUrl,
7980
String climaNombre,
8081
List<String> ocasionesNombres
8182
) {
82-
System.out.println(brandCode);
8383
MarcaEntity brandEntity = this.brandJpaRepository.findByCodigoMarca(brandCode);
84-
System.out.println("ES NULL ?????? ----------" + brandEntity + " ---- NOSE: --" + brandEntity == null );
84+
8585
if (brandEntity == null) throw new GarmentNotFoundException("No encontramos la brand: " + brandCode);
86+
8687
ClimaEntity climaEntity = this.climaJpaRepository.findClimaEntityByNombre(climaNombre)
8788
.orElseThrow(() -> new IllegalArgumentException("Clima no válido: " + climaNombre));
89+
8890
ColorEntity colorEntity = this.colorJpaRepository.findColorEntityByNombre(colorNombre)
8991
.orElseThrow(() -> new IllegalArgumentException("Color no válido: " + colorNombre));
92+
9093
Set<OcasionEntity> ocasionesEntities = ocasionesNombres.stream()
9194
.map(nombre -> this.ocacionJpaRepository.findOcasionEntityByNombre(nombre)
9295
.orElseThrow(() -> new IllegalArgumentException("Ocasión no válida: " + nombre)))
9396
.collect(Collectors.toSet());
97+
9498
this.garmentJpaRepository.save(new PrendaEntity(
9599
name,
96100
brandEntity,
97101
type,
98102
imageUrl,
103+
garmentCode,
99104
colorEntity,
100105
climaEntity,
101106
ocasionesEntities

0 commit comments

Comments
 (0)