Skip to content

Commit 0126bf8

Browse files
committed
Fixed deletion and broadccasting of notes
1 parent 58c79a2 commit 0126bf8

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/main/java/edu/tamu/app/controller/NoteController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,18 @@ public ApiResponse create(@ApiValidatedModel Note note, @ApiCredentials Credenti
7272
@Auth(role = "ROLE_SERVICE_MANAGER")
7373
public ApiResponse update(@ApiValidatedModel Note note) {
7474
note = noteRepo.save(note);
75-
simpMessagingTemplate.convertAndSend("/channel/note", new ApiResponse(SUCCESS, noteRepo.findAll()));
76-
return new ApiResponse(SUCCESS, note);
75+
ApiResponse response = new ApiResponse(SUCCESS, noteRepo.getOne(note.getId()));
76+
simpMessagingTemplate.convertAndSend("/channel/note/" + note.getId(), response);
77+
return response;
7778
}
7879

7980
@Transactional
8081
@ApiMapping("/remove")
8182
@Auth(role = "ROLE_SERVICE_MANAGER")
8283
public ApiResponse remove(@ApiValidatedModel Note note) {
8384
noteRepo.delete(note);
84-
simpMessagingTemplate.convertAndSend("/channel/note", new ApiResponse(SUCCESS, noteRepo.findAll()));
85-
return new ApiResponse(SUCCESS, serviceRepo.getOne(note.getService().getId()));
85+
simpMessagingTemplate.convertAndSend("/channel/service" + note.getService().getId(), new ApiResponse(SUCCESS, serviceRepo.getOne(note.getService().getId())));
86+
return new ApiResponse(SUCCESS);
8687
}
8788

8889
@ApiMapping("/page")

src/main/java/edu/tamu/app/model/Service.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class Service extends BaseEntity {
6161
@Column(nullable = true)
6262
private String description;
6363

64-
@OneToMany(fetch = EAGER, cascade = { DETACH, REMOVE, PERSIST, REFRESH }, mappedBy = "service")
64+
@OneToMany(fetch = EAGER, cascade = { REMOVE, REFRESH }, mappedBy = "service")
6565
@Fetch(FetchMode.SELECT)
6666
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, scope = Note.class, property = "id")
6767
@JsonIdentityReference(alwaysAsId = true)

0 commit comments

Comments
 (0)