Beispiel #1
0
  /**
   * 删除客户.
   *
   * @param id
   * @return 被删除的客户
   */
  @Transactional(readOnly = false)
  public Customer delete(String id) {
    Customer org = get(id);
    userDao.deleteByCustomerId(id);
    getDao().delete(org);

    return org;
  }
Beispiel #2
0
  /**
   * 删除组织机构
   *
   * @param id
   * @throws Exception
   */
  @Transactional(readOnly = false)
  public void deleteOrganization(String id) throws Exception {
    Customer customer = get(id);
    if (!CollectionUtils.isEmpty(mediaDao.findByOrganizationId(id))) {
      throw new Exception("此机构下属有媒体,暂时不能删除!");
    }

    userDao.delete(customer.getUsers());
    this.remove(customer);
  }
Beispiel #3
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);
  }
Beispiel #4
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);
  }
Beispiel #5
0
 /** 更新登录名. */
 private void updateLoginName(CustomerVO vo, Customer cust) {
   User user = userDao.findByLoginName(cust.getMobPhone());
   if (user != null) {
     userDao.updateLoginName(vo.getMobPhone(), cust.getMobPhone());
   }
 }