Esempio n. 1
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);
 }
Esempio n. 2
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);
 }
Esempio n. 3
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);
 }
Esempio n. 4
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);
 }