Пример #1
0
 @RequestMapping("replyList")
 @ResponseBody
 public String replyList(String uid, String params) {
   Result result = null;
   try {
     JSONObject jsonObject = JSON.parseObject(params);
     Integer pageNum = jsonObject.getInteger("pageNum");
     Integer newsId = jsonObject.getInteger("cofId");
     if (newsId != null) {
       List<COFReplyVO> replyList = cofService.getReplyListByNewsId(newsId, pageNum);
       result = Result.getSuccessResult();
       Map<String, Object> map = Maps.newHashMap();
       if (replyList != null) {
         map.put("size", replyList.size());
         map.put("replyList", replyList);
       } else {
         map.put("size", 0);
         map.put("replyList", null);
       }
       result.setRe(map);
     } else {
       result = new Result(EEchoCode.ERROR.getCode(), "读取失败,动态ID不能为空");
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "读取失败,未找到相关的回复");
     }
   }
   return ResultUtil.getJsonString(result);
 }
Пример #2
0
 @RequestMapping("newsList")
 @ResponseBody
 public String newsList(String uid, String params) {
   Result result = null;
   try {
     JSONObject jsonObject = JSON.parseObject(params);
     Integer pageNum = jsonObject.getInteger("pageNum");
     Member member = memberService.getMemberByUID(uid);
     List<CofNewsVO> newsList = cofService.getCofNewsList(pageNum, member.getId());
     result = Result.getSuccessResult();
     Map<String, Object> map = Maps.newHashMap();
     if (newsList != null) {
       map.put("size", newsList.size());
       map.put("newsList", newsList);
     } else {
       map.put("size", 0);
       map.put("newsList", null);
     }
     result.setRe(map);
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "读取失败,未找到相关的新鲜事");
     }
   }
   return ResultUtil.getJsonString(result);
 }
Пример #3
0
 @RequestMapping("search")
 @ResponseBody
 public String searchNews(String uid, String params) {
   Result result = null;
   try {
     JSONObject jsonObject = JSON.parseObject(params);
     Integer pageNum = jsonObject.getInteger("pageNum");
     String keyword = jsonObject.getString("keyword");
     if (StringUtils.isNotEmpty(keyword)) {
       List<CofNewsVO> newsList = cofService.searchNews(pageNum, keyword);
       result = Result.getSuccessResult();
       Map<String, Object> map = Maps.newHashMap();
       if (newsList != null) {
         map.put("size", newsList.size());
         map.put("newsList", newsList);
       } else {
         map.put("size", 0);
         map.put("newsList", null);
       }
       result.setRe(map);
     } else {
       result = new Result(EEchoCode.ERROR.getCode(), "请输入查询关键字");
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "读取失败,未找到相关的新鲜事");
     }
   }
   return ResultUtil.getJsonString(result);
 }
Пример #4
0
 @RequestMapping("shareNews")
 @ResponseBody
 public String shareNews(String uid, String params) {
   Result result = null;
   try {
     JSONObject jsonObject = JSON.parseObject(params);
     Integer newsId = jsonObject.getInteger("cofId");
     Member member = memberService.getMemberByUID(uid);
     if (newsId != null && member != null) {
       COFAffiliatedInfo affiliatedInfo = new COFAffiliatedInfo();
       affiliatedInfo.setCofId(newsId);
       affiliatedInfo.setType(EAffiliatedType.SHARE.getCode());
       affiliatedInfo.setMemberId(member.getId());
       cofService.addCofAffiliated(affiliatedInfo);
       result = Result.getSuccessResult();
     } else {
       result = new Result(EEchoCode.ERROR.getCode(), "缺少动态ID");
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "系统异常");
     }
   }
   return ResultUtil.getJsonString(result);
 }
Пример #5
0
 @RequestMapping("getNewsInfo")
 @ResponseBody
 public String getNewsInfo(String uid, String params) {
   Result result = null;
   try {
     JSONObject jsonObject = JSON.parseObject(params);
     Integer newsId = jsonObject.getInteger("cofId");
     if (newsId != null) {
       CofNewsVO cofNewsVO = cofService.getNewsInfoById(newsId);
       result = Result.getSuccessResult();
       result.setRe(cofNewsVO);
     } else {
       result = new Result(EEchoCode.ERROR.getCode(), "缺少动态ID");
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "系统异常");
     }
   }
   return ResultUtil.getJsonString(result);
 }
Пример #6
0
 @RequestMapping("reply")
 @ResponseBody
 public String reply(String uid, String params) {
   Result result = null;
   try {
     COFReply reply = JSON.parseObject(params, COFReply.class);
     Member member = memberService.getMemberByUID(uid);
     if (reply != null && member != null && StringUtils.isNotEmpty(reply.getMessage())) {
       reply.setMemberId(member.getId());
       cofService.addReply(reply);
       result = Result.getSuccessResult();
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "信息不全,回复失败!");
     }
   }
   return ResultUtil.getJsonString(result);
 }
Пример #7
0
 @RequestMapping("addNews")
 @ResponseBody
 public String addNews(String uid, String params) {
   Result result = null;
   try {
     CircleOfFriends cof = JSON.parseObject(params, CircleOfFriends.class);
     Member member = memberService.getMemberByUID(uid);
     if (cof != null && member != null && StringUtils.isNotEmpty(cof.getContent())) {
       cof.setMemberId(member.getId());
       cofService.addNews(cof);
       result = Result.getSuccessResult();
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   } finally {
     if (result == null) {
       result = new Result(EEchoCode.ERROR.getCode(), "信息不全,发布失败!");
     }
   }
   return ResultUtil.getJsonString(result);
 }