| | |
| | | public R sensorUpload(MultipartFile file, @RequestParam("issueId") Long issueId) { |
| | | Issue issue = issueService.selectById(issueId); |
| | | if (null == issue) { |
| | | return R.error("设备不存在"); |
| | | return R.error("故障不存在"); |
| | | } |
| | | String img = issue.getImg(); |
| | | JSONArray jsonArray = JSON.parseArray(img); |
| | |
| | | String upload = ossService.upload(inputStream,file.getOriginalFilename()); |
| | | if (Cools.isEmpty(upload)) { |
| | | return R.error("上传OSS服务失败"); |
| | | } |
| | | jsonArray.add(upload); |
| | | // 持久化 |
| | | issue.setImg(jsonArray.toJSONString()); |
| | | issue.setUpdateBy(getUserId()); |
| | | issue.setUpdateTime(new Date()); |
| | | if (!issueService.updateById(issue)) { |
| | | return R.error("上传图片失败"); |
| | | } |
| | | return R.ok(Cools.add("src", upload)); |
| | | } |
| | |
| | | issue.setUpdateBy(getUserId()); |
| | | issue.setUpdateTime(new Date()); |
| | | if (!issueService.updateById(issue)) { |
| | | return R.error("保持数据库失败"); |
| | | return R.error("删除图片失败"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |