|
@@ -28,23 +28,16 @@ public class MuseumPictureServiceImpl implements MuseumPictureService {
|
|
|
@Resource
|
|
|
private FileApi fileApi;
|
|
|
|
|
|
-// @Override
|
|
|
-// public Integer createMuseumPicture(MuseumPictureSaveVO saveVO){
|
|
|
-// return museumPictureMapper.insert(BeanUtils.toBean(saveVO, MuseumPictureDO.class));
|
|
|
-// }
|
|
|
-
|
|
|
@Override
|
|
|
public Integer createMuseumPicture(MuseumPictureSaveVO saveVO) {
|
|
|
Integer photoGroupId = saveVO.getGroupId();
|
|
|
List<String> urls = saveVO.getPicturePath();
|
|
|
-
|
|
|
for (String url : urls) {
|
|
|
MuseumPictureDO museumPicture = new MuseumPictureDO();
|
|
|
museumPicture.setGroupId(photoGroupId);
|
|
|
museumPicture.setPicturePath(url);
|
|
|
museumPictureMapper.insert(museumPicture);
|
|
|
}
|
|
|
-
|
|
|
return photoGroupId; // 返回照片组ID作为操作成功的标识
|
|
|
}
|
|
|
|
|
@@ -55,12 +48,11 @@ public class MuseumPictureServiceImpl implements MuseumPictureService {
|
|
|
|
|
|
@Override
|
|
|
public void deleteMuseumPicture(Integer picture_id){
|
|
|
-// museumPictureMapper.deleteMuseumPicture(picture_id);
|
|
|
museumPictureMapper.deleteById(picture_id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MuseumPictureDO selectMuseumPicture(Integer picture_id){
|
|
|
+ public MuseumPictureDO selectMuseumPicture(Integer picture_id){
|
|
|
return museumPictureMapper.selectMuseumPictureById(picture_id);
|
|
|
}
|
|
|
|
|
@@ -69,47 +61,6 @@ public class MuseumPictureServiceImpl implements MuseumPictureService {
|
|
|
return museumPictureMapper.selectMuseumPicturePage(pageVO);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// private final Set<String> ALLOWED_EXTENSIONS = Set.of("jpg", "jpeg", "png", "gif");
|
|
|
-
|
|
|
-// @Override
|
|
|
-// public void processZipUpload(MultipartFile file, Long groupId) throws IOException {
|
|
|
-// try (ZipInputStream zis = new ZipInputStream(file.getInputStream())) {
|
|
|
-// ZipEntry entry;
|
|
|
-// while ((entry = zis.getNextEntry()) != null) {
|
|
|
-// processZipEntry(zis, entry, groupId);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// private void processZipEntry(ZipInputStream zis, ZipEntry entry, Long groupId) throws IOException {
|
|
|
-// if (entry.isDirectory() || !isImageFile(entry.getName())) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 读取文件内容并上传
|
|
|
-// byte[] content = IoUtil.readBytes(zis);
|
|
|
-// String url = fileApi.createFile(content);
|
|
|
-//
|
|
|
-// // 构建并保存数据库记录
|
|
|
-// MuseumPictureDO photo = new MuseumPictureDO();
|
|
|
-// photo.setGroupId(Math.toIntExact(groupId));
|
|
|
-// photo.setPictureUrl(url);
|
|
|
-// museumPictureMapper.insert(photo);
|
|
|
-// }
|
|
|
-//
|
|
|
-// private boolean isImageFile(String filename) {
|
|
|
-// String extension = FilenameUtil.getExtension(filename);
|
|
|
-// return StringUtils.isNotEmpty(extension);
|
|
|
-//// ALLOWED_EXTENSIONS.contains(extension.toLowerCase());
|
|
|
-// }
|
|
|
-
|
|
|
-// @Override
|
|
|
-// public MuseumPictureDO selectMuseumPictureSet(Integer group_id){
|
|
|
-// return museumPictureMapper.selectMuseumPictureSetById(group_id);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public void processZipUpload(MultipartFile file, Long groupId) {
|
|
|
if (file == null || file.isEmpty()) {
|
|
@@ -157,46 +108,3 @@ public class MuseumPictureServiceImpl implements MuseumPictureService {
|
|
|
museumPictureMapper.insert(photo);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// @Override
|
|
|
-// public void unzipAndAddToGroup(String groupId, String zipFilePath) throws IOException {
|
|
|
-// String photoGroupDir = "photos/" + groupId;
|
|
|
-// File groupDir = new File(photoGroupDir);
|
|
|
-// if (!groupDir.exists()) {
|
|
|
-// groupDir.mkdirs();
|
|
|
-// }
|
|
|
-//
|
|
|
-// unzip(zipFilePath, photoGroupDir);
|
|
|
-// }
|
|
|
-
|
|
|
-// private void unzip(String zipFilePath, String destDir) throws IOException {
|
|
|
-// byte[] buffer = new byte[1024];
|
|
|
-// try (
|
|
|
-// FileInputStream fis = new FileInputStream(zipFilePath);
|
|
|
-// ZipInputStream zis = new ZipInputStream(fis)
|
|
|
-// ) {
|
|
|
-// ZipEntry zipEntry = zis.getNextEntry();
|
|
|
-// while (zipEntry != null) {
|
|
|
-// String filePath = destDir + File.separator + zipEntry.getName();
|
|
|
-// if (!zipEntry.isDirectory()) {
|
|
|
-// extractFile(zis, buffer, filePath);
|
|
|
-// } else {
|
|
|
-// File dir = new File(filePath);
|
|
|
-// dir.mkdir();
|
|
|
-// }
|
|
|
-// zis.closeEntry();
|
|
|
-// zipEntry = zis.getNextEntry();
|
|
|
-// }
|
|
|
-// zis.closeEntry();
|
|
|
-// }
|
|
|
-//}
|
|
|
-//
|
|
|
-//private void extractFile(ZipInputStream zis, byte[] buffer, String filePath) throws IOException {
|
|
|
-// try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
|
|
-// int len;
|
|
|
-// while ((len = zis.read(buffer)) > 0) {
|
|
|
-// fos.write(buffer, 0, len);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//}
|
|
|
-//}
|