コード例 #1
0
ファイル: BasicController.java プロジェクト: gspandy/sxj-src
 /**
  * 会员联想
  *
  * @param request
  * @param response
  * @param keyword
  * @return
  * @throws IOException
  */
 @RequestMapping("autoCompleMember")
 public @ResponseBody Map<String, String> autoCompleMember(
     HttpServletRequest request, HttpServletResponse response, String keyword) throws IOException {
   MemberQuery mq = new MemberQuery();
   if (keyword != "" && keyword != null) {
     mq.setMemberName(keyword);
   }
   // mq.setMemberTypeB(0);
   List<MemberEntity> list = memberService.queryMembers(mq);
   List strlist = new ArrayList();
   String sb = "";
   for (MemberEntity memberEntity : list) {
     sb =
         "{\"title\":\""
             + memberEntity.getName()
             + "\",\"result\":\""
             + memberEntity.getMemberNo()
             + "\"}";
     strlist.add(sb);
   }
   String json = "{\"data\":" + strlist.toString() + "}";
   response.setCharacterEncoding("UTF-8");
   PrintWriter out = response.getWriter();
   out.print(json);
   out.flush();
   out.close();
   return null;
 }
コード例 #2
0
ファイル: BasicController.java プロジェクト: gspandy/sxj-src
  @RequestMapping("enter")
  @ResponseBody
  public void enter(
      String functionId, String url, HttpSession session, HttpServletRequest request) {
    Date enterTime = (Date) session.getAttribute("enterTime");
    Date nowTime = new Date();
    String currentUrl = (String) session.getAttribute("currentUrl");
    String currentFunction = (String) session.getAttribute("currentFunction");
    String nextUrl = (String) session.getAttribute("nextUrl");
    String nextFunction = (String) session.getAttribute("nextFunction");
    if (currentUrl == null) {
      session.setAttribute("currentUrl", request.getHeader("Referer"));
    }
    session.setAttribute("previousUrl", currentUrl);
    session.setAttribute("currentUrl", nextUrl);
    session.setAttribute("nextUrl", url);

    session.setAttribute("previousFunction", currentFunction);
    session.setAttribute("currentFunction", nextFunction);
    session.setAttribute("nextFunction", functionId);

    MemberEntity principal = (MemberEntity) SecurityUtils.getSubject().getPrincipal();
    if (principal != null) {
      MemberLogEntity log = new MemberLogEntity();
      log.setMemberNo(principal.getMemberNo());
      log.setMemberName(principal.getName());
      log.setNowPage(nextUrl);
      log.setNextpage(url);
      log.setPrePage(currentUrl);

      MemberFunctionEntity function = functionService.getFunction(nextFunction);
      if (function != null) {
        log.setNowName(function.getTitle());
      }

      function = functionService.getFunction(functionId);
      if (function != null) {
        log.setNextName(function.getTitle());
      }

      function = functionService.getFunction(currentFunction);
      if (function != null) {
        log.setPreName(function.getTitle());
      }

      log.setCallTime(enterTime);
      log.setIp(getIpAddr(request));
      if (enterTime != null) {
        long waitTime = (nowTime.getTime() - enterTime.getTime()) / 1000;
        log.setWaitTime(waitTime + "");
      }
      logService.addLog(log);
    }
    session.setAttribute("enterTime", nowTime);
  }
コード例 #3
0
ファイル: BasicController.java プロジェクト: gspandy/sxj-src
  @RequestMapping(value = "login", method = RequestMethod.POST)
  public String login(
      String memberName,
      String accountName,
      String password,
      HttpSession session,
      HttpServletRequest request,
      ModelMap map) {
    map.put("accountName", accountName);
    map.put("memberName", memberName);
    SupervisorSiteToken token = null;
    SupervisorPrincipal userBean = null;
    AccountEntity account = null;
    if (StringUtils.isNotEmpty(memberName) && StringUtils.isNotEmpty(accountName)) {
      MemberEntity member = memberService.getMemberByName(memberName);
      if (member == null) {
        map.put("message", "会员不存在");
        return LOGIN;
      }
      if (!member.getName().equals(memberName)) {
        map.put("message", "会员名错误");
        return LOGIN;
      }
      if (MemberCheckStateEnum.UNAUDITED.equals(member.getCheckState())) {
        map.put("message", "会员未审核");
        return LOGIN;
      }
      if (MemberStatesEnum.STOP.equals(member.getState())) {
        map.put("message", "会员已冻结");
        return LOGIN;
      }

      account = accountService.getAccountByName(accountName, member.getMemberNo());
      if (account == null) {
        map.put("amessage", "会员子账户不存在");
        return LOGIN;
      }
      if (AccountStatesEnum.STOP.equals(account.getState())) {
        map.put("amessage", "会员子账户已冻结");
        return LOGIN;
      }

      userBean = new SupervisorPrincipal();
      userBean.setAccount(account);
      userBean.setMember(member);
      token = new SupervisorSiteToken(userBean, password);
    } else if (StringUtils.isNotEmpty(memberName) && StringUtils.isEmpty(accountName)) {
      MemberEntity member = memberService.getMemberByName(memberName);
      if (member == null) {
        map.put("message", "会员不存在");
        return LOGIN;
      }
      if (MemberCheckStateEnum.UNAUDITED.equals(member.getCheckState())) {
        map.put("message", "会员未审核");
        return LOGIN;
      }
      if (MemberStatesEnum.STOP.equals(member.getState())) {
        map.put("message", "会员已冻结");
        return LOGIN;
      }
      userBean = new SupervisorPrincipal();
      userBean.setMember(member);
      token = new SupervisorSiteToken(userBean, password);
    } else {
      map.put("message", "公司名称和密码不能为空");
      // map.put("pmessage", "密码不能为空");
      return LOGIN;
    }
    Subject currentUser = SecurityUtils.getSubject();
    try {
      currentUser.login(token);
      PrincipalCollection principals = currentUser.getPrincipals();
      if (userBean.getAccount() != null) {
        SupervisorShiroRedisCache.addToMap(userBean.getAccount().getId(), principals);
      } else {
        SupervisorShiroRedisCache.addToMap(userBean.getMember().getMemberNo(), principals);
      }
    } catch (AuthenticationException e) {
      SxjLogger.error("登陆失败", e, this.getClass());
      map.put("pmessage", "密码错误");
      return LOGIN;
    }
    if (currentUser.isAuthenticated()) {
      session.setAttribute("userinfo", userBean);
      if (account != null) {
        accountService.edit_Login(account.getId());
      }
      return "redirect:" + getBasePath(request) + "index.htm";
    } else {
      map.put("message", "登陆失败");
      return LOGIN;
    }
  }