Esempio n. 1
0
  /**
   * 删除对象
   *
   * @return
   */
  public String delete() {

    String deleteMessage = "";
    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);

      try {
      } catch (Exception e) {
      }

      // 超级管理员禁止删除
      if (user.getLoginname() != null && user.getLoginname().equals("admin")) {
        deleteMessage = "超级管理员禁止删除";
      } else {
        // 删除时,置换删除标记
        user.setDf("1");
        // 删除人员时 需要把人员与角色的关系 以及管理员与分区的关系删除
        user.setRoles(new HashSet<Role>(0));
        user.setOuRelations(null);
        user.setPartitions(new HashSet<Partition>(0));

        userManager.delete(user);
      }
    }

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

    return LIST_ACTION;
  }
Esempio n. 2
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;
  }
Esempio n. 3
0
 /** 保存更新对象 */
 public String update() {
   // 先判断分区名称是否重复
   if (!partitionManager.isUniqueByDf(partition, "name")) {
     Flash.current().success(Partition.ALIAS_NAME + "已存在!");
     return EDIT_JSP;
   }
   partitionManager.update(this.partition);
   Flash.current().success(UPDATE_SUCCESS);
   return LIST_ACTION;
 }
Esempio n. 4
0
  /**
   * 为每个用户赋予默认角色教师
   *
   * @return
   */
  public String saveUserRole() {
    try {
      this.userManager.saveUserRole();
      Flash.current().success("为每个用户赋予默认角色教师成功!");
    } catch (Exception e) {
      e.printStackTrace();
      Flash.current().success("为每个用户赋予默认角色教师失败!");
    }

    return LIST_ACTION;
  }
Esempio n. 5
0
 /** 保存新增对象 */
 public String save() {
   // 先判断分区名称是否重复
   if (!partitionManager.isUniqueByDf(partition, "name")) {
     Flash.current().success(Partition.ALIAS_NAME + "已存在!");
     return CREATE_JSP;
   }
   partition.setDf("0");
   partition.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
   partitionManager.save(partition);
   Flash.current().success(CREATED_SUCCESS); // 存放在Flash中的数据,在下一次http请求中仍然可以读取数据,error()用于显示错误消息
   return LIST_ACTION;
 }
Esempio n. 6
0
 /**
  * 修改密码
  *
  * @return
  */
 public String editPassword() {
   User dbResult = userManager.getById(getCurrUser().getUserID());
   User user = this.userManager.getById(getCurrUser().getUserID());
   String pwd = getRequest().getParameter("password");
   String pwdold = getRequest().getParameter("password_old");
   String msg = "修改密码成功";
   int type = 1;
   if (pwdold.equals(dbResult.getPassword())) {
     dbResult.setPassword(pwd);
     try {
       userManager.saveOrUpdate(dbResult);
       // 提示信息
       Flash.current().success(RESET_PASSWORD_SUCCESS);
     } catch (Exception e) {
       e.printStackTrace();
       msg = "修改密码失败!";
       type = 2;
       // 提示信息
       // Flash.current().success(RESET_PASSWORD_FAILURE);
     }
   } else {
     msg = "原始密码错误!";
     type = 3;
   }
   getRequest().setAttribute("type", type);
   getRequest().setAttribute("msg", msg);
   return "update_password";
 }
