示例#1
0
  /**
   * 修改组织机构
   *
   * @param customer
   */
  @Transactional(readOnly = false)
  public void updateOrganization(CustomerVO vo) {
    Customer customer = customerDao.findOne(vo.getId());
    customer.setMobPhone(vo.getLoginName());
    customer.setName(vo.getName());
    customer.setOrgSummary(vo.getOrgSummary());
    customer.setOrgType(vo.getOrgType());
    Date now = new Date();
    customer.setModifyBy(UserContext.getCurrent().getId());
    customer.setModifyTime(now);
    save(customer);

    User user = userDao.findByCustomerId(customer.getId());
    user.setLoginName(vo.getLoginName());
    user.setNickname(customer.getName());
    String[] hash = Encrypts.hashPassword(vo.getLoginName());
    user.setPassword(hash[0]);
    user.setSalt(hash[1]);
    userDao.save(user);
  }
示例#2
0
  private void createUser(CustomerVO vo, Customer cust) {
    User user = new User();
    Date now = new Date();

    user.setLoginName(vo.getLoginName());

    String[] hash = Encrypts.hashPassword(vo.getPassword());
    user.setPassword(hash[0]);
    user.setSalt(hash[1]);

    user.setNickname(getNickname(vo));
    user.setSecMobile(vo.getMobPhone());

    user.setCustomer(cust);
    user.setType(UserType.MEMBER);
    user.setStatus(UserStatus.ENABLED);
    user.setCreateTime(now);

    user.setRole(getUserRole(cust)); // 创建用户角色关系

    userDao.save(user);
  }