/**
  * @Description: 宁静
  *
  * @author [email protected]
  * @date 2015年12月2日 下午2:43:38
  * @param station
  * @return
  */
 private AgentListDto toDto(User user) {
   AgentListDto agentListDto = new AgentListDto();
   agentListDto.setId(user.getId());
   agentListDto.setName(user.getName());
   agentListDto.setAgentCode(user.getCode());
   agentListDto.setCreater(user.getCreater());
   agentListDto.setAddress(user.getAddress());
   agentListDto.setTelephone(user.getTelephone());
   if (!StringUtils.isEmpty(user.getParentUid())) {
     try {
       String parentName = userService.getUserById(user.getParentUid()).getName();
       agentListDto.setParentName(parentName);
     } catch (BizException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   // 处理实体中的特殊转换值
   if (null != user.getCreaterTime()) // 创建时间
   {
     agentListDto.setCreaterTime(
         DateUtil.formatDate(user.getCreaterTime(), DateUtil.FULL_DATE_FORMAT));
   }
   if (null != user.getProvinceCode()) // 省级区域
   {
     Province province = new Province();
     province = provinceService.getProvinceByPcode(user.getProvinceCode());
     agentListDto.setProvince(null != province ? province.getPname() : "");
   }
   if (null != user.getCityCode()) // 市级区域
   {
     if (Constants.CITY_ALL.equals(user.getCityCode())) {
       agentListDto.setCity(Constants.CITY_ALL_NAME);
     } else {
       City city = new City();
       city = cityService.getCityByCcode(user.getCityCode());
       agentListDto.setCity(null != city ? city.getCname() : "");
     }
   }
   if (null != user.getRegionCode()) // 市级区域
   {
     if (Constants.REGION_ALL.equals(user.getRegionCode())) {
       agentListDto.setCity(Constants.REGION_ALL_NAME);
     } else {
       Region region = new Region();
       region = regionService.getRegionByAcode(user.getRegionCode());
       agentListDto.setRegion(null != region ? region.getAname() : "");
     }
   }
   return agentListDto;
 }
 /**
  * demo登录提交后跳转方法
  *
  * @param userName
  * @param password
  * @param model
  * @return
  * @throws Exception
  */
 @SuppressWarnings("finally")
 @RequestMapping(value = "/saveOrUpdate", method = RequestMethod.POST)
 public @ResponseBody ResultBean saveOrUpdate(
     AddAgentForm addAgentForm, ModelMap model, HttpSession httpSession) {
   ResultBean resultBean = new ResultBean();
   try {
     String userId = LoginUtils.getAuthenticatedUserCode(httpSession);
     userService.saveOrUpdate(addAgentForm, userId);
     resultBean.setMessage("操作成功!");
     resultBean.setStatus("success");
   } catch (BizException bizEx) {
     resultBean.setMessage(bizEx.getMessage());
     resultBean.setStatus("failure");
   } catch (Exception e) {
     resultBean.setMessage("操作异常!");
     resultBean.setStatus("failure");
     e.printStackTrace();
   } finally {
     return resultBean;
   }
 }
 /**
  * @Description: 帐号删除
  *
  * @author [email protected]
  * @date 2015年10月22日 下午1:35:59
  * @param ids
  * @param model
  * @param httpSession
  * @return
  * @throws Exception
  */
 @SuppressWarnings("finally")
 @RequestMapping(value = "/deleteAgentByIds", method = RequestMethod.POST)
 public @ResponseBody ResultBean deleteAgent(
     @RequestParam(value = "ids", required = false) String[] ids,
     ModelMap model,
     HttpSession httpSession)
     throws Exception {
   ResultBean resultBean = new ResultBean();
   try {
     String userId = LoginUtils.getAuthenticatedUserCode(httpSession);
     userService.deleteAccountByIds(ids, userId);
     resultBean.setStatus("success");
     resultBean.setMessage("删除成功!");
   } catch (BizException bizEx) {
     resultBean.setStatus("failure");
     resultBean.setMessage(bizEx.getMessage());
   } catch (Exception e) {
     resultBean.setStatus("failure");
     resultBean.setMessage(e.getMessage());
   } finally {
     return resultBean;
   }
 }