Esempio n. 7
0
  /**
   * 保存更新对象
   *
   * @return
   */
  public String update() {
    this.organizationUserRelationManager.removeOURByUserId(user.getId());
    if (user.getDeptIDs() != null && !user.getDeptIDs().equals("")) {
      String[] organizationIds = user.getDeptIDs().split(",");
      for (String organizationId : organizationIds) {
        OrganizationUserRelation our = new OrganizationUserRelation();
        our.setOrganizationId(organizationId);
        our.setUserId(user.getId());
        this.organizationUserRelationManager.save(our);
      }
    }
    // user.setOuRelations(ours);
    /*if (user.getIsLeave().equals("0")) // 已离职 账户禁用 1 启用 0
    {
    	user.setAbledFlag("1");
    } else if (user.getIsLeave().equals("1")) {
    	user.setAbledFlag("0");
    } else {
    	if (this.abledFlag != null && !this.abledFlag.equals("")) {
    		// user.setAbledFlag("0");
    		user.setAbledFlag(this.abledFlag);
    	}
    }*/
    // 加密工资
    try {

    } catch (Exception e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }
    this.userManager.update(user);

    Flash.current().success(UPDATE_SUCCESS);
    return LIST_ACTION;
  }
 /** 批量删除 */
 @RequestMapping(method = RequestMethod.DELETE)
 public String batchDelete(ModelMap model, @RequestParam("items") java.lang.Integer[] items) {
   for (int i = 0; i < items.length; i++) {
     permissionGroupManager.removeById(items[i]);
   }
   Flash.current().success(DELETE_SUCCESS);
   return LIST_ACTION;
 }
 /** 删除对象 */
 public String delBatch() {
   for (int i = 0; i < items.length; i++) {
     Hashtable params = HttpUtils.parseQueryString(items[i]);
     java.lang.Integer id = new java.lang.Integer((String) params.get("id"));
     noteSendManager.removeById(id);
   }
   Flash.current().success(DELETE_SUCCESS);
   return LIST_ACTION;
 }
Esempio n. 10
0
  /**
   * 重置密码
   *
   * @return
   */
  public String resetPassword() {

    try {
      User user = this.userManager.getById(id);
      // 默认重置为000000
      user.setPassword("111111");
      this.userManager.save(user);

      // 提示信息
      Flash.current().success(RESET_PASSWORD_SUCCESS);
    } catch (Exception e) {
      e.printStackTrace();

      // 提示信息
      Flash.current().success(RESET_PASSWORD_FAILURE);
    }
    return LIST_ACTION;
  }
Esempio n. 11
0
 /** 删除对象 */
 public String delete() {
   for (int i = 0; i < items.length; i++) {
     Hashtable params = HttpUtils.parseQueryString(items[i]);
     java.lang.String id = new java.lang.String((String) params.get("id"));
     partition = (Partition) partitionManager.getById(id);
     partition.setDf("1");
     // 删除分区时,把分区与管理员的关系 分区与角色的关系删除
     //			partition.setApplications(new HashSet<Application>(0));
     //			partition.setUsers(new HashSet<User>(0));
     partition.setOrganizations(new HashSet<Organization>(0));
     List roles = roleManager.findAllByDf("partitionId", partition.getId());
     if (!roles.isEmpty() && roles.size() > 0) {
       Flash.current().error("分区" + partition.getName() + "下已经有角色等数据,不能删除!");
       return LIST_ACTION;
     }
     partitionManager.update(this.partition);
   }
   Flash.current().success(DELETE_SUCCESS);
   return LIST_ACTION;
 }
