Merge branch 'dev-csm-split-1126' of http://git.yoho.cn/platform/platform-cms in…
…to dev-csm-split-1126
Showing
17 changed files
with
378 additions
and
44 deletions
@@ -176,6 +176,22 @@ public class MakePromotionController { | @@ -176,6 +176,22 @@ public class MakePromotionController { | ||
176 | return responseBean; | 176 | return responseBean; |
177 | } | 177 | } |
178 | 178 | ||
179 | + @RequestMapping("/updateNotEffectMakePromotion") | ||
180 | + @ResponseBody | ||
181 | + public Integer updateNotEffectMakePromotion(MakePromotionReq makePromotionReq) { | ||
182 | + logger.info("enter updateNotEffectMakePromotion with param is {}", makePromotionReq); | ||
183 | + Integer updateResult = makePromotionService.updateNotEffectMakePromotion(makePromotionReq); | ||
184 | + return updateResult; | ||
185 | + } | ||
186 | + | ||
187 | + @RequestMapping("/addMakePromotion") | ||
188 | + @ResponseBody | ||
189 | + public Integer addMakePromotion(MakePromotionReq makePromotionReq) { | ||
190 | + logger.info("enter addMakePromotion with param is {}", makePromotionReq); | ||
191 | + Integer result = makePromotionService.addMakePromotion(makePromotionReq); | ||
192 | + return result; | ||
193 | + } | ||
194 | + | ||
179 | /** | 195 | /** |
180 | * 获取专区活动相关商品列表 | 196 | * 获取专区活动相关商品列表 |
181 | */ | 197 | */ |
@@ -63,7 +63,7 @@ public class SpecialController { | @@ -63,7 +63,7 @@ public class SpecialController { | ||
63 | * @return | 63 | * @return |
64 | */ | 64 | */ |
65 | // @RequestMapping(params = "method=getStyleListSel") | 65 | // @RequestMapping(params = "method=getStyleListSel") |
66 | - @RequestMapping(params = "/getStyleListSel") | 66 | + @RequestMapping("/getStyleListSel") |
67 | @ResponseBody | 67 | @ResponseBody |
68 | public JSONArray getStyleListSel(EnumTypeRequestBean enumTypeRequestBean) { | 68 | public JSONArray getStyleListSel(EnumTypeRequestBean enumTypeRequestBean) { |
69 | logger.info("begin getStyleListSel"); | 69 | logger.info("begin getStyleListSel"); |
1 | package com.yohobuy.platform.cms.restapi; | 1 | package com.yohobuy.platform.cms.restapi; |
2 | 2 | ||
3 | import com.yohobuy.platform.cms.service.VersionService; | 3 | import com.yohobuy.platform.cms.service.VersionService; |
4 | -import com.yohobuy.platform.common.page.PageRequest; | ||
5 | -import com.yohobuy.platform.model.cms.bo.AppVersionClientTypeBO; | ||
6 | -import com.yohobuy.platform.model.cms.bo.AppVersionEditPageBO; | ||
7 | -import com.yohobuy.platform.model.cms.bo.AppVersionIndexBo; | ||
8 | import com.yohobuy.platform.model.cms.bo.AppVersionWarningBo; | 4 | import com.yohobuy.platform.model.cms.bo.AppVersionWarningBo; |
9 | import com.yohobuy.platform.model.common.ApiResponse; | 5 | import com.yohobuy.platform.model.common.ApiResponse; |
10 | import com.yohobuy.platform.model.common.PageRequestBO; | 6 | import com.yohobuy.platform.model.common.PageRequestBO; |
@@ -17,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | @@ -17,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||
17 | import org.springframework.web.bind.annotation.ResponseBody; | 13 | import org.springframework.web.bind.annotation.ResponseBody; |
18 | import org.springframework.web.bind.annotation.RestController; | 14 | import org.springframework.web.bind.annotation.RestController; |
19 | 15 | ||
20 | -import java.util.List; | ||
21 | -import java.util.Map; | ||
22 | 16 | ||
23 | /** | 17 | /** |
24 | * APP版本 | 18 | * APP版本 |
@@ -1238,6 +1238,12 @@ public class ResourcesServiceImpl implements ResourcesService { | @@ -1238,6 +1238,12 @@ public class ResourcesServiceImpl implements ResourcesService { | ||
1238 | addressArray.add(addAddress("go.vipInfo","会员中心页")); | 1238 | addressArray.add(addAddress("go.vipInfo","会员中心页")); |
1239 | addressArray.add(addAddress("go.vipexclusivepro","会员专享列表")); | 1239 | addressArray.add(addAddress("go.vipexclusivepro","会员专享列表")); |
1240 | addressArray.add(addAddress("go.minealliance","联盟")); | 1240 | addressArray.add(addAddress("go.minealliance","联盟")); |
1241 | + addressArray.add(addAddress("go.miniapp", "跳转到小程序")); | ||
1242 | + addressArray.add(addAddress("go.collagehome", "拼团首页")); | ||
1243 | + addressArray.add(addAddress("go.switchchannel", "频道切换")); | ||
1244 | + addressArray.add(addAddress("go.mineredpackage", "我的红包")); | ||
1245 | + addressArray.add(addAddress("go.ufo", "UFO落地页")); | ||
1246 | + addressArray.add(addAddress("go.bargainlist", "砍价商品列表")); | ||
1241 | return addressArray; | 1247 | return addressArray; |
1242 | } | 1248 | } |
1243 | 1249 |
@@ -73,14 +73,35 @@ public class SpecialServiceImpl implements ISpecialService { | @@ -73,14 +73,35 @@ public class SpecialServiceImpl implements ISpecialService { | ||
73 | //头部Banner(上) | 73 | //头部Banner(上) |
74 | special.setBannerImg(ImagesHelper.getImageUrl(jsonObjectList.get(0).get("img").toString(), 480, 280, 0, ImagesConstant.BUCKET_ERP_COUPONIMG)); | 74 | special.setBannerImg(ImagesHelper.getImageUrl(jsonObjectList.get(0).get("img").toString(), 480, 280, 0, ImagesConstant.BUCKET_ERP_COUPONIMG)); |
75 | special.setHeight1(jsonObjectList.get(0).get("height").toString()); | 75 | special.setHeight1(jsonObjectList.get(0).get("height").toString()); |
76 | - if (jsonObjectList.size() > 1) { | ||
77 | - //头部Banner(下) | ||
78 | - special.setImg2(ImagesHelper.getImageUrl(jsonObjectList.get(1).get("img").toString(), 480, 280, 0, ImagesConstant.BUCKET_ERP_COUPONIMG)); | ||
79 | - special.setHeight2(jsonObjectList.get(1).get("height").toString()); | ||
80 | - } | ||
81 | - if (jsonObjectList.size() > 2) { | ||
82 | - //详情页图片 | ||
83 | - special.setImg3(ImagesHelper.getImageUrl(jsonObjectList.get(2).get("img").toString(), 480, 280, 0, ImagesConstant.BUCKET_ERP_COUPONIMG)); | 76 | + for (int j = 1; j < jsonObjectList.size(); j++) { |
77 | + if (jsonObjectList.get(j).containsKey("flag")) { | ||
78 | + String flag = jsonObjectList.get(j).getString("flag"); | ||
79 | + String img, height; | ||
80 | + if(jsonObjectList.get(j).containsKey("img")) { | ||
81 | + img = ImagesHelper.getImageUrl(jsonObjectList.get(j).get("img").toString(), 480, 280, 0, ImagesConstant.BUCKET_ERP_COUPONIMG); | ||
82 | + } else { | ||
83 | + img = ""; | ||
84 | + } | ||
85 | + if (jsonObjectList.get(j).containsKey("height")) { | ||
86 | + height = jsonObjectList.get(j).get("height").toString(); | ||
87 | + } else { | ||
88 | + height = ""; | ||
89 | + } | ||
90 | + //头部Banner(下) | ||
91 | + if(StringUtils.equals(flag, "head2")) { | ||
92 | + special.setImg2(img); | ||
93 | + special.setHeight2(height); | ||
94 | + } | ||
95 | + //app banner | ||
96 | + if(StringUtils.equals(flag, "appBanner")) { | ||
97 | + special.setImg4(img); | ||
98 | + special.setHeight4(height); | ||
99 | + } | ||
100 | + //详情页图片 | ||
101 | + if(StringUtils.equals(flag, "detail")) { | ||
102 | + special.setImg3(img); | ||
103 | + } | ||
104 | + } | ||
84 | } | 105 | } |
85 | } | 106 | } |
86 | // 专区对应商品数量 | 107 | // 专区对应商品数量 |
@@ -173,12 +194,22 @@ public class SpecialServiceImpl implements ISpecialService { | @@ -173,12 +194,22 @@ public class SpecialServiceImpl implements ISpecialService { | ||
173 | obj = new JSONObject(); | 194 | obj = new JSONObject(); |
174 | obj.put("img", ImagesHelper.getImageRelativeUrl(req.getImg2(), ImagesConstant.BUCKET_ERP_COUPONIMG)); | 195 | obj.put("img", ImagesHelper.getImageRelativeUrl(req.getImg2(), ImagesConstant.BUCKET_ERP_COUPONIMG)); |
175 | obj.put("height", req.getHeight2()); | 196 | obj.put("height", req.getHeight2()); |
197 | + obj.put("flag", "head2"); | ||
176 | jsonObjectList.add(obj); | 198 | jsonObjectList.add(obj); |
177 | } | 199 | } |
178 | //详情页图片 | 200 | //详情页图片 |
179 | if (StringUtils.isNotEmpty(req.getImg3())) { | 201 | if (StringUtils.isNotEmpty(req.getImg3())) { |
180 | obj = new JSONObject(); | 202 | obj = new JSONObject(); |
181 | obj.put("img", ImagesHelper.getImageRelativeUrl(req.getImg3(), ImagesConstant.BUCKET_ERP_COUPONIMG)); | 203 | obj.put("img", ImagesHelper.getImageRelativeUrl(req.getImg3(), ImagesConstant.BUCKET_ERP_COUPONIMG)); |
204 | + obj.put("flag", "detail"); | ||
205 | + jsonObjectList.add(obj); | ||
206 | + } | ||
207 | + //appBanner | ||
208 | + if (StringUtils.isNotEmpty(req.getImg4())) { | ||
209 | + obj = new JSONObject(); | ||
210 | + obj.put("img", ImagesHelper.getImageRelativeUrl(req.getImg4(), ImagesConstant.BUCKET_ERP_COUPONIMG)); | ||
211 | + obj.put("height", req.getHeight4()); | ||
212 | + obj.put("flag", "appBanner"); | ||
182 | jsonObjectList.add(obj); | 213 | jsonObjectList.add(obj); |
183 | } | 214 | } |
184 | // 转义 | 215 | // 转义 |
@@ -7,6 +7,7 @@ import com.yohobuy.platform.common.convert.Convert; | @@ -7,6 +7,7 @@ import com.yohobuy.platform.common.convert.Convert; | ||
7 | import com.yohobuy.platform.common.error.ErrorCode; | 7 | import com.yohobuy.platform.common.error.ErrorCode; |
8 | import com.yohobuy.platform.common.exception.PlatformException; | 8 | import com.yohobuy.platform.common.exception.PlatformException; |
9 | import com.yohobuy.platform.common.util.IntegerUtils; | 9 | import com.yohobuy.platform.common.util.IntegerUtils; |
10 | +import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorDetailMapper; | ||
10 | import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorDetail; | 11 | import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorDetail; |
11 | import com.yohobuy.platform.model.operations.ActivtyTemplatedFloorBo; | 12 | import com.yohobuy.platform.model.operations.ActivtyTemplatedFloorBo; |
12 | import com.yohobuy.platform.model.operations.ActivtyTemplatedFloorDetailBo; | 13 | import com.yohobuy.platform.model.operations.ActivtyTemplatedFloorDetailBo; |
@@ -18,6 +19,7 @@ import org.apache.commons.collections.CollectionUtils; | @@ -18,6 +19,7 @@ import org.apache.commons.collections.CollectionUtils; | ||
18 | import org.apache.commons.lang3.StringUtils; | 19 | import org.apache.commons.lang3.StringUtils; |
19 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
20 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
22 | +import org.springframework.beans.factory.annotation.Autowired; | ||
21 | 23 | ||
22 | import java.util.List; | 24 | import java.util.List; |
23 | import java.util.Set; | 25 | import java.util.Set; |
@@ -30,7 +32,7 @@ public final class ActivityTemplatedFloorDetailHelper { | @@ -30,7 +32,7 @@ public final class ActivityTemplatedFloorDetailHelper { | ||
30 | private static Logger logger = LoggerFactory.getLogger(ActivityTemplatedFloorDetailHelper.class); | 32 | private static Logger logger = LoggerFactory.getLogger(ActivityTemplatedFloorDetailHelper.class); |
31 | 33 | ||
32 | public static Set<Integer> paramTypeIntSet = Sets.newHashSet(TempCompParamType.number.getIntVal(), | 34 | public static Set<Integer> paramTypeIntSet = Sets.newHashSet(TempCompParamType.number.getIntVal(), |
33 | - TempCompParamType.string.getIntVal(),TempCompParamType.image.getIntVal()); | 35 | + TempCompParamType.string.getIntVal(),TempCompParamType.image.getIntVal(),TempCompParamType.date.getIntVal()); |
34 | 36 | ||
35 | 37 | ||
36 | private static final Convert convert = new BeanConvert(); | 38 | private static final Convert convert = new BeanConvert(); |
@@ -266,8 +268,7 @@ public final class ActivityTemplatedFloorDetailHelper { | @@ -266,8 +268,7 @@ public final class ActivityTemplatedFloorDetailHelper { | ||
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
269 | - | ||
270 | - private static void MergeWithComp(ActivtyTemplatedFloorDetailBo floorDetailBo, | 271 | + public static void MergeWithComp(ActivtyTemplatedFloorDetailBo floorDetailBo, |
271 | int atId,int floorId,int level, | 272 | int atId,int floorId,int level, |
272 | TemplatedComponentBo componentBo){ | 273 | TemplatedComponentBo componentBo){ |
273 | 274 | ||
@@ -280,7 +281,7 @@ public final class ActivityTemplatedFloorDetailHelper { | @@ -280,7 +281,7 @@ public final class ActivityTemplatedFloorDetailHelper { | ||
280 | floorDetailBo.setLevel(level); | 281 | floorDetailBo.setLevel(level); |
281 | } | 282 | } |
282 | 283 | ||
283 | - private static void MergeWithComponentParam(ActivtyTemplatedFloorDetailBo floorDetailBo,TemplatedComponentParamBo paramBo){ | 284 | + public static void MergeWithComponentParam(ActivtyTemplatedFloorDetailBo floorDetailBo,TemplatedComponentParamBo paramBo){ |
284 | 285 | ||
285 | floorDetailBo.setParamType(paramBo.getType()); | 286 | floorDetailBo.setParamType(paramBo.getType()); |
286 | floorDetailBo.setParamId(paramBo.getId()); | 287 | floorDetailBo.setParamId(paramBo.getId()); |
@@ -8,12 +8,16 @@ import com.yohobuy.platform.model.common.api.OperationName; | @@ -8,12 +8,16 @@ import com.yohobuy.platform.model.common.api.OperationName; | ||
8 | import com.yohobuy.platform.model.operations.ActivtyTemplatedBo; | 8 | import com.yohobuy.platform.model.operations.ActivtyTemplatedBo; |
9 | import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo; | 9 | import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo; |
10 | import com.yohobuy.platform.operations.service.impl.ActivtyTemplatedService; | 10 | import com.yohobuy.platform.operations.service.impl.ActivtyTemplatedService; |
11 | +import com.yohobuy.platform.operations.util.HttpUtil; | ||
12 | +import org.apache.commons.lang3.StringUtils; | ||
11 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
12 | import org.slf4j.LoggerFactory; | 14 | import org.slf4j.LoggerFactory; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Controller; | 16 | import org.springframework.stereotype.Controller; |
17 | +import org.springframework.web.bind.annotation.CrossOrigin; | ||
15 | import org.springframework.web.bind.annotation.RequestBody; | 18 | import org.springframework.web.bind.annotation.RequestBody; |
16 | import org.springframework.web.bind.annotation.RequestMapping; | 19 | import org.springframework.web.bind.annotation.RequestMapping; |
20 | +import org.springframework.web.bind.annotation.RequestParam; | ||
17 | import org.springframework.web.bind.annotation.ResponseBody; | 21 | import org.springframework.web.bind.annotation.ResponseBody; |
18 | 22 | ||
19 | import java.util.List; | 23 | import java.util.List; |
@@ -73,7 +77,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -73,7 +77,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
73 | 77 | ||
74 | @RequestMapping(value = "/getActivtyTemplated") | 78 | @RequestMapping(value = "/getActivtyTemplated") |
75 | @ResponseBody | 79 | @ResponseBody |
76 | - public ApiResponse getActivtyTemplated(Integer id){ | 80 | + public ApiResponse getActivtyTemplated(@RequestParam("id") Integer id){ |
77 | logger.info("ActivtyTemplatedController.getActivtyTemplated id {}",id); | 81 | logger.info("ActivtyTemplatedController.getActivtyTemplated id {}",id); |
78 | if (id == null){ | 82 | if (id == null){ |
79 | return handleParamIsNull(); | 83 | return handleParamIsNull(); |
@@ -89,7 +93,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -89,7 +93,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
89 | 93 | ||
90 | @RequestMapping(value = "/getActivtyTemplatedBaseInfo") | 94 | @RequestMapping(value = "/getActivtyTemplatedBaseInfo") |
91 | @ResponseBody | 95 | @ResponseBody |
92 | - public ApiResponse getActivtyTemplatedBaseInfo(Integer id){ | 96 | + public ApiResponse getActivtyTemplatedBaseInfo(@RequestParam("id") Integer id){ |
93 | logger.info("ActivtyTemplatedController.getActivtyTemplatedBaseInfo id {}",id); | 97 | logger.info("ActivtyTemplatedController.getActivtyTemplatedBaseInfo id {}",id); |
94 | if (id == null){ | 98 | if (id == null){ |
95 | return handleParamIsNull(); | 99 | return handleParamIsNull(); |
@@ -144,7 +148,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -144,7 +148,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
144 | 148 | ||
145 | @RequestMapping(value = "/deleteActivtyTemplated") | 149 | @RequestMapping(value = "/deleteActivtyTemplated") |
146 | @ResponseBody | 150 | @ResponseBody |
147 | - public ApiResponse deleteActivtyTemplated(Integer id){ | 151 | + public ApiResponse deleteActivtyTemplated(@RequestParam("id") Integer id){ |
148 | if (id == null){ | 152 | if (id == null){ |
149 | return handleParamIsNull(); | 153 | return handleParamIsNull(); |
150 | } | 154 | } |
@@ -158,7 +162,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -158,7 +162,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
158 | 162 | ||
159 | @RequestMapping(value = "/resumeActivtyTemplated") | 163 | @RequestMapping(value = "/resumeActivtyTemplated") |
160 | @ResponseBody | 164 | @ResponseBody |
161 | - public ApiResponse resumeActivtyTemplated(Integer id){ | 165 | + public ApiResponse resumeActivtyTemplated(@RequestParam("id") Integer id){ |
162 | if (id == null){ | 166 | if (id == null){ |
163 | return handleParamIsNull(); | 167 | return handleParamIsNull(); |
164 | } | 168 | } |
@@ -187,7 +191,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -187,7 +191,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
187 | 191 | ||
188 | @RequestMapping(value = "/open") | 192 | @RequestMapping(value = "/open") |
189 | @ResponseBody | 193 | @ResponseBody |
190 | - public ApiResponse open(Integer id){ | 194 | + public ApiResponse open(@RequestParam("id") Integer id){ |
191 | logger.info("ActivtyTemplatedController.open id {}",id); | 195 | logger.info("ActivtyTemplatedController.open id {}",id); |
192 | if (id == null){ | 196 | if (id == null){ |
193 | return handleParamIsNull(); | 197 | return handleParamIsNull(); |
@@ -203,7 +207,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -203,7 +207,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
203 | 207 | ||
204 | @RequestMapping(value = "/close") | 208 | @RequestMapping(value = "/close") |
205 | @ResponseBody | 209 | @ResponseBody |
206 | - public ApiResponse close(Integer id){ | 210 | + public ApiResponse close(@RequestParam("id") Integer id){ |
207 | logger.info("ActivtyTemplatedController.close id {}",id); | 211 | logger.info("ActivtyTemplatedController.close id {}",id); |
208 | if (id == null){ | 212 | if (id == null){ |
209 | return handleParamIsNull(); | 213 | return handleParamIsNull(); |
@@ -219,7 +223,7 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -219,7 +223,7 @@ public class ActivtyTemplatedController extends BasicController{ | ||
219 | 223 | ||
220 | @RequestMapping(value = "/clone") | 224 | @RequestMapping(value = "/clone") |
221 | @ResponseBody | 225 | @ResponseBody |
222 | - public ApiResponse clone(Integer id){ | 226 | + public ApiResponse clone(@RequestParam("id") Integer id){ |
223 | logger.info("ActivtyTemplatedController.clone id {}",id); | 227 | logger.info("ActivtyTemplatedController.clone id {}",id); |
224 | if (id == null){ | 228 | if (id == null){ |
225 | return handleParamIsNull(); | 229 | return handleParamIsNull(); |
@@ -250,4 +254,32 @@ public class ActivtyTemplatedController extends BasicController{ | @@ -250,4 +254,32 @@ public class ActivtyTemplatedController extends BasicController{ | ||
250 | .build(); | 254 | .build(); |
251 | } | 255 | } |
252 | 256 | ||
257 | + @RequestMapping(value = "/checkUrl") | ||
258 | + @ResponseBody | ||
259 | + public ApiResponse checkUrl(@RequestParam("url") String url){ | ||
260 | + boolean result = true; | ||
261 | + try{ | ||
262 | + logger.info("in checkUrl, url {}", url); | ||
263 | + if (StringUtils.isBlank(url)){ | ||
264 | + return new ApiResponse(FAIL, Message.buildApiMessage("URL","检查", Message.FAIL)); | ||
265 | + } | ||
266 | + HttpUtil.doGet(url); | ||
267 | + }catch (Exception e){ | ||
268 | + logger.warn("in checkUrl, occur error", e); | ||
269 | + result = false; | ||
270 | + } | ||
271 | + return new ApiResponse.ApiResponseBuilder() | ||
272 | + .code(SUCCESS) | ||
273 | + .data(result) | ||
274 | + .message(Message.buildApiMessage("URL","检查", Message.SUCCESS)) | ||
275 | + .build(); | ||
276 | + } | ||
277 | + | ||
278 | + | ||
279 | + @RequestMapping(value = "/layout") | ||
280 | + @CrossOrigin(origins="*", maxAge = 3600) | ||
281 | + public String layout(Integer id, Integer shareid){ | ||
282 | + | ||
283 | + return "redirect:/html/activeModule/layout.html?id=" + id + "&shareid=" + shareid; | ||
284 | + } | ||
253 | } | 285 | } |
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; | @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.stereotype.Controller; | 11 | import org.springframework.stereotype.Controller; |
12 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
13 | +import org.springframework.web.bind.annotation.RequestParam; | ||
13 | import org.springframework.web.bind.annotation.ResponseBody; | 14 | import org.springframework.web.bind.annotation.ResponseBody; |
14 | 15 | ||
15 | import com.yohobuy.platform.model.common.ApiResponse; | 16 | import com.yohobuy.platform.model.common.ApiResponse; |
@@ -58,7 +59,7 @@ public class ConsultController { | @@ -58,7 +59,7 @@ public class ConsultController { | ||
58 | */ | 59 | */ |
59 | @RequestMapping("/batchDel") | 60 | @RequestMapping("/batchDel") |
60 | @ResponseBody | 61 | @ResponseBody |
61 | - public ApiResponse batchDel(String id) { | 62 | + public ApiResponse batchDel(@RequestParam("id")String id) { |
62 | try { | 63 | try { |
63 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.batchDel(id)).build(); | 64 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.batchDel(id)).build(); |
64 | } catch (ServiceException e) { | 65 | } catch (ServiceException e) { |
@@ -74,7 +75,7 @@ public class ConsultController { | @@ -74,7 +75,7 @@ public class ConsultController { | ||
74 | */ | 75 | */ |
75 | @RequestMapping("/delByUid") | 76 | @RequestMapping("/delByUid") |
76 | @ResponseBody | 77 | @ResponseBody |
77 | - public ApiResponse delByUid(String uid) { | 78 | + public ApiResponse delByUid(@RequestParam("uid") String uid) { |
78 | try { | 79 | try { |
79 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.delByUid(uid)).build(); | 80 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.delByUid(uid)).build(); |
80 | } catch (ServiceException e) { | 81 | } catch (ServiceException e) { |
@@ -90,7 +91,7 @@ public class ConsultController { | @@ -90,7 +91,7 @@ public class ConsultController { | ||
90 | */ | 91 | */ |
91 | @RequestMapping("/del") | 92 | @RequestMapping("/del") |
92 | @ResponseBody | 93 | @ResponseBody |
93 | - public ApiResponse del(String id) { | 94 | + public ApiResponse del(@RequestParam("id") String id) { |
94 | try { | 95 | try { |
95 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.del(id)).build(); | 96 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.del(id)).build(); |
96 | } catch (ServiceException e) { | 97 | } catch (ServiceException e) { |
@@ -106,7 +107,7 @@ public class ConsultController { | @@ -106,7 +107,7 @@ public class ConsultController { | ||
106 | */ | 107 | */ |
107 | @RequestMapping("/restore") | 108 | @RequestMapping("/restore") |
108 | @ResponseBody | 109 | @ResponseBody |
109 | - public ApiResponse restore(String id) { | 110 | + public ApiResponse restore(@RequestParam("id") String id) { |
110 | try { | 111 | try { |
111 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.restore(id)).build(); | 112 | return new ApiResponse.ApiResponseBuilder().code(200).message("success").data(consultService.restore(id)).build(); |
112 | } catch (ServiceException e) { | 113 | } catch (ServiceException e) { |
1 | package com.yohobuy.platform.operations.service; | 1 | package com.yohobuy.platform.operations.service; |
2 | 2 | ||
3 | 3 | ||
4 | -import com.yoho.service.model.request.AreaReqBO; | ||
5 | -import com.yoho.service.model.response.AreaRspBo; | 4 | +import com.yohobuy.platform.model.operations.request.AreaReqBO; |
5 | +import com.yohobuy.platform.model.operations.AreaRspBo; | ||
6 | 6 | ||
7 | import java.util.List; | 7 | import java.util.List; |
8 | 8 |
@@ -93,6 +93,28 @@ public class ActivtyTemplatedFloorDetailService implements BaseService<ActivtyTe | @@ -93,6 +93,28 @@ public class ActivtyTemplatedFloorDetailService implements BaseService<ActivtyTe | ||
93 | } | 93 | } |
94 | 94 | ||
95 | /** | 95 | /** |
96 | + * 新加方法 不需要递归组件 忽略组件中套组件 | ||
97 | + * @param atfdList | ||
98 | + * @return | ||
99 | + */ | ||
100 | + public void insertDetailBatch(List<ActivtyTemplatedFloorDetailBo> atfdList){ | ||
101 | + List<ActivtyTemplatedFloorDetail> commonDetails = Lists.newArrayList(); | ||
102 | + for(ActivtyTemplatedFloorDetailBo detailBo : atfdList) { | ||
103 | + if (!IntegerUtils.withInBizSign(detailBo.getParamType())) { | ||
104 | + continue; | ||
105 | + } | ||
106 | + if (ActivityTemplatedFloorDetailHelper.paramTypeIntSet.contains(detailBo.getParamType())){ | ||
107 | + ActivtyTemplatedFloorDetail param = convert.convertFrom(detailBo,new ActivtyTemplatedFloorDetail(),ActivtyTemplatedFloorDetail.class); | ||
108 | + ActivityTemplatedFloorDetailHelper.fillStautsOfSingle(FloorDetailStatus.open,param); | ||
109 | + commonDetails.add(param); | ||
110 | + } | ||
111 | + } | ||
112 | + if (CollectionUtils.isNotEmpty(commonDetails)){ | ||
113 | + atfdMapper.insertBatch(commonDetails); | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
96 | * 跳开老数据,老数据有id | 118 | * 跳开老数据,老数据有id |
97 | * @param atfdList | 119 | * @param atfdList |
98 | * @return | 120 | * @return |
1 | package com.yohobuy.platform.operations.service.impl; | 1 | package com.yohobuy.platform.operations.service.impl; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | +import com.google.common.collect.Lists; | ||
4 | import com.yohobuy.platform.common.convert.BeanConvert; | 5 | import com.yohobuy.platform.common.convert.BeanConvert; |
5 | import com.yohobuy.platform.common.convert.Convert; | 6 | import com.yohobuy.platform.common.convert.Convert; |
6 | import com.yohobuy.platform.common.error.ErrorCode; | 7 | import com.yohobuy.platform.common.error.ErrorCode; |
@@ -10,24 +11,31 @@ import com.yohobuy.platform.common.util.DateUtil; | @@ -10,24 +11,31 @@ import com.yohobuy.platform.common.util.DateUtil; | ||
10 | import com.yohobuy.platform.common.util.IntegerUtils; | 11 | import com.yohobuy.platform.common.util.IntegerUtils; |
11 | import com.yohobuy.platform.dal.cms.IWebShareDao; | 12 | import com.yohobuy.platform.dal.cms.IWebShareDao; |
12 | import com.yohobuy.platform.dal.cms.model.WebShare; | 13 | import com.yohobuy.platform.dal.cms.model.WebShare; |
14 | +import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorDetailMapper; | ||
13 | import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorMapper; | 15 | import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorMapper; |
16 | +import com.yohobuy.platform.dal.operations.ActivtyTemplatedFloorTableMapper; | ||
14 | import com.yohobuy.platform.dal.operations.ActivtyTemplatedMapper; | 17 | import com.yohobuy.platform.dal.operations.ActivtyTemplatedMapper; |
15 | import com.yohobuy.platform.dal.operations.model.ActivtyTemplated; | 18 | import com.yohobuy.platform.dal.operations.model.ActivtyTemplated; |
16 | import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloor; | 19 | import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloor; |
20 | +import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorDetail; | ||
21 | +import com.yohobuy.platform.dal.operations.model.ActivtyTemplatedFloorTable; | ||
17 | import com.yohobuy.platform.model.cms.bo.WebShareBO; | 22 | import com.yohobuy.platform.model.cms.bo.WebShareBO; |
18 | import com.yohobuy.platform.model.common.CheckResult; | 23 | import com.yohobuy.platform.model.common.CheckResult; |
19 | import com.yohobuy.platform.model.common.PageResponseVO; | 24 | import com.yohobuy.platform.model.common.PageResponseVO; |
20 | -import com.yohobuy.platform.model.operations.ActivtyTemplatedBo; | ||
21 | -import com.yohobuy.platform.model.operations.ActivtyTemplatedFloorBo; | 25 | +import com.yohobuy.platform.model.operations.*; |
22 | import com.yohobuy.platform.model.operations.consistant.ActivtyTemplatedStatus; | 26 | import com.yohobuy.platform.model.operations.consistant.ActivtyTemplatedStatus; |
27 | +import com.yohobuy.platform.model.operations.consistant.FloorDetailStatus; | ||
23 | import com.yohobuy.platform.model.operations.consistant.LogActionType; | 28 | import com.yohobuy.platform.model.operations.consistant.LogActionType; |
29 | +import com.yohobuy.platform.model.operations.consistant.TempCompParamType; | ||
24 | import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo; | 30 | import com.yohobuy.platform.model.operations.request.ActivityTemplatedPageBo; |
25 | import com.yohobuy.platform.model.users.response.UserInfoResponseBO; | 31 | import com.yohobuy.platform.model.users.response.UserInfoResponseBO; |
26 | import com.yohobuy.platform.common.helper.mvc.LogInUserHelper; | 32 | import com.yohobuy.platform.common.helper.mvc.LogInUserHelper; |
27 | import com.yohobuy.platform.operations.constants.CommonStatus; | 33 | import com.yohobuy.platform.operations.constants.CommonStatus; |
28 | import com.yohobuy.platform.operations.constants.LayoutStatus; | 34 | import com.yohobuy.platform.operations.constants.LayoutStatus; |
29 | import com.yohobuy.platform.operations.convert.ActivtyTemplatedConvert; | 35 | import com.yohobuy.platform.operations.convert.ActivtyTemplatedConvert; |
36 | +import com.yohobuy.platform.operations.convert.ActivtyTemplatedFloorConvert; | ||
30 | import com.yohobuy.platform.operations.helper.ActTempFloorHelper; | 37 | import com.yohobuy.platform.operations.helper.ActTempFloorHelper; |
38 | +import com.yohobuy.platform.operations.helper.ActivityTemplatedFloorDetailHelper; | ||
31 | import com.yohobuy.platform.operations.service.check.ActivtyTemplatedCheckService; | 39 | import com.yohobuy.platform.operations.service.check.ActivtyTemplatedCheckService; |
32 | import com.yohobuy.platform.operations.service.check.WebShareCheckService; | 40 | import com.yohobuy.platform.operations.service.check.WebShareCheckService; |
33 | import org.apache.commons.collections.CollectionUtils; | 41 | import org.apache.commons.collections.CollectionUtils; |
@@ -70,6 +78,12 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> | @@ -70,6 +78,12 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> | ||
70 | @Autowired | 78 | @Autowired |
71 | private ActivtyTemplatedFloorMapper atfMapper; | 79 | private ActivtyTemplatedFloorMapper atfMapper; |
72 | 80 | ||
81 | + @Autowired | ||
82 | + private ActivtyTemplatedFloorTableMapper atftMapper; | ||
83 | + | ||
84 | + @Autowired | ||
85 | + private ActivtyTemplatedFloorDetailMapper atfdMapper; | ||
86 | + | ||
73 | private static Convert convert = new BeanConvert(); | 87 | private static Convert convert = new BeanConvert(); |
74 | 88 | ||
75 | @Value("${activity.url:http://activity.yoho.cn/feature/}") | 89 | @Value("${activity.url:http://activity.yoho.cn/feature/}") |
@@ -231,13 +245,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> | @@ -231,13 +245,14 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> | ||
231 | if(!otherInfoCR.isValidateResult()){ | 245 | if(!otherInfoCR.isValidateResult()){ |
232 | throw new PlatformException(otherInfoCR.getErrorMsg().getErrorMsg(), ErrorCode.req_param_illegal); | 246 | throw new PlatformException(otherInfoCR.getErrorMsg().getErrorMsg(), ErrorCode.req_param_illegal); |
233 | } | 247 | } |
234 | - int result = doUpdate(bo); | 248 | + upateActivityTemplate(bo); |
249 | +// int result = doUpdate(bo); | ||
250 | +// | ||
251 | +// if (result > 0) { | ||
252 | +// logService.recordLog(bo.getId(), LogActionType.update, JSON.toJSONString(bo)); | ||
253 | +// } | ||
254 | + return 1; | ||
235 | 255 | ||
236 | - if (result > 0) { | ||
237 | - logService.recordLog(bo.getId(), LogActionType.update, JSON.toJSONString(bo)); | ||
238 | - } | ||
239 | - | ||
240 | - return result; | ||
241 | } | 256 | } |
242 | 257 | ||
243 | @Override | 258 | @Override |
@@ -380,6 +395,123 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> | @@ -380,6 +395,123 @@ public class ActivtyTemplatedService implements BaseService<ActivtyTemplatedBo> | ||
380 | return true; | 395 | return true; |
381 | } | 396 | } |
382 | 397 | ||
398 | + private void upateActivityTemplate(ActivtyTemplatedBo bo) throws PlatformException{ | ||
399 | + if (!isExists(bo.getId())){ | ||
400 | + logger.error("{}.doUpdate ,can not query record,bo.id {}",getClass().getSimpleName(),bo.getId()); | ||
401 | + return; | ||
402 | + } | ||
403 | + //1.修改活动主表activty_templated的相关值 | ||
404 | + ActivtyTemplated activtyTemplated= ActivtyTemplatedConvert.bo2Do(bo); | ||
405 | + activtyTemplated.setIsDel(0); | ||
406 | + activtyTemplated.setUpdateTime(DateUtil.getCurrentTimeSeconds()); | ||
407 | + activtyTemplated.setUpdateUser(this.buildOperatorInfo()); | ||
408 | + activtyTemplatedMapper.updateByPrimaryKeySelective(activtyTemplated); | ||
409 | + //2.根据模板ID依次删除除主表外其他表的相关数据,activty_templated_floor,activty_templated_floor_detail,activty_templated_floor_table | ||
410 | + atfMapper.deleteByTempId(bo.getId()); | ||
411 | + atftMapper.deleteByTempId(bo.getId()); | ||
412 | + atfdMapper.deleteByTempId(bo.getId()); | ||
413 | + | ||
414 | + //3.依次将相关数据插入以上相关表中 | ||
415 | + List<ActivtyTemplatedFloor> atfList = Lists.newArrayList(); | ||
416 | + List<ActivtyTemplatedFloorTable> atftList = Lists.newArrayList(); | ||
417 | + for(ActivtyTemplatedFloorBo floorBo: bo.getFloors()){ | ||
418 | + //处理activty_templated_floor表数据 | ||
419 | + ActivtyTemplatedFloor atf = ActivtyTemplatedFloorConvert.bo2Do(floorBo); | ||
420 | + atf.setActivtyTemplatedId(bo.getId()); | ||
421 | + //activty_templated_floor表数据入库 | ||
422 | + atfMapper.insertSelective(atf); | ||
423 | + //处理activty_templated_floor_table表数据 | ||
424 | + if (StringUtils.isNotBlank(floorBo.getTableComp())){ | ||
425 | + ActivtyTemplatedFloorTable table = new ActivtyTemplatedFloorTable(); | ||
426 | + table.setStatus(1); | ||
427 | + table.setActivtyTemplatedId(bo.getId()); | ||
428 | + table.setFloorId(atf.getId()); | ||
429 | + table.setTableComp(floorBo.getTableComp()); | ||
430 | + atftList.add(table); | ||
431 | + } | ||
432 | + //处理activty_templated_floor_detail表数据并入库 | ||
433 | + floorBo.setId(atf.getId()); | ||
434 | + List<ActivtyTemplatedFloorDetail> atfdp = Lists.newArrayList(); | ||
435 | + if (CollectionUtils.isNotEmpty(floorBo.getParams())) { | ||
436 | + atfdp = ActivityTemplatedFloorDetailHelper.buildDetailsOfFloor(bo.getId(), FloorDetailStatus.open.getIntVal(), floorBo); | ||
437 | + } | ||
438 | + if (CollectionUtils.isNotEmpty(atfdp)){ | ||
439 | + atfdMapper.insertBatch(atfdp); | ||
440 | + } | ||
441 | + List<ActivtyTemplatedFloorDetailBo> atfdc = Lists.newArrayList(); | ||
442 | + if (CollectionUtils.isNotEmpty(floorBo.getComponents())){ | ||
443 | + atfdc = buildDetailBo(bo.getId(), floorBo.getId(), floorBo.getComponents()); | ||
444 | + } | ||
445 | + if (CollectionUtils.isNotEmpty(atfdc)){ | ||
446 | + atfdService.insertDetailBatch(atfdc); | ||
447 | + } | ||
448 | + } | ||
449 | + //activty_templated_floor_table表数据批量入库 | ||
450 | + if (CollectionUtils.isNotEmpty(atftList)){ | ||
451 | + atftMapper.insertBatch(atftList); | ||
452 | + } | ||
453 | + } | ||
454 | + | ||
455 | + /** | ||
456 | + * 新加方法 不需要递归组件 忽略组件中套组件 | ||
457 | + * @param atId | ||
458 | + * @param floorId | ||
459 | + * @param components | ||
460 | + * @return | ||
461 | + * @throws PlatformException | ||
462 | + */ | ||
463 | + public List<ActivtyTemplatedFloorDetailBo> buildDetailBo(int atId,int floorId, List<TemplatedComponentBo> components) throws PlatformException { | ||
464 | + List<ActivtyTemplatedFloorDetailBo> result = Lists.newArrayList(); | ||
465 | + | ||
466 | + for(TemplatedComponentBo componentBo: components){ | ||
467 | + result.addAll(buidDetailBoFromComponent(atId, floorId, componentBo)); | ||
468 | + } | ||
469 | + return result; | ||
470 | + } | ||
471 | + | ||
472 | + /** | ||
473 | + * 新加方法 不需要递归组件 忽略组件中套组件 | ||
474 | + * @param atId | ||
475 | + * @param floorId | ||
476 | + * @param componentBo | ||
477 | + * @return | ||
478 | + */ | ||
479 | + public List<ActivtyTemplatedFloorDetailBo> buidDetailBoFromComponent(int atId, int floorId, TemplatedComponentBo componentBo){ | ||
480 | + List<ActivtyTemplatedFloorDetailBo> result = Lists.newArrayList(); | ||
481 | + List<TemplatedComponentParamBo> params = componentBo.getParams(); | ||
482 | + if(CollectionUtils.isNotEmpty(params)) { | ||
483 | + for (TemplatedComponentParamBo paramBo : params) { | ||
484 | + ActivtyTemplatedFloorDetailBo floorDetailBo = new ActivtyTemplatedFloorDetailBo(); | ||
485 | + ActivityTemplatedFloorDetailHelper.MergeWithComponentParam(floorDetailBo,paramBo); | ||
486 | + ActivityTemplatedFloorDetailHelper.MergeWithComp(floorDetailBo,atId,floorId,0,componentBo); | ||
487 | + if(ActivityTemplatedFloorDetailHelper.paramTypeIntSet.contains(paramBo.getType())){ | ||
488 | + result.add(floorDetailBo); | ||
489 | + }else if (TempCompParamType.component.getIntVal() == paramBo.getType()){ | ||
490 | + ActivtyTemplatedFloorDetail param = convert.convertFrom(floorDetailBo,new ActivtyTemplatedFloorDetail(),ActivtyTemplatedFloorDetail.class); | ||
491 | + ActivityTemplatedFloorDetailHelper.fillStautsOfSingle(FloorDetailStatus.open,param); | ||
492 | + atfdMapper.insertSelective(param); | ||
493 | + List<TemplatedComponentBo> components = componentBo.getComponents(); | ||
494 | + for (TemplatedComponentBo tcp : components){ | ||
495 | + List<ActivtyTemplatedFloorDetailBo> childAtfd = Lists.newArrayList(); | ||
496 | + List<TemplatedComponentParamBo> tcpb = tcp.getParams(); | ||
497 | + if (CollectionUtils.isNotEmpty(tcpb)){ | ||
498 | + for (TemplatedComponentParamBo tp : tcpb){ | ||
499 | + ActivtyTemplatedFloorDetailBo fdb = new ActivtyTemplatedFloorDetailBo(); | ||
500 | + ActivityTemplatedFloorDetailHelper.MergeWithComponentParam(fdb,tp); | ||
501 | + ActivityTemplatedFloorDetailHelper.MergeWithComp(fdb,atId,floorId,0,tcp); | ||
502 | + fdb.setPid(param.getId()); | ||
503 | + childAtfd.add(fdb); | ||
504 | + } | ||
505 | + } | ||
506 | + atfdService.insertDetailBatch(childAtfd); | ||
507 | + } | ||
508 | + | ||
509 | + } | ||
510 | + } | ||
511 | + } | ||
512 | + return result; | ||
513 | + } | ||
514 | + | ||
383 | private int doUpdate(ActivtyTemplatedBo bo) throws PlatformException { | 515 | private int doUpdate(ActivtyTemplatedBo bo) throws PlatformException { |
384 | 516 | ||
385 | //activity templated main body, update one | 517 | //activity templated main body, update one |
1 | package com.yohobuy.platform.operations.service.impl; | 1 | package com.yohobuy.platform.operations.service.impl; |
2 | 2 | ||
3 | -import com.yoho.service.model.request.AreaReqBO; | ||
4 | -import com.yoho.service.model.response.AreaRspBo; | 3 | +import com.yohobuy.platform.model.operations.request.AreaReqBO; |
4 | +import com.yohobuy.platform.model.operations.AreaRspBo; | ||
5 | import com.yohobuy.platform.dal.users.IAreaNewDao; | 5 | import com.yohobuy.platform.dal.users.IAreaNewDao; |
6 | import com.yohobuy.platform.dal.users.model.AreaNew; | 6 | import com.yohobuy.platform.dal.users.model.AreaNew; |
7 | import com.yohobuy.platform.operations.service.IAreaService; | 7 | import com.yohobuy.platform.operations.service.IAreaService; |
@@ -170,9 +170,9 @@ public class ImageCheckServiceImpl implements ImageCheckService { | @@ -170,9 +170,9 @@ public class ImageCheckServiceImpl implements ImageCheckService { | ||
170 | } | 170 | } |
171 | String fileMode = finalStr.substring(15, 17); | 171 | String fileMode = finalStr.substring(15, 17); |
172 | if(fileMode.equals("01")) { | 172 | if(fileMode.equals("01")) { |
173 | - newBucket ="yhb-img-01"; | 173 | + newBucket ="yhb-img01"; |
174 | }else if (fileMode.equals("02")){ | 174 | }else if (fileMode.equals("02")){ |
175 | - newBucket ="yhb-img-02"; | 175 | + newBucket ="yhb-img02"; |
176 | } | 176 | } |
177 | }else { | 177 | }else { |
178 | newBucket = request.getBucket(); | 178 | newBucket = request.getBucket(); |
1 | package com.yohobuy.platform.operations.util; | 1 | package com.yohobuy.platform.operations.util; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | +import org.apache.http.HttpEntity; | ||
5 | +import org.apache.http.HttpResponse; | ||
6 | +import org.apache.http.client.HttpClient; | ||
7 | +import org.apache.http.client.methods.HttpGet; | ||
8 | +import org.apache.http.conn.ClientConnectionManager; | ||
9 | +import org.apache.http.conn.scheme.Scheme; | ||
10 | +import org.apache.http.conn.scheme.SchemeRegistry; | ||
11 | +import org.apache.http.conn.ssl.SSLSocketFactory; | ||
12 | +import org.apache.http.impl.client.DefaultHttpClient; | ||
13 | +import org.apache.http.util.EntityUtils; | ||
14 | +import org.slf4j.Logger; | ||
15 | +import org.slf4j.LoggerFactory; | ||
4 | import org.springframework.web.multipart.MultipartFile; | 16 | import org.springframework.web.multipart.MultipartFile; |
5 | 17 | ||
6 | import javax.activation.MimetypesFileTypeMap; | 18 | import javax.activation.MimetypesFileTypeMap; |
19 | +import javax.net.ssl.SSLContext; | ||
20 | +import javax.net.ssl.TrustManager; | ||
21 | +import javax.net.ssl.X509TrustManager; | ||
7 | import java.io.*; | 22 | import java.io.*; |
8 | import java.net.HttpURLConnection; | 23 | import java.net.HttpURLConnection; |
9 | import java.net.URL; | 24 | import java.net.URL; |
10 | import java.security.KeyManagementException; | 25 | import java.security.KeyManagementException; |
11 | import java.security.NoSuchAlgorithmException; | 26 | import java.security.NoSuchAlgorithmException; |
12 | import java.security.NoSuchProviderException; | 27 | import java.security.NoSuchProviderException; |
28 | +import java.security.cert.CertificateException; | ||
29 | +import java.security.cert.X509Certificate; | ||
13 | 30 | ||
14 | /** | 31 | /** |
15 | * Created by zhouxiang on 2017/2/8. | 32 | * Created by zhouxiang on 2017/2/8. |
16 | */ | 33 | */ |
17 | public class HttpUtil { | 34 | public class HttpUtil { |
18 | 35 | ||
36 | + private final static Logger logger = LoggerFactory.getLogger(HttpUtil.class); | ||
37 | + | ||
19 | /** | 38 | /** |
20 | * 上传素材 | 39 | * 上传素材 |
21 | * @param path | 40 | * @param path |
@@ -98,4 +117,72 @@ public class HttpUtil { | @@ -98,4 +117,72 @@ public class HttpUtil { | ||
98 | return result; | 117 | return result; |
99 | } | 118 | } |
100 | 119 | ||
120 | + public static HttpResponse doGet(String url) throws Exception { | ||
121 | + logger.debug("in HttpUtil.doGet url {}", url); | ||
122 | + HttpResponse result= null; | ||
123 | + Exception exception = null; | ||
124 | + try { | ||
125 | + | ||
126 | + HttpClient httpclient = new DefaultHttpClient(); | ||
127 | + //Secure Protocol implementation. | ||
128 | + SSLContext ctx = SSLContext.getInstance("SSL"); | ||
129 | + //Implementation of a trust manager for X509 certificates | ||
130 | + X509TrustManager tm = new X509TrustManager() { | ||
131 | + | ||
132 | + public void checkClientTrusted(X509Certificate[] xcs, | ||
133 | + String string) throws CertificateException { | ||
134 | + | ||
135 | + } | ||
136 | + | ||
137 | + public void checkServerTrusted(X509Certificate[] xcs, | ||
138 | + String string) throws CertificateException { | ||
139 | + } | ||
140 | + | ||
141 | + public X509Certificate[] getAcceptedIssuers() { | ||
142 | + return null; | ||
143 | + } | ||
144 | + }; | ||
145 | + ctx.init(null, new TrustManager[] { tm }, null); | ||
146 | + SSLSocketFactory ssf = new SSLSocketFactory(ctx); | ||
147 | + | ||
148 | + ClientConnectionManager ccm = httpclient.getConnectionManager(); | ||
149 | + //register https protocol in httpclient's scheme registry | ||
150 | + SchemeRegistry sr = ccm.getSchemeRegistry(); | ||
151 | + sr.register(new Scheme("https", 443, ssf)); | ||
152 | + | ||
153 | + HttpGet httpget = new HttpGet(url); | ||
154 | + | ||
155 | + | ||
156 | + httpget.setHeader("accept", "*/*"); | ||
157 | + httpget.setHeader("connection", "Keep-Alive"); | ||
158 | + httpget.setHeader("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); | ||
159 | + result = httpclient.execute(httpget); | ||
160 | + | ||
161 | + try { | ||
162 | + HttpEntity entity = result.getEntity(); | ||
163 | + String content = EntityUtils.toString(entity); | ||
164 | + logger.info("ContentLength {}", entity.getContentLength()); | ||
165 | + EntityUtils.consume(entity); | ||
166 | + } catch (Exception e) { | ||
167 | + exception = e; | ||
168 | + } finally { | ||
169 | + httpclient.getConnectionManager().shutdown(); | ||
170 | + } | ||
171 | + | ||
172 | + } catch (NoSuchAlgorithmException e) { | ||
173 | + exception = e; | ||
174 | + logger.warn("in doGet , occur NoSuchAlgorithmException"); | ||
175 | + } catch (Exception ex) { | ||
176 | + exception = ex; | ||
177 | + logger.warn("in doGet , occur other Exception"); | ||
178 | + }finally { | ||
179 | + if (exception != null){ | ||
180 | + throw exception; | ||
181 | + } | ||
182 | + | ||
183 | + return result; | ||
184 | + } | ||
185 | + | ||
186 | + | ||
187 | + } | ||
101 | } | 188 | } |
@@ -27,6 +27,15 @@ search.server.address=http://192.168.102.216:8080/yohosearch/ | @@ -27,6 +27,15 @@ search.server.address=http://192.168.102.216:8080/yohosearch/ | ||
27 | # qiniu config | 27 | # qiniu config |
28 | qiniu.accesskey=atSf7xxIl8alEnsXbhC1bOD1GWVW3qYffz8SlB4m | 28 | qiniu.accesskey=atSf7xxIl8alEnsXbhC1bOD1GWVW3qYffz8SlB4m |
29 | qiniu.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm | 29 | qiniu.secretkey=pyoJzPygXIkFWrc1BAsH6tAJ0yweTchpJwGKEwhm |
30 | + | ||
31 | +qiniu.accesskey.cmsimg01=BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU | ||
32 | +qiniu.secretkey.cmsimg01=_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK | ||
33 | + | ||
34 | +qiniu.accesskey.yohomars=cY9B5ZgON_7McTS5zV5nTeRyQ98MOcVD7W4eGVbE | ||
35 | +qiniu.secretkey.yohomars=RduqgmK7cAtaQvdIa1ax_zzmMsnv9ac-Ka0uF6wG | ||
36 | + | ||
37 | +qiniu.accesskey.yohoimimgs=EJhU5jwtkfMm3k5RTeOCH9_jc0A0o-mIfD3Iba5J | ||
38 | +qiniu.secretkey.yohoimimgs=qAns6jrf9pg6bHNvS1IcKi-pnVBWV46pbpFWKwJ7 | ||
30 | #who add this item? whatever, it's used | 39 | #who add this item? whatever, it's used |
31 | qiniu.bucket=test | 40 | qiniu.bucket=test |
32 | 41 |
@@ -416,6 +416,7 @@ datasources: | @@ -416,6 +416,7 @@ datasources: | ||
416 | - com.yohobuy.platform.dal.users.YohoCoinActivityDao | 416 | - com.yohobuy.platform.dal.users.YohoCoinActivityDao |
417 | - com.yohobuy.platform.dal.users.IPermitLoginUser | 417 | - com.yohobuy.platform.dal.users.IPermitLoginUser |
418 | - com.yohobuy.platform.dal.product.RecommendSknMapper | 418 | - com.yohobuy.platform.dal.product.RecommendSknMapper |
419 | + - com.yohobuy.platform.dal.users.IAreaNewDao | ||
419 | 420 | ||
420 | yh_community: | 421 | yh_community: |
421 | servers: | 422 | servers: |
@@ -417,6 +417,8 @@ datasources: | @@ -417,6 +417,8 @@ datasources: | ||
417 | - com.yohobuy.platform.dal.users.YohoCoinActivityDao | 417 | - com.yohobuy.platform.dal.users.YohoCoinActivityDao |
418 | - com.yohobuy.platform.dal.users.IPermitLoginUser | 418 | - com.yohobuy.platform.dal.users.IPermitLoginUser |
419 | - com.yohobuy.platform.dal.product.RecommendSknMapper | 419 | - com.yohobuy.platform.dal.product.RecommendSknMapper |
420 | + - com.yohobuy.platform.dal.users.IAreaNewDao | ||
421 | + | ||
420 | 422 | ||
421 | yh_community: | 423 | yh_community: |
422 | servers: | 424 | servers: |
-
Please register or login to post a comment