Exemplo n.º 1
0
 /**
  * 业务功能:保存用户的名片信息
  *
  * @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);
 }
Exemplo n.º 2
0
 // 封装用户间的距离信息
 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));
 }