| | |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | @RestController |
| | | @RequestMapping("/device/maintenance") |
| | | @AllArgsConstructor |
| | | public class DeviceMaintenanceController { |
| | | public class DeviceMaintenanceController extends BaseController { |
| | | |
| | | |
| | | private IDeviceMaintenanceService deviceMaintenanceService; |
| | |
| | | |
| | | @Operation(summary = "设备保养列表") |
| | | @GetMapping("/page") |
| | | public AjaxResult page(Page page , DeviceMaintenanceDto deviceMaintenanceDto) { |
| | | return AjaxResult.success(deviceMaintenanceService.queryPage(page,deviceMaintenanceDto)); |
| | | public R<?> page(Page page , DeviceMaintenanceDto deviceMaintenanceDto) { |
| | | return R.ok(deviceMaintenanceService.queryPage(page,deviceMaintenanceDto)); |
| | | } |
| | | |
| | | @PostMapping() |
| | | @Operation(summary = "添加设备保养") |
| | | public AjaxResult add(@RequestBody DeviceMaintenance deviceMaintenance) { |
| | | public R<?> add(@RequestBody DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceMaintenance.getDeviceLedgerId()); |
| | | deviceMaintenance.setDeviceName(byId.getDeviceName()); |
| | | deviceMaintenance.setDeviceModel(byId.getDeviceModel()); |
| | |
| | | |
| | | @Operation(summary = "根据id查询设备保养") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult detail(@PathVariable Long id) { |
| | | return AjaxResult.success(deviceMaintenanceService.detailById(id)); |
| | | public R<?> detail(@PathVariable Long id) { |
| | | return R.ok(deviceMaintenanceService.detailById(id)); |
| | | } |
| | | |
| | | @PutMapping () |
| | | @Operation(summary = "修改设备保养") |
| | | public AjaxResult update(@RequestBody DeviceMaintenance deviceMaintenance) { |
| | | public R<?> update(@RequestBody DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceMaintenance.getDeviceLedgerId()); |
| | | deviceMaintenance.setDeviceName(byId.getDeviceName()); |
| | | deviceMaintenance.setDeviceModel(byId.getDeviceModel()); |
| | |
| | | |
| | | @PostMapping ("maintenance") |
| | | @Operation(summary = "修改设备保养") |
| | | public AjaxResult maintenance(@RequestBody DeviceMaintenance deviceMaintenance) { |
| | | public R<?> maintenance(@RequestBody DeviceMaintenanceDto deviceMaintenance) { |
| | | return deviceMaintenanceService.updateDeviceDeviceMaintenance(deviceMaintenance); |
| | | } |
| | | |
| | | |
| | | @DeleteMapping("/{ids}") |
| | | @Operation(summary = "删除设备保养") |
| | | public AjaxResult delete(@PathVariable("ids") Long[] ids) { |
| | | public R<?> delete(@PathVariable("ids") Long[] ids) { |
| | | boolean b = deviceMaintenanceService.removeBatchByIds(Arrays.asList(ids)); |
| | | if (!b) { |
| | | return AjaxResult.error("删除失败"); |
| | | return R.fail("删除失败"); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("export") |