Fix response of tobuy API

feature-backend-tobuy-stock
Masaharu.Kato 5 months ago
parent 865f1e2337
commit b08c92f6c0
  1. 9
      backend/src/main/java/com/example/todoapp/controller/ToBuysController.java

@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -57,19 +58,19 @@ public class ToBuysController {
*/ */
@PostMapping("/add") @PostMapping("/add")
public ResponseEntity<String> addToBuys( public ResponseEntity<Map<String, Boolean>> addToBuys(
@Valid @RequestBody ToBuysDTO dto, @Valid @RequestBody ToBuysDTO dto,
Authentication authentication) { Authentication authentication) {
toBuysService.addToBuys(dto, authentication); toBuysService.addToBuys(dto, authentication);
return ResponseEntity.ok("Item added to 'To Buys' successfully"); return ResponseEntity.ok(Collections.singletonMap("result", true));
} }
@PutMapping("/update") @PutMapping("/update")
public ResponseEntity<String> updateToBuys( public ResponseEntity<Map<String, Boolean>> updateToBuys(
@Valid @RequestBody ToBuysDTO dto, @Valid @RequestBody ToBuysDTO dto,
Authentication authentication) { Authentication authentication) {
toBuysService.updateToBuys(dto, authentication); toBuysService.updateToBuys(dto, authentication);
return ResponseEntity.ok("Item updated to 'To Buys' successfully"); return ResponseEntity.ok(Collections.singletonMap("result", true));
} }

Loading…
Cancel
Save