0% found this document useful (0 votes)
5 views1 page

Plan Management REST API Controller

The PlanMasterController is a Spring REST controller that manages plan-related operations. It provides endpoints to save, retrieve, and update plans using the PlanMasterService. The controller handles responses based on the success or failure of the operations performed on the plans.

Uploaded by

Abhishek Gawade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Plan Management REST API Controller

The PlanMasterController is a Spring REST controller that manages plan-related operations. It provides endpoints to save, retrieve, and update plans using the PlanMasterService. The controller handles responses based on the success or failure of the operations performed on the plans.

Uploaded by

Abhishek Gawade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package [Link].

controller;

import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;

import [Link];

@RestController
@RequestMapping("/plan")
public class PlanMasterController {

@Autowired
private PlanMasterService service;

@PostMapping("/save")
public ResponseEntity<String> savePlan(@RequestBody PlanDto dto) {
boolean saved = [Link](dto);
return saved ? [Link]("Plan saved successfully")
:
[Link](HttpStatus.INTERNAL_SERVER_ERROR).body("Plan save failed");
}

@GetMapping("/all")
public ResponseEntity<List<PlanDto>> getAllPlans() {
return [Link]([Link]());
}

@GetMapping("/{id}")
public ResponseEntity<PlanDto> getPlan(@PathVariable Integer id) {
PlanDto dto = [Link](id);
return dto != null ? [Link](dto) :
[Link]().build();
}

@PutMapping("/update/{id}")
public ResponseEntity<String> updatePlan(@PathVariable Integer id, @RequestBody
PlanDto dto) {
boolean updated = [Link](id, dto);
return updated ? [Link]("Plan updated successfully")
: [Link](HttpStatus.NOT_FOUND).body("Plan not
found");
}
}

You might also like