// 封装用户之间的好友关系 private void friendUserMap(User user, String client_id, Map<String, Object> msg) { boolean is_friend = userService.isFriend(client_id, user.getClient_id()); msg.put("is_friend", is_friend); if (!is_friend) msg.put("has_invitation", friendService.isInvited(client_id, user.getClient_id())); else msg.put("has_invitation", !is_friend); }
/** * 业务功能:保存用户的名片信息 * * @param client_id 用户的client_id * @param mapstr 包含名片所有信息 * @return * @throws JsonParseException * @throws JsonMappingException * @throws IOException * <p>notice:名片的交换次数exchange_times在addCard时默认为0. */ @RequestMapping("{client_id}/add") @ResponseBody public ResponseEntity<Map<String, Object>> addCard( @PathVariable String client_id, @RequestParam String mapstr) throws JsonParseException, JsonMappingException, IOException { Map<String, Object> map = new ObjectMapper().readValue(mapstr, HashMap.class); Card card = new Card(); User user = userService.findUserById(client_id); card.setCompanyname((String) map.get("companyname")); card.setDiploma((String) map.get("diploma")); card.setEmail((String) map.get("email")); card.setRealname((String) map.get("realname")); card.setExchange_times(0); card.setWork_date((String) map.get("work_date")); card.setMajor((String) map.get("major")); card.setPhone((String) map.get("phone")); card.setPosition((String) map.get("position")); card.setSchool_date((String) map.get("school_date")); card.setSchoolname((String) map.get("schoolname")); card.setUser(user); return new ResponseEntity<Map<String, Object>>(cardService.addCard(card), HttpStatus.OK); }
// 封装用户间的距离信息 private void distanceUserMap(User user, String client_id, Map<String, Object> msg) { Location my_local = locationService.findLocationByUser(userService.findUserById(client_id)); msg.put("distance", locationService.computeDistance(user, my_local)); }