⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usersession.java

📁 招标投标网上系统
💻 JAVA
字号:
package cn.com.syntc.webapp.session;
/*
 *********************************************************************
 *  文件 : UserSession:$
 *  项目 : 考试系统
 *  公司 : 沈阳NTC计算机工程公司
 *  日期 : $Date$
 *  说明 :
 **********************************************************************
 * 版本历史:
 * $Log:  $
 *********************************************************************
 */
import java.io.*;
import java.util.*;
import java.text.*;

import cn.com.syntc.webapp.define.Constant;

/**
 *  <p>
 *
 *  Description:登录用户信息接口</p> <p>
 *
 *  Copyright: Copyright (c) 2003</p> <p>
 *
 *  Company: SYNTC </p>
 *
 *@author     wangy    Mail : wangy@syntc.com.cn
 *@created    2003年12月9日
 *@version    1.0
 */
public class UserSession
{
  /**
   *  用户ID
   */
  public String UserID = "";

  /**
   *  用户名
   */
  public String UserName = "";

  /**
   *  用户别名
   */
  public String NiceName = "";

  /**
   *  用户密码(加密后存储于session中)
   */
  public String Password = "";

  /**
   *  用户性别
   */
  public String Sex = "";

  /**
   *  出生年月
   */
  public String Birthday = "";

  /**
   *  用户邮件
   */
  public String Mail = "";

  /**
   *  用户QQ
   */
  public String Oicq = "";

  /**
   *  来自哪儿
   */
  public String ComeFrom = "";

  /**
   *  个人主页
   */
  public String HomePage = "";

  /**
   *  个人介绍
   */
  public String Introduction = "";

  /**
   *  所属单位名称
   */
  public String OrgName = "";

  /**
   *  所属部门名称
   */
  public String UnitName = "";


  /**
   *  登录时间
   */
  public String LoginTime = "";

  /**
   *  登录IP
   */
  public String LogonIP = "";

  /**
   *  角色ID
   */
  public int RoleID = Constant.GUEST;

  /**
   *  角色名
   */
  public String RoleName = "";

  /**
   *  构造对象 UserSession
   */
  public UserSession() { }

  /**
   *  取得用户ID
   *
   *@return                用户ID
   */
  public String getUserID()
  {
    return this.UserID;
  }

  /**
   *  取得用户名
   *
   *@return                用户名
   */
  public String getUserName()
  {
    return this.UserName;
  }

  /**
   *  取得用户别名
   *
   *@return                用户别名
   */
  public String getNiceName()
  {
    return this.NiceName;
  }

  /**
   *  取得用户密码(加密后存储于session中)
   *
   *@return                用户密码
   */
  public String getPassword()
  {
    return this.Password;
  }

  /**
   *  取得用户邮件
   *
   *@return                用户邮件
   */
  public String getMail()
  {
    return this.Mail;
  }

  /**
   *  取得用户性别
   */
  public String getSex()
  {
    return this.Sex;
  }

  /**
   *  取得出生年月
   */
  public String getBirthday()
  {
    return this.Birthday;
  }

  /**
   *  取得所属单位名称
   *
   *@return                所属单位名称
   */
  public String getOrgName()
  {
    return this.OrgName;
  }

  /**
   *  取得所属部门名称
   *
   *@return                所属部门名称
   */
  public String getUnitName()
  {
    return this.UnitName;
  }

  /**
   *  用户QQ
   */
  public String getOicq()
  {
    return this.Oicq;
  }

  /**
   *  来自哪儿
   */
  public String getComeFrom()
  {
    return this.ComeFrom;
  }

  /**
   *  个人主页
   */
  public String getHomePage()
  {
    return this.HomePage;
  }

  /**
   *  个人介绍
   */
  public String getIntroduction()
  {
    return this.Introduction;
  }

  /**
   *  取得登录时间
   *
   *@return                登录时间
   */
  public String getLoginTime()
  {
    return this.LoginTime;
  }

  /**
   *  取得登录IP
   *
   *@return                登录IP
   */
  public String getLogonIP()
  {
    return this.LogonIP;
  }

  /**
   *  取得用户角色ID
   *
   *@return                用户角色ID
   */
  public int getRoleID()
  {
    return this.RoleID;
  }

  /**
   *  取得用户角色名
   *
   *@return                用户角色名
   */
  public String getRoleName()
  {
    return this.RoleName;
  }

  /**
   *  取得用户停留时间
   *
   *@return                用户停留时间
   */
  public String getStayTime()
  {
    // 2003-11-30 00:00:00   
    String StayTime = "";
    try
    {
      Calendar loginCalendar = Calendar.getInstance();
      Calendar nowCalendar = Calendar.getInstance();
      DateFormat df = DateFormat.getDateTimeInstance();

      // 取得登录的时间
      Date LoginDate = df.parse(this.LoginTime);
      loginCalendar.setTime(LoginDate);

      // 取得当前的时间
      nowCalendar.setTime(new Date());

      // 计算停留时间(微秒)
      long lStayTime = nowCalendar.getTimeInMillis() - loginCalendar.getTimeInMillis();

      StayTime = lStayTime / (60 * 60 * 1000) + "小时" 
               + lStayTime % 60 / (60 * 1000) + "分钟" 
               + lStayTime % (60 * 1000) / 1000 + "秒";
    }
    catch(Exception ex)
    {
      System.out.println("取得用户停留时间错误:"+ex.getMessage());
    }
    return StayTime;
  }

