对比新文件 |
| | |
| | | package com.ruoyi.device.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.device.pojo.DeviceDocuments; |
| | | import com.ruoyi.device.service.DeviceDocumentsService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | |
| | | /** |
| | | * 璁惧妗f鏂囨。 |
| | | * |
| | | * @author zhuo |
| | | * @since 2025-02-28 |
| | | */ |
| | | @RestController |
| | | @Api(tags = "璁惧妗f鏂囨。") |
| | | @RequestMapping("/deviceDocuments") |
| | | public class DeviceDocumentsController { |
| | | |
| | | @Resource |
| | | private DeviceDocumentsService deviceDocumentsService; |
| | | |
| | | |
| | | /** |
| | | * 鏂板璁惧妗f |
| | | * @param document |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "鏂板璁惧妗f") |
| | | @PostMapping("/addDocument") |
| | | public Result addDocument(@RequestBody DeviceDocuments document) { |
| | | if (document.getDeviceId() == null) { |
| | | throw new RuntimeException("璁惧id涓虹┖"); |
| | | } |
| | | deviceDocumentsService.save(document); |
| | | return Result.success(); |
| | | } |
| | | |
| | | /** |
| | | * 鏌ヨ璁惧妗f淇℃伅 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "鏌ヨ璁惧妗f淇℃伅") |
| | | @GetMapping("/getDocumentById") |
| | | public Result getDocumentById(Integer id) { |
| | | return Result.success(deviceDocumentsService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 淇敼璁惧妗f |
| | | * @param document |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "淇敼璁惧妗f") |
| | | @PostMapping("/updateDocument") |
| | | public Result updateDocument(@RequestBody DeviceDocuments document) { |
| | | return Result.success(deviceDocumentsService.updateById(document)); |
| | | } |
| | | |
| | | /** |
| | | * 鍒犻櫎璁惧妗f |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "鍒犻櫎璁惧妗f") |
| | | @DeleteMapping("/deleteDocumentById") |
| | | public Result deleteDocumentById(Integer id) { |
| | | return Result.success(deviceDocumentsService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 鏌ヨ璁惧妗f鍒楄〃 |
| | | * @param deviceId |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "鏌ヨ璁惧妗f鍒楄〃") |
| | | @GetMapping("/getAllDocuments") |
| | | public Result getAllDocuments(Integer deviceId) { |
| | | LambdaQueryWrapper<DeviceDocuments> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(DeviceDocuments::getDeviceId, deviceId); |
| | | return Result.success(deviceDocumentsService.list(lambdaQueryWrapper)); |
| | | } |
| | | |
| | | } |
| | | |