Exemplo n.º 1
0
  /**
   * 批量 启用/停用 0/1
   *
   * @return
   */
  public String batchAble() {
    String message = "";
    for (int i = 0; i < items.length; i++) {
      Hashtable params = HttpUtils.parseQueryString(items[i]);
      String id = (String) params.get("id");
      User user = userManager.getById(id);

      // 超级管理员不允许禁用
      if (user.getLoginname() != null && user.getLoginname().equals("admin")) {
        message = "超级管理员禁止执行当前操作";
      } else {
        if (ableFlag != null && ableFlag.equals("enabled")) {
          if (user.getIsLeave().equals("0")) // 判断是否离职,如果已离职,则不允许启用该用户
          {
            message = "该员工已离职!不允许做操作!";
          } else {
            user.setAbledFlag("0");
          }
        }
        if (ableFlag != null && ableFlag.equals("disabled")) {
          user.setAbledFlag("1");
        }
        this.userManager.save(user);
      }
    }

    if (message != null && !message.equals("")) {
      Flash.current().success(message);
    } else {
      Flash.current().success(ADMIT_SUCCESS);
    }

    return LIST_ACTION;
  }
Exemplo n.º 2
0
  /**
   * 保存新增对象
   *
   * @return
   */
  public String save() {

    if (partitionId != null
        && !"".equals(partitionId)
        && (user.getDeptIDs() == null || "".equals(user.getDeptIDs()))) {
      Flash.current().error("分区下用户必须选择组织机构!");
      return CREATE_JSP;
    }

    // 校验登录名是否重复
    User _user = this.userManager.findByName(user.getLoginname());
    if (_user != null) {

      // 性别
      this.sexMap = dicUtil.getDicList("DICT_SEX");
      // 部门列表
      // getRequest().setAttribute(DEPTS, deptManager.findAll());
      getRequest().setAttribute(DEPTS, organizationManager.findAllByDf());

      // 登录名重复
      Flash.current().error("登录名已经存在,请重新填写!");
      return CREATE_JSP;
    }

    user.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    // 设置删除标记
    user.setDf("0");
    // 默认启用
    if (user.getIsLeave().equals("0")) // 已离职 账户禁用 0 启用 1
    {
      user.setAbledFlag("1");
    } else {
      user.setAbledFlag("0");
    }
    // user.setPhoto(getRequest().getParameter("articleAttachPic"));
    userManager.save(user);
    // 创建一个webservice
    /*
     * WebApplicationContext wac =
     * WebApplicationContextUtils.getRequiredWebApplicationContext
     * (getRequest().getSession().getServletContext()); PictureService
     * pictureService = (PictureService)wac.getBean("pictureService");
     * pictureService
     * .saveAttach(user.getId(),getRequest().getParameter("attach_client_id"
     * ), getRequest().getParameter("attach_form_key"), FILE_NAME,FILE_MODEL
     * );
     */
    ClientAttachmentService clientAttach = new ClientAttachmentService();
    clientAttach.saveAttach(
        user.getId(),
        getRequest().getParameter("attach_client_id"),
        getRequest().getParameter("attach_form_key"),
        FILE_NAME,
        FILE_MODEL);
    // 用户和组织机构的这种关系需要清除了
    if (user.getDeptIDs() != null && !user.getDeptIDs().equals("")) {
      String[] organizationIds = user.getDeptIDs().split(",");
      for (String organizationId : organizationIds) {
        OrganizationUserRelation our = new OrganizationUserRelation();
        our.setUserId(user.getId());
        our.setOrganizationId(organizationId);
        this.organizationUserRelationManager.save(our);
      }
    }
    Flash.current().success(CREATED_SUCCESS); // 存放在Flash中的数据,在下一次http请求中仍然可以读取数据,error()用于显示错误消息
    return LIST_ACTION;
  }