添加小区图片
This commit is contained in:
+25
@@ -1285,6 +1285,31 @@ public class DistrictController {
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
public Object deletePicAction(DistrictModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
if (StringUtils.isBlank(model.getId())) {
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入"));
|
||||
return mav;
|
||||
}
|
||||
seaweedImagesService.deleteImage(model.getId(),model.getUrl(),model.getPicType(), model.getRoomType());
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "删除成功"));
|
||||
return mav;
|
||||
}
|
||||
public Object addPicAction(DistrictModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
if (model.getImageUrls()!=null){
|
||||
model.setImageUrls(convertToList(model.getImageUrls().toString()));
|
||||
}
|
||||
if (StringUtils.isBlank(model.getId())) {
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.ARGUMENT_LOSE, "ID必须输入"));
|
||||
return mav;
|
||||
}
|
||||
seaweedImagesService.addImage(model.getId(),model.getImageUrls(),model.getPicType(), model.getRoomType());
|
||||
mav.setModel(new HttpCode(OpenHttpCodeEnum.OK, "添加成功"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
public Object addrFacilitysAction(DistrictSearchModel model, @Param(name = "city") String city, @Param(name = "address") String address) throws Exception {
|
||||
|
||||
@@ -57,6 +57,15 @@ public class DistrictModel extends BaseModel {
|
||||
* 判断是不是友达
|
||||
*/
|
||||
private boolean isYouDa;
|
||||
//用于删除和新增
|
||||
// 图片url
|
||||
private String url;
|
||||
//房型图 或 外景图
|
||||
private String PicType;
|
||||
//几室
|
||||
private String roomType;
|
||||
|
||||
private List<String> imageUrls;
|
||||
|
||||
public Boolean getShowPrice() {
|
||||
return showPrice;
|
||||
@@ -241,4 +250,35 @@ public class DistrictModel extends BaseModel {
|
||||
// public void setBuildName(String buildName) {
|
||||
// this.buildName = buildName;
|
||||
// }
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getRoomType() {
|
||||
return roomType;
|
||||
}
|
||||
public void setRoomType(String roomType) {
|
||||
this.roomType = roomType;
|
||||
}
|
||||
|
||||
public String getPicType() {
|
||||
return PicType;
|
||||
}
|
||||
|
||||
public void setPicType(String picType) {
|
||||
PicType = picType;
|
||||
}
|
||||
|
||||
public List<String> getImageUrls() {
|
||||
return imageUrls;
|
||||
}
|
||||
|
||||
public void setImageUrls(List<String> imageUrls) {
|
||||
this.imageUrls = imageUrls;
|
||||
}
|
||||
}
|
||||
|
||||
+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