/** * 5.13 修改问题 * * @param param * @param request * @return */ @ResponseBody @RequestMapping("/changeQuestion") public String changeQuestion(@RequestBody String param, HttpServletRequest request) { System.out.println(param); String backInfo = ""; try { Map<String, Object> map = JsonHandler.json2Map(param); System.out.println(map); String questionId = (String) map.get("questionId"); System.out.println(questionId); map.remove("questionId"); System.out.println(map); Map<String, Object> mapHead = JsonHandler.json2MapHead(param); System.out.println(mapHead); String token = (String) mapHead.get("X-AUTH-TOKEN"); System.out.println(token); String info = JsonHandler.objectToJson(map); System.out.println(info); backInfo = HttpClientUtils.httpPostToken(UrlUtil.URL + "/api/question/" + questionId, info, token); System.out.println(backInfo); } catch (Exception e) { e.printStackTrace(); } return backInfo; }
/** * 5.19 取消收藏 * * @param param * @param request * @return */ @ResponseBody @RequestMapping("/removeAnswer") public String removeAnswer(@RequestBody String param, HttpServletRequest request) { System.out.println(param); String backInfo = ""; try { Map<String, Object> map = JsonHandler.json2Map(param); System.out.println(map); String answerId = (String) map.get("answerId"); System.out.println(answerId); Map<String, Object> mapHead = JsonHandler.json2MapHead(param); System.out.println(mapHead); String token = (String) mapHead.get("X-AUTH-TOKEN"); System.out.println(token); String info = JsonHandler.objectToJson(map); System.out.println(info); backInfo = HttpClientUtils.httpDelete( UrlUtil.URL + "/api/qa/answer/favorite/" + answerId, null, token); System.out.println(backInfo); } catch (Exception e) { e.printStackTrace(); } return backInfo; }
/** * 5.8 点赞或者取消点赞 * * @param param * @param request * @return */ @ResponseBody @RequestMapping("/getPraise") public String getPraise(@RequestBody String param, HttpServletRequest request) { System.out.println(param); String backInfo = ""; try { Map<String, Object> map = JsonHandler.json2Map(param); System.out.println(map); Map<String, Object> mapHead = JsonHandler.json2MapHead(param); System.out.println(mapHead); String token = (String) mapHead.get("X-AUTH-TOKEN"); System.out.println(token); String info = JsonHandler.objectToJson(map); System.out.println(info); backInfo = HttpClientUtils.httpPostToken(UrlUtil.URL + "/api/qa/answer/rank", info, token); System.out.println(backInfo); } catch (Exception e) { e.printStackTrace(); } return backInfo; }