Beispiel #1
0
  /**
   * 设置短信验证码
   *
   * @return
   */
  @Action(
      value = "smsCheckSetting",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String smsCheckSetting() {
    try {
      entityMap = new HashMap<String, Object>();
      String smsCheckServer =
          (String)
              getSession()
                  .getAttribute(
                      ApSmsConstants
                          .SESSION_SMS_CHECKING_NUMBER); // .get(ApSmsConstants.SESSION_SMS_CHECKING_NUMBER);
      if (!smsCheckServer.equalsIgnoreCase(smsCheckContent)) {
        entityMap.put("flag", false);
        entityMap.put("resultMsg", "短信验证码错误!");
        return SUCCESS;
      }
      //			UserVO sessionUser = (UserVO)
      // getSession().getAttribute(ApSmsConstants.SESSION_USER_INFO);
      if (!users
          .getPassword()
          .equalsIgnoreCase(MasPasswordTool.getEncString(userPsw, users.getAccount()))) {
        entityMap.put("flag", false);
        entityMap.put("resultMsg", "管理员密码错误!");
        return SUCCESS;
      }
      PortalUserExtBean tempUserExt = portalUserExtService.getByPk(portalUserExt.getId());
      tempUserExt.setSmsMobile(portalUserExt.getSmsMobile());
      portalUserExtService.update(tempUserExt);
      ActionContext.getContext().getSession().remove(ApSmsConstants.SESSION_SMS_CHECKING_NUMBER);
      // 地市管理员更新企业管理员,需要同步至业务节点 20130926
      if (users.getUserType() == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        try {
          updateUserExtToNode(portalUser, tempUserExt);
        } catch (Exception e) {
          logger.error("Add sms mobile to node faile", e);
        }
      }
      entityMap.put("flag", true);
      entityMap.put("resultMsg", "短信验证码绑定成功!");
    } catch (Exception e) {
      logger.error("delete user error", e);
    }

    return SUCCESS;
  }
Beispiel #2
0
  /**
   * 修改用户
   *
   * @return
   */
  @Action(
      value = "updateUser",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String updateUser() {
    try {
      logger.debug("userRoles	:" + multiUserRoles);
      logger.debug("begin update user " + portalUser);
      // 地市管理员编辑用户分配角色硬编码
      Set<RoleVO> rSet = new HashSet<RoleVO>();
      if (users.getUserType() == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        RoleVO roleVO = new RoleVO();
        roleVO.setId(ApSmsConstants.UNION_CORP_ADMIN_ROLEID);
        roleVO.setCreateBy(users.getId());
        rSet.add(roleVO);
      } else {
        String[] roles = multiUserRoles.split(", ");
        RoleVO roleVO = null;
        for (String _role : roles) {
          roleVO = new RoleVO();
          roleVO.setId(Long.parseLong(_role));
          roleVO.setCreateBy(users.getId());
          rSet.add(roleVO);
        }
      }
      // 添加解锁~加锁
      isLockFlag(portalUser);

      portalUser.setRoles(rSet);
      portalUser.setUpdateBy(users.getId()); // 这里是登录用户的ID;
      userService.updateUser(portalUser);

      // 更新用户扩展信息(不含发送条数,统计时间)
      portalUserExt.setId(portalUser.getId());
      portalUserExt.setSmsSendCount(null);
      portalUserExt.setCountTime(null);
      portalUserExtService.update(portalUserExt);

      // 地市管理员更新企业管理员,需要同步至业务节点 20130926
      if (users.getUserType() == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        addUserToNode(portalUser, portalUserExt);
      }
      entityMap = new HashMap<String, Object>();
      entityMap.put("flag", SUCCESS);
    } catch (Exception exception) {
      entityMap = new HashMap<String, Object>();
      entityMap.put("flag", ERROR);
      logger.error("update user error", exception);
      return ERROR;
    }
    return SUCCESS;
  }
Beispiel #3
0
 /**
  * 用户管理短信验证设置,初始化数据
  *
  * @return
  */
 @Action(
     value = "smsCheckSettingForward",
     results = {
       @Result(name = SUCCESS, location = "/ap/user/smsCheckDialog.jsp"),
       @Result(name = ERROR, location = "/error.jsp")
     })
 public String smsCheckSettingForward() {
   try {
     portalUserExt = portalUserExtService.getByPk(portalUser.getId());
     //			List<Role> rolesList = userService.getAllRoles();
     //			logger.info("qeury allRoles: " + rolesList);
     //			request.setAttribute("rolesList", rolesList);
     // 查询用户列表
     // query();
   } catch (Exception e) {
     logger.error("query error, ", e);
     return ERROR;
   }
   return SUCCESS;
 }
Beispiel #4
0
  /**
   * 删除用户(含删除多个用户情况)
   *
   * @return
   */
  @Action(
      value = "deleteUser",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String deleteUser() {
    try {
      entityMap = new HashMap<String, Object>();
      // 多个id以逗号分隔
      String Ids = request.getParameter("userId");
      logger.info("delete user's id: " + Ids);
      String[] deleteIds = Ids.split(",");
      if (0 <= Arrays.binarySearch(deleteIds, "" + users.getId())) {
        // 如果删除的包含自己,将自己的id从删除列表里清除
        List<String> list = new ArrayList<String>();
        for (String dId : deleteIds) list.add(dId);
        list.remove("" + users.getId());
        deleteIds = (String[]) list.toArray(new String[list.size()]);
      }
      Long[] deleteIdLongs = ConvertUtil.arrStringToLong(deleteIds);
      for (Long id : deleteIdLongs) {
        logger.info("delete portal_user  -->" + id);
      }
      userService.deleteUser(deleteIdLongs);
      for (Long id : deleteIdLongs) {
        logger.info("delete portal_user_ext -->" + id);
        portalUserExtService.delete(id);
      }
    } catch (Exception e) {
      logger.error("delete user error", e);
    }

    return SUCCESS;
  }
Beispiel #5
0
  /**
   * 新增用户
   *
   * @return
   * @throws Exception
   */
  @Action(
      value = "adduser",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String adduser() {
    try {
      logger.info("add user: 	"******"V_P_" + portalUser.getProvince());
          merchant.setGroupCode(String.valueOf(merchantPin));
          merchant.setPlatform(ApSmsConstants.MERCHANT_PROVINCE_VIRTUAL_TYPE);
          merchant.setCreateTime(new Date());
          boolean result = MbnMerchantVipIService.insertMerchant(merchant);
          logger.info(
              "Province ["
                  + portalUser.getProvince()
                  + "] add virtual merchant ["
                  + merchantPin
                  + "] result:"
                  + result);
        } else {
          merchantPin = vProvinceMerchant.getMerchantPin();
        }
      } else if (userType == ApSmsConstants.USER_TYPE_PROVINCE_ADMIN) {
        // 省管理员创建市管理员
        portalUser.setUserType(ApSmsConstants.USER_TYPE_CITY_ADMIN);
        MbnMerchantVip vCityMerchant =
            MbnMerchantVipIService.loadVirtualProvinceMerchant(
                portalUser.getCity(), ApSmsConstants.MERCHANT_CITY_VIRTUAL_TYPE);
        // 判断地市虚拟企业是否存在,不存在增加
        if (vCityMerchant == null) {
          MbnMerchantVip merchant = new MbnMerchantVip();
          merchantPin = PinGen.getMerchantPin();
          merchant.setProvince(portalUser.getProvince());
          merchant.setCity(portalUser.getCity());
          merchant.setMerchantPin(merchantPin);
          merchant.setName("V_C_" + portalUser.getCity());
          merchant.setGroupCode(String.valueOf(merchantPin));
          merchant.setPlatform(ApSmsConstants.MERCHANT_CITY_VIRTUAL_TYPE);
          merchant.setCreateTime(new Date());
          boolean result = MbnMerchantVipIService.insertMerchant(merchant);
          logger.info(
              "Province ["
                  + portalUser.getProvince()
                  + "] City ["
                  + portalUser.getCity()
                  + "] "
                  + "add virtual merchant ["
                  + merchantPin
                  + "] result:"
                  + result);
        } else {
          merchantPin = vCityMerchant.getMerchantPin();
        }
      } else if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        // 市管理员创建企业管理员
        portalUser.setUserType(ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN);
        merchantPin = portalUser.getMerchantPin();
      } else if (userType == ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN) {
        // 企业管理员创建企业用户
        portalUser.setUserType(ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL);
      } else {
        // 默认企业用户
        portalUser.setUserType(ApSmsConstants.USER_TYPE_ENTERPRISE_NORMAL);
      }
      portalUser.setCreateBy(users.getId());
      // 设定是否为托管mas处理方式
      if (WebUtils.isHostMas()) {
        // 20130427 为用户随机生成zxtUserId
        String zxtUserId = getZxtUserId();
        portalUser.setZxtUserId(zxtUserId);
        portalUser.setMerchantPin(merchantPin);
      }
      Users existUser = userService.validateUser(portalUser);
      if (existUser != null) {
        entityMap.put("flag", "用户账号已存在,请重新填写");
        return SUCCESS;
      }
      // add wangyu
      portalUser.setMerchantPin(merchantPin);
      // 地市管理员创建用户分配角色硬编码
      Set<RoleVO> rSet = new HashSet<RoleVO>();
      if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        RoleVO roleVO = new RoleVO();
        roleVO.setId(ApSmsConstants.UNION_CORP_ADMIN_ROLEID);
        roleVO.setCreateBy(users.getId());
        rSet.add(roleVO);
      } else {
        String[] roles = multiUserRoles.split(", ");
        RoleVO roleVO = null;
        for (String _role : roles) {
          roleVO = new RoleVO();
          roleVO.setId(Long.parseLong(_role));
          roleVO.setCreateBy(users.getId());
          rSet.add(roleVO);
        }
      }
      portalUser.setRoles(rSet);
      // 添加解锁~加锁
      isLockFlag(portalUser);
      portalUser.setFirstLoginFlag(0);
      if (!org.apache.commons.lang3.StringUtils.isBlank(
          WebUtils.getPropertyByName(com.leadtone.mas.admin.common.ApSmsConstants.TUNNELALL))) {
        String tunnelAll =
            WebUtils.getPropertyByName(com.leadtone.mas.admin.common.ApSmsConstants.TUNNELALL);
        if ("true".equalsIgnoreCase(tunnelAll)) {
          Integer corpId = MbnMerchantVipIService.getCorpZXTId(merchantPin);
          int userId =
              ZXTUserTool.addUser(
                  portalUser.getAccount(),
                  portalUser.getPassword(),
                  corpId.toString(),
                  portalUser.getZxtUserId());
          portalUser.setZxtId(userId);
          portalUser.setZxtLoginAcount(portalUser.getAccount());
          portalUser.setZxtPwd(portalUser.getPassword());
        }
      }
      portalUser.setId(PinGen.getSerialPin());
      if (StringUtil.isEmpty(portalUser.getZxtUserId())) {
        // TODO
        portalUser.setZxtUserId(portalUser.getId().toString());
      }
      userService.addUser(portalUser);
      // 增加扩展信息
      portalUserExt.setId(portalUser.getId());
      portalUserExtService.save(portalUserExt);

      // 地市管理员创建企业管理员,需要同步至业务节点 20130926
      if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        try {
          addUserToNode(portalUser, portalUserExt);
        } catch (Exception e) {
          logger.error("Add user to node faile", e);
        }
      }

      entityMap.put("flag", SUCCESS);
      logger.info("add user success");
    } catch (Exception exception) {
      entityMap = new HashMap<String, Object>();
      entityMap.put("flag", ERROR);
      logger.error("add user error: ", exception);
      return ERROR;
    }
    return SUCCESS;
  }
