@RequestMapping(method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8)
  public List<ProvinceDTO> list() {
    List<Province> provinceEntitys = provinceService.getAll();

    List<ProvinceDTO> provinceDTOs = BeanMapper.mapList(provinceEntitys, ProvinceDTO.class);

    return provinceDTOs;
  }
  @RequestMapping(method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8)
  MyResponse list() {
    List<CategoryPredefined> categoryPredifinedList = categoryPredefinedService.getAll();

    List<CategoryPredefinedDTO> categoryPredefinedDTOList =
        BeanMapper.mapList(categoryPredifinedList, CategoryPredefinedDTO.class);

    return MyResponse.ok(categoryPredefinedDTOList);
  }
  /** @see AccountWebService#searchUser() */
  @Override
  public UserListResult searchUser(String loginName, String name) {
    try {
      List<User> entityList = accountManager.searchUser(loginName, name);

      List<UserDTO> dtoList = BeanMapper.mapList(entityList, UserDTO.class);

      return new UserListResult(dtoList);
    } catch (RuntimeException e) {
      logger.error(e.getMessage(), e);
      return new UserListResult().setDefaultError();
    }
  }
  /** 获取部门详细信息. */
  @GET
  @Path("{id}")
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + WsConstants.CHARSET})
  public DepartmentDTO getDepartmentDetail(@PathParam("id") Long id) {
    try {
      Department entity = accountManager.getDepartmentDetail(id);

      if (entity == null) {
        String message = "部门不存在(id:" + id + ")";
        throw WebExceptionFactory.buildException(Status.NOT_FOUND, message, logger);
      }

      return BeanMapper.map(entity, DepartmentDTO.class);
    } catch (RuntimeException e) {
      throw WebExceptionFactory.buildDefaultException(e, logger);
    }
  }
  /** @see AccountWebService#getDepartmentDetail() */
  @Override
  public DepartmentResult getDepartmentDetail(Long id) {
    try {
      Department entity = accountManager.getDepartmentDetail(id);

      Validate.notNull(entity, "部门不存在(id:" + id + ")");

      DepartmentDTO dto = BeanMapper.map(entity, DepartmentDTO.class);

      return new DepartmentResult(dto);
    } catch (IllegalArgumentException e) {
      logger.error(e.getMessage());
      return new DepartmentResult().setError(WSResult.PARAMETER_ERROR, e.getMessage());
    } catch (RuntimeException e) {
      logger.error(e.getMessage(), e);
      return new DepartmentResult().setDefaultError();
    }
  }
  /** @see AccountWebService#createUser() */
  @Override
  public IdResult createUser(UserDTO user) {
    try {
      User userEntity = BeanMapper.map(user, User.class);

      Long userId = accountManager.saveUser(userEntity);

      return new IdResult(userId);
    } catch (ConstraintViolationException e) {
      String message = StringUtils.join(BeanValidators.extractPropertyAndMessage(e), "\n");
      return new IdResult().setError(WSResult.PARAMETER_ERROR, message);
    } catch (DataIntegrityViolationException e) {
      String message = "新建用户参数存在唯一性冲突(用户:" + user + ")";
      logger.error(message, e);
      return new IdResult().setError(WSResult.PARAMETER_ERROR, message);
    } catch (RuntimeException e) {
      logger.error(e.getMessage(), e);
      return new IdResult().setDefaultError();
    }
  }