  /**
   *  设置用户ID
   *
   *@param  UserId         用户ID
   */
  public void setUserID(String UserID)
  {
    if(UserID==null)
      this.UserID = "";
    else
      this.UserID = UserID;
  }

  /**
   *  设置用户名
   *
   *@param  UserName       设置用户名
   */
  public void setUserName(String UserName)
  {
    if(UserName==null)
      this.UserName = "";
    else
      this.UserName = UserName;
  }

  /**
   *  设置用户别名
   *
   *@param NiceName        用户别名
   */
  public void setNiceName(String NiceName)
  {
    if(NiceName==null)
      this.NiceName = "";
    else
      this.NiceName = NiceName;
  }

  /**
   *  设置用户密码(加密后存储于session中)
   *
   *@param Password        用户密码
   */
  public void setPassword(String Password)
  {
    if(Password==null)
      this.Password = "";
    else
      this.Password = Password;
  }

  /**
   *  设置用户邮件
   *
   *@param Mail            用户邮件
   */
  public void setMail(String Mail)
  {
    if(Mail==null)
      this.Mail = "";
    else
      this.Mail = Mail;
  }

  /**
   *  设置所属单位名称
   *
   *@param OrgName       所属单位名称
   */
  public void setOrgName(String OrgName)
  {
    if(OrgName==null)
      this.OrgName = "";
    else
      this.OrgName = OrgName;
  }

  /**
   *  设置所属部门名称
   *
   *@param UnitName       所属部门名称
   */
  public void setUnitName(String UnitName)
  {
    if(UnitName==null)
      this.UnitName = "";
    else
      this.UnitName = UnitName;
  }

  /**
   *  设置用户性别
   *
   *@param Sex        用户性别
   */
  public void setSex(String Sex)
  {
    if(Sex==null)
      this.Sex = "";
    else
      this.Sex = Sex;
  }

  /**
   *  设置出生年月
   *
   *@param Birthday        出生年月
   */
  public void setBirthday(String Birthday)
  {
    if(Birthday==null)
      this.Birthday = "";
    else
      this.Birthday = Birthday;
  }

  /**
   *  设置用户QQ
   *
   *@param Oicq       用户QQ
   */
  public void setOicq(String Oicq)
  {
    if(Oicq==null)
      this.Oicq = "";
    else
      this.Oicq = Oicq;
  }

  /**
   *  设置来自哪儿
   *
   *@param ComeFrom       来自哪儿
   */
  public void setComeFrom(String ComeFrom)
  {
    if(ComeFrom==null)
      this.ComeFrom = "";
    else
      this.ComeFrom = ComeFrom;
  }

  /**
   *  设置个人主页
   *
   *@param HomePage       个人主页
   */
  public void setHomePage(String HomePage)
  {
    if(HomePage==null)
      this.HomePage = "";
    else
      this.HomePage = HomePage;
  }

  /**
   *  设置个人介绍
   *
   *@param Introduction       个人介绍
   */
  public void setIntroduction(String Introduction)
  {
    if(Introduction==null)
      this.Introduction = "";
    else
      this.Introduction = Introduction;
  }

  /**
   *  设置登录时间
   *
   *@param LoginTime     登录时间
   */
  public void setLoginTime(String LoginTime)
  {
    if(LoginTime==null)
      this.LoginTime = "";
    else
      this.LoginTime = LoginTime;
  }

  /**
   *  设置登录IP
   *
   *@param LogonIP       登录IP
   */
  public void setLogonIP(String LogonIP)
  {
    if(LogonIP==null)
      this.LogonIP = "";
    else
      this.LogonIP = LogonIP;
  }

  /**
   *  设置用户角色
   *
   *@param RoleID       用户角色
   */
  public void setRoleID(int RoleID) 
  {
    if(RoleID<0)
      this.RoleID = Constant.GUEST;
    else
      this.RoleID = RoleID;
  }

  /**
   *  设置用户角色名
   *
   *@param RoleName       用户角色名
   */
  public void setRoleName(String RoleName) 
  {
    if(RoleName==null)
      this.RoleName = "";
    else
      this.RoleName = RoleName;
  }

  /**
   *  是否是系统管理员
   *
   *@return                判断结果 true 是系统管理员
   */
  public boolean isAdmin() 
  {
    if(this.RoleID == Constant.ADMIN)
      return true;
    else
      return false;
  }

  /**
   *  是否是教师
   *
   *@return                判断结果 true 是教师
   */
  public boolean isTeacher() 
  {
    if(this.RoleID == Constant.TEACHER)
      return true;
    else
      return false;
  }

  /**
   *  是否是学生
   *
   *@return                判断结果 true 是学生
   */
  public boolean isStudent() 
  {
    if(this.RoleID == Constant.STUDENT)
      return true;
    else
      return false;
  }

  /**
   *  是否是游客
   *
   *@return                判断结果 true 是游客
   */
  public boolean isGuest() 
  {
    if(this.RoleID == Constant.GUEST)
      return true;
    else
      return false;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -