| | |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void deleteSupervision(Integer id) { |
| | | supervisionMapper.deleteById(id); |
| | | public void deleteSupervision(Integer supervisionId) { |
| | | QueryWrapper<Supervision> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("id", "images").eq("id", supervisionId); |
| | | Supervision supervision = supervisionMapper.selectOne(queryWrapper); |
| | | String[] images = supervision.getImages().split(","); |
| | | |
| | | //逻辑删除 |
| | | supervision.setIsDelete(Constants.DELETE); |
| | | supervision.setImages(null); |
| | | supervisionMapper.updateById(supervision); |
| | | |
| | | |
| | | //删除服务器中的督办单中图片 |
| | | String path = this.getClass().getClassLoader() |
| | | .getResource("").getFile() + "static/img"; |
| | | for (String image : images) { |
| | | String realPath = path + File.separator + image; |
| | | File file = new File(realPath); |
| | | if (file.exists() && file.isFile()) { |
| | | file.delete(); |
| | | } |
| | | } |
| | | } |
| | | } |