package org.bubu.struts.action;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
import org.bubu.bean.Adminuser;
import org.bubu.bean.Ans;
import org.bubu.bean.Ques;
import org.bubu.dao.IAdminuserDAO;
import org.bubu.dao.IOrderDAO;
import org.bubu.dao.IPrivilegeDAO;
import org.bubu.dao.IQuesDAO;
import org.bubu.dao.IQuesanswDAO;
import org.bubu.dao.IRoleDAO;
import org.bubu.dao.IUserDAO;
import org.bubu.dao.IUseruserDAO;
import org.bubu.struts.form.AdminForm;
import org.bubu.util.MD5Code;
import org.bubu.util.StrUtil;
/**
* MyEclipse Struts
* Creation date: 04-24-2008
*
* XDoclet definition:
* @struts.action path="/admin" name="adminForm" input="/form/admin.jsp" parameter="method" scope="request" validate="true"
* @struts.action-forward name="error" path="/admin/error.jsp"
* @struts.action-forward name="success" path="/admin/frame.jsp" redirect="true"
*/
public class AdminAction extends DispatchAction {
private IAdminuserDAO adminuserDAO;
private IRoleDAO roleDAO;
private IPrivilegeDAO privilegeDAO;
private IOrderDAO orderDAO;
private IUserDAO userDAO;
private IUseruserDAO useruserDAO;
private IQuesDAO quesDAO;
private IQuesanswDAO quesanswDAO;
public IQuesanswDAO getQuesanswDAO() {
return quesanswDAO;
}
public void setQuesanswDAO(IQuesanswDAO quesanswDAO) {
this.quesanswDAO = quesanswDAO;
}
public IQuesDAO getQuesDAO() {
return quesDAO;
}
public void setQuesDAO(IQuesDAO quesDAO) {
this.quesDAO = quesDAO;
}
public IUseruserDAO getUseruserDAO() {
return useruserDAO;
}
public void setUseruserDAO(IUseruserDAO useruserDAO) {
this.useruserDAO = useruserDAO;
}
public IUserDAO getUserDAO() {
return userDAO;
}
public void setUserDAO(IUserDAO userDAO) {
this.userDAO = userDAO;
}
public IOrderDAO getOrderDAO() {
return orderDAO;
}
public void setOrderDAO(IOrderDAO orderDAO) {
this.orderDAO = orderDAO;
}
public IPrivilegeDAO getPrivilegeDAO() {
return privilegeDAO;
}
public void setPrivilegeDAO(IPrivilegeDAO privilegeDAO) {
this.privilegeDAO = privilegeDAO;
}
public IRoleDAO getRoleDAO() {
return roleDAO;
}
public void setRoleDAO(IRoleDAO roleDAO) {
this.roleDAO = roleDAO;
}
public IAdminuserDAO getAdminuserDAO() {
return adminuserDAO;
}
public void setAdminuserDAO(IAdminuserDAO adminuserDAO) {
this.adminuserDAO = adminuserDAO;
}
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdminForm adminForm = (AdminForm) form;
try {
boolean isok=adminuserDAO.isstatus(adminForm.getName());
if(isok==false){
ActionMessages msg=new ActionMessages();
msg.add("statuserro", new ActionMessage("page.admin.status.error"));
this.saveErrors(request, msg);
//System.out.println("000000000000000000");
return mapping.findForward("error");
}
MD5Code MD5=new MD5Code();
boolean is=adminuserDAO.querylogin(adminForm.getName(), MD5.getMD5ofStr(adminForm.getPwd()));
if(is==true){
String name=adminForm.getName();
request.getSession().setAttribute("isadminlogin", is);
request.getSession().setAttribute("adminname", name);
String enterlast=adminuserDAO.getenterlast(name);
request.getSession().setAttribute("enterlast", enterlast);
adminuserDAO.updateenterlast(name);
//System.out.println("1111111111111111111111");
return mapping.findForward("success");
}else{
ActionMessages msg=new ActionMessages();
msg.add("loginerror", new ActionMessage("page.admin.login.error"));
this.saveErrors(request, msg);
//System.out.println("2222222222222222222222");
return mapping.findForward("error");
}
} catch (Exception e) {
e.printStackTrace();
}
//System.out.println("333333333333333333333");
return mapping.findForward("error");
}
public ActionForward mainjsp(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int isnotokcount=0;
int isokcount=0;
int subquescount=0;
int luiyancount=0;
try {
isnotokcount = orderDAO.queryokcount(0);
isokcount=orderDAO.queryokcount(1);
subquescount=quesanswDAO.querynoanswcount(0);
luiyancount = quesanswDAO.querynoanswcount(1);
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("subquescount", subquescount);
request.setAttribute("isnotokcount", isnotokcount);
request.setAttribute("isokcount", isokcount);
request.setAttribute("luiyancount", luiyancount);
return mapping.findForward("main");
}
public ActionForward show(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
List list=adminuserDAO.Queryall();
request.setAttribute("adminuserlist", list);
return mapping.findForward("adminusershow");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//添加管理员
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdminForm adminForm = (AdminForm) form;
try {
boolean is=adminuserDAO.isexist(adminForm.getName());
if(is==true){
ActionMessages msg=new ActionMessages();
msg.add("nameexist", new ActionMessage("page.admin.user.name.error"));
this.saveErrors(request, msg);
return mapping.findForward("error");
}
MD5Code MD5=new MD5Code();
Adminuser adminuser=new Adminuser();
adminuser.setName(adminForm.getName());
adminuser.setRealname(adminForm.getRealname());
adminuser.setDescription(adminForm.getDescription());
adminuser.setPwd(MD5.getMD5ofStr(adminForm.getPwd()));
adminuser.setStatus(1);
adminuser.setEnterCount(0);
adminuser.setAddtime(StrUtil.FormatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
adminuserDAO.insert(adminuser);
String url="admin.do?method=show";
request.setAttribute("urledit", url);
return mapping.findForward("updatesuccess");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public ActionForward editinfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String name=(String)request.getSession().getAttribute("adminname");
try {
Adminuser adminuser=adminuserDAO.getadminuser(name);
request.setAttribute("adminuser", adminuser);
return mapping.findForward("modifyinfo");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdminForm adminForm = (AdminForm) form;
String name=request.getParameter("name");
try {
Adminuser adminuser=adminuserDAO.getadminuser(name);
request.setAttribute("adminuser", adminuser);
//这里取出原来已有的权限项,以数组形式
String priv=adminuser.getPrivilege();
String[] select=StrUtil.splitStr(priv, ',');
List rolelist=roleDAO.queryall();
request.setAttribute("rolelist", rolelist);
List privilegelist=privilegeDAO.Queryall();
//这里取出共有的权限项,以数组形式
String[] source=privilegeDAO.privarray(privilegelist);
/*
for(int i=0;i<select.length;i++){
没有合适的资源?快使用搜索试试~ 我知道了~
完整的ssh项目(带说明)
共1915个文件
gif:623个
jsp:308个
class:207个
4星 · 超过85%的资源 需积分: 34 394 下载量 19 浏览量
2011-05-27
10:04:49
上传
评论 11
收藏 6.95MB RAR 举报
温馨提示
完整的ssh项目(带说明)完整的ssh项目(带说明)完整的ssh项目(带说明)完整的ssh项目(带说明)完整的ssh项目(带说明)
资源详情
资源评论
资源推荐
收起资源包目录
完整的ssh项目(带说明) (1915个子文件)
flower.css.bak 2KB
AdminAction.class 20KB
GgleftAction.class 17KB
SublabelDAOImpl.class 14KB
UserAction.class 12KB
SublabelAction.class 12KB
UsercenterAction.class 10KB
LeftinfoAction.class 9KB
UserDAOImpl.class 9KB
GgadminAction.class 8KB
SpecialAction.class 8KB
MD5Code.class 7KB
Sublabel.class 7KB
IGgleftDAOImpl.class 7KB
ItemAction.class 7KB
LabelAction.class 7KB
SublabelForm.class 7KB
UserForm.class 7KB
IndexcommonAction.class 7KB
SublabelshowAction.class 7KB
EditWebhelper.class 6KB
EditWebhelper.class 6KB
GgguanggaoImpl.class 6KB
CommonAction.class 6KB
QuesAction.class 6KB
GuanggaoAction.class 6KB
OrderDAOImpl.class 6KB
QuesanswAction.class 6KB
LatestnewsAction.class 5KB
FlashAction.class 5KB
SpecialDAOImpl.class 5KB
User.class 5KB
AdminuserDAOImpl.class 5KB
QuesanswDAOImpl.class 5KB
QuesanswmarAction.class 5KB
LabelDAOImpl.class 5KB
OrdermarAction.class 5KB
Makegglogo.class 5KB
Makegglefter.class 5KB
IItemDAOImpl.class 4KB
LeftinfoDAOImpl.class 4KB
QuesDAOImpl.class 4KB
Leftinfo.class 4KB
Makeggleftinfo.class 4KB
OrdermarForm.class 4KB
LeftinfoForm.class 4KB
Orders.class 4KB
GgleftForm.class 4KB
Makeggbest.class 4KB
PrivilegeAction.class 4KB
EditBean.class 4KB
EditBean.class 4KB
QuestionshowAction.class 4KB
Makeleftinfo.class 4KB
Makeggleft.class 4KB
ShoppingcartAction.class 4KB
RoleAction.class 4KB
discountsubbean.class 4KB
Makealllist.class 4KB
GgMakeheader.class 4KB
Makehotsale.class 4KB
Makelatenews.class 4KB
MakeSpecial.class 4KB
NavleftAction.class 4KB
Sublist.class 3KB
LeftinfoshowAction.class 3KB
SpecialForm.class 3KB
FocusAction.class 3KB
AdminForm.class 3KB
Special.class 3KB
OrderdiscountAction.class 3KB
LatestnewsDAOImpl.class 3KB
QuesForm.class 3KB
GgLeftinfo.class 3KB
QuestionDAOImpl.class 3KB
Adminuser.class 3KB
Makecontentright.class 3KB
Makelefter.class 3KB
UploadWebHelper.class 3KB
UploadWebHelper.class 3KB
QuesanswForm.class 3KB
Makemiddlepic.class 3KB
LatestnewsForm.class 3KB
Makelistheader.class 3KB
Makehelpheader.class 3KB
Makeuserheader.class 3KB
Makecontentleft.class 3KB
Makemiddle.class 3KB
Latestnews.class 3KB
StrUtil.class 3KB
GgadminForm.class 3KB
Makeheader.class 3KB
PrivilegeDAOImpl.class 3KB
Question.class 3KB
QuestionForm.class 3KB
Quesansw.class 3KB
NavleftDAOImpl.class 3KB
QuestionAction.class 3KB
Gonggao.class 3KB
SubitemAction.class 3KB
共 1915 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
zhzh56983
- 粉丝: 1
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论30