예제 #1
0
  public Map login(String userId, String password) throws Exception {
    Map res = new HashMap();
    res.put("success", Boolean.valueOf(true));

    User paramUser = new User();
    paramUser.setUserId(userId);
    paramUser.setPassword(MD5Utils.getMD5String(password));
    List userList = this.userDao.selectByCriteria(paramUser);
    if ((userList == null) || (userList.size() != 1)) {
      res.put("success", Boolean.valueOf(false));
      res.put("message", "用户名或密码错误.");
    } else {
      User currentUser = (User) userList.get(0);
      if (!"1".equals(currentUser.getStatus())) {
        res.put("success", Boolean.valueOf(false));
        res.put("message", "该用户已被禁用.");
      } else {
        currentUser = getUserWithMetaByUserId(currentUser.getUserId());

        ClientSession cs = SessionUtils.getClientSession(currentUser);
        res.put("session", cs);
      }
    }

    return res;
  }
예제 #2
0
 public List<User> selectByCriteria(User paramUser) {
   List userList = this.userDao.selectByCriteria(paramUser);
   List results = new ArrayList();
   if (userList != null) {
     for (int i = 0; i < userList.size(); i++) {
       User user = (User) userList.get(i);
       user.setBirthdayStr(DateUtils.formatDate2Str(user.getBirthday(), "yyyy-MM-dd"));
       user.setSex((String) Constants.SEX_MAP.get(user.getSex()));
       user.setStatus((String) Constants.USER_STATUS_MAP.get(user.getStatus()));
       user.setCreateDateStr(
           DateUtils.formatDate2Str(user.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
       results.add(user);
     }
   }
   return results;
 }
예제 #3
0
 public List<User> selectByCriteriaForPaging(User paramUser) {
   if ("1".equals(SessionUtils.getUserRole())) paramUser.setRole("'2','3'");
   else {
     paramUser.setRole("'3'");
   }
   List userList =
       this.userDao.selectByCriteriaForPaging(
           paramUser, paramUser.getStart(), paramUser.getLimit());
   List results = new ArrayList();
   if (userList != null) {
     for (int i = 0; i < userList.size(); i++) {
       User user = (User) userList.get(i);
       user.setBirthdayStr(DateUtils.formatDate2Str(user.getBirthday(), "yyyy-MM-dd"));
       user.setRole((String) Constants.ROLE_MAP.get(user.getRole()));
       user.setSex((String) Constants.SEX_MAP.get(user.getSex()));
       user.setStatus((String) Constants.USER_STATUS_MAP.get(user.getStatus()));
       results.add(user);
     }
   }
   return results;
 }