Beispiel #6
0
  /**
   * 初始化新增页面
   *
   * @return
   */
  @Action(
      value = "forward",
      results = {
        @Result(name = "forward", location = "/ap/user/useradd.jsp"),
        @Result(name = ERROR, location = "/error.jsp"),
        @Result(name = INPUT, location = "/ap/user/useradd.jsp")
      })
  public String forward() {
    try {
      List<Role> roleList = userService.getRolesByMerchantPin(users.getMerchantPin());
      // 初次进入新增页面,得初始化角色
      request.setAttribute("rolesList", roleList);

      // REX@20130111 判断管理员类型 0:超级管理员 1:省系统管理员;2:地市管理员3、企业超级管理员4、企业用户
      // 0返回省列表
      // 1返回省代码,地市列表
      // 2,3,4 返回省代码、地市代码
      int userType = users.getUserType();
      if (userType == ApSmsConstants.USER_TYPE_SUPER_ADMIN) {
        List<Region> list = regionService.findProvinces();
        request.setAttribute("regionList", list);
      } else if (userType == ApSmsConstants.USER_TYPE_PROVINCE_ADMIN) {
        Long prov = Long.parseLong(users.getProvince());
        List<Region> list = regionService.findCityByProvinceId(prov);
        request.setAttribute("regionList", list);
        request.setAttribute("province", users.getProvince());
      } else if (userType == ApSmsConstants.USER_TYPE_CITY_ADMIN) { // 地市管理员。列出企业。
        Long prov = Long.parseLong(users.getProvince());
        List<MbnMerchantVip> list =
            MbnMerchantVipIService.loadByProvinceAndCity(users.getProvince(), users.getCity());
        request.setAttribute("merchantList", list);
        request.setAttribute("province", users.getProvince());
        request.setAttribute("city", users.getCity());
        //			}else if(userType == ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN){
        //				request.setAttribute("entAdmin", true);
        //				request.setAttribute("province", users.getProvince());
        //				request.setAttribute("city", users.getCity());
      } else {
        MbnConfigMerchant mbnConfigMerchant =
            mbnConfigMerchantIService.loadByMerchantPin(users.getMerchantPin(), "corp_login_port");
        if (mbnConfigMerchant != null) {
          request.setAttribute("corpLoginPort", mbnConfigMerchant.getItemValue());
        }
        request.setAttribute("province", users.getProvince());
        request.setAttribute("city", users.getCity());
      }

      logger.debug(" inser into useradd.jsp before -->flag: " + flag);
      if ("addForward".equals(flag)) {

        return "forward";
      } else if ("updateForward".equals(flag)) {
        request.setAttribute("allList", userService.getAllRoles());
        // 修改用户之前的初始化新增页面角色,查询要修改的用户信息
        List<UserVO> uList = userService.queryUserLikeAccount(portalUser);
        logger.info("query updateForward user: "******"corp_login_port");
          if (mbnConfigMerchant != null) {
            request.setAttribute("corpLoginPort", mbnConfigMerchant.getItemValue());
          }
        }
        userVO.setPassword(
            new MasPasswordTool().getDesString(userVO.getPassword(), userVO.getAccount()));
        // 从全部角色里去掉此用户已经有的角色
        List<Role> delList = new ArrayList<Role>();
        // List<Long> longs = userVO.getRoles();
        Set<Role> userRoles = userVO.getRole();
        // logger.info("------userRoles-"+ userRoles);
        // 从所有的用户里删除此角色拥有的用户,待选 用户里显示
        for (Iterator<Role> uIterator = userRoles.iterator(); uIterator.hasNext(); ) {
          Role _roleUser = uIterator.next();
          // logger.debug("; roleUsers: "+ _roleUser.getId()+";");
          for (Role _role : roleList) {
            if (_roleUser.getId().equals(_role.getId())) {
              // logger.debug("into le.");
              delList.add(_role);
            }
          }
        }
        roleList.removeAll(delList);
        // 增加扩展信息
        PortalUserExtBean bean = portalUserExtService.getByPk(userVO.getId());

        Users temp = userService.queryByUserId(userVO.getId());
        userVO.setWebService(temp.getWebService());
        request.setAttribute("portalUserExt", bean);

        // 初次进入新增页面,得初始化角色
        request.setAttribute("rolesList", roleList);
        request.setAttribute("userVO", userVO);
        return "forward";
      }

    } catch (Exception e) {
      logger.error("", e);
      return ERROR;
    }
    return SUCCESS;
  }