?? manageaction.java
字號:
package com.easyjf.asp.action;
import com.easyjf.asp.business.ActiveUser;
import com.easyjf.asp.business.SystemDept;
import com.easyjf.asp.business.SystemUser;
import com.easyjf.asp.business.UserModule;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.AbstractCmdAction;
public class ManageAction extends AbstractCmdAction {
public Page doInit(WebForm form, Module module) {
// TODO Auto-generated method stub
return doShowLogin(form,module);
}
public Page doLogout(WebForm form, Module module)
{
ActionContext.getContext().getSession().removeAttribute("user");
return new Page("goto","/index.ejf","html");
}
public Page doExit(WebForm form, Module module)
{
ActionContext.getContext().getSession().removeAttribute("user");
return new Page("goto","/exit.htm","html");
}
public Page doShowLogin(WebForm form, Module module)
{
return module.findPage("login");
}
public Page doShowMenu(WebForm form, Module module)
{
ActiveUser user=(ActiveUser)ActionContext.getContext().getSession().getAttribute("user");
if(user==null)return new Page("popedomError","/nologin.htm","page");
if(UserModule.checkAdmin(user))
{
form.addResult("administrator","true");
}
if(UserModule.checkManager(user))
{
form.addResult("manager","true");
}
return module.findPage("menu");
}
public Page doShowBottom(WebForm form, Module module)
{
ActiveUser user=(ActiveUser)ActionContext.getContext().getSession().getAttribute("user");
if(user==null)return new Page("popedomError","/index.ejf","page");
SystemUser userInfo=SystemUser.readByUserName(user.getUserName());
if(userInfo!=null){
SystemDept dept=SystemDept.readBySn(userInfo.getBelongDept());
if(dept!=null)form.addResult("dept",dept.getTitle());
form.addResult("trueName",userInfo.getTrueName());
}
form.addResult("userName",user.getUserName());
return module.findPage("bottom");
}
public Page doLogin(WebForm form, Module module)
{
Page page=null;
String randomCode=(String)ActionContext.getContext().getSession().getAttribute("rand");
if(randomCode==null){
form.addResult("msg","您沒有登錄,或者登錄信息已經超時,請重新登錄!");
return doShowLogin(form,module);
}
if(!randomCode.equals((String)form.get("randomCode")))
{
form.addResult("msg","驗證碼不正確,請重新輸入!");
return module.findPage("login");
}
String userName=CommUtil.null2String(form.get("userName"));
String password=CommUtil.null2String(form.get("password"));
if(userName.equals("")|| password.equals(""))
{
form.addResult("msg","用戶名或者密碼不能為空,請重新輸入!");
return doShowLogin(form,module);
}
ActiveUser user=UserModule.login(userName,password,ActionContext.getContext().getRequest().getRemoteAddr());//UserManage..login(CommUtil.null2String(form.get("userName")),CommUtil.null2String(form.get("password")),request.getRemoteAddr());
if(user!=null)
{
user.setIp(ActionContext.getContext().getRequest().getLocalAddr());
ActionContext.getContext().getSession().setAttribute("user",user);//登錄標志
//if(user.isAdministrator())form.addResult("administragor","true");
page=module.findPage("main");
}
else
{
form.addResult("msg","用戶名或者密碼不正確,請重新輸入!");
page=doShowLogin(form,module);
}
return page;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -