Authored by 胡古飞

fix

package com.yoho.search.consumer.restapi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -17,54 +19,73 @@ public class ForbiddenPageIdsController {
@Autowired
private ForbiddenPageIdsLogicService forbiddenPageIdsLogicService;
@Autowired
private BigDataRedisOper<?,?> bigDataRedisOper;
private BigDataRedisOper<?, ?> bigDataRedisOper;
@RequestMapping(value = "/reloadForbiddenPageIds")
@ResponseBody
public Map<String, Object> reloadForbiddenPageIds() {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", forbiddenPageIdsLogicService.reloadForbiddenPageIds());
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@ResponseBody
public Map<String, Object> reloadForbiddenPageIds() {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", forbiddenPageIdsLogicService.reloadForbiddenPageIds());
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@RequestMapping(value = "/getPageIdForbiddenSkns")
@ResponseBody
public Map<String, Object> reloadForbiddenPageIds(@RequestParam(required=false,defaultValue="2") String pageId) {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", forbiddenPageIdsLogicService.getPageIdForbiddenSkns(pageId));
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@ResponseBody
public Map<String, Object> getPageIdForbiddenSkns(@RequestParam(required = false, defaultValue = "2") String pageId) {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", forbiddenPageIdsLogicService.getPageIdForbiddenSkns(pageId));
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@RequestMapping(value = "/existPageIdForbiddenSkns")
@ResponseBody
public Map<String, Object> existPageIdForbiddenSkns(@RequestParam(required = false, defaultValue = "2") String pageId, @RequestParam String productSkn) {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
List<String> skns = forbiddenPageIdsLogicService.getPageIdForbiddenSkns(pageId);
if(skns==null){
skns = new ArrayList<String>();
}
testResult.put("data",skns.contains(productSkn));
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@RequestMapping(value = "/testRecomListDataid")
@ResponseBody
public Map<String, Object> testRecomListDataid() {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", bigDataRedisOper.getValue("recom_list_dataid"));
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
@ResponseBody
public Map<String, Object> testRecomListDataid() {
Map<String, Object> testResult = new HashMap<String, Object>();
try {
testResult.put("data", bigDataRedisOper.getValue("recom_list_dataid"));
testResult.put("code", 200);
testResult.put("message", "success");
} catch (Exception e) {
e.printStackTrace();
testResult.put("code", 400);
testResult.put("message", e.getMessage());
}
return testResult;
}
}
... ...