@RequestMapping("favNews") @ResponseBody public String favNews(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.FAV.getCode()); affiliatedInfo.setMemberId(member.getId()); Integer isDone = cofService.findCofAffiliatedInfo(affiliatedInfo); if (isDone == null || isDone == 0) { cofService.addCofAffiliated(affiliatedInfo); result = Result.getSuccessResult(); } else { result = new Result(EEchoCode.ERROR.getCode(), "已经收藏了"); } } 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); }