Esempio n. 12
0
  /**
   * 修改用户继教号
   *
   * @return
   */
  public String changeUserNum() {
    try {
      InputStream templatInputStream =
          this.getClass().getResourceAsStream("/com/opendata/organiz/action/teacher.xls");
      BufferedInputStream in = new BufferedInputStream(templatInputStream);
      POIFSFileSystem fs = new POIFSFileSystem(in);
      HSSFWorkbook book = new HSSFWorkbook(fs);
      HSSFSheet sheet = book.getSheetAt(0);
      int num = sheet.getLastRowNum();

      List<Map<String, String>> l = new ArrayList<Map<String, String>>();
      for (int i = 1; i < num; i++) {
        HSSFRow row = sheet.getRow(i);
        HSSFCell c1 = row.getCell(1);
        if (c1 != null) {
          // 继教号
          String userNum = c1.toString();
          HSSFCell c5 = row.getCell(5);
          if (c5 != null) {
            // 身份证号
            String IDNum = c5.toString();
            Map<String, String> map = new HashMap<String, String>();
            map.put("userNum", userNum);
            map.put("IDNum", IDNum);
            l.add(map);
          }
        }
      }
      userManager.batchUpdateUserNum(l);
      Flash.current().success("继教号同步成功!");
    } catch (Exception e) {
      e.printStackTrace();
      Flash.current().success("继教号同步失败!");
    }

    return LIST_ACTION;
  }
  /** 保存新增,@Valid标注spirng在绑定对象时自动为我们验证对象属性并存放errors在BindingResult */
  @RequestMapping(method = RequestMethod.POST)
  public String create(
      ModelMap model,
      @Valid PermissionGroup permissionGroup,
      BindingResult errors,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    if (errors.hasErrors()) {
      return "/permissiongroup/new";
    }

    permissionGroupManager.save(permissionGroup);
    Flash.current().success(CREATED_SUCCESS); // 存放在Flash中的数据,在下一次http请求中仍然可以读取数据,error()用于显示错误消息
    return LIST_ACTION;
  }
  /** 保存更新,@Valid标注spirng在绑定对象时自动为我们验证对象属性并存放errors在BindingResult */
  @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
  public String update(
      ModelMap model,
      @PathVariable java.lang.Integer id,
      @Valid PermissionGroup permissionGroup,
      BindingResult errors,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    if (errors.hasErrors()) {
      return "/permissiongroup/edit";
    }

    permissionGroupManager.update(permissionGroup);
    Flash.current().success(UPDATE_SUCCESS);
    return LIST_ACTION;
  }
Esempio n. 15
0
  /**
   * 修改个人设置
   *
   * @return
   */
  public String editPerson() {
    User dbResult = userManager.getById(getCurrUser().getUserID());
    //		dbResult.setPhone(user.getPhone());
    // dbResult.setBirthday(user.getBirthday());
    // dbResult.setSex(user.getSex());
    //		dbResult.setMail(user.getMail());
    //		dbResult.setQq(user.getQq());
    //		dbResult.setMsn(user.getMsn());
    //		dbResult.setWblog(user.getWblog());
    /*// 维护组织机构信息
    this.organizationUserRelationManager.removeOURByUserId(getCurrUser().getUserID());
    if (user.getDeptIDs() != null && !user.getDeptIDs().equals("")) {
    	String[] organizationIds = user.getDeptIDs().split(",");
    	for (String organizationId : organizationIds) {
    		OrganizationUserRelation our = new OrganizationUserRelation();
    		our.setOrganizationId(organizationId);
    		our.setUserId(getCurrUser().getUserID());

    		this.organizationUserRelationManager.save(our);
    	}
    }*/
    /*
     * 判断图片是否被更改,以优化程序,不必每次都调用webservice

    String fileName = getRequest().getParameter(FILE_NAME);
    if (StringUtils.isNotEmpty(fileName)) {
    	// 创建一个webservice
    	ClientAttachmentService clientAttach = new ClientAttachmentService();
    	clientAttach.deleteAttach(dbResult.getId(), "true", null,
    			getRequest().getParameter("attach_client_id"));
    	clientAttach.saveAttach(dbResult.getId(), getRequest()
    			.getParameter("attach_client_id"), getRequest()
    			.getParameter("attach_form_key"), FILE_NAME, FILE_MODEL);
    	System.out.println(getRequest().getParameter("attach_client_id"));
    	System.out.println(getRequest().getParameter("attach_form_key"));
    }*/
    userManager.saveOrUpdate(dbResult);
    Flash.current().success("修改个人信息成功!");
    return "editPersonPage";
  }
Esempio n. 16
0
 /** 保存更新对象 */
 public String update() {
   noteSendManager.update(this.noteSend);
   Flash.current().success(UPDATE_SUCCESS);
   return LIST_ACTION;
 }
Esempio n. 17
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;
  }
 /** 删除 */
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 public String delete(ModelMap model, @PathVariable java.lang.Integer id) {
   permissionGroupManager.removeById(id);
   Flash.current().success(DELETE_SUCCESS);
   return LIST_ACTION;
 }