Skip to content

Commit 8269985

Browse files
committed
refactor(soundservice): replace dto parameter with uuid to unlink a sound source
1 parent 57f12b4 commit 8269985

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/main/java/net/onelitefeather/vulpes/backend/controller/SoundController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public HttpResponse<SoundResponseDTO> updateSource(
376376
@Produces(MediaType.APPLICATION_JSON)
377377
public HttpResponse<SoundResponseDTO> deleteSource(
378378
@PathVariable("id") UUID soundEventId,
379-
@Body SoundFileSourceDTO sourceDTO
379+
@Body UUID sourceDTO
380380
) {
381381
SoundResponseDTO result = soundService.deleteLinkedSource(soundEventId, sourceDTO);
382382
return HttpResponse.ok(result);

src/main/java/net/onelitefeather/vulpes/backend/service/SoundService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,28 @@ public interface SoundService {
7272

7373
/**
7474
* Creates a new sound file source and links it to a sound event.
75+
*
7576
* @param soundEventId the ID of the sound event to link the source to
76-
* @param sourceDTO the source data to create
77+
* @param sourceDTO the source data to create
7778
* @return the created source response
7879
*/
7980
SoundResponseDTO createAndLinkSource(UUID soundEventId, SoundFileSourceDTO sourceDTO);
8081

8182
/**
8283
* Updates an existing sound file source linked to a sound event by ID.
84+
*
8385
* @param soundEventId the ID of the sound event
84-
* @param sourceDTO the source data to update
86+
* @param sourceDTO the source data to update
8587
* @return the updated source response
8688
*/
8789
SoundResponseDTO updateLinkedSource(UUID soundEventId, SoundFileSourceDTO sourceDTO);
8890

8991
/**
9092
* Deletes an existing sound file source linked to a sound event by ID.
93+
*
9194
* @param soundEventId the ID of the sound event
92-
* @param sourceDTO the source data to delete
95+
* @param sourceId the ID of the source to delete
9396
* @return the deleted source response
9497
*/
95-
SoundResponseDTO deleteLinkedSource(UUID soundEventId, SoundFileSourceDTO sourceDTO);
98+
SoundResponseDTO deleteLinkedSource(UUID soundEventId, UUID sourceId);
9699
}

src/main/java/net/onelitefeather/vulpes/backend/service/impl/SoundServiceImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public SoundResponseDTO.SoundFileSourceDTO updateLinkedSource(UUID soundEventId,
140140

141141
@Override
142142
@Transactional
143-
public SoundResponseDTO.SoundFileSourceDTO deleteLinkedSource(UUID soundEventId, SoundFileSourceDTO sourceDTO) {
144-
if (soundEventId == null || sourceDTO == null || sourceDTO.id() == null) {
143+
public SoundResponseDTO.SoundFileSourceDTO deleteLinkedSource(UUID soundEventId, UUID sourceID) {
144+
if (soundEventId == null || sourceID == null) {
145145
throw new IllegalArgumentException("SoundEventId and SourceDTO and SourceDTO.Id must not be null");
146146
}
147147

@@ -154,12 +154,12 @@ public SoundResponseDTO.SoundFileSourceDTO deleteLinkedSource(UUID soundEventId,
154154
.stream()
155155
.filter(SoundResponseDTO.SoundFileSourceDTO.class::isInstance)
156156
.map(SoundResponseDTO.SoundFileSourceDTO.class::cast)
157-
.filter(s -> s.id().equals(sourceDTO.id()))
157+
.filter(s -> s.id().equals(sourceID))
158158
.findFirst();
159159
if (existingSourceOpt.isEmpty()) {
160160
throw new IllegalArgumentException("Sound source not found for the given sound event");
161161
}
162-
soundFileSourceRepository.deleteById(sourceDTO.id());
162+
soundFileSourceRepository.deleteById(sourceID);
163163
return existingSourceOpt.get();
164164
}
165165
}

src/test/java/net/onelitefeather/vulpes/backend/controller/SoundControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public SoundResponseDTO.SoundFileSourceDTO updateLinkedSource(UUID soundEventId,
7676
}
7777

7878
@Override
79-
public SoundResponseDTO.SoundFileSourceDTO deleteLinkedSource(UUID soundEventId, SoundFileSourceDTO sourceDTO) {
79+
public SoundResponseDTO.SoundFileSourceDTO deleteLinkedSource(UUID soundEventId, UUID sourceDTO) {
8080
return sourceResponse;
8181
}
8282
}

0 commit comments

Comments
 (0)