📄 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 + -