Skip to content

Commit 2eece9a

Browse files
committed
refactor logica segun Ismael, solo fashion, falta todo lo demás
1 parent b37ab9b commit 2eece9a

File tree

127 files changed

+434
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+434
-467
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.outfitlab.project.domain.interfaces.repositories;
2+
3+
import com.outfitlab.project.domain.exceptions.FashnApiException;
4+
import com.outfitlab.project.domain.exceptions.PredictionFailedException;
5+
6+
public interface FashnRepository {
7+
8+
String combine(String garmentUrl, String category, String avatarType) throws FashnApiException;
9+
10+
String combineSecondGarment(String garmentUrl, String category, String avatarCombinedUrl) throws FashnApiException;
11+
12+
String pollStatus(String id) throws FashnApiException, PredictionFailedException;
13+
14+
String combineTopAndBottom(String top, String bottom, String avatarType) throws PredictionFailedException, FashnApiException;
15+
}

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/com/outfitlab/project/domain/interfaces/repositories/IMarcaRepository.java renamed to src/main/java/com/outfitlab/project/domain/interfaces/repositories/MarcaRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.outfitlab.project.domain.model.MarcaModel;
44
import java.util.List;
55

6-
public interface IMarcaRepository{
6+
public interface MarcaRepository {
77
MarcaModel buscarPorCodigoMarca(String codigoMarca);// hay que hacer un DTO que no me deje traer el id
88
List<MarcaModel> obtenerTodas();
99
}

src/main/java/com/outfitlab/project/domain/interfaces/repositories/ITripoRepository.java renamed to src/main/java/com/outfitlab/project/domain/interfaces/repositories/TripoRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.Map;
77

88

9-
public interface ITripoRepository {
9+
public interface TripoRepository {
1010

1111
TripoModel buscarPorTaskId(String taskId);
1212

src/main/java/com/outfitlab/project/domain/interfaces/repositories/IAwsRepository.java renamed to src/main/java/com/outfitlab/project/domain/interfaces/repositories/UploadImageRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import org.springframework.web.multipart.MultipartFile;
44

5-
public interface IAwsRepository {
5+
public interface UploadImageRepository {
66

77
String uploadFile(MultipartFile file, String folder);
88

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.outfitlab.project.domain.model.dto;
2+
3+
public class CombineRequestModel {
4+
private String top;
5+
private String bottom;
6+
private Boolean isMan;
7+
private String avatarType;
8+
9+
public CombineRequestModel() {}
10+
public CombineRequestModel(String top, String bottom, Boolean isMan, String avatarType) {}
11+
12+
public String getAvatarType() {return avatarType;}
13+
public void setAvatarType(String avatarType) {this.avatarType = avatarType;}
14+
public String getTop() { return top; }
15+
public void setTop(String top) { this.top = top; }
16+
public String getBottom() { return bottom; }
17+
public void setBottom(String bottom) { this.bottom = bottom; }
18+
public Boolean getIsMan() {return isMan;}
19+
public void setIsMan(Boolean isMan) {this.isMan = isMan;}
20+
21+
}

src/main/java/com/outfitlab/project/domain/service/FashnService.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/main/java/com/outfitlab/project/domain/service/TrippoService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
public class TrippoService {
1010

1111
private final UploadImageToTripo uploadImageToTripo;
12-
private final UploadImageToAws uploadImageToAws;
12+
private final SaveImage uploadImageToAws;
1313
private final GenerateImageToModelTrippo generateImageToModelTrippo;
1414
private final SaveTripoModel saveTripoModel;
1515
private final CheckTaskStatus checkTaskStatus;
1616
private final UpdateTripoModel updateTripoModel;
1717
private final FindTripoModelByTaskid findTripoModelByTaskid;
1818

19-
public TrippoService(UploadImageToTripo uploadImageToTripo, UploadImageToAws uploadImageToAws, GenerateImageToModelTrippo generateImageToModelTrippo,
19+
public TrippoService(UploadImageToTripo uploadImageToTripo, SaveImage uploadImageToAws, GenerateImageToModelTrippo generateImageToModelTrippo,
2020
SaveTripoModel saveTripoModel, CheckTaskStatus checkTaskStatus, UpdateTripoModel updateTripoModel, FindTripoModelByTaskid findTripoModelByTaskid) {
2121
this.uploadImageToTripo = uploadImageToTripo;
2222
this.uploadImageToAws = uploadImageToAws;

src/main/java/com/outfitlab/project/domain/useCases/fashn/CheckRequestCombine.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,46 @@
11
package com.outfitlab.project.domain.useCases.fashn;
22

33
import com.outfitlab.project.domain.exceptions.FashnApiException;
4-
import com.outfitlab.project.domain.interfaces.repositories.IFashnRepository;
5-
import com.outfitlab.project.presentation.dto.CombineRequest;
4+
import com.outfitlab.project.domain.exceptions.PredictionFailedException;
5+
import com.outfitlab.project.domain.interfaces.repositories.FashnRepository;
6+
import com.outfitlab.project.domain.model.dto.CombineRequestModel;
67

78
public class CombinePrendas {
89

10+
private final String TOPS = "tops";
11+
private final String BOTTOMS = "bottoms";
12+
private final FashnRepository iFashnRepository;
913

10-
private final IFashnRepository iFashnRepository;
11-
12-
public CombinePrendas(IFashnRepository iFashnRepository) {
14+
public CombinePrendas(FashnRepository iFashnRepository) {
1315
this.iFashnRepository = iFashnRepository;
1416
}
1517

16-
public String execute(CombineRequest req, String category, String avatarUrl) throws FashnApiException {
17-
return this.iFashnRepository.combine(req, category, avatarUrl);
18+
public String execute(CombineRequestModel request) throws FashnApiException, PredictionFailedException {
19+
checkRequestCombine(request.getTop(), request.getBottom());
20+
21+
if (isOnlyTop(request.getTop(), request.getBottom())) return combine(request.getTop(), TOPS, request.getAvatarType());
22+
if (isOnlyBotton(request.getBottom(), request.getTop())) return combine(request.getBottom(), BOTTOMS, request.getAvatarType());
23+
24+
return combineTopAndBottom(request.getTop(), request.getBottom(), request.getAvatarType());
25+
}
26+
27+
private boolean isOnlyTop(String top, String bottom) {
28+
return top != null && (bottom == null || bottom.isBlank());
29+
}
30+
31+
private void checkRequestCombine(String top, String bottom) throws FashnApiException {
32+
if ((top == null || top.isBlank()) && (bottom == null || bottom.isBlank())) throw new FashnApiException("Debe proporcionarse al menos una prenda (superior o inferior).");
33+
}
34+
35+
private boolean isOnlyBotton(String bottom, String top) {
36+
return bottom != null && (top == null || top.isBlank());
37+
}
38+
39+
private String combine(String garmentUrl, String category, String avatarType) throws FashnApiException, PredictionFailedException {
40+
return this.iFashnRepository.pollStatus(this.iFashnRepository.combine(garmentUrl, category, avatarType));
41+
}
42+
43+
private String combineTopAndBottom(String top, String bottom, String avatarType) throws FashnApiException, PredictionFailedException {
44+
return this.iFashnRepository.combineTopAndBottom(top, bottom, avatarType);
1845
}
1946
}

0 commit comments

Comments
 (0)