Example #1
0
  public void insert(Album album) {
    album.setDelflag("1");

    Timestamp sysdate = new Timestamp(System.currentTimeMillis());
    album.setCreateUser(SessionUtils.getCurrentUserId());
    album.setCreateTime(sysdate);
    album.setUpdateUser(SessionUtils.getCurrentUserId());
    album.setUpdateTime(sysdate);
    this.albumDao.insert(album);
  }
Example #2
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;
  }
Example #3
0
 public int countByCriteria(User paramUser) {
   if ("1".equals(SessionUtils.getUserRole())) paramUser.setRole("'2','3'");
   else {
     paramUser.setRole("'3'");
   }
   int count = this.userDao.countByCriteria(paramUser);
   return count;
 }
Example #4
0
  public JSONObject update(Map map) throws Exception {
    boolean isSuccess = true;
    String message = "";

    User paramUser = new User();
    BeanUtils.populate(paramUser, map);
    paramUser.setBirthday(DateUtils.formatStr2Date(paramUser.getBirthdayStr(), "yyyy-MM-dd"));

    List<User> userList = selectByCriteria(new User());
    if (userList != null) {
      for (User user : userList) {
        if ((paramUser.getEmail().equals(user.getEmail()))
            && (!paramUser.getUserId().equals(user.getUserId()))) {
          isSuccess = false;
          message = "邮箱已被使用.";
          break;
        }
      }
    }

    if (isSuccess) {
      update(paramUser);

      Map userMetaMap = new HashMap();
      userMetaMap.put("theme", (String) map.get("theme"));
      userMetaMap.put("homePage", (String) map.get("homePage"));
      userMetaMap.put("showTodo", (String) map.get("showTodo"));
      userMetaMap.put("showNote", (String) map.get("showNote"));
      userMetaMap.put("showPicture", (String) map.get("showPicture"));
      userMetaMap.put("showAccount", (String) map.get("showAccount"));
      userMetaMap.put("showFeed", (String) map.get("showFeed"));
      userMetaMap.put("showDocument", (String) map.get("showDocument"));
      userMetaMap.put("showSystem", (String) map.get("showSystem"));
      this.userMetaService.updateByUserIdAndMetaKey(paramUser.getUserId(), userMetaMap);

      ((HttpSession) map.get("session")).removeAttribute("CLIENT_SESSION");

      User currentUser = getUserWithMetaByUserId((String) map.get("userId"));

      ClientSession cs = SessionUtils.getClientSession(currentUser);
      ((HttpSession) map.get("session")).setAttribute("CLIENT_SESSION", cs);
    }

    JSONObject res = new JSONObject();
    res.put("success", Boolean.valueOf(isSuccess));
    res.put("message", message);
    return res;
  }
Example #5
0
  public void insert(User user) {
    String userId = SessionUtils.getCurrentUserId();
    if (StringUtils.isEmpty(userId)) {
      userId = user.getUserId();
    }

    user.setPassword(MD5Utils.getMD5String(user.getPassword()));

    user.setDelflag("1");

    Timestamp sysdate = new Timestamp(System.currentTimeMillis());
    user.setCreateUser(userId);
    user.setCreateTime(sysdate);
    user.setUpdateUser(userId);
    user.setUpdateTime(sysdate);
    this.userDao.insert(user);
  }
Example #6
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;
 }
Example #7
0
 public void update(Album album) {
   Timestamp sysdate = new Timestamp(System.currentTimeMillis());
   album.setUpdateUser(SessionUtils.getCurrentUserId());
   album.setUpdateTime(sysdate);
   this.albumDao.updateByPrimaryKey(album);
 }
Example #8
0
 private Album getConditions(Album parentAlbum) {
   parentAlbum.setCreateUser(SessionUtils.getCurrentUserId());
   return parentAlbum;
 }
