Skip to content

Instantly share code, notes, and snippets.

@Fabien-V
Created September 27, 2019 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fabien-V/3020b0560afe4b157a69196ae3653783 to your computer and use it in GitHub Desktop.
Save Fabien-V/3020b0560afe4b157a69196ae3653783 to your computer and use it in GitHub Desktop.
package com.example.demo.controllers;
import com.example.demo.callNP6.SegmentsServices;
import com.example.demo.entities.Segment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/apiCifeaNp6")
public class SegmentController {
@Autowired
SegmentsServices segmentsServices;
/*GET ALL SEGMENTS*/
@GetMapping("/segments")
public Segment[] getAllSegments() {
return segmentsServices.getAllSegments();
}
/*GET A SPECIFIC SEGMENTS*/
@GetMapping("/segments/{ID}")
public Segment getSpecificSegment(@PathVariable String ID) {
return segmentsServices.getSpecificSegment(ID);
}
/*CREATE SEGMENTS*/
@PostMapping("/segments")
public Segment createSegment(@RequestBody String segment) {
return segmentsServices.createSegment(segment);
}
/*UPDATE A SPECIFIC SEGMENT*/
@PutMapping("segments/{ID}")
public Segment updateSegment(@PathVariable("ID") String ID, @RequestBody String segment){
return segmentsServices.updateSegment(ID, segment);
}
/*EMPTY A SPECIFIC SEGMENT*/
@DeleteMapping("segments/{ID}/targets")
public Segment emptySegment(@PathVariable String ID) {
return segmentsServices.emptySegment(ID);
}
/*DELETE A SPECIFIC SEGMENTS*/
@DeleteMapping("segments/{ID}")
public Segment deleteSegment(@PathVariable String ID) {
return segmentsServices.deleteSegment(ID);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment