添加小区图片
This commit is contained in:
+4
@@ -12,4 +12,8 @@ import java.util.Map;
|
||||
*/
|
||||
public interface SeaweedImagesService {
|
||||
public SeaweedImages findById(String id);
|
||||
|
||||
public void deleteImage(String id, String url,String picType,String roomType);
|
||||
public void addImage(String id, List<String> urls,String picType,String roomType);
|
||||
|
||||
}
|
||||
|
||||
+50
@@ -3,13 +3,63 @@ package com.fangjia.service.mongo.fangjia;
|
||||
import com.fangjia.dal.mongo.dao.SeaweedImagesDao;
|
||||
import com.fangjia.dal.mongo.model.SeaweedImages;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SeaweedImagesServiceImpl implements SeaweedImagesService {
|
||||
private SeaweedImagesDao seaweedImagesDao;
|
||||
|
||||
@Override
|
||||
public SeaweedImages findById(String id) {
|
||||
return seaweedImagesDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteImage(String id, String url, String picType, String roomType) {
|
||||
SeaweedImages seaweedImages = seaweedImagesDao.findById(id);
|
||||
if ("floorplanPics".equals(picType)) {
|
||||
Map<String, List<String>> floorplanPics = seaweedImages.getFloorplanPics();
|
||||
List<String> roomPicList = floorplanPics.get(roomType);
|
||||
if (roomPicList!=null && !roomPicList.isEmpty()){
|
||||
roomPicList.remove(url);
|
||||
floorplanPics.put(roomType,roomPicList);
|
||||
seaweedImages.setFloorplanPics(floorplanPics);
|
||||
}
|
||||
} else if ("outPics".equals(picType)) {
|
||||
List<String> outPics = seaweedImages.getOutPics();
|
||||
if (outPics != null && !outPics.isEmpty()) {
|
||||
outPics.remove(url);
|
||||
seaweedImages.setOutPics(outPics);
|
||||
}
|
||||
}
|
||||
seaweedImagesDao.update(seaweedImages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addImage(String id, List<String> urls, String picType, String roomType) {
|
||||
SeaweedImages seaweedImages = seaweedImagesDao.findById(id);
|
||||
if ("floorplanPics".equals(picType)) {
|
||||
Map<String, List<String>> floorplanPics = seaweedImages.getFloorplanPics();
|
||||
List<String> roomPicList = floorplanPics.get(roomType);
|
||||
if (roomPicList!=null && !roomPicList.isEmpty()){
|
||||
roomPicList.addAll(urls);
|
||||
floorplanPics.put(roomType,roomPicList);
|
||||
}else {
|
||||
floorplanPics.put(roomType,urls);
|
||||
}
|
||||
seaweedImages.setFloorplanPics(floorplanPics);
|
||||
} else if ("outPics".equals(picType)) {
|
||||
List<String> outPics = seaweedImages.getOutPics();
|
||||
if (outPics != null && !outPics.isEmpty()) {
|
||||
outPics.addAll(urls);
|
||||
seaweedImages.setOutPics(outPics);
|
||||
}else {
|
||||
seaweedImages.setOutPics(urls);
|
||||
}
|
||||
}
|
||||
seaweedImagesDao.update(seaweedImages);
|
||||
}
|
||||
|
||||
public void setSeaweedImagesDao(SeaweedImagesDao seaweedImagesDao) {
|
||||
this.seaweedImagesDao = seaweedImagesDao;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user