Example #9
0
  public JSONObject register(Map map) throws Exception {
    boolean isSuccess = true;
    String errorMsg = "";

    User paramUser = new User();
    BeanUtils.populate(paramUser, map);
    paramUser.setBirthday(DateUtils.formatStr2Date(paramUser.getBirthdayStr(), "yyyy-MM-dd"));
    paramUser.setStatus("1");
    if ((StringUtils.isEmpty(SessionUtils.getUserRole()))
        || ("3".equals(SessionUtils.getUserRole()))) {
      paramUser.setRole("3");
    }

    String userId = map.get("userId").toString();

    String password = map.get("password").toString();

    String repassword = map.get("repassword").toString();

    String verifyCode = map.get("verifyCode").toString();
    String verifyCodeInSession = map.get("verifyCodeInSession").toString();

    if ("1".equals(SessionUtils.getUserRole())) {
      if ((!"2".equals(paramUser.getRole())) && (!"3".equals(paramUser.getRole()))) {
        isSuccess = false;
        errorMsg = "角色设置错误.";
      }
    } else if (!"3".equals(paramUser.getRole())) {
      isSuccess = false;
      errorMsg = "角色设置错误.";
    }

    if (!password.equals(repassword)) {
      isSuccess = false;
      errorMsg = "两次输入的密码不一致.";
    }

    if (!verifyCode.equals(verifyCodeInSession)) {
      isSuccess = false;
      errorMsg = "验证码错误.";
    }

    List<User> userList = selectByCriteria(new User());
    if (userList != null) {
      for (User user : userList) {
        if (userId.equals(user.getUserId())) {
          isSuccess = false;
          errorMsg = "账号已存在.";
          break;
        }
        if (paramUser.getEmail().equals(user.getEmail())) {
          isSuccess = false;
          errorMsg = "邮箱已被使用.";
          break;
        }
      }
    }

    if (isSuccess) {
      insert(paramUser);

      Map userMetaMap = new HashMap();
      userMetaMap.put("theme", (String) map.get("theme"));
      userMetaMap.put("homePage", (String) map.get("homePage"));
      userMetaMap.put("showTodo", (String) map.get("showTodo"));
      userMetaMap.put("showNote", (String) map.get("showNote"));
      userMetaMap.put("showPicture", (String) map.get("showPicture"));
      userMetaMap.put("showAccount", (String) map.get("showAccount"));
      userMetaMap.put("showFeed", (String) map.get("showFeed"));
      userMetaMap.put("showDocument", (String) map.get("showDocument"));
      if ("3".equals(paramUser.getRole())) userMetaMap.put("showSystem", "off");
      else {
        userMetaMap.put("showSystem", "on");
      }
      this.userMetaService.insert(userId, userMetaMap);

      String uploadFilePath =
          ServletHelp.getRealPath(
              (HttpServletRequest) map.get("request"),
              MessageUtils.setParamMessage("/websrc/file/{0}/document", new String[] {userId}));
      FileUtils.createDirs(uploadFilePath);

      String uploadPicturePath =
          ServletHelp.getRealPath(
              (HttpServletRequest) map.get("request"),
              MessageUtils.setParamMessage("/websrc/file/{0}/picture", new String[] {userId}));
      FileUtils.createDirs(uploadPicturePath);

      FileUtils.createDirs(uploadPicturePath + "/" + "thumbnail");

      String feedFilePath =
          ServletHelp.getRealPath(
              (HttpServletRequest) map.get("request"),
              MessageUtils.setParamMessage("/websrc/file/{0}/feed", new String[] {userId}));
      FileUtils.createDirs(feedFilePath);
    }

    JSONObject res = new JSONObject();
    res.put("success", Boolean.valueOf(isSuccess));
    res.put("message", errorMsg);
    return res;
  }
Example #10
0
 public void update(User user) {
   Timestamp sysdate = new Timestamp(System.currentTimeMillis());
   user.setUpdateUser(SessionUtils.getCurrentUserId());
   user.setUpdateTime(sysdate);
   this.userDao.updateByPrimaryKey(user);
 }