Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/getAgentDetail", method = RequestMethod.GET)
 public @ResponseBody AddAgentForm getAgentDetail(
     @RequestParam(value = "id", required = true) String id,
     ModelMap model,
     HttpSession httpSession)
     throws Exception {
   AddAgentForm addAgentForm = new AddAgentForm();
   User user = userService.getUserById(id);
   addAgentForm.setId(user.getId());
   addAgentForm.setAddFormAgentCode(user.getCode());
   addAgentForm.setAddFormName(user.getName());
   addAgentForm.setAddFormTelephone(user.getTelephone());
   addAgentForm.setAddFormParentId(user.getParentUid());
   addAgentForm.setAddFormProvince(user.getProvinceCode());
   addAgentForm.setAddFormCity(user.getCityCode());
   addAgentForm.setAddFormRegion(user.getRegionCode());
   addAgentForm.setAddFormAddress(user.getAddress());
   addAgentForm.setPassword(user.getPassword());
   addAgentForm.setConfirmPassword(user.getPassword());
   return addAgentForm;
 }