package com.ruoyi.device.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.device.pojo.DeviceArea; import com.ruoyi.device.service.IDeviceAreaService; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.domain.AjaxResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @Api(tags = "设备区域管理") @RestController @RequestMapping("/device/area") public class DeviceAreaController { @Autowired private IDeviceAreaService deviceAreaService; @GetMapping("/tree") @ApiOperation("设备区域树") public AjaxResult tree() { return AjaxResult.success(deviceAreaService.listTree()); } @GetMapping("/treeWithDevices") @ApiOperation("设备区域树-包含设备列表") public AjaxResult treeWithDevices() { return AjaxResult.success(deviceAreaService.listTreeWithDevices()); } @GetMapping("/page") @ApiOperation("设备区域分页") public AjaxResult page(Page page, DeviceArea deviceArea) { return AjaxResult.success(deviceAreaService.queryPage(page, deviceArea)); } @GetMapping("/{id}") @ApiOperation("设备区域详情") public AjaxResult detail(@PathVariable Long id) { return AjaxResult.success(deviceAreaService.getById(id)); } @PostMapping @ApiOperation("新增设备区域") @Log(title = "设备区域", businessType = BusinessType.INSERT) public AjaxResult add(@RequestBody DeviceArea deviceArea) { return deviceAreaService.saveDeviceArea(deviceArea); } @PutMapping @ApiOperation("修改设备区域") @Log(title = "设备区域", businessType = BusinessType.UPDATE) public AjaxResult update(@RequestBody DeviceArea deviceArea) { return deviceAreaService.updateDeviceArea(deviceArea); } @DeleteMapping @ApiOperation("删除设备区域") @Log(title = "设备区域", businessType = BusinessType.DELETE) public AjaxResult delete(@RequestBody List ids) { return deviceAreaService.removeDeviceAreas(ids); } }