package com.app.Controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.app.Dto.SourceCompagneDto;
import com.app.Services.SourceCompagneService;

public class SourceCompagneController {
	@RestController
	@RequestMapping("/api/v1/sourceCompagne")
	@CrossOrigin(origins = "http://localhost:4200")
	public class ParcoursController {
		@Autowired
		  private SourceCompagneService servSourceCompagne ;
		//
		@PostMapping("/save")
		public SourceCompagneDto save(@RequestBody SourceCompagneDto dto) {

			return servSourceCompagne.save(dto);
		}


		@DeleteMapping("/delet/{id}")
		public void delete(@PathVariable Long id) {
			servSourceCompagne.delete(id);
		}
		 @GetMapping("/getbyid/{id}")
		public SourceCompagneDto findById(@PathVariable Long id) {
				return servSourceCompagne.findById(id);
		}
		 @GetMapping("/getall")
		public List<SourceCompagneDto> findAllParcours() {
				return servSourceCompagne.findAllSource();
		}
	}

}
