package com.example.demo11.Controller;标签:,Result,device,import,com,example,demo11 From: https://www.cnblogs.com/luoqingci/p/18556205
import com.example.demo11.Service.DeviceService;
import com.example.demo11.entity.Device;
import com.example.demo11.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
//设备管理
@RestController
@RequestMapping("/device")
public class DeviceController {
@Autowired
private DeviceService deviceService;
@GetMapping("/list")
public Result<List<Device>> list() {
List<Device> device = deviceService.list();
return Result.success(device);
}
@PostMapping("/add")
public Result<Device> add(@RequestBody Device device) {
deviceService.save(device);
return Result.success(device);
}
}