|
@@ -15,14 +15,17 @@ import org.springframework.stereotype.Service; |
|
@@ -15,14 +15,17 @@ import org.springframework.stereotype.Service; |
15
|
import com.google.common.collect.Lists;
|
15
|
import com.google.common.collect.Lists;
|
16
|
import com.yoho.ufo.dal.BrandMapper;
|
16
|
import com.yoho.ufo.dal.BrandMapper;
|
17
|
import com.yoho.ufo.dal.SizePoolDetailMapper;
|
17
|
import com.yoho.ufo.dal.SizePoolDetailMapper;
|
|
|
18
|
+import com.yoho.ufo.dal.SizePoolImageMapper;
|
18
|
import com.yoho.ufo.dal.SizePoolMapper;
|
19
|
import com.yoho.ufo.dal.SizePoolMapper;
|
19
|
import com.yoho.ufo.dal.model.SizePool;
|
20
|
import com.yoho.ufo.dal.model.SizePool;
|
20
|
import com.yoho.ufo.dal.model.SizePoolDetail;
|
21
|
import com.yoho.ufo.dal.model.SizePoolDetail;
|
|
|
22
|
+import com.yoho.ufo.dal.model.SizePoolImage;
|
21
|
import com.yoho.ufo.exception.PlatformException;
|
23
|
import com.yoho.ufo.exception.PlatformException;
|
22
|
import com.yoho.ufo.model.brand.Brand;
|
24
|
import com.yoho.ufo.model.brand.Brand;
|
23
|
import com.yoho.ufo.service.ISizePoolService;
|
25
|
import com.yoho.ufo.service.ISizePoolService;
|
24
|
import com.yoho.ufo.service.model.PageResponseBO;
|
26
|
import com.yoho.ufo.service.model.PageResponseBO;
|
25
|
import com.yoho.ufo.util.DateUtil;
|
27
|
import com.yoho.ufo.util.DateUtil;
|
|
|
28
|
+import com.yohobuy.ufo.model.request.size.SizePoolImageBo;
|
26
|
import com.yohobuy.ufo.model.request.size.SizePoolRequest;
|
29
|
import com.yohobuy.ufo.model.request.size.SizePoolRequest;
|
27
|
import com.yohobuy.ufo.model.request.size.SizePoolResp;
|
30
|
import com.yohobuy.ufo.model.request.size.SizePoolResp;
|
28
|
|
31
|
|
|
@@ -54,6 +57,9 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -54,6 +57,9 @@ public class SizePoolService implements ISizePoolService{ |
54
|
|
57
|
|
55
|
@Autowired
|
58
|
@Autowired
|
56
|
private BrandMapper brandMapper;
|
59
|
private BrandMapper brandMapper;
|
|
|
60
|
+
|
|
|
61
|
+ @Autowired
|
|
|
62
|
+ private SizePoolImageMapper sizePoolImageMapper;
|
57
|
|
63
|
|
58
|
@Override
|
64
|
@Override
|
59
|
public int addSizePool(SizePoolRequest bo) throws PlatformException {
|
65
|
public int addSizePool(SizePoolRequest bo) throws PlatformException {
|
|
@@ -68,9 +74,9 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -68,9 +74,9 @@ public class SizePoolService implements ISizePoolService{ |
68
|
SizePool sizePool = new SizePool();
|
74
|
SizePool sizePool = new SizePool();
|
69
|
sizePool.setStatus(STATUS_OPEN);//默认开启
|
75
|
sizePool.setStatus(STATUS_OPEN);//默认开启
|
70
|
sizePool.setRangeType(bo.getRangeType());
|
76
|
sizePool.setRangeType(bo.getRangeType());
|
71
|
- sizePool.setImageUrl(bo.getImageUrl());
|
|
|
72
|
- sizePool.setImageWidth(bo.getImageWidth());
|
|
|
73
|
- sizePool.setImageHeight(bo.getImageHeight());
|
77
|
+ sizePool.setImageUrl(bo.getImageInfoList().get(0).getImageUrl());
|
|
|
78
|
+ sizePool.setImageWidth(bo.getImageInfoList().get(0).getImageWidth());
|
|
|
79
|
+ sizePool.setImageHeight(bo.getImageInfoList().get(0).getImageHeight());
|
74
|
sizePool.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
80
|
sizePool.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
75
|
sizePool.setUpdateUid(new UserHelper().getUserId());
|
81
|
sizePool.setUpdateUid(new UserHelper().getUserId());
|
76
|
|
82
|
|
|
@@ -79,10 +85,26 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -79,10 +85,26 @@ public class SizePoolService implements ISizePoolService{ |
79
|
return result;
|
85
|
return result;
|
80
|
}
|
86
|
}
|
81
|
|
87
|
|
|
|
88
|
+ saveSizePoolImage(bo.getImageInfoList(), sizePool.getId());
|
|
|
89
|
+
|
82
|
return batchAddSizePoolDetail(sizePool.getId(), bo);
|
90
|
return batchAddSizePoolDetail(sizePool.getId(), bo);
|
83
|
|
91
|
|
84
|
}
|
92
|
}
|
85
|
|
93
|
|
|
|
94
|
+ private void saveSizePoolImage(List<SizePoolImageBo> imageInfoList, Integer sizePoolId) {
|
|
|
95
|
+ List<SizePoolImage> list = Lists.newArrayList();
|
|
|
96
|
+ for(SizePoolImageBo item : imageInfoList) {
|
|
|
97
|
+ SizePoolImage image = new SizePoolImage();
|
|
|
98
|
+ image.setId(sizePoolId);
|
|
|
99
|
+ image.setImageUrl(item.getImageUrl());
|
|
|
100
|
+ image.setImageWidth(item.getImageWidth());
|
|
|
101
|
+ image.setImageHeight(item.getImageHeight());
|
|
|
102
|
+ list.add(image);
|
|
|
103
|
+ }
|
|
|
104
|
+
|
|
|
105
|
+ sizePoolImageMapper.batchInsert(list);
|
|
|
106
|
+ }
|
|
|
107
|
+
|
86
|
@Override
|
108
|
@Override
|
87
|
public int updateSizePool(SizePoolRequest bo) throws PlatformException {
|
109
|
public int updateSizePool(SizePoolRequest bo) throws PlatformException {
|
88
|
Optional<SizePoolRequest> poolOptional = Optional.ofNullable(bo);
|
110
|
Optional<SizePoolRequest> poolOptional = Optional.ofNullable(bo);
|
|
@@ -95,9 +117,9 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -95,9 +117,9 @@ public class SizePoolService implements ISizePoolService{ |
95
|
|
117
|
|
96
|
SizePool sizePool = new SizePool();
|
118
|
SizePool sizePool = new SizePool();
|
97
|
sizePool.setId(bo.getId());
|
119
|
sizePool.setId(bo.getId());
|
98
|
- sizePool.setImageUrl(bo.getImageUrl());
|
|
|
99
|
- sizePool.setImageWidth(bo.getImageWidth());
|
|
|
100
|
- sizePool.setImageHeight(bo.getImageHeight());
|
120
|
+ sizePool.setImageUrl(bo.getImageInfoList().get(0).getImageUrl());
|
|
|
121
|
+ sizePool.setImageWidth(bo.getImageInfoList().get(0).getImageWidth());
|
|
|
122
|
+ sizePool.setImageHeight(bo.getImageInfoList().get(0).getImageHeight());
|
101
|
sizePool.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
123
|
sizePool.setUpdateTime(DateUtil.getCurrentTimeSeconds());
|
102
|
sizePool.setUpdateUid(new UserHelper().getUserId());
|
124
|
sizePool.setUpdateUid(new UserHelper().getUserId());
|
103
|
|
125
|
|
|
@@ -125,14 +147,28 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -125,14 +147,28 @@ public class SizePoolService implements ISizePoolService{ |
125
|
}
|
147
|
}
|
126
|
|
148
|
|
127
|
List<SizePoolDetail> list = sizePoolDetailMapper.queryBySizePoolId(sizePoolId);
|
149
|
List<SizePoolDetail> list = sizePoolDetailMapper.queryBySizePoolId(sizePoolId);
|
|
|
150
|
+ List<SizePoolImage> imageList = sizePoolImageMapper.queryBySizePoolId(sizePoolId);
|
128
|
SizePoolResp resp = new SizePoolResp();
|
151
|
SizePoolResp resp = new SizePoolResp();
|
129
|
resp.setId(sizePoolId);
|
152
|
resp.setId(sizePoolId);
|
130
|
resp.setRangeType(sizePool.getRangeType());
|
153
|
resp.setRangeType(sizePool.getRangeType());
|
131
|
- resp.setImageUrl(sizePool.getImageUrl());
|
154
|
+ buildImageResp(resp, imageList);
|
132
|
buildResp(resp, list);
|
155
|
buildResp(resp, list);
|
133
|
return resp;
|
156
|
return resp;
|
134
|
}
|
157
|
}
|
135
|
|
158
|
|
|
|
159
|
+ private void buildImageResp(SizePoolResp resp, List<SizePoolImage> imageList) {
|
|
|
160
|
+ List<SizePoolImageBo> list = Lists.newArrayList();
|
|
|
161
|
+ for(SizePoolImage item : imageList) {
|
|
|
162
|
+ SizePoolImageBo image = new SizePoolImageBo();
|
|
|
163
|
+ image.setImageUrl(item.getImageUrl());
|
|
|
164
|
+ image.setImageWidth(item.getImageWidth());
|
|
|
165
|
+ image.setImageHeight(item.getImageHeight());
|
|
|
166
|
+ list.add(image);
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ resp.setImageInfoList(list);
|
|
|
170
|
+ }
|
|
|
171
|
+
|
136
|
@Override
|
172
|
@Override
|
137
|
public int deleteSizePool(Integer sizePoolId) throws PlatformException{
|
173
|
public int deleteSizePool(Integer sizePoolId) throws PlatformException{
|
138
|
if(null == sizePoolId){
|
174
|
if(null == sizePoolId){
|
|
@@ -147,6 +183,7 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -147,6 +183,7 @@ public class SizePoolService implements ISizePoolService{ |
147
|
|
183
|
|
148
|
int result = sizePoolDetailMapper.deleteBySizePoolId(sizePoolId);
|
184
|
int result = sizePoolDetailMapper.deleteBySizePoolId(sizePoolId);
|
149
|
if(result > 0) {
|
185
|
if(result > 0) {
|
|
|
186
|
+ sizePoolImageMapper.deleteBySizePoolId(sizePoolId);
|
150
|
return sizePoolMapper.deleteByPrimaryKey(sizePoolId);
|
187
|
return sizePoolMapper.deleteByPrimaryKey(sizePoolId);
|
151
|
}else {
|
188
|
}else {
|
152
|
return 0;
|
189
|
return 0;
|
|
@@ -166,6 +203,8 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -166,6 +203,8 @@ public class SizePoolService implements ISizePoolService{ |
166
|
List<Integer> poolIdList = list.stream().map(SizePool::getId).collect(Collectors.toList());
|
203
|
List<Integer> poolIdList = list.stream().map(SizePool::getId).collect(Collectors.toList());
|
167
|
List<SizePoolDetail> detailList = sizePoolDetailMapper.queryBySizePoolIds(poolIdList);
|
204
|
List<SizePoolDetail> detailList = sizePoolDetailMapper.queryBySizePoolIds(poolIdList);
|
168
|
Map<Integer, List<SizePoolDetail>> poolIdMap = detailList.stream().collect(Collectors.groupingBy(SizePoolDetail::getSizePoolId));
|
205
|
Map<Integer, List<SizePoolDetail>> poolIdMap = detailList.stream().collect(Collectors.groupingBy(SizePoolDetail::getSizePoolId));
|
|
|
206
|
+ List<SizePoolImage> imageList = sizePoolImageMapper.queryBySizePoolIds(poolIdList);
|
|
|
207
|
+ Map<Integer, List<SizePoolImage>> poolIdImageMap = imageList.stream().collect(Collectors.groupingBy(SizePoolImage::getSizePoolId));
|
169
|
List<SizePoolResp> respList = Lists.newArrayList();
|
208
|
List<SizePoolResp> respList = Lists.newArrayList();
|
170
|
for(SizePool pool : list) {
|
209
|
for(SizePool pool : list) {
|
171
|
SizePoolResp resp = new SizePoolResp();
|
210
|
SizePoolResp resp = new SizePoolResp();
|
|
@@ -173,7 +212,7 @@ public class SizePoolService implements ISizePoolService{ |
|
@@ -173,7 +212,7 @@ public class SizePoolService implements ISizePoolService{ |
173
|
resp.setStatus(pool.getStatus());
|
212
|
resp.setStatus(pool.getStatus());
|
174
|
resp.setStatusStr(getStatusStr(pool.getStatus()));
|
213
|
resp.setStatusStr(getStatusStr(pool.getStatus()));
|
175
|
resp.setRangeTypeStr(getRangeTypeStr(pool.getRangeType()));
|
214
|
resp.setRangeTypeStr(getRangeTypeStr(pool.getRangeType()));
|
176
|
- resp.setImageUrl(pool.getImageUrl());
|
215
|
+ buildImageResp(resp, poolIdImageMap.get(pool.getId()));
|
177
|
List<SizePoolDetail> itemList = poolIdMap.get(pool.getId());
|
216
|
List<SizePoolDetail> itemList = poolIdMap.get(pool.getId());
|
178
|
if(CollectionUtils.isNotEmpty(itemList)) {
|
217
|
if(CollectionUtils.isNotEmpty(itemList)) {
|
179
|
if(pool.getRangeType().equals(RANGE_TYPE_BRAND)) {
|
218
|
if(pool.getRangeType().equals(RANGE_TYPE_BRAND)) {
|