コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 5.16 获取我收藏的问题列表
  *
  * @param param
  * @param request
  * @return
  */
 @ResponseBody
 @RequestMapping("/getMyCollectQuestion")
 public String getMyCollectQuestion(@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 sid = (String) map.get("sid");
     System.out.println(sid);
     String p_size = (String) map.get("p_size");
     System.out.println(p_size);
     if (sid.trim() == null || "".equals(sid.trim())) {
       sid = "1,10";
     }
     if (p_size.trim() == null || "".equals(p_size.trim())) {
       p_size = "10";
     }
     //			String info = JsonHandler.objectToJson(null);
     //			System.out.println(info);
     backInfo =
         HttpClientUtils.getToken(
             UrlUtil.URL + "/api/my-favorite-answers?sid=" + sid + "&p_size=" + p_size,
             null,
             token);
     System.out.println(backInfo);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return backInfo;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
 /**
  * 5.10 获取我的回答列表
  *
  * @param param
  * @param request
  * @return
  */
 @ResponseBody
 @RequestMapping("/getMyAnswerList")
 public String getMyAnswerList(@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 sid = (String) map.get("sid");
     System.out.println(sid);
     String status = (String) map.get("status");
     System.out.println(status);
     String p_size = (String) map.get("p_size");
     System.out.println(p_size);
     if (sid.trim() == null || "".equals(sid.trim())) {
       sid = "1";
     }
     if (p_size.trim() == null || "".equals(p_size.trim())) {
       p_size = "10";
     }
     if (status.trim() == null || "".equals(status.trim())) {
       status = "all";
     }
     backInfo =
         HttpClientUtils.getToken(
             UrlUtil.URL
                 + "/api/my-answers?sid="
                 + sid
                 + "&p_size="
                 + p_size
                 + "&status="
                 + status,
             null,
             token);
     System.out.println(backInfo);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return backInfo;
 }
コード例 #5
0
 /**
  * 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;
 }