34 lines
917 B
Java
34 lines
917 B
Java
package com.example.springdemo.controller;
|
|
|
|
import com.example.springdemo.entities.Orders;
|
|
import com.example.springdemo.service.OrdersService;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@RestController
|
|
@RequestMapping("/orders")
|
|
public class OrdersController {
|
|
@Resource
|
|
private OrdersService ordersService;
|
|
|
|
@PostMapping("/add")
|
|
public Orders addIndent(@RequestBody Orders orders) {
|
|
return ordersService.addOrder(orders);
|
|
}
|
|
|
|
@DeleteMapping("/delete/id")
|
|
public void deleteOrderById(@RequestParam("id") Long id) {
|
|
ordersService.deleteOrderById(id);
|
|
}
|
|
|
|
@PutMapping("/update")
|
|
public Orders updateOrder(@RequestBody Orders orders) {
|
|
return ordersService.updateOrder(orders);
|
|
}
|
|
|
|
@GetMapping("/find/all")
|
|
public Iterable<Orders> getAllOrders() {
|
|
return ordersService.findAllOrders();
|
|
}
|
|
}
|