|
@@ -3,8 +3,10 @@ package com.huiju.estateagents.service.impl;
|
3
|
3
|
import com.alibaba.fastjson.JSONArray;
|
4
|
4
|
import com.alibaba.fastjson.JSONObject;
|
5
|
5
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
6
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
6
|
7
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
7
|
8
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
9
|
+import com.google.common.collect.Lists;
|
8
|
10
|
import com.huiju.estateagents.base.ResponseBean;
|
9
|
11
|
import com.huiju.estateagents.common.CommConstant;
|
10
|
12
|
import com.huiju.estateagents.common.DateUtils;
|
|
@@ -97,7 +99,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
97
|
99
|
//查询当前图片
|
98
|
100
|
QueryWrapper<TaBuildingImg> queryWrapper = new QueryWrapper<>();
|
99
|
101
|
queryWrapper.eq("building_id", taBuilding.getBuildingId());
|
100
|
|
- queryWrapper.eq("img_type", "banner");
|
|
102
|
+ queryWrapper.eq("img_type", CommConstant.BUILDING_IMG_BANNER);
|
101
|
103
|
queryWrapper.orderByAsc("create_date");
|
102
|
104
|
|
103
|
105
|
List<TaBuildingImg> buildingImg = taBuildingImgMapper.selectList(queryWrapper);
|
|
@@ -120,6 +122,21 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
120
|
122
|
return ResponseBean.success(page);
|
121
|
123
|
}
|
122
|
124
|
|
|
125
|
+ /**
|
|
126
|
+ * 查询项目图片
|
|
127
|
+ * @param buildingId
|
|
128
|
+ * @param imgType
|
|
129
|
+ * @return
|
|
130
|
+ */
|
|
131
|
+ private List<TaBuildingImg> getBuildingImg(String buildingId, String imgType) {
|
|
132
|
+ //查询当前图片
|
|
133
|
+ QueryWrapper<TaBuildingImg> BuildingImgQueryWrapper = new QueryWrapper<>();
|
|
134
|
+ BuildingImgQueryWrapper.eq("building_id", buildingId);
|
|
135
|
+ BuildingImgQueryWrapper.eq("img_type", imgType);
|
|
136
|
+ List<TaBuildingImg> buildingImg = taBuildingImgMapper.selectList(BuildingImgQueryWrapper);
|
|
137
|
+ return buildingImg.size() > 0 ? buildingImg : null;
|
|
138
|
+ }
|
|
139
|
+
|
123
|
140
|
@Override
|
124
|
141
|
public ResponseBean buildingSelectId(String id) {
|
125
|
142
|
// 查询基础信息
|
|
@@ -129,19 +146,13 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
129
|
146
|
TaBuilding building = taBuildingMapper.selectOne(buildingtWrapper);
|
130
|
147
|
|
131
|
148
|
//查询当前图片
|
132
|
|
- QueryWrapper<TaBuildingImg> BuildingImgQueryWrapper = new QueryWrapper<>();
|
133
|
|
- BuildingImgQueryWrapper.eq("building_id", id);
|
134
|
|
- BuildingImgQueryWrapper.eq("img_type", "banner");
|
135
|
|
- List<TaBuildingImg> buildingImg = taBuildingImgMapper.selectList(BuildingImgQueryWrapper);
|
136
|
|
- building.setBuildingImg(buildingImg);
|
|
149
|
+ building.setBuildingImg(getBuildingImg(id, CommConstant.BUILDING_IMG_BANNER));
|
137
|
150
|
|
138
|
151
|
// 列表图
|
139
|
|
- QueryWrapper<TaBuildingImg> BuildingListImgQueryWrapper = new QueryWrapper<>();
|
140
|
|
- BuildingListImgQueryWrapper.eq("building_id", building.getBuildingId());
|
141
|
|
- BuildingListImgQueryWrapper.eq("img_type", "list");
|
142
|
|
- List<TaBuildingImg> buildingListImg = taBuildingImgMapper.selectList(BuildingListImgQueryWrapper);
|
143
|
|
- building.setBuildingListImg(buildingListImg);
|
|
152
|
+ building.setBuildingListImg(getBuildingImg(building.getBuildingId(), CommConstant.BUILDING_IMG_LIST));
|
144
|
153
|
|
|
154
|
+ // 视频封面图
|
|
155
|
+ building.setVideoImage(getBuildingImg(building.getBuildingId(), CommConstant.BUILDING_IMG_VIDEOIMAGE));
|
145
|
156
|
|
146
|
157
|
// 查询tag
|
147
|
158
|
QueryWrapper<TaBuildingTag> BuildingTagQueryWrapper = new QueryWrapper<>();
|
|
@@ -169,11 +180,10 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
169
|
180
|
TaBuilding building = taBuildingMapper.selectOne(buildingtWrapper);
|
170
|
181
|
|
171
|
182
|
//查询当前图片
|
172
|
|
- QueryWrapper<TaBuildingImg> BuildingImgQueryWrapper = new QueryWrapper<>();
|
173
|
|
- BuildingImgQueryWrapper.eq("building_id", id);
|
174
|
|
- BuildingImgQueryWrapper.eq("img_type", "banner");
|
175
|
|
- List<TaBuildingImg> buildingImg = taBuildingImgMapper.selectList(BuildingImgQueryWrapper);
|
176
|
|
- building.setBuildingImg(buildingImg);
|
|
183
|
+ building.setBuildingImg(getBuildingImg(id, CommConstant.BUILDING_IMG_BANNER));
|
|
184
|
+
|
|
185
|
+ // 视频封面图
|
|
186
|
+ building.setVideoImage(getBuildingImg(building.getBuildingId(), CommConstant.BUILDING_IMG_VIDEOIMAGE));
|
177
|
187
|
|
178
|
188
|
// 查询tag
|
179
|
189
|
QueryWrapper<TaBuildingTag> BuildingTagQueryWrapper = new QueryWrapper<>();
|
|
@@ -250,6 +260,12 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
250
|
260
|
|
251
|
261
|
TaBuilding building = JSONObject.parseObject(parameter,TaBuilding.class);
|
252
|
262
|
|
|
263
|
+ // 先删除视频
|
|
264
|
+ UpdateWrapper<TaBuilding> updateWrapper = new UpdateWrapper<>();
|
|
265
|
+ updateWrapper.eq("building_id", building.getBuildingId());
|
|
266
|
+ updateWrapper.set("video_url", null);
|
|
267
|
+ this.update(updateWrapper);
|
|
268
|
+
|
253
|
269
|
//图片先删除再添加
|
254
|
270
|
String imgStr = object.getString("img");
|
255
|
271
|
List<TaBuildingImg> buildingImgs = JSONObject.parseArray(imgStr, TaBuildingImg.class);
|
|
@@ -261,7 +277,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
261
|
277
|
taBuildingMapper.update(building,buildingIdQueryWrapper);
|
262
|
278
|
QueryWrapper<TaBuildingImg> BuildingImgQueryWrapper = new QueryWrapper<>();
|
263
|
279
|
BuildingImgQueryWrapper.eq("building_id", building.getBuildingId());
|
264
|
|
- BuildingImgQueryWrapper.eq("img_type", "banner");
|
|
280
|
+ BuildingImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_BANNER);
|
265
|
281
|
taBuildingImgMapper.delete(BuildingImgQueryWrapper);
|
266
|
282
|
insertImgBatch(buildingImgs, building.getBuildingId());
|
267
|
283
|
}
|
|
@@ -272,11 +288,22 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
272
|
288
|
if (CollectionUtils.isNotEmpty(buildingListImg)) {
|
273
|
289
|
QueryWrapper<TaBuildingImg> BuildingListImgQueryWrapper = new QueryWrapper<>();
|
274
|
290
|
BuildingListImgQueryWrapper.eq("building_id", building.getBuildingId());
|
275
|
|
- BuildingListImgQueryWrapper.eq("img_type", "list");
|
|
291
|
+ BuildingListImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_LIST);
|
276
|
292
|
taBuildingImgMapper.delete(BuildingListImgQueryWrapper);
|
277
|
293
|
buildingListImg = insertImgBatch(buildingListImg, building.getBuildingId());
|
278
|
294
|
}
|
279
|
295
|
|
|
296
|
+ // 视频封面图
|
|
297
|
+ String videoImage = object.getString("videoImage");
|
|
298
|
+ List<TaBuildingImg> videoImageList = JSONObject.parseArray(videoImage, TaBuildingImg.class);
|
|
299
|
+ if (CollectionUtils.isNotEmpty(videoImageList)) {
|
|
300
|
+ QueryWrapper<TaBuildingImg> BuildingListImgQueryWrapper = new QueryWrapper<>();
|
|
301
|
+ BuildingListImgQueryWrapper.eq("building_id", building.getBuildingId());
|
|
302
|
+ BuildingListImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_VIDEOIMAGE);
|
|
303
|
+ taBuildingImgMapper.delete(BuildingListImgQueryWrapper);
|
|
304
|
+ videoImageList = insertImgBatch(videoImageList, building.getBuildingId());
|
|
305
|
+ }
|
|
306
|
+
|
280
|
307
|
|
281
|
308
|
// tag先删除再增加
|
282
|
309
|
String tagStr = object.getString("tag");
|
|
@@ -347,6 +374,13 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
347
|
374
|
buildingImgs = insertImgBatch(buildingImgs, building.getBuildingId());
|
348
|
375
|
}
|
349
|
376
|
|
|
377
|
+ // 视频封面图
|
|
378
|
+ String videoImage = object.getString("videoImage");
|
|
379
|
+ List<TaBuildingImg> videoImageList = JSONObject.parseArray(imgStr, TaBuildingImg.class);
|
|
380
|
+ if (CollectionUtils.isNotEmpty(videoImageList)) {
|
|
381
|
+ videoImageList = insertImgBatch(videoImageList, building.getBuildingId());
|
|
382
|
+ }
|
|
383
|
+
|
350
|
384
|
// 列表图
|
351
|
385
|
String listImg = object.getString("listImg");
|
352
|
386
|
List<TaBuildingImg> buildingListImg = JSONObject.parseArray(listImg, TaBuildingImg.class);
|
|
@@ -474,7 +508,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
474
|
508
|
for (TaApartmentImg apartmentImg:buildingImg){
|
475
|
509
|
QueryWrapper<TaBuildingImg> buildingImgQueryWrapper = new QueryWrapper<>();
|
476
|
510
|
buildingImgQueryWrapper.eq("img_id",apartmentImg.getImgId());
|
477
|
|
- buildingImgQueryWrapper.eq("img_type","aparment");
|
|
511
|
+ buildingImgQueryWrapper.eq("img_type",CommConstant.BUILDING_IMG_APARMENT);
|
478
|
512
|
List<TaBuildingImg> buildingImgList= taBuildingImgMapper.selectList(buildingImgQueryWrapper);
|
479
|
513
|
for (TaBuildingImg buImg:buildingImgList) {
|
480
|
514
|
arrayList.add(buImg);
|
|
@@ -532,11 +566,9 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
532
|
566
|
}
|
533
|
567
|
|
534
|
568
|
private void getBuildingAttaches(TaBuilding build) {
|
535
|
|
- QueryWrapper<TaBuildingImg> BuildingImgQueryWrapper = new QueryWrapper<>();
|
536
|
|
- BuildingImgQueryWrapper.eq("building_id", build.getBuildingId());
|
537
|
|
- BuildingImgQueryWrapper.eq("img_type", "banner");
|
538
|
|
- List<TaBuildingImg> buildingImg = taBuildingImgMapper.selectList(BuildingImgQueryWrapper);
|
539
|
|
- build.setBuildingImg(buildingImg);
|
|
569
|
+ build.setBuildingImg(getBuildingImg(build.getBuildingId(), CommConstant.BUILDING_IMG_BANNER));
|
|
570
|
+ build.setBuildingListImg(getBuildingImg(build.getBuildingId(), CommConstant.BUILDING_IMG_LIST));
|
|
571
|
+ build.setVideoImage(getBuildingImg(build.getBuildingId(), CommConstant.BUILDING_IMG_VIDEOIMAGE));
|
540
|
572
|
|
541
|
573
|
// QueryWrapper<Visit> BuildingVisitQueryWrapper = new QueryWrapper<>();
|
542
|
574
|
// BuildingVisitQueryWrapper.eq("visit_type", "building");
|
|
@@ -598,7 +630,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
598
|
630
|
// 楼盘Banner
|
599
|
631
|
QueryWrapper<TaBuildingImg> buildingImgBannerQueryWrapper = new QueryWrapper<>();
|
600
|
632
|
buildingImgBannerQueryWrapper.eq("building_id", building.getBuildingId());
|
601
|
|
- buildingImgBannerQueryWrapper.eq("img_type", "banner");
|
|
633
|
+ buildingImgBannerQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_BANNER);
|
602
|
634
|
buildingImgBannerQueryWrapper.orderBy(true, true, "order_no");
|
603
|
635
|
List<TaBuildingImg> buildingBannerImg = taBuildingImgMapper.selectList(buildingImgBannerQueryWrapper);
|
604
|
636
|
|
|
@@ -640,7 +672,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
640
|
672
|
List<TaBuildingImg> buildingImag = buildingImg.stream().map(img -> {
|
641
|
673
|
QueryWrapper<TaBuildingImg> buildingImgQueryWrapper = new QueryWrapper<>();
|
642
|
674
|
buildingImgQueryWrapper.eq("img_id", img.getImgId());
|
643
|
|
- buildingImgQueryWrapper.eq("img_type", "aparment");
|
|
675
|
+ buildingImgQueryWrapper.eq("img_type", CommConstant.BUILDING_IMG_APARMENT);
|
644
|
676
|
return taBuildingImgMapper.selectOne(buildingImgQueryWrapper);
|
645
|
677
|
}).collect(Collectors.toList());
|
646
|
678
|
|