Exemplo n.º 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);
  }
Exemplo n.º 2
0
  /**
   * 创建组织机构.
   *
   * @param vo
   */
  @Transactional(readOnly = false)
  public Customer createOrganization(CustomerVO vo) {
    Date now = new Date();
    // 创建客户信息
    Customer org = BeanMapper.map(vo, Customer.class);
    org.setCreateBy(UserContext.getSystemUser().getId());
    org.setCreateTime(now);
    org.setModifyBy(org.getCreateBy());
    org.setModifyTime(now);

    org.setCredit(0);
    org.setStatus(CustStatus.NORMAL);
    org.setCustType(CustType.CUST_ORG);
    org.setCustProperty(CustProperty.CUST_C);

    getDao().save(org);

    // 创建登录账号
    createUser(vo, org);

    return org;
  }