Skip to content

Commit fb97e75

Browse files
committed
refactor(soundservice): replace dto parameter with uuid to unlink a sound source
1 parent 4fa46d2 commit fb97e75

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
@@ -73,25 +73,28 @@ public interface SoundService {
7373

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

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

9092
/**
9193
* Deletes an existing sound file source linked to a sound event by ID.
94+
*
9295
* @param soundEventId the ID of the sound event
93-
* @param sourceDTO the source data to delete
96+
* @param sourceId the ID of the source to delete
9497
* @return the deleted source response
9598
*/
96-
SoundResponseDTO deleteLinkedSource(UUID soundEventId, SoundFileSourceDTO sourceDTO);
99+
SoundResponseDTO deleteLinkedSource(UUID soundEventId, UUID sourceId);
97100
}

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.getId() == 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.getId()))
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.getId());
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)