-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from KevinAlvss/feat/post-musician-portifolio
Feat/post musician portifolio
- Loading branch information
Showing
10 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/pi/procurarteapi/app/musician/dtos/PostImagesPortifolio/ImagesRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package pi.procurarteapi.app.musician.dtos.PostImagesPortifolio; | ||
|
||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ImagesRequestDto { | ||
private List<String> Images; | ||
} |
15 changes: 15 additions & 0 deletions
15
.../procurarteapi/app/musician/dtos/PostImagesPortifolio/PostImagesPortifolioRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package pi.procurarteapi.app.musician.dtos.PostImagesPortifolio; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PostImagesPortifolioRequestDto { | ||
private String id; | ||
private ImagesRequestDto Images; | ||
} |
16 changes: 16 additions & 0 deletions
16
...procurarteapi/app/musician/dtos/PostImagesPortifolio/PostImagesPortifolioResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package pi.procurarteapi.app.musician.dtos.PostImagesPortifolio; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import pi.procurarteapi.infra.entities.Musician; | ||
|
||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PostImagesPortifolioResponseDto { | ||
private Musician musician; | ||
} |
8 changes: 8 additions & 0 deletions
8
...in/java/pi/procurarteapi/app/musician/interfaces/IPostMusicianImagePortifolioService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package pi.procurarteapi.app.musician.interfaces; | ||
|
||
import pi.procurarteapi.app.musician.dtos.PostImagesPortifolio.PostImagesPortifolioRequestDto; | ||
import pi.procurarteapi.app.musician.dtos.PostImagesPortifolio.PostImagesPortifolioResponseDto; | ||
|
||
public interface IPostMusicianImagePortifolioService { | ||
public PostImagesPortifolioResponseDto execute(PostImagesPortifolioRequestDto images)throws Exception; | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/pi/procurarteapi/app/musician/services/PostMusicianImagePortifolioService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package pi.procurarteapi.app.musician.services; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import pi.procurarteapi.app.musician.dtos.PostImagesPortifolio.PostImagesPortifolioRequestDto; | ||
import pi.procurarteapi.app.musician.dtos.PostImagesPortifolio.PostImagesPortifolioResponseDto; | ||
import pi.procurarteapi.app.musician.interfaces.IPostMusicianImagePortifolioService; | ||
import pi.procurarteapi.infra.entities.Musician; | ||
import pi.procurarteapi.infra.entities.Musician.Portfolio; | ||
import pi.procurarteapi.infra.repositories.IMusicianRepository; | ||
|
||
@Service | ||
public class PostMusicianImagePortifolioService implements IPostMusicianImagePortifolioService{ | ||
|
||
@Autowired | ||
private IMusicianRepository musicianRepository; | ||
|
||
public PostMusicianImagePortifolioService(IMusicianRepository musicianRepository) { | ||
this.musicianRepository = musicianRepository; | ||
} | ||
|
||
@Override | ||
public PostImagesPortifolioResponseDto execute(PostImagesPortifolioRequestDto request) throws Exception { | ||
|
||
try { | ||
Musician musician = musicianRepository.findById(request.getId()) | ||
.orElseThrow(() -> new Exception("Musician Not Found")); | ||
|
||
Portfolio portfolio = musician.getPortfolio(); | ||
portfolio.setMedia(request.getImages().getImages()); | ||
musician.setPortfolio(portfolio); | ||
|
||
Musician savedMusician = musicianRepository.save(musician); | ||
|
||
PostImagesPortifolioResponseDto response = new PostImagesPortifolioResponseDto(); | ||
response.setMusician(savedMusician); | ||
|
||
|
||
return response; | ||
} catch (Exception e) { | ||
throw new Exception(e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/pi/procurarteapi/infra/repositories/IImagesRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package pi.procurarteapi.infra.repositories; | ||
|
||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
import pi.procurarteapi.infra.entities.Instrument; | ||
|
||
public interface IImagesRepository extends MongoRepository<Instrument, String>{ | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,7 @@ | |
|
||
@SpringBootTest | ||
class ProcurarteApiApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |