Esempio n. 1
0
  /**
   * 查询用户信息<未完成的,分页列表>
   *
   * @return
   * @throws Exception
   */
  @Action(
      value = "query",
      results = {
        @Result(
            type = "json",
            params = {"root", "entityMap", "contentType", "text/html"})
      })
  public String query() {
    try {
      PageUtil pageUtil = new PageUtil();
      pageUtil.setStart(page);
      pageUtil.setPageSize(rows);
      pageUtil.setMerchantPin(users.getMerchantPin());
      if (portalUser != null) {
        pageUtil.setAccount(portalUser.getAccount());
        pageUtil.setMobile(portalUser.getMobile());
        pageUtil.setEmail(portalUser.getEmail());
        // Integer activeFlag =
        //		portalUser.getActiveFlag()== -99 ? null : portalUser.getActiveFlag();
        pageUtil.setActiveFlag(portalUser.getActiveFlag());
        String roleId = request.getParameter("roleId");
        if (roleId != null && !"-99".equals(roleId)) pageUtil.setRoleId(Long.parseLong(roleId));
      }
      logger.info("role query portalUser:"******"role query pageUtil:" + pageUtil);

      // REX@20130112  判断登陆用户类型
      if (users.getUserType() == ApSmsConstants.USER_TYPE_SUPER_ADMIN) {
        // 在省、地市 管理员的时候,不需要pin码
        pageUtil.setMerchantPin(null);
        String[] provArray = null;
        List<Region> regionList = regionService.findProvinces();
        if (regionList != null) {
          provArray = new String[regionList.size()];
          for (int i = 0; i < regionList.size(); i++) {
            provArray[i] = String.valueOf(regionList.get(i).getId());
          }
        }
        // 增加全省列表
        pageUtil.setAreaRange(provArray);
        // 设置用户类型为省管理员
        pageUtil.setUserType(users.getUserType());
      } else if (users.getUserType() == ApSmsConstants.USER_TYPE_PROVINCE_ADMIN) {
        // 在省、地市 管理员的时候,不需要pin码
        pageUtil.setMerchantPin(null);
        Long provinceId = 0L;
        provinceId = Long.parseLong(users.getProvince());
        String[] cityArray = null;
        List<Region> regionList = regionService.findCityByProvinceId(provinceId);
        if (regionList != null) {
          cityArray = new String[regionList.size()];
          for (int i = 0; i < regionList.size(); i++) {
            cityArray[i] = String.valueOf(regionList.get(i).getId());
          }
        }
        // 增加地区列表
        pageUtil.setAreaRange(cityArray);
        // 设置用户类型为地市管理员
        pageUtil.setUserType(users.getUserType());
      } else if (users.getUserType() == ApSmsConstants.USER_TYPE_CITY_ADMIN) {
        pageUtil.setMerchantPin(null);
        // 增加地区列表
        pageUtil.setAreaRange(new String[] {users.getCity()});
        // 设置用户类型为企业管理员
        pageUtil.setUserType(users.getUserType());

      } else if (users.getUserType() == ApSmsConstants.USER_TYPE_ENTERPRISE_ADMIN) {
        // 设置用户类型为企业管理员

        pageUtil.setUserType(users.getUserType());

      } else {
        pageUtil.setUserType(users.getUserType());
      }
      Page page = userService.page(pageUtil);
      if (page != null) {
        @SuppressWarnings("unchecked")
        List<UserVO> datas = (List<UserVO>) page.getData();
        entityMap = new HashMap<String, Object>();
        entityMap.put("total", page.getRecords());
        if (datas == null) {
          datas = new ArrayList<UserVO>();
        }
        entityMap.put("rows", datas);
        entityMap.put("totalrecords", page.getTotal());
        entityMap.put("currpage", page.getStart());
      }
      logger.info("query user page: " + entityMap);
    } catch (Exception e) {
      e.printStackTrace();
      return ERROR;
    }
    return SUCCESS;
  }
Esempio n. 2
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;
  }