| | |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param deviceMaintenanceFile |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@RequestBody DeviceMaintenanceFile deviceMaintenanceFile) { |
| | | return AjaxResult.success(deviceMaintenanceFileService.save(deviceMaintenanceFile)); |
| | | try { |
| | | return AjaxResult.success(deviceMaintenanceFileService.saveRecord(deviceMaintenanceFile)); |
| | | } catch (Exception e) { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 上传附件 |
| | | */ |
| | | @PostMapping("/upload") |
| | | public AjaxResult upload(@RequestParam("file") MultipartFile file, |
| | | @RequestParam("deviceMaintenanceId") Integer deviceMaintenanceId) { |
| | | try { |
| | | return AjaxResult.success(deviceMaintenanceFileService.uploadFile(file, deviceMaintenanceId)); |
| | | } catch (Exception e) { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/del") |
| | | public AjaxResult delQualityUnqualified(@RequestBody List<Integer> ids) { |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return AjaxResult.error("请选择至少一条数据"); |
| | | } |
| | | //删除检验附件 |
| | |
| | | } |
| | | |
| | | /** |
| | | *分页查询 |
| | | * 分页查询 |
| | | * |
| | | * @param page |
| | | * @param deviceMaintenanceFile |
| | | * @return |
| | | */ |
| | | @GetMapping("/listPage") |
| | | public AjaxResult qualityInspectFileListPage(Page page, DeviceMaintenanceFile deviceMaintenanceFile) { |
| | | return AjaxResult.success(deviceMaintenanceFileService.page(page, Wrappers.<DeviceMaintenanceFile>lambdaQuery().eq(DeviceMaintenanceFile::getDeviceMaintenanceId,deviceMaintenanceFile.getDeviceMaintenanceId()))); |
| | | Page<DeviceMaintenanceFile> result = deviceMaintenanceFileService.page(page, |
| | | Wrappers.<DeviceMaintenanceFile>lambdaQuery() |
| | | .eq(DeviceMaintenanceFile::getDeviceMaintenanceId, deviceMaintenanceFile.getDeviceMaintenanceId()) |
| | | .orderByDesc(DeviceMaintenanceFile::getCreateTime)); |
| | | deviceMaintenanceFileService.enrichAccessUrl(result.getRecords